class_docstr: Encapsulate CmdStanPy specific logic.
code: def __init__(
      self,
      *,
      posterior=None,
      posterior_predictive=None,
      predictions=None,
      prior=None,
      prior_predictive=None,
      observed_data=None,
      constant_data=None,
      predictions_constant_data=None,
      log_likelihood=None,
      index_origin=None,
      coords=None,
      dims=None,
      save_warmup=None,
      dtypes=None,
  ):
      self.posterior = posterior  # CmdStanPy CmdStanMCMC object
      self.posterior_predictive = posterior_predictive
      self.predictions = predictions
      self.prior = prior
      self.prior_predictive = prior_predictive
      self.observed_data = observed_data
      self.constant_data = constant_data
      self.predictions_constant_data = predictions_constant_data
      self.log_likelihood = (
          rcParams["data.log_likelihood"]
          if log_likelihood is None
          else log_likelihood
      )
      self.index_origin = index_origin
      self.coords = coords
      self.dims = dims
  
      self.save_warmup = (
          rcParams["data.save_warmup"]
          if save_warmup is None
          else save_warmup
      )
  
      import cmdstanpy  # pylint: disable=import-error
  
      if dtypes is None:
          dtypes = {}
      elif isinstance(dtypes, cmdstanpy.model.CmdStanModel):
          model_code = dtypes.code()
          dtypes = infer_stan_dtypes(model_code)
      elif isinstance(dtypes, str):
          dtypes_path = Path(dtypes)
          if dtypes_path.exists():
              with dtypes_path.open("r", encoding="UTF-8") as f_obj:
                  model_code = f_obj.read()
          else:
              model_code = dtypes
          dtypes = infer_stan_dtypes(model_code)
  
      self.dtypes = dtypes
  
      if hasattr(self.posterior, "metadata") and hasattr(
          self.posterior.metadata, "stan_vars_cols"
      ):
          if (
              self.log_likelihood is True
              and "log_lik" in self.posterior.metadata.stan_vars_cols
          ):
              self.log_likelihood = ["log_lik"]
      elif hasattr(self.posterior, "metadata") and hasattr(
          self.posterior.metadata, "stan_vars_cols"
      ):
          if (
              self.log_likelihood is True
              and "log_lik" in self.posterior.metadata.stan_vars_cols
          ):
              self.log_likelihood = ["log_lik"]
      elif hasattr(self.posterior, "stan_vars_cols"):
          if (
              self.log_likelihood is True
              and "log_lik" in self.posterior.stan_vars_cols
          ):
              self.log_likelihood = ["log_lik"]
      elif hasattr(self.posterior, "metadata") and hasattr(
          self.posterior.metadata, "stan_vars"
      ):
          if (
              self.log_likelihood is True
              and "log_lik" in self.posterior.metadata.stan_vars
          ):
              self.log_likelihood = ["log_lik"]
      elif (
          self.log_likelihood is True
          and self.posterior is not None
          and hasattr(self.posterior, "column_names")
          and any(
              name.split("[")[0] == "log_lik"
              for name in self.posterior.column_names
          )
      ):
          self.log_likelihood = ["log_lik"]
  
      if isinstance(self.log_likelihood, bool):
          self.log_likelihood = None
  
      self.cmdstanpy = cmdstanpy
  
imports: import logging
  import re
  from collections import defaultdict
  from copy import deepcopy
  from pathlib import Path
  import numpy
  from ..rcparams import rcParams
  from .base import dict_to_dataset, infer_stan_dtypes, make_attrs, requires
  from .inference_data import InferenceData
label_desc: Use image node_id 1 to create a new CmdStanPyConverter object  with example: obj = CmdStanPyConverter()