code: def multinomial(
      population_size: int,
      num_samples: int,
      /,
      *,
      batch_size: int = 1,
      probs: Optional[np.ndarray] = None,
      replace: bool = True,
      device: Optional[str] = None,
      seed: Optional[int] = None,
      out: Optional[np.ndarray] = None,
  ) -> np.ndarray:
      if seed:
          np.random.seed(seed)
      if probs is None:
          probs = (
              np.ones(
                  (
                      batch_size,
                      population_size,
                  )
              )
              / population_size
          )
      orig_probs_shape = list(probs.shape)
      num_classes = orig_probs_shape[-1]
      probs_flat = np.reshape(probs, (-1, orig_probs_shape[-1]))
      probs_flat = probs_flat / np.sum(
          probs_flat, -1, keepdims=True, dtype="float64"
      )
      probs_stack = np.split(probs_flat, probs_flat.shape[0])
      samples_stack = [
          np.random.choice(num_classes, num_samples, replace, p=prob[0])
          for prob in probs_stack
      ]
      samples_flat = np.stack(samples_stack)
      return np.asarray(
          np.reshape(
              samples_flat, orig_probs_shape[:-1] + [num_samples]
          )
      )
  
file_path: ivy/ivy/functional/backends/numpy/random.py
imports: import numpy
  from typing import Optional, Union, Sequence
  import ivy
  from ivy.functional.ivy.random import _check_bounds_and_get_shape, _randint_check_dtype_and_bound, _check_valid_scale
  from ivy.func_wrapper import with_unsupported_dtypes
  from .None import backend_version
label_desc: Use image node_id 3 for calling a global function with example usage: multinomial() and returns: np