code: def multinomial(n, pvals, size=None):
      """Returns an array from multinomial distribution.
  
      Args:
          n (int): Number of trials.
          pvals (cupy.ndarray): Probabilities of each of the ``p`` different
              outcomes. The sum of these values must be 1.
          size (int or tuple of ints or None): Shape of a sample in each trial.
              For example when ``size`` is ``(a, b)``, shape of returned value is
              ``(a, b, p)`` where ``p`` is ``len(pvals)``.
              If ``size`` is ``None``, it is treated as ``()``. So, shape of
              returned value is ``(p,)``.
  
      Returns:
          cupy.ndarray: An array drawn from multinomial distribution.
  
      .. note::
         It does not support ``sum(pvals) < 1`` case.
  
      .. seealso:: :meth:`numpy.random.multinomial`
      """
  
      if size is None:
          m = 1
          size = ()
      elif isinstance(size, int):
          m = size
          size = (size,)
      else:
          size = tuple(size)
          m = 1
          for x in size:
              m *= x
  
      p = len(pvals)
      shape = size + (p,)
      ys = basic.zeros(shape, "l")
      if ys.size > 0:
          xs = choice(p, p=pvals, size=n * m)
          _multinominal_kernel(xs, p, n, ys)
      return ys
  
file_path: cupy/cupy/random/_sample.py
imports: from cupy import _core
  from cupy._creation import basic
  from cupy.random import _distributions
  from cupy.random import _generator
label_desc: Use image node_id 7 for calling a global function with example usage: multinomial(n, pvals, size) and returns: ys