torch.bincount
torch.bincount(input, weights=None, minlength=0) -> Tensor
Count the frequency of each value in an array of non-negative ints.
The number of bins (size 1) is one larger than the largest value in
   "input" unless "input" is empty, in which case the result is a
   tensor of size 0. If "minlength" is specified, the number of bins
   is at least "minlength" and if "input" is empty, then the result is
   tensor of size "minlength" filled with zeros. If "n" is the value
   at position "i", "out[n] += weights[i]" if "weights" is specified
   else "out[n] += 1".
Note:
 This operation may produce nondeterministic gradients when given
 tensors on a CUDA device. See Reproducibility for more
 information.

Parameters:
      * input (Tensor) -- 1-d int tensor
  * **weights** (*Tensor*) -- optional, weight for each value in
    the input tensor. Should be of same size as input tensor.
