code: def _bincount(
      arr,
      weights=None,
      minlength=None,
      maxlength=None,  # pylint: disable=unused-argument
      dtype=np.int32,
      name=None,
  ):  # pylint: disable=unused-argument
      """Counts number of occurences of each value in `arr`."""
      # TODO(https://github.com/google/jax/issues/5719): Use np.bincount directly?
      if not JAX_MODE:
          return np.bincount(arr, weights, minlength).astype(
              utils.numpy_dtype(dtype)
          )
  
      dtype = utils.numpy_dtype(dtype)
      num_buckets = (np.max(arr) + 1) if np.size(arr) else 0
      if (
          minlength is not None
          and maxlength is not None
          and minlength == maxlength
      ):
          # In the case where we can use minlength directly, this helps avoids the
          # use of an abstract value, which prevents JAX JIT.
          num_buckets = minlength
      else:
          if minlength is not None:
              num_buckets = np.maximum(num_buckets, minlength)
          if maxlength is not None:
              num_buckets = np.minimum(num_buckets, maxlength)
      one_hots = one_hot(arr, num_buckets)
      # Reduce over every dimension except the last one.
      axes = tuple(range(0, one_hots.ndim - 1))
      if weights is not None:
          return np.sum(
              one_hots * weights[..., np.newaxis], axis=axes
          ).astype(dtype)
      return np.sum(one_hots, axis=axes).astype(dtype)
  
imports: import collections
  import functools
  import numpy
  import numpy
  from tensorflow_probability.python.internal.backend.numpy import _utils
  from tensorflow_probability.python.internal.backend.numpy.numpy_array import _reverse
  from tensorflow_probability.python.internal.backend.numpy.numpy_array import one_hot
  from tensorflow_probability.python.internal.backend.numpy.ops import _convert_to_tensor
label_desc: Use image node_id 3 for calling a global function with example usage: _bincount(arr, weights, minlength, maxlength, dtype, name) and returns: np, np, np