import torch


def to_one_hot(indexes, output_dim):
    """
    :param indexes: list of numbers in the range [0, output_dim)
    :param output_dim: size of a single one-hot tensor
    :return: tensor containing one_hot representation of indexes
    """
    assert output_dim >= 2
    assert output_dim > max(indexes)
    assert min(indexes) >= 0

    return torch.eye(output_dim)[indexes]