class_docstr: Encapsulate NumPyro specific logic.
class_docstr_tok: ["Encapsulate","NumPyro","specific","logic","."]
docstr: Extract sample_stats from NumPyro posterior.
docstr_tok: ["Extract","sample_stats","from","NumPyro","posterior","."]
code: def sample_stats_to_xarray(self):
      """Extract sample_stats from NumPyro posterior."""
      rename_key = {
          "potential_energy": "lp",
          "adapt_state.step_size": "step_size",
          "num_steps": "n_steps",
          "accept_prob": "acceptance_rate",
      }
      data = {}
      for stat, value in self.posterior.get_extra_fields(
          group_by_chain=True
      ).items():
          if isinstance(value, (dict, tuple)):
              continue
          name = rename_key.get(stat, stat)
          value = value.copy()
          data[name] = value
          if stat == "num_steps":
              data["tree_depth"] = np.log2(value).astype(int) + 1
      return dict_to_dataset(
          data,
          library=self.numpyro,
          dims=None,
          coords=self.coords,
          index_origin=self.index_origin,
      )
  
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 3 for calling the NumPyroConverter obj's underlying member method code with example usage: obj.sample_stats_to_xarray() and returns: dict_to_dataset