code: def sample_prior_predictive(
      samples: int = 500,
      model: Optional[Model] = None,
      var_names: Optional[Iterable[str]] = None,
      random_seed: RandomState = None,
      return_inferencedata: bool = True,
      idata_kwargs: dict = None,
      compile_kwargs: dict = None,
  ) -> Union[InferenceData, Dict[str, np.ndarray]]:
      """Generate samples from the prior predictive distribution.
  
      Parameters
      ----------
      samples : int
          Number of samples from the prior predictive to generate. Defaults to 500.
      model : Model (optional if in ``with`` context)
      var_names : Iterable[str]
          A list of names of variables for which to compute the prior predictive
          samples. Defaults to both observed and unobserved RVs. Transformed values
          are not allowed.
      random_seed : int, RandomState or Generator, optional
          Seed for the random number generator.
      return_inferencedata : bool
          Whether to return an :class:`arviz:arviz.InferenceData` (True) object or a dictionary (False).
          Defaults to True.
      idata_kwargs : dict, optional
          Keyword arguments for :func:`pymc.to_inference_data`
      compile_kwargs: dict, optional
          Keyword arguments for :func:`pymc.pytensorf.compile_pymc`.
  
      Returns
      -------
      arviz.InferenceData or Dict
          An ArviZ ``InferenceData`` object containing the prior and prior predictive samples (default),
          or a dictionary with variable names as keys and samples as numpy arrays.
      """
      model = modelcontext(model)
  
      if model.potentials:
          warnings.warn(
              "The effect of Potentials on other parameters is ignored during prior predictive sampling. "
              "This is likely to lead to invalid or biased predictive samples.",
              UserWarning,
              stacklevel=2,
          )
  
      if var_names is None:
          vars_: Set[str] = {
              var.name for var in model.basic_RVs + model.deterministics
          }
      else:
          vars_ = set(var_names)
  
      names = sorted(
          get_default_varnames(vars_, include_transformed=False)
      )
      vars_to_sample = [model[name] for name in names]
  
      # Any variables from var_names still missing are assumed to be transformed variables.
      missing_names = vars_.difference(names)
      if missing_names:
          raise ValueError(f"Unrecognized var_names: {missing_names}")
  
      if random_seed is not None:
          (random_seed,) = _get_seeds_per_chain(random_seed, 1)
  
      if compile_kwargs is None:
          compile_kwargs = {}
      compile_kwargs.setdefault("allow_input_downcast", True)
      compile_kwargs.setdefault("accept_inplace", True)
  
      (
          sampler_fn,
          volatile_basic_rvs,
      ) = compile_forward_sampling_function(
          vars_to_sample,
          vars_in_trace=[],
          basic_rvs=model.basic_RVs,
          givens_dict=None,
          random_seed=random_seed,
          **compile_kwargs,
      )
  
      # All model variables have a name, but mypy does not know this
      _log.info(f"Sampling: {list(sorted(volatile_basic_rvs, key=lambda var: var.name))}")  # type: ignore
      values = zip(*(sampler_fn() for i in range(samples)))
  
      data = {k: np.stack(v) for k, v in zip(names, values)}
      if data is None:
          raise AssertionError(
              "No variables sampled: attempting to sample %s" % names
          )
  
      prior: Dict[str, np.ndarray] = {}
      for var_name in vars_:
          if var_name in data:
              prior[var_name] = data[var_name]
  
      if not return_inferencedata:
          return prior
      ikwargs: Dict[str, Any] = dict(model=model)
      if idata_kwargs:
          ikwargs.update(idata_kwargs)
      return pm.to_inference_data(prior=prior, **ikwargs)
  
imports: import logging
  import warnings
  from typing import Any, Callable, Dict, Iterable, List, Optional, Sequence, Set, Tuple, Union, cast
  import numpy
  import xarray
  from arviz import InferenceData
  from fastprogress.fastprogress import progress_bar
  from pytensor import tensor
  from pytensor.graph.basic import Apply, Constant, Variable, ancestors, general_toposort, walk
  from pytensor.graph.fg import FunctionGraph
  from pytensor.tensor.random.var import RandomGeneratorSharedVariable, RandomStateSharedVariable
  from pytensor.tensor.sharedvar import SharedVariable
  from typing_extensions import TypeAlias
  import pymc
  from pymc.backends.arviz import _DefaultTrace
  from pymc.backends.base import MultiTrace
  from pymc.blocking import PointType
  from pymc.model import Model, modelcontext
  from pymc.pytensorf import compile_pymc
  from pymc.util import RandomState, _get_seeds_per_chain, dataset_to_point_list, get_default_varnames, point_wrapper
label_desc: Use image node_id 5 for calling a global function with example usage: sample_prior_predictive(samples, model, var_names, random_seed, return_inferencedata, idata_kwargs, compile_kwargs) and returns: pm, prior