code: def to_inference_data(
      trace: Optional["MultiTrace"] = None,
      *,
      prior: Optional[Mapping[str, Any]] = None,
      posterior_predictive: Optional[Mapping[str, Any]] = None,
      log_likelihood: Union[bool, Iterable[str]] = False,
      coords: Optional[CoordSpec] = None,
      dims: Optional[DimSpec] = None,
      sample_dims: Optional[List] = None,
      model: Optional["Model"] = None,
      save_warmup: Optional[bool] = None,
      include_transformed: bool = False,
  ) -> InferenceData:
      """Convert pymc data into an InferenceData object.
  
      All three of them are optional arguments, but at least one of ``trace``,
      ``prior`` and ``posterior_predictive`` must be present.
      For a usage example read the
      :ref:`Creating InferenceData section on from_pymc <creating_InferenceData>`
  
      Parameters
      ----------
      trace : MultiTrace, optional
          Trace generated from MCMC sampling. Output of
          :func:`~pymc.sampling.sample`.
      prior : dict, optional
          Dictionary with the variable names as keys, and values numpy arrays
          containing prior and prior predictive samples.
      posterior_predictive : dict, optional
          Dictionary with the variable names as keys, and values numpy arrays
          containing posterior predictive samples.
      log_likelihood : bool or array_like of str, optional
          List of variables to calculate `log_likelihood`. Defaults to True which calculates
          `log_likelihood` for all observed variables. If set to False, log_likelihood is skipped.
      coords : dict of {str: array-like}, optional
          Map of coordinate names to coordinate values
      dims : dict of {str: list of str}, optional
          Map of variable names to the coordinate names to use to index its dimensions.
      model : Model, optional
          Model used to generate ``trace``. It is not necessary to pass ``model`` if in
          ``with`` context.
      save_warmup : bool, optional
          Save warmup iterations InferenceData object. If not defined, use default
          defined by the rcParams.
      include_transformed : bool, optional
          Save the transformed parameters in the InferenceData object. By default, these are
          not saved.
  
      Returns
      -------
      arviz.InferenceData
      """
      if isinstance(trace, InferenceData):
          return trace
  
      return InferenceDataConverter(
          trace=trace,
          prior=prior,
          posterior_predictive=posterior_predictive,
          log_likelihood=log_likelihood,
          coords=coords,
          dims=dims,
          sample_dims=sample_dims,
          model=model,
          save_warmup=save_warmup,
          include_transformed=include_transformed,
      ).to_inference_data()
  
imports: import logging
  import warnings
  from typing import TYPE_CHECKING, Any, Dict, Iterable, List, Mapping, Optional, Tuple, Union
  import numpy
  from arviz import InferenceData, concat, rcParams
  from arviz.data.base import CoordSpec, DimSpec, dict_to_dataset, requires
  from pytensor.graph.basic import Constant
  from pytensor.tensor.sharedvar import SharedVariable
  import pymc
  from pymc.model import Model, modelcontext
  from pymc.pytensorf import extract_obs_data
  from pymc.util import get_default_varnames
label_desc: Use image node_id 4 for calling a global function with example usage: to_inference_data(trace) and returns: InferenceDataConverter, trace