def get_slice(tensors, slicer):
    """Return slice from tensors.

    We handle case where tensors are just one tensor or dict of tensors.
    """
    if isinstance(tensors, dict):
        tensors_sliced = {}
        for key, tens in tensors.items():
            tensors_sliced[key] = tens[slicer]
    else:
        tensors_sliced = tensors[slicer]

    return tensors_sliced