code: def create_minibatch_rv(
      rv: TensorVariable,
      total_size: Union[
          int, None, Sequence[Union[int, EllipsisType, None]]
      ],
  ) -> TensorVariable:
      """Create variable whose logp is rescaled by total_size."""
      if isinstance(total_size, int):
          if rv.ndim <= 1:
              total_size = [total_size]
          else:
              missing_ndims = rv.ndim - 1
              total_size = [total_size] + [None] * missing_ndims
      elif isinstance(total_size, (list, tuple)):
          total_size = list(total_size)
          if Ellipsis in total_size:
              # Replace Ellipsis by None
              if total_size.count(Ellipsis) > 1:
                  raise ValueError(
                      "Only one Ellipsis can be present in total_size"
                  )
              sep = total_size.index(Ellipsis)
              begin = total_size[:sep]
              end = total_size[sep + 1 :]
              missing_ndims = max((rv.ndim - len(begin) - len(end), 0))
              total_size = begin + [None] * missing_ndims + end
          if len(total_size) > rv.ndim:
              raise ValueError(
                  f"Length of total_size {total_size} is langer than RV ndim {rv.ndim}"
              )
      else:
          raise TypeError(f"Invalid type for total_size: {total_size}")
  
      return cast(TensorVariable, minibatch_rv(rv, *total_size))
  
file_path: pymc/pymc/variational/minibatch_rv.py
imports: from typing import Any, Sequence, Union, cast
  import pytensor.tensor
  from pytensor import Variable, config
  from pytensor.graph import Apply, Op
  from pytensor.tensor import NoneConst, TensorVariable, as_tensor_variable
  from pymc.logprob.abstract import MeasurableVariable, _logprob, _logprob_helper
label_desc: Use image node_id 1 for calling a global function with example usage: create_minibatch_rv(rv, total_size) and returns: cast