class_docstr: Module component with similar interface to `numpy.random.Generator`.
  
  Attributes
  ----------
  seed: None or int
      A default seed to initialize the `Generator` instances after build.
  state_updates: list
      A list of pairs of the form ``(input_r, output_r)``.  This will be
      over-ridden by the module instance to contain stream generators.
  default_instance_seed: int
      Instance variable should take None or integer value. Used to seed the
      random number generator that provides seeds for member streams.
  gen_seedgen: numpy.random.Generator
      `Generator` instance that `RandomStream.gen` uses to seed new
      streams.
  rng_ctor: type
      Constructor used to create the underlying RNG objects.  The default
      is `np.random.default_rng`.
class_docstr_tok: ["Module","component","with","similar","interface","to","`","numpy.random.Generator","`",".","Attributes","--","--","--","--","--","seed",":","None","or","int","A","default","seed","to","initialize","the","`","Generator","`","instances","after","build",".","state_updates",":","list","A","list","of","pairs","of","the","form","``","(","input_r",",","output_r",")","``",".","This","will","be","over-ridden","by","the","module","instance","to","contain","stream","generators",".","default_instance_seed",":","int","Instance","variable","should","take","None","or","integer","value",".","Used","to","seed","the","random","number","generator","that","provides","seeds","for","member","streams",".","gen_seedgen",":","numpy.random.Generator","`","Generator","`","instance","that","`","RandomStream.gen","`","uses","to","seed","new","streams",".","rng_ctor",":","type","Constructor","used","to","create","the","underlying","RNG","objects",".","The","default","is","`","np.random.default_rng","`","."]
docstr: Generate a draw from `op` seeded from this `RandomStream`.
  
  Parameters
  ----------
  op
      A `RandomVariable` instance
  args
      Positional arguments passed to `op`.
  kwargs
      Keyword arguments passed to `op`.
  
  Returns
  -------
  The symbolic random draw performed by `op`.  This function stores
  the updated `RandomType`\s for use at compile time.
docstr_tok: ["Generate","a","draw","from","`","op","`","seeded","from","this","`","RandomStream","`",".","Parameters","--","--","--","--","--","op","A","`","RandomVariable","`","instance","args","Positional","arguments","passed","to","`","op","`",".","kwargs","Keyword","arguments","passed","to","`","op","`",".","Returns","--","--","--","-","The","symbolic","random","draw","performed","by","`","op","`",".","This","function","stores","the","updated","`","RandomType","`","\\s","for","use","at","compile","time","."]
code: def gen(
      self, op: "RandomVariable", *args, **kwargs
  ) -> TensorVariable:
      r"""Generate a draw from `op` seeded from this `RandomStream`.
  
      Parameters
      ----------
      op
          A `RandomVariable` instance
      args
          Positional arguments passed to `op`.
      kwargs
          Keyword arguments passed to `op`.
  
      Returns
      -------
      The symbolic random draw performed by `op`.  This function stores
      the updated `RandomType`\s for use at compile time.
  
      """
      if "rng" in kwargs:
          raise ValueError(
              "The `rng` option cannot be used with a variate in a `RandomStream`"
          )
  
      # Generate a new random state
      (seed,) = self.gen_seedgen.spawn(1)
      rng = shared(self.rng_ctor(seed), borrow=True)
  
      # Generate the sample
      out = op(*args, **kwargs, rng=rng)
  
      # This is the value that should be used to replace the old state
      # (i.e. `rng`) after `out` is sampled/evaluated.
      # The updates mechanism in `pytensor.function` is supposed to perform
      # this replace action.
      new_rng = out.owner.outputs[0]
  
      self.state_updates.append((rng, new_rng))
  
      rng.default_update = new_rng
  
      return out
  
imports: from collections.abc import Sequence
  from functools import wraps
  from itertools import zip_longest
  from types import ModuleType
  from typing import TYPE_CHECKING, Literal, Optional, Union
  import numpy
  from pytensor.compile.sharedvalue import shared
  from pytensor.graph.basic import Constant, Variable
  from pytensor.scalar import ScalarVariable
  from pytensor.tensor import get_vector_length
  from pytensor.tensor.basic import as_tensor_variable, cast, constant
  from pytensor.tensor.extra_ops import broadcast_to
  from pytensor.tensor.math import maximum
  from pytensor.tensor.shape import specify_shape
  from pytensor.tensor.type import int_dtypes
  from pytensor.tensor.variable import TensorVariable
label_desc: Use image node_id 5 for calling the RandomStream obj's underlying member method code with example usage: obj.gen(op) and returns: out