pub fn validate_dimension(dim: i32, ndim: usize) -> PyResult<usize>
Validate that a dimension index is valid for a tensor