import torch


def is_legal(v):
    """
    Checks that tensor is not NaN or Inf.
    Inputs:
        v (tensor): tensor to be checked
    """
    legal = not torch.isnan(v).any() and not torch.isinf(v)

    return legal