class_docstr: Encapsulate InferenceData specific logic.
docstr: Convert the posterior to an xarray dataset.
docstr_tok: ["Convert","the","posterior","to","an","xarray","dataset","."]
code: def posterior_to_xarray(self):
      """Convert the posterior to an xarray dataset."""
      var_names = get_default_varnames(
          self.trace.varnames,
          include_transformed=self.include_transformed,
      )
      data = {}
      data_warmup = {}
      for var_name in var_names:
          if self.warmup_trace:
              data_warmup[var_name] = np.array(
                  self.warmup_trace.get_values(
                      var_name, combine=False, squeeze=False
                  )
              )
          if self.posterior_trace:
              data[var_name] = np.array(
                  self.posterior_trace.get_values(
                      var_name, combine=False, squeeze=False
                  )
              )
      return (
          dict_to_dataset(
              data,
              library=pymc,
              coords=self.coords,
              dims=self.dims,
              attrs=self.attrs,
          ),
          dict_to_dataset(
              data_warmup,
              library=pymc,
              coords=self.coords,
              dims=self.dims,
              attrs=self.attrs,
          ),
      )
  
imports: import logging
  import warnings
  from typing import TYPE_CHECKING, Any, Dict, Iterable, List, Mapping, Optional, Tuple, Union
  import numpy
  from arviz import InferenceData, concat, rcParams
  from arviz.data.base import CoordSpec, DimSpec, dict_to_dataset, requires
  from pytensor.graph.basic import Constant
  from pytensor.tensor.sharedvar import SharedVariable
  import pymc
  from pymc.model import Model, modelcontext
  from pymc.pytensorf import extract_obs_data
  from pymc.util import get_default_varnames
label_desc: Use image node_id 3 for calling the InferenceDataConverter obj's underlying member method code with example usage: obj.posterior_to_xarray() and returns: dict_to_dataset,  dict_to_dataset