Resolve one signed dim against a tensor of rank ndim.
The rule every dim argument follows. A 0-d tensor answers to dim 0
and -1 as if it had one axis, as the reference does; the result is then 0
and names no real axis, so an op that indexes shape()[dim] must take
the 0-d case apart first (ops/utils/ScalarAxis.h).
Raises
IndexErrordim falls outside [-max(ndim, 1), max(ndim, 1)).