class_docstr: Encapsulate NumPyro specific logic.
class_docstr_tok: ["Encapsulate","NumPyro","specific","logic","."]
docstr: Extract log likelihood from NumPyro posterior.
docstr_tok: ["Extract","log","likelihood","from","NumPyro","posterior","."]
code: def log_likelihood_to_xarray(self):
      """Extract log likelihood from NumPyro posterior."""
      if not self.log_likelihood:
          return None
      data = {}
      if self.observations is not None:
          samples = self.posterior.get_samples(group_by_chain=False)
          if hasattr(samples, "_asdict"):
              samples = samples._asdict()
          log_likelihood_dict = self.numpyro.infer.log_likelihood(
              self.model, samples, *self._args, **self._kwargs
          )
          for obs_name, log_like in log_likelihood_dict.items():
              shape = (self.nchains, self.ndraws) + log_like.shape[1:]
              data[obs_name] = np.reshape(log_like.copy(), shape)
      return dict_to_dataset(
          data,
          library=self.numpyro,
          dims=self.dims,
          coords=self.coords,
          index_origin=self.index_origin,
          skip_event_dims=True,
      )
  
imports: import logging
  from typing import Callable, Optional
  import numpy
  from ..None import utils
  from ..rcparams import rcParams
  from .base import dict_to_dataset, requires
  from .inference_data import InferenceData
label_desc: Use image node_id 4 for calling the NumPyroConverter obj's underlying member method code with example usage: obj.log_likelihood_to_xarray() and returns: dict_to_dataset, None