nnrl/nn/distributions/flows/utils.py
def sum_rightmost(value: torch.Tensor, dim: int):
    """Sum out ``dim`` many rightmost dimensions of a given tensor.

    Args:
        value: A tensor of ``.dim()`` at least ``dim``.
        dim: The number of rightmost dims to sum out.
    """
    if dim == 0:
        return value
    required_shape = value.shape[:-dim] + (-1,)
    return value.reshape(required_shape).sum(-1)
Sum out ``dim`` many rightmost dimensions of a given tensor.

    Args:
        value: A tensor of ``.dim()`` at least ``dim``.
        dim: The number of rightmost dims to sum out.
    
Sum out ``dim`` many rightmost dimensions of a given tensor.
Sum out ` ` dim ` ` many rightmost dimensions of a given tensor .
def sum_rightmost(value: torch.Tensor, dim: int):
    if dim == 0:
        return value
    required_shape = value.shape[:-dim] + (-1,)
    return value.reshape(required_shape).sum(-1)
def sum_rightmost ( value : torch . Tensor , dim : int ) : if dim == 0 : return value required_shape = value . shape [ : - dim ] + ( - 1 , ) return value . reshape ( required_shape ) . sum ( - 1 )
Sum out ``dim`` many rightmost dimensions of a given tensor.
Sum out ` ` dim ` ` many rightmost dimensions of a given tensor .
"""Sum out ``dim`` many rightmost dimensions of a given tensor.

    Args:
        value: A tensor of ``.dim()`` at least ``dim``.
        dim: The number of rightmost dims to sum out.
    """
value
torch.Tensor
None
dim
int
The number of rightmost dims to sum out.
The number of rightmost dims to sum out .