import torch


def _convert_to_int_if_lossless(a: torch.Tensor) -> torch.Tensor:
    """Converts the supplied tensor to int, if the conversion can be done lossless.

    :param a: tensor
    :return: Input tensor as int, if lossless conversion is possible or as original data type, if
        not.
    """
    if torch.sum(a % 1) == 0:
        a = a.int()

    return a