pub fn validate_index(index: i64, dim_size: usize) -> PyResult<usize>
Validate that an index is within bounds for a given dimension