class_docstr: Encapsulate CmdStan specific logic.
class_docstr_tok: ["Encapsulate","CmdStan","specific","logic","."]
docstr: Extract sample_stats from fit.
docstr_tok: ["Extract","sample_stats","from","fit","."]
code: def sample_stats_prior_to_xarray(self):
      """Extract sample_stats from fit."""
      dtypes = {
          "diverging": bool,
          "n_steps": np.int64,
          "tree_depth": np.int64,
          **self.dtypes,
      }
      rename_dict = {
          "divergent": "diverging",
          "n_leapfrog": "n_steps",
          "treedepth": "tree_depth",
          "stepsize": "step_size",
          "accept_stat": "acceptance_rate",
      }
  
      columns_new = {}
      for key, idx in self.sample_stats_prior_columns.items():
          name = re.sub("__$", "", key)
          name = rename_dict.get(name, name)
          columns_new[name] = idx
  
      data = _unpack_ndarrays(self.posterior[0], columns_new, dtypes)
      data_warmup = _unpack_ndarrays(
          self.posterior[1], columns_new, dtypes
      )
      return (
          dict_to_dataset(
              data,
              coords=self.coords,
              dims=self.dims,
              attrs={item: key for key, item in rename_dict.items()},
              index_origin=self.index_origin,
          ),
          dict_to_dataset(
              data_warmup,
              coords=self.coords,
              dims=self.dims,
              attrs={item: key for key, item in rename_dict.items()},
              index_origin=self.index_origin,
          ),
      )
  
imports: import logging
  import os
  import re
  from collections import defaultdict
  from glob import glob
  from pathlib import Path
  from typing import Dict, List, Optional, Union
  import numpy
  from ..None import utils
  from ..rcparams import rcParams
  from .base import CoordSpec, DimSpec, dict_to_dataset, infer_stan_dtypes, requires
  from .inference_data import InferenceData
label_desc: Use image node_id 10 for calling the CmdStanConverter obj's underlying member method code with example usage: obj.sample_stats_prior_to_xarray() and returns: dict_to_dataset,  dict_to_dataset