def is_scalar(x):
    """Checks if the input is a scalar."""
    return (
        len(x.shape) == 0 if isinstance(x, torch.Tensor) else isinstance(x, int)
    )
Checks if the input is a scalar.
python/dgl/graphbolt/itemset.py