class_docstr: Container for inference data storage using xarray.
  
  For a detailed introduction to ``InferenceData`` objects and their usage, see
  :ref:`xarray_for_arviz`. This page provides help and documentation
  on ``InferenceData`` methods and their low level implementation.
class_docstr_tok: ["Container","for","inference","data","storage","using","xarray",".","For","a","detailed","introduction","to","``","InferenceData","``","objects","and","their","usage",",","see",":","ref",":","`","xarray_for_arviz","`",".","This","page","provides","help","and","documentation","on","``","InferenceData","``","methods","and","their","low","level","implementation","."]
docstr: Initialize InferenceData object from keyword xarray datasets.
  
  Parameters
  ----------
  attrs : dict
      sets global attribute for InferenceData object.
  kwargs :
      Keyword arguments of xarray datasets
  
  Examples
  --------
  Initiate an InferenceData object from scratch, not recommended. InferenceData
  objects should be initialized using ``from_xyz`` methods, see :ref:`data_api` for more
  details.
  
  .. ipython::
  
      In [1]: import arviz as az
         ...: import numpy as np
         ...: import xarray as xr
         ...: dataset = xr.Dataset(
         ...:     {
         ...:         "a": (["chain", "draw", "a_dim"], np.random.normal(size=(4, 100, 3))),
         ...:         "b": (["chain", "draw"], np.random.normal(size=(4, 100))),
         ...:     },
         ...:     coords={
         ...:         "chain": (["chain"], np.arange(4)),
         ...:         "draw": (["draw"], np.arange(100)),
         ...:         "a_dim": (["a_dim"], ["x", "y", "z"]),
         ...:     }
         ...: )
         ...: idata = az.InferenceData(posterior=dataset, prior=dataset)
         ...: idata
  
  We have created an ``InferenceData`` object with two groups. Now we can check its
  contents:
  
  .. ipython::
  
      In [1]: idata.posterior
docstr_tok: ["Initialize","InferenceData","object","from","keyword","xarray","datasets",".","Parameters","--","--","--","--","--","attrs",":","dict","sets","global","attribute","for","InferenceData","object",".","kwargs",":","Keyword","arguments","of","xarray","datasets","Examples","--","--","--","--","Initiate","an","InferenceData","object","from","scratch",",","not","recommended",".","InferenceData","objects","should","be","initialized","using","``","from_xyz","``","methods",",","see",":","ref",":","`","data_api","`","for","more","details",".","..","ipython",":",":","In","[","1","]",":","import","arviz","as","az","...",":","import","numpy","as","np","...",":","import","xarray","as","xr","...",":","dataset","=","xr.Dataset","(","...",":","{","...",":","``","a","''",":","(","[","``","chain","''",",","``","draw","''",",","``","a_dim","''","]",",","np.random.normal","(","size=","(","4",",","100",",","3",")",")",")",",","...",":","``","b","''",":","(","[","``","chain","''",",","``","draw","''","]",",","np.random.normal","(","size=","(","4",",","100",")",")",")",",","...",":","}",",","...",":","coords=","{","...",":","``","chain","''",":","(","[","``","chain","''","]",",","np.arange","(","4",")",")",",","...",":","``","draw","''",":","(","[","``","draw","''","]",",","np.arange","(","100",")",")",",","...",":","``","a_dim","''",":","(","[","``","a_dim","''","]",",","[","``","x","''",",","``","y","''",",","``","z","''","]",")",",","...",":","}","...",":",")","...",":","idata","=","az.InferenceData","(","posterior=dataset",",","prior=dataset",")","...",":","idata","We","have","created","an","``","InferenceData","``","object","with","two","groups",".","Now","we","can","check","its","contents",":","..","ipython",":",":","In","[","1","]",":","idata.posterior"]
code: def __init__(
      self,
      attrs: Union[None, Mapping[Any, Any]] = None,
      **kwargs: Union[
          xr.Dataset, List[xr.Dataset], Tuple[xr.Dataset, xr.Dataset]
      ],
  ) -> None:
      """Initialize InferenceData object from keyword xarray datasets.
  
      Parameters
      ----------
      attrs : dict
          sets global attribute for InferenceData object.
      kwargs :
          Keyword arguments of xarray datasets
  
      Examples
      --------
      Initiate an InferenceData object from scratch, not recommended. InferenceData
      objects should be initialized using ``from_xyz`` methods, see :ref:`data_api` for more
      details.
  
      .. ipython::
  
          In [1]: import arviz as az
             ...: import numpy as np
             ...: import xarray as xr
             ...: dataset = xr.Dataset(
             ...:     {
             ...:         "a": (["chain", "draw", "a_dim"], np.random.normal(size=(4, 100, 3))),
             ...:         "b": (["chain", "draw"], np.random.normal(size=(4, 100))),
             ...:     },
             ...:     coords={
             ...:         "chain": (["chain"], np.arange(4)),
             ...:         "draw": (["draw"], np.arange(100)),
             ...:         "a_dim": (["a_dim"], ["x", "y", "z"]),
             ...:     }
             ...: )
             ...: idata = az.InferenceData(posterior=dataset, prior=dataset)
             ...: idata
  
      We have created an ``InferenceData`` object with two groups. Now we can check its
      contents:
  
      .. ipython::
  
          In [1]: idata.posterior
  
      """
      self._groups: List[str] = []
      self._groups_warmup: List[str] = []
      self._attrs: Union[None, dict] = (
          dict(attrs) if attrs is not None else None
      )
      save_warmup = kwargs.pop("save_warmup", False)
      key_list = [key for key in SUPPORTED_GROUPS_ALL if key in kwargs]
      for key in kwargs:
          if key not in SUPPORTED_GROUPS_ALL:
              key_list.append(key)
              warnings.warn(
                  f"{key} group is not defined in the InferenceData scheme",
                  UserWarning,
              )
      for key in key_list:
          dataset = kwargs[key]
          dataset_warmup = None
          if dataset is None:
              continue
          elif isinstance(dataset, (list, tuple)):
              dataset, dataset_warmup = dataset
          elif not isinstance(dataset, xr.Dataset):
              raise ValueError(
                  "Arguments to InferenceData must be xarray Datasets "
                  f"(argument '{key}' was type '{type(dataset)}')"
              )
          if not key.startswith(WARMUP_TAG):
              if dataset:
                  setattr(self, key, dataset)
                  self._groups.append(key)
          elif key.startswith(WARMUP_TAG):
              if dataset:
                  setattr(self, key, dataset)
                  self._groups_warmup.append(key)
          if (
              save_warmup
              and dataset_warmup is not None
              and dataset_warmup
          ):
              key = f"{WARMUP_TAG}{key}"
              setattr(self, key, dataset_warmup)
              self._groups_warmup.append(key)
  
imports: import os
  import re
  import sys
  import uuid
  import warnings
  from collections import OrderedDict, defaultdict
  from collections.abc import MutableMapping, Sequence
  from copy import copy
  from copy import deepcopy
  from datetime import datetime
  from html import escape
  from typing import TYPE_CHECKING, Any, Iterable, Iterator, List, Mapping, Optional, Tuple, TypeVar, Union, overload
  import numpy
  import xarray
  from packaging import version
  from ..rcparams import rcParams
  from ..utils import HtmlTemplate, _subset_list, _var_names, either_dict_or_kwargs
  from .base import _extend_xr_method, _make_json_serializable, dict_to_dataset
label_desc: Use image node_id 1 to create a new InferenceData object from inherited base classes: Mapping with example: obj = InferenceData(attrs)