code: def multinomial(
      population_size: int,
      num_samples: int,
      /,
      *,
      batch_size: int = 1,
      probs: Optional[Union[ivy.Array, ivy.NativeArray]] = None,
      replace: bool = True,
      device: Optional[Union[ivy.Device, ivy.NativeDevice]] = None,
      seed: Optional[int] = None,
      out: Optional[ivy.Array] = None,
  ) -> ivy.Array:
      """Draws samples from a multinomial distribution. Specifically, returns a
      tensor where each row contains num_samples indices sampled from the
      multinomial probability distribution located in the corresponding row of
      tensor input.
  
      Parameters
      ----------
      population_size
          The size of the population from which to draw samples.
      num_samples
          Number of independent samples to draw from the population.
      batch_size
          Number of tensors to generate. Default is 1.
      probs
          The unnormalized probabilities for all elements in population,
          default is uniform *[batch_shape, population_size]*
      replace
          Whether to replace samples once they've been drawn. Default is ``True``.
      device
          device on which to create the array 'cuda:0', 'cuda:1', 'cpu' etc.
          (Default value = None)
      seed
          A python integer. Used to create a random seed distribution
      out
          optional output array, for writing the result to. It must have a shape that the
          inputs broadcast to.
  
      Returns
      -------
      ret
          Drawn samples indices from the multinomial distribution.
  
      Examples
      --------
      >>> y = ivy.multinomial(10, 5)
      >>> print(y)
      ivy.array([[1, 8, 7, 8, 3]])
  
      >>> y = ivy.multinomial(10, 5, batch_size=2, seed=42)
      >>> print(y)
      ivy.array([[3, 9, 7, 5, 1],
             [1, 0, 8, 6, 7]])
  
      >>> y = ivy.multinomial(10, 5, replace=False)
      >>> print(y)
      ivy.array([[2, 6, 4, 7, 0]])
  
      With :class:`ivy.Array` input:
  
      >>> y = ivy.multinomial(10, 5, probs=ivy.array([1/10]*10))
      >>> print(y)
      ivy.array([5, 2, 7, 6, 9])
  
      >>> y = ivy.multinomial(7, 5, batch_size=2, probs=ivy.array([[1/7]*7, [1/7]*7]))
      >>> print(y)
      ivy.array([[0, 4, 3, 4, 5], [1, 1, 0, 3, 2]])
  
      >>> y = ivy.multinomial(7, 5, batch_size=2, probs=ivy.array([[1/7]*7, [1/7]*7]),
      ...                     replace=False)
      >>> print(y)
      ivy.array([[2, 6, 1, 0, 3], [1, 0, 2, 5, 6]])
  
      With :class:`ivy.NativeArray` input:
  
      >>> y = ivy.multinomial(10, 5, probs=ivy.native_array([1/10]*10))
      >>> print(y)
      ivy.array([5, 7, 4, 2, 1])
  
      >>> y = ivy.multinomial(10, 5, batch_size=2,
      ...                     probs=ivy.native_array([[1/10]*10, [1/10]*10]))
      >>> print(y)
      ivy.array([[8, 0, 4, 1, 7], [2, 3, 4, 9, 3]])
  
      >>> y = ivy.multinomial(10, 5, batch_size=2,
      ...                     probs=ivy.native_array([[1/10]*10, [1/10]*10]),
      ...                     replace=False)
      >>> print(y)
      ivy.array([[0, 2, 6, 9, 1], [6, 7, 2, 4, 3]])
      """
      return ivy.current_backend().multinomial(
          population_size,
          num_samples,
          batch_size=batch_size,
          probs=probs,
          replace=replace,
          device=device,
          seed=seed,
          out=out,
      )
  
file_path: ivy/ivy/functional/ivy/random.py
imports: from typing import Optional, Union
  import ivy
  from ivy.func_wrapper import handle_array_function, infer_dtype, handle_out_argument, to_native_arrays_and_back, inputs_to_native_shapes, handle_nestable, handle_device, handle_backend_invalid
  from ivy.utils.backend import backend_stack
  from ivy.utils.exceptions import handle_exceptions
label_desc: Use image node_id 7 for calling a global function with example usage: multinomial() and returns: ivy