ndim

property Tensor4.ndim

As for numpy.ndarray