torch.ValidateScalar
export type ValidateScalar<S extends Shape> = S extends readonly []
? number // Valid scalar
: number extends S['length']
? number // Dynamic shape, can't check at compile time
: item_error_not_scalar<S>;Sextends ShapeValidate that a shape is a scalar (empty tuple). Returns number if valid, error type otherwise.
Examples
type A = ValidateScalar<readonly []>; // number ✓
type B = ValidateScalar<readonly [2, 3]>; // item_error_not_scalar<...> ✗