def METHOD_NAME(a: torch.Tensor, dim: int, num: int) -> torch.Tensor:
    """
    Take last elements from a given tensor along a given dimension.
    Parameters
    ----------
    a
        Original tensor to slice.
    dim
        Dimension to slice over.
    num
        Number of trailing elements to retain (non-negative).
    Returns
    -------
    torch.Tensor
        A tensor with the same size as the input one, except dimension
        ``dim`` which has length equal to ``num``.
    """
    assert num >= 0
    return slice_along_dim(a, dim, slice(a.shape[dim] - num, None))