class_docstr: Op that draws random numbers from a numpy.random.RandomState object.
  
  Parameters
  ----------
  fn : string or function reference
      A member function of numpy.random.RandomState. A string will
      be interpreted as the name of a member function of
      numpy.random.RandomState.
      Technically, any function with a signature like the ones in
      numpy.random.RandomState will do. This function must accept
      the shape (sometimes called size) of the output as the last
      positional argument.
  outtype
      The theano Type of the output.
  args
      A list of default arguments for the function
      kwargs
      If the 'inplace' key is there, its value will be used to
      determine if the op operates inplace or not.
      If the 'ndim_added' key is there, its value indicates how
      many more dimensions this op will add to the output, in
      addition to the shape's dimensions (used in multinomial and
      permutation).
class_docstr_tok: ["Op","that","draws","random","numbers","from","a","numpy.random.RandomState","object",".","Parameters","--","--","--","--","--","fn",":","string","or","function","reference","A","member","function","of","numpy.random.RandomState",".","A","string","will","be","interpreted","as","the","name","of","a","member","function","of","numpy.random.RandomState",".","Technically",",","any","function","with","a","signature","like","the","ones","in","numpy.random.RandomState","will","do",".","This","function","must","accept","the","shape","(","sometimes","called","size",")","of","the","output","as","the","last","positional","argument",".","outtype","The","theano","Type","of","the","output",".","args","A","list","of","default","arguments","for","the","function","kwargs","If","the","'inplace","'","key","is","there",",","its","value","will","be","used","to","determine","if","the","op","operates","inplace","or","not",".","If","the","'ndim_added","'","key","is","there",",","its","value","indicates","how","many","more","dimensions","this","op","will","add","to","the","output",",","in","addition","to","the","shape","'s","dimensions","(","used","in","multinomial","and","permutation",")","."]
code: def perform(self, node, inputs, out_):
      rout, out = out_
      # Use self.fn to draw shape worth of random numbers.
      # Numbers are drawn from r if self.inplace is True, and from a
      # copy of r if self.inplace is False
      r, shape, args = inputs[0], inputs[1], inputs[2:]
      assert type(r) == np.random.RandomState, (type(r), r)
  
      # If shape == [], that means no shape is enforced, and numpy is
      # trusted to draw the appropriate number of samples, numpy uses
      # shape "None" to represent that. Else, numpy expects a tuple.
      # TODO: compute the appropriate shape, and pass it to numpy.
      if len(shape) == 0:
          shape = None
      else:
          shape = tuple(shape)
  
      if (
          shape is not None
          and self.outtype.ndim != len(shape) + self.ndim_added
      ):
          raise ValueError(
              "Shape mismatch: self.outtype.ndim (%i) !="
              " len(shape) (%i) + self.ndim_added (%i)"
              % (self.outtype.ndim, len(shape), self.ndim_added)
          )
      if not self.inplace:
          r = copy(r)
      rout[0] = r
      rval = self.exec_fn(r, *(args + [shape]))
      if (
          not isinstance(rval, np.ndarray)
          or str(rval.dtype) != node.outputs[1].type.dtype
      ):
          rval = theano._asarray(rval, dtype=node.outputs[1].type.dtype)
  
      # When shape is None, numpy has a tendency to unexpectedly
      # return a scalar instead of a higher-dimension array containing
      # only one element. This value should be reshaped
      if shape is None and rval.ndim == 0 and self.outtype.ndim > 0:
          rval = rval.reshape([1] * self.outtype.ndim)
  
      if len(rval.shape) != self.outtype.ndim:
          raise ValueError(
              'Shape mismatch: "out" should have dimension %i,'
              ' but the value produced by "perform" has'
              " dimension %i" % (self.outtype.ndim, len(rval.shape))
          )
  
      # Check the output has the right shape
      if shape is not None:
          if self.ndim_added == 0 and shape != rval.shape:
              raise ValueError(
                  'Shape mismatch: "out" should have shape %s, but the'
                  ' value produced by "perform" has shape %s'
                  % (shape, rval.shape)
              )
          elif (
              self.ndim_added > 0
              and shape != rval.shape[: -self.ndim_added]
          ):
              raise ValueError(
                  'Shape mismatch: "out" should have shape starting with'
                  " %s (plus %i extra dimensions), but the value produced"
                  ' by "perform" has shape %s'
                  % (shape, self.ndim_added, rval.shape)
              )
  
      out[0] = rval
  
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 7 for calling the RandomFunction obj's underlying member method code with example usage: obj.perform(node, inputs, out_) without return types