@classmethod
def as_number(cls, obj: TScalar) -> Union[(int, float)]:
    if isinstance(obj, torch.Tensor):
        obj_as_number: Union[(int, float)] = obj.item()
    else:
        obj_as_number = obj
    assert (isinstance(obj_as_number, int) or isinstance(obj_as_number, float))
    return obj_as_number
@classmethod
def as_number(cls, obj: TScalar) -> Union[(int, float)]:
    if isinstance(obj, torch.Tensor):
        obj_as_number: Union[(int, float)] = obj.item()
    else:
        obj_as_number = obj
    assert (isinstance(obj_as_number, int) or isinstance(obj_as_number, float))
    return obj_as_number