import torch


def from_onehot(y):
    """Converts one-hot encoded probabilities to label indices.
    
    Parameters
    ----------
    y: Tensor or Variable
    
    Returns
    -------
    Tensor or Variable containing the label indices.
    """
    _, labels_pred = torch.max(y, 1)
    return labels_pred