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: Apply a function to multiple groups.
  
  Applies ``fun`` groupwise to the selected ``InferenceData`` groups and overwrites the
  group with the result of the function.
  
  Parameters
  ----------
  fun : callable
      Function to be applied to each group. Assumes the function is called as
      ``fun(dataset, *args, **kwargs)``.
  groups : str or list of str, optional
      Groups where the selection is to be applied. Can either be group names
      or metagroup names.
  filter_groups : {None, "like", "regex"}, optional
      If `None` (default), interpret var_names as the real variables names. If "like",
      interpret var_names as substrings of the real variables names. If "regex",
      interpret var_names as regular expressions on the real variables names. A la
      `pandas.filter`.
  inplace : bool, optional
      If ``True``, modify the InferenceData object inplace,
      otherwise, return the modified copy.
  args : array_like, optional
      Positional arguments passed to ``fun``.
  **kwargs : mapping, optional
      Keyword arguments passed to ``fun``.
  
  Returns
  -------
  InferenceData
      A new InferenceData object by default.
      When `inplace==True` perform selection in place and return `None`
  
  Examples
  --------
  Shift observed_data, prior_predictive and posterior_predictive.
  
  .. jupyter-execute::
  
      import arviz as az
      import numpy as np
      idata = az.load_arviz_data("non_centered_eight")
      idata_shifted_obs = idata.map(lambda x: x + 3, groups="observed_vars")
      idata_shifted_obs
  
  Rename and update the coordinate values in both posterior and prior groups.
  
  .. jupyter-execute::
  
      idata = az.load_arviz_data("radon")
      idata = idata.map(
          lambda ds: ds.rename({"g_coef": "uranium_coefs"}).assign(
              uranium_coefs=["intercept", "u_slope"]
          ),
          groups=["posterior", "prior"]
      )
      idata
  
  Add extra coordinates to all groups containing observed variables
  
  .. jupyter-execute::
  
      idata = az.load_arviz_data("rugby")
      home_team, away_team = np.array([
          m.split() for m in idata.observed_data.match.values
      ]).T
      idata = idata.map(
          lambda ds, **kwargs: ds.assign_coords(**kwargs),
          groups="observed_vars",
          home_team=("match", home_team),
          away_team=("match", away_team),
      )
      idata
docstr_tok: ["Apply","a","function","to","multiple","groups",".","Applies","``","fun","``","groupwise","to","the","selected","``","InferenceData","``","groups","and","overwrites","the","group","with","the","result","of","the","function",".","Parameters","--","--","--","--","--","fun",":","callable","Function","to","be","applied","to","each","group",".","Assumes","the","function","is","called","as","``","fun","(","dataset",",","*","args",",","*","*","kwargs",")","``",".","groups",":","str","or","list","of","str",",","optional","Groups","where","the","selection","is","to","be","applied",".","Can","either","be","group","names","or","metagroup","names",".","filter_groups",":","{","None",",","``","like","''",",","``","regex","''","}",",","optional","If","`","None","`","(","default",")",",","interpret","var_names","as","the","real","variables","names",".","If","``","like","''",",","interpret","var_names","as","substrings","of","the","real","variables","names",".","If","``","regex","''",",","interpret","var_names","as","regular","expressions","on","the","real","variables","names",".","A","la","`","pandas.filter","`",".","inplace",":","bool",",","optional","If","``","True","``",",","modify","the","InferenceData","object","inplace",",","otherwise",",","return","the","modified","copy",".","args",":","array_like",",","optional","Positional","arguments","passed","to","``","fun","``",".","*","*","kwargs",":","mapping",",","optional","Keyword","arguments","passed","to","``","fun","``",".","Returns","--","--","--","-","InferenceData","A","new","InferenceData","object","by","default",".","When","`","inplace==True","`","perform","selection","in","place","and","return","`","None","`","Examples","--","--","--","--","Shift","observed_data",",","prior_predictive","and","posterior_predictive",".","..","jupyter-execute",":",":","import","arviz","as","az","import","numpy","as","np","idata","=","az.load_arviz_data","(","``","non_centered_eight","''",")","idata_shifted_obs","=","idata.map","(","lambda","x",":","x","+","3",",","groups=","''","observed_vars","''",")","idata_shifted_obs","Rename","and","update","the","coordinate","values","in","both","posterior","and","prior","groups",".","..","jupyter-execute",":",":","idata","=","az.load_arviz_data","(","``","radon","''",")","idata","=","idata.map","(","lambda","ds",":","ds.rename","(","{","``","g_coef","''",":","``","uranium_coefs","''","}",")",".assign","(","uranium_coefs=","[","``","intercept","''",",","``","u_slope","''","]",")",",","groups=","[","``","posterior","''",",","``","prior","''","]",")","idata","Add","extra","coordinates","to","all","groups","containing","observed","variables","..","jupyter-execute",":",":","idata","=","az.load_arviz_data","(","``","rugby","''",")","home_team",",","away_team","=","np.array","(","[","m.split","(",")","for","m","in","idata.observed_data.match.values","]",")",".T","idata","=","idata.map","(","lambda","ds",",","*","*","kwargs",":","ds.assign_coords","(","*","*","kwargs",")",",","groups=","''","observed_vars","''",",","home_team=","(","``","match","''",",","home_team",")",",","away_team=","(","``","match","''",",","away_team",")",",",")","idata"]
code: def map(
      self,
      fun,
      groups=None,
      filter_groups=None,
      inplace=False,
      args=None,
      **kwargs,
  ):
      """Apply a function to multiple groups.
  
      Applies ``fun`` groupwise to the selected ``InferenceData`` groups and overwrites the
      group with the result of the function.
  
      Parameters
      ----------
      fun : callable
          Function to be applied to each group. Assumes the function is called as
          ``fun(dataset, *args, **kwargs)``.
      groups : str or list of str, optional
          Groups where the selection is to be applied. Can either be group names
          or metagroup names.
      filter_groups : {None, "like", "regex"}, optional
          If `None` (default), interpret var_names as the real variables names. If "like",
          interpret var_names as substrings of the real variables names. If "regex",
          interpret var_names as regular expressions on the real variables names. A la
          `pandas.filter`.
      inplace : bool, optional
          If ``True``, modify the InferenceData object inplace,
          otherwise, return the modified copy.
      args : array_like, optional
          Positional arguments passed to ``fun``.
      **kwargs : mapping, optional
          Keyword arguments passed to ``fun``.
  
      Returns
      -------
      InferenceData
          A new InferenceData object by default.
          When `inplace==True` perform selection in place and return `None`
  
      Examples
      --------
      Shift observed_data, prior_predictive and posterior_predictive.
  
      .. jupyter-execute::
  
          import arviz as az
          import numpy as np
          idata = az.load_arviz_data("non_centered_eight")
          idata_shifted_obs = idata.map(lambda x: x + 3, groups="observed_vars")
          idata_shifted_obs
  
      Rename and update the coordinate values in both posterior and prior groups.
  
      .. jupyter-execute::
  
          idata = az.load_arviz_data("radon")
          idata = idata.map(
              lambda ds: ds.rename({"g_coef": "uranium_coefs"}).assign(
                  uranium_coefs=["intercept", "u_slope"]
              ),
              groups=["posterior", "prior"]
          )
          idata
  
      Add extra coordinates to all groups containing observed variables
  
      .. jupyter-execute::
  
          idata = az.load_arviz_data("rugby")
          home_team, away_team = np.array([
              m.split() for m in idata.observed_data.match.values
          ]).T
          idata = idata.map(
              lambda ds, **kwargs: ds.assign_coords(**kwargs),
              groups="observed_vars",
              home_team=("match", home_team),
              away_team=("match", away_team),
          )
          idata
  
      """
      if args is None:
          args = []
      groups = self._group_names(groups, filter_groups)
  
      out = self if inplace else deepcopy(self)
      for group in groups:
          dataset = getattr(self, group)
          dataset = fun(dataset, *args, **kwargs)
          setattr(out, group, dataset)
      if inplace:
          return None
      else:
          return out
  
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 36 for calling the InferenceData obj's underlying member method code with example usage: obj.map(fun, groups, filter_groups, inplace, args) and returns: None, out