code: def choice(a, size=None, replace=True, p=None, ctx=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.
      ctx : Context, optional
          Device context of output. Default is current context.
  
      Returns
      --------
      samples : _Symbol
          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])
      """
      from ._symbol import _Symbol as np_symbol
  
      if ctx is None:
          ctx = current_context()
      if size == ():
          size = None
      if isinstance(a, np_symbol):
          ctx = None
          if p is None:
              indices = _npi.choice(
                  a,
                  a=None,
                  size=size,
                  replace=replace,
                  ctx=ctx,
                  weighted=False,
              )
              return _npi.take(a, indices)
          else:
              indices = _npi.choice(
                  a,
                  p,
                  a=None,
                  size=size,
                  replace=replace,
                  ctx=ctx,
                  weighted=True,
              )
              return _npi.take(a, indices)
      else:
          if p is None:
              return _npi.choice(
                  a=a,
                  size=size,
                  replace=replace,
                  ctx=ctx,
                  weighted=False,
                  out=out,
              )
          else:
              return _npi.choice(
                  p,
                  a=a,
                  size=size,
                  replace=replace,
                  ctx=ctx,
                  weighted=True,
                  out=out,
              )
  
imports: import numpy
  from ...context import current_context
  from ...util import is_np_default_dtype
  from .None import _internal
label_desc: Use image node_id 8 for calling a global function with example usage: choice(a, size, replace, p, ctx, out) and returns: _npi, _npi, _npi, _npi