class_docstr: Encapsulate PyStan3 specific logic.
class_docstr_tok: ["Encapsulate","PyStan3","specific","logic","."]
docstr: Store log_likelihood data in log_likelihood group.
code: def log_likelihood_to_xarray(self):
      """Store log_likelihood data in log_likelihood group."""
      fit = self.posterior
  
      log_likelihood = self.log_likelihood
      model = self.posterior_model
      if isinstance(log_likelihood, str):
          log_likelihood = [log_likelihood]
      if isinstance(log_likelihood, (list, tuple)):
          log_likelihood = {name: name for name in log_likelihood}
      (
          log_likelihood_draws,
          log_likelihood_draws_warmup,
      ) = get_draws_stan3(
          fit,
          model=model,
          variables=list(log_likelihood.values()),
          warmup=self.save_warmup,
          dtypes=self.dtypes,
      )
      data = {
          obs_var_name: log_likelihood_draws[log_like_name]
          for obs_var_name, log_like_name in log_likelihood.items()
          if log_like_name in log_likelihood_draws
      }
      data_warmup = {
          obs_var_name: log_likelihood_draws_warmup[log_like_name]
          for obs_var_name, log_like_name in log_likelihood.items()
          if log_like_name in log_likelihood_draws_warmup
      }
  
      return (
          dict_to_dataset(
              data,
              library=self.stan,
              coords=self.coords,
              dims=self.dims,
          ),
          dict_to_dataset(
              data_warmup,
              library=self.stan,
              coords=self.coords,
              dims=self.dims,
          ),
      )
  
imports: import re
  from collections import OrderedDict
  from copy import deepcopy
  from math import ceil
  import numpy
  import xarray
  from ..None import _log
  from ..rcparams import rcParams
  from .base import dict_to_dataset, generate_dims_coords, infer_stan_dtypes, make_attrs, requires
  from .inference_data import InferenceData
label_desc: Use image node_id 4 for calling the PyStan3Converter obj's underlying member method code with example usage: obj.log_likelihood_to_xarray() and returns: dict_to_dataset,  dict_to_dataset