def range_splits(tensor, split_ranges, dim):
    """Splits the tensor according to chunks of split_ranges.

    Arguments:
        tensor (Tensor): tensor to split.
        split_ranges (list(tuples(int,int))): sizes of chunks (start,end).
        dim (int): dimension along which to split the tensor.
    """
    return [tensor.narrow(int(dim), start, end - start) for start, end in split_ranges]