code: def choice(a, size=None, replace=True, p=None, device=None, out=None):
      r"""Generates a random sample from a given 1-D array
  
      Parameters
      -----------
      a : 1-D array-like or int
          If an ndarray, a random sample is generated from its elements.
          If an int, the random sample is generated as if a were np.arange(a)
      size : int or tuple of ints, optional
          Output shape.  If the given shape is, e.g., ``(m, n, k)``, then
          ``m * n * k`` samples are drawn.  Default is None, in which case a
          single value is returned.
      replace : boolean, optional
          Whether the sample is with or without replacement
      p : 1-D array-like, optional
          The probabilities associated with each entry in a.
          If not given the sample assumes a uniform distribution over all
          entries in a.
      device : Device, optional
          Device context of output. Default is current device.
  
      Returns
      --------
      samples : ndarray
          The generated random samples
  
      Examples
      ---------
      Generate a uniform random sample from np.arange(5) of size 3:
  
      >>> np.random.choice(5, 3)
      array([0, 3, 4])
      >>> #This is equivalent to np.random.randint(0,5,3)
  
      Generate a non-uniform random sample from np.arange(5) of size 3:
  
      >>> np.random.choice(5, 3, p=[0.1, 0, 0.3, 0.6, 0])
      array([3, 3, 0])
  
      Generate a uniform random sample from np.arange(5) of size 3 without
      replacement:
  
      >>> np.random.choice(5, 3, replace=False)
      array([3,1,0])
      >>> #This is equivalent to np.random.permutation(np.arange(5))[:3]
  
      Generate a non-uniform random sample from np.arange(5) of size
      3 without replacement:
  
      >>> np.random.choice(5, 3, replace=False, p=[0.1, 0, 0.3, 0.6, 0])
      array([2, 3, 0])
      """
      return _mx_nd_np.random.choice(a, size, replace, p, device, out)
  
imports: from ..ndarray import numpy
  from ..random import seed
  from ..util import wrap_ctx_to_device_func
label_desc: Use image node_id 9 for calling a global function with example usage: choice(a, size, replace, p, device, out) and returns: _mx_nd_np