code: def choice(a, size=None, replace=True, p=None):
      sc_size = 1
      if isinstance(size, int):
          sc_size = size
      elif size is not None:
          #  If the given shape is, e.g., (m, n, k)
          #  then m * n * k samples are drawn. As per numpy docs
          sc_size = 1
          for s in size:
              if s is not None:
                  sc_size *= s
      if isinstance(a, int):
          a = ivy.arange(a)
      index = ivy.multinomial(len(a), sc_size, replace=replace, probs=p)
      return a[index]
  
imports: import ivy
  from ivy.functional.frontends.numpy.func_wrapper import to_ivy_arrays_and_back, from_zero_dim_arrays_to_scalar
  from ivy import with_supported_dtypes
label_desc: Use image node_id 4 for calling a global function with example usage: choice(a, size, replace, p) and returns: a