(data, num_labels)
return counts.view(len(data), num_labels)
Computes elementwise bincount on a batch of data.  The input tensor is
    size (batch_size, ...), and the output is (batch_size, num_labels),
    where each row of the output is the bincount of the corresponding
    entry of the input.
Computes elementwise bincount on a batch of data.  The input tensor is
    size (batch_size, ...), and the output is (batch_size, num_labels),
    where each row of the output is the bincount of the corresponding
    entry of the input.
Computes elementwise bincount on a batch of data . The input tensor is size ( batch_size ... ) and the output is ( batch_size num_labels ) where each row of the output is the bincount of the corresponding entry of the input .
def batch_bincount(data, num_labels):
    '''
    Computes elementwise bincount on a batch of data.  The input tensor is
    size (batch_size, ...), and the output is (batch_size, num_labels),
    where each row of the output is the bincount of the corresponding
    entry of the input.
    '''
    data = data.view(len(data), -1)
    strided = data + torch.arange(len(data), dtype=data.dtype,
         device=data.device)[:,None] * num_labels
    counts = torch.bincount(strided.view(-1), minlength=num_labels * len(data))
    return counts.view(len(data), num_labels)
def batch_bincount ( data , num_labels ) : data = data . view ( len ( data ) , - 1 ) strided = data + torch . arange ( len ( data ) , dtype = data . dtype , device = data . device ) [ : , None ] * num_labels counts = torch . bincount ( strided . view ( - 1 ) , minlength = num_labels * len ( data ) ) return counts . view ( len ( data ) , num_labels )