class_docstr: Encapsulate Pyro specific logic.
docstr: Extract sample_stats from Pyro posterior.
docstr_tok: ["Extract","sample_stats","from","Pyro","posterior","."]
code: def sample_stats_to_xarray(self):
      """Extract sample_stats from Pyro posterior."""
      divergences = self.posterior.diagnostics()["divergences"]
      diverging = np.zeros((self.nchains, self.ndraws), dtype=bool)
      for i, k in enumerate(sorted(divergences)):
          diverging[i, divergences[k]] = True
      data = {"diverging": diverging}
      return dict_to_dataset(
          data, library=self.pyro, coords=self.coords, dims=None
      )
  
imports: import logging
  from typing import Callable, Optional
  import warnings
  import numpy
  from packaging import version
  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 PyroConverter obj's underlying member method code with example usage: obj.sample_stats_to_xarray() and returns: dict_to_dataset