import torch


def precision_fn(precision):
    """Returns a function which takes a Tensor as input and returns a new Tensor
    where all elements are the nearest multiple of `precision`."""
    def round_to_precision(tensor):
        multiples = tensor / precision
        multiples = torch.round(multiples)
        return multiples * precision
    
    return round_to_precision