code: def choice(
      random_state,
      size=None,
      a=2,
      replace=True,
      p=None,
      ndim=None,
      dtype="int64",
  ):
      """
      Choose values from `a` with or without replacement. `a` can be a 1-D array
      or a positive scalar. If `a` is a scalar, the samples are drawn from the
      range 0,...,a-1.
  
      If the size argument is ambiguous on the number of dimensions, ndim
      may be a plain integer to supplement the missing information.
  
      If size is None, a scalar will be returned.
  
      """
      a = tensor.as_tensor_variable(a)
      if isinstance(replace, bool):
          replace = tensor.constant(replace, dtype="int8")
      else:
          replace = tensor.as_tensor_variable(replace)
      # encode p=None as an empty vector
      p = tensor.as_tensor_variable(p or [])
      ndim, size, bcast = _infer_ndim_bcast(ndim, size)
      op = RandomFunction(
          choice_helper,
          tensor.TensorType(dtype=dtype, broadcastable=bcast),
      )
      return op(random_state, size, a, replace, p)
  
imports: from __future__ import absolute_import, print_function, division
  import sys
  from copy import copy
  import numpy
  from six import string_types
  from six.moves import reduce, xrange
  import theano
  from theano import tensor
  from theano.tensor import opt
  from theano import gof
  from theano.compile import optdb
label_desc: Use image node_id 9 for calling a global function with example usage: choice(random_state, size, a, replace, p, ndim, dtype) and returns: op