code: def normalize_size_param(
      size: Optional[Union[int, np.ndarray, Variable, Sequence]],
  ) -> Variable:
      """Create an PyTensor value for a ``RandomVariable`` ``size`` parameter."""
      if size is None:
          size = constant([], dtype="int64")
      elif isinstance(size, int):
          size = as_tensor_variable([size], ndim=1)
      elif not isinstance(size, (np.ndarray, Variable, Sequence)):
          raise TypeError(
              "Parameter size must be None, an integer, or a sequence with integers."
          )
      else:
          size = cast(
              as_tensor_variable(size, ndim=1, dtype="int64"), "int64"
          )
  
          if not isinstance(size, Constant):
              # This should help ensure that the length of non-constant `size`s
              # will be available after certain types of cloning (e.g. the kind
              # `Scan` performs)
              size = specify_shape(size, (get_vector_length(size),))
  
      assert not any(s is None for s in size.type.shape)
      assert size.dtype in int_dtypes
  
      return size
  
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 3 for calling a global function with example usage: normalize_size_param(size) and returns: size