code: def digitize(x, bins, right=False):
      """Finds the indices of the bins to which each value in input array belongs.
  
      .. note::
  
          In order to avoid device synchronization, digitize does not raise
          an exception when the array is not monotonic
  
      Args:
          x (cupy.ndarray): Input array.
          bins (cupy.ndarray): Array of bins.
              It has to be 1-dimensional and monotonic increasing or decreasing.
          right (bool):
              Indicates whether the intervals include the right or the left bin
              edge.
  
      Returns:
          cupy.ndarray: Output array of indices, of same shape as ``x``.
  
      .. seealso:: :func:`numpy.digitize`
      """  # NOQA
      # This is for NumPy compat, although it works fine
      if x.dtype.kind == "c":
          raise TypeError("x may not be complex")
  
      if bins.ndim > 1:
          raise ValueError("object too deep for desired array")
      if bins.ndim < 1:
          raise ValueError(
              "object of too small depth for desired array"
          )
  
      # As the order of the arguments are reversed, the side must be too.
      side = "left" if right else "right"
      return cupy._sorting.search._searchsorted(
          bins, x, side, None, False
      )
  
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 8 for calling a global function with example usage: digitize(x, bins, right) and returns: cupy