def METHOD_NAME(x: torch.Tensor):
    x -= x.min()  # This operation -= may lead to mem leak without detach() before this assignment. (x = x - x.min() won't lead to such a problem.)
    if x.max() == 0:
        return torch.zeros(x.size(), device=x.device)
    x /= x.max()
    return x