class_docstr: An `Op` that produces a sample from a random variable.
  
  This is essentially `RandomFunction`, except that it removes the
  `outtype` dependency and handles shape dimension information more
  directly.
class_docstr_tok: ["An","`","Op","`","that","produces","a","sample","from","a","random","variable",".","This","is","essentially","`","RandomFunction","`",",","except","that","it","removes","the","`","outtype","`","dependency","and","handles","shape","dimension","information","more","directly","."]
code: def perform(self, node, inputs, outputs):
      rng_var_out, smpl_out = outputs
  
      rng, size, dtype, *args = inputs
  
      out_var = node.outputs[1]
  
      # If `size == []`, that means no size is enforced, and NumPy is trusted
      # to draw the appropriate number of samples, NumPy uses `size=None` to
      # represent that.  Otherwise, NumPy expects a tuple.
      if np.size(size) == 0:
          size = None
      else:
          size = tuple(size)
  
      # Draw from `rng` if `self.inplace` is `True`, and from a copy of `rng`
      # otherwise.
      if not self.inplace:
          rng = copy(rng)
  
      rng_var_out[0] = rng
  
      smpl_val = self.rng_fn(rng, *(args + [size]))
  
      if (
          not isinstance(smpl_val, np.ndarray)
          or str(smpl_val.dtype) != out_var.type.dtype
      ):
          smpl_val = _asarray(smpl_val, dtype=out_var.type.dtype)
  
      smpl_out[0] = smpl_val
  
imports: from collections.abc import Sequence
  from copy import copy
  from typing import Optional, Union
  import numpy
  import pytensor
  from pytensor.configdefaults import config
  from pytensor.graph.basic import Apply, Variable, equal_computations
  from pytensor.graph.op import Op
  from pytensor.graph.replace import _vectorize_node
  from pytensor.misc.safe_asarray import _asarray
  from pytensor.scalar import ScalarVariable
  from pytensor.tensor.basic import as_tensor_variable, concatenate, constant, get_underlying_scalar_constant_value, get_vector_length, infer_static_shape
  from pytensor.tensor.random.type import RandomGeneratorType, RandomStateType, RandomType
  from pytensor.tensor.random.utils import broadcast_params, normalize_size_param
  from pytensor.tensor.shape import shape_tuple
  from pytensor.tensor.type import TensorType, all_dtypes
  from pytensor.tensor.type_other import NoneConst
  from pytensor.tensor.variable import TensorVariable
label_desc: Use image node_id 9 for calling the RandomVariable obj's underlying member method code with example usage: obj.perform(node, inputs, outputs) without return types