import torch


def particle_to_quantile(predictions):
    """ Converts a particle prediction to a quantile prediction. 
    
    Not fully differentiable because of the sorting operation involved. Should be thought of as a permutation function 
    
    Args: 
        predictions (tensor): array [batch_size, n_particles], a batch of particle predictions
        
    Returns: 
        tensor: a batch of quantile predictions
    """
    return torch.sort(predictions, dim=1)[0]