code: def bincount(x, weights=None, minlength=None):
      """Count number of occurrences of each value in array of non-negative ints.
  
      Args:
          x (cupy.ndarray): Input array.
          weights (cupy.ndarray): Weights array which has the same shape as
              ``x``.
          minlength (int): A minimum number of bins for the output array.
  
      Returns:
          cupy.ndarray: The result of binning the input array. The length of
          output is equal to ``max(cupy.max(x) + 1, minlength)``.
  
      .. warning::
  
          This function may synchronize the device.
  
      .. seealso:: :func:`numpy.bincount`
  
      """
      if x.ndim > 1:
          raise ValueError("object too deep for desired array")
      if x.ndim < 1:
          raise ValueError(
              "object of too small depth for desired array"
          )
      if x.dtype.kind == "f":
          raise TypeError("x must be int array")
      if (x < 0).any():  # synchronize!
          raise ValueError(
              "The first argument of bincount must be non-negative"
          )
      if weights is not None and x.shape != weights.shape:
          raise ValueError(
              "The weights and list don't have the same length."
          )
      if minlength is not None:
          minlength = int(minlength)
          if minlength < 0:
              raise ValueError("minlength must be non-negative")
  
      size = int(cupy.max(x)) + 1  # synchronize!
      if minlength is not None:
          size = max(size, minlength)
  
      if weights is None:
          b = cupy.zeros((size,), dtype=numpy.intp)
          # TODO(leofang): we temporarily remove CUB histogram support for now,
          # see cupy/cupy#7698. When it's ready, revert the commit that checked
          # in this comment to restore the support.
          _bincount_kernel(x, b)
      else:
          b = cupy.zeros((size,), dtype=numpy.float64)
          _bincount_with_weight_kernel(x, weights, b)
  
      return b
  
file_path: cupy/cupy/_statistics/histogram.py
imports: import operator
  import warnings
  import numpy
  import cupy
  from cupy import _core
label_desc: Use image node_id 7 for calling a global function with example usage: bincount(x, weights, minlength) and returns: b