Canonicalise a list of axis indices for an ndim-rank tensor.
Wraps each negative axis to its positive counterpart, deduplicates the
result, sorts ascending, and returns the canonical list. When axes
is empty the function treats the call as "reduce over everything" and
returns [0, ndim).
Parameters
axesconst std::vector<int>&Raw axis list; may contain negatives and duplicates.
ndimintRank of the tensor the axes refer to.
Returns
std::vector<int>Sorted, deduplicated, all-positive axis list.
Raises
IndexErrorSome entry of
axes falls outside [-ndim, ndim).