import torch


def is_tensor_nan_or_inf(tensor: torch.Tensor) -> bool:
    """
    Returns True if any of the tensor elements is Not a Number or Infinity.

    :param tensor: The tensor to check.
    :return: True if any of the tensor elements is Not a Number or Infinity, False if all entries are valid numbers.
    """
    result = torch.isnan(tensor).any().item() or torch.isinf(tensor).any().item()
    if isinstance(result, bool):
        return result
    raise ValueError("torch not returning bool as we expected")