import torch


def _has_nans(tensor):
    """Return whether a tensor contains NaNs.

    Args:
        tensor (torch.Tensor): Tensor to be checked.

    Returns:
        bool: ``True`` if ``tensor`` contains NaNs, else ``False``.
    """

    return torch.any(torch.isnan(tensor))