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","."]
docstr: Create a random variable node.
  
  Parameters
  ----------
  rng: RandomGeneratorType or RandomStateType
      Existing PyTensor `Generator` or `RandomState` object to be used.  Creates a
      new one, if `None`.
  size: int or Sequence
      NumPy-like size parameter.
  dtype: str
      The dtype of the sampled output.  If the value ``"floatX"`` is
      given, then `dtype` is set to ``pytensor.config.floatX``.  This value is
      only used when ``self.dtype`` isn't set.
  dist_params: list
      Distribution parameters.
  
  Results
  -------
  out: Apply
      A node with inputs ``(rng, size, dtype) + dist_args`` and outputs
      ``(rng_var, out_var)``.
docstr_tok: ["Create","a","random","variable","node",".","Parameters","--","--","--","--","--","rng",":","RandomGeneratorType","or","RandomStateType","Existing","PyTensor","`","Generator","`","or","`","RandomState","`","object","to","be","used",".","Creates","a","new","one",",","if","`","None","`",".","size",":","int","or","Sequence","NumPy-like","size","parameter",".","dtype",":","str","The","dtype","of","the","sampled","output",".","If","the","value","``","``","floatX","''","``","is","given",",","then","`","dtype","`","is","set","to","``","pytensor.config.floatX","``",".","This","value","is","only","used","when","``","self.dtype","``","is","n't","set",".","dist_params",":","list","Distribution","parameters",".","Results","--","--","--","-","out",":","Apply","A","node","with","inputs","``","(","rng",",","size",",","dtype",")","+","dist_args","``","and","outputs","``","(","rng_var",",","out_var",")","``","."]
code: def make_node(self, rng, size, dtype, *dist_params):
      """Create a random variable node.
  
      Parameters
      ----------
      rng: RandomGeneratorType or RandomStateType
          Existing PyTensor `Generator` or `RandomState` object to be used.  Creates a
          new one, if `None`.
      size: int or Sequence
          NumPy-like size parameter.
      dtype: str
          The dtype of the sampled output.  If the value ``"floatX"`` is
          given, then `dtype` is set to ``pytensor.config.floatX``.  This value is
          only used when ``self.dtype`` isn't set.
      dist_params: list
          Distribution parameters.
  
      Results
      -------
      out: Apply
          A node with inputs ``(rng, size, dtype) + dist_args`` and outputs
          ``(rng_var, out_var)``.
  
      """
      size = normalize_size_param(size)
  
      dist_params = tuple(
          as_tensor_variable(p) if not isinstance(p, Variable) else p
          for p in dist_params
      )
  
      if rng is None:
          rng = pytensor.shared(np.random.default_rng())
      elif not isinstance(rng.type, RandomType):
          raise TypeError(
              "The type of rng should be an instance of either RandomGeneratorType or RandomStateType"
          )
  
      shape = self._infer_shape(size, dist_params)
      _, static_shape = infer_static_shape(shape)
      dtype = self.dtype or dtype
  
      if dtype == "floatX":
          dtype = config.floatX
      elif dtype is None or (
          isinstance(dtype, str) and dtype not in all_dtypes
      ):
          raise TypeError("dtype is unspecified")
  
      if isinstance(dtype, str):
          dtype_idx = constant(all_dtypes.index(dtype), dtype="int64")
      else:
          dtype_idx = constant(dtype, dtype="int64")
          dtype = all_dtypes[dtype_idx.data]
  
      outtype = TensorType(dtype=dtype, shape=static_shape)
      out_var = outtype()
      inputs = (rng, size, dtype_idx) + dist_params
      outputs = (rng.type(), out_var)
  
      return Apply(self, inputs, outputs)
  
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 8 for calling the RandomVariable obj's underlying member method code with example usage: obj.make_node(rng, size, dtype) and returns: Apply