code: def _extend_xr_method(
      func, doc=None, description="", examples="", see_also=""
  ):
      """Make wrapper to extend methods from xr.Dataset to InferenceData Class.
  
      Parameters
      ----------
      func : callable
          An xr.Dataset function
      doc : str
          docstring for the func
      description : str
          the description of the func to be added in docstring
      examples : str
          the examples of the func to be added in docstring
      see_also : str, list
          the similar methods of func to be included in See Also section of docstring
  
      """
      # pydocstyle requires a non empty line
  
      @functools.wraps(func)
      def wrapped(self, *args, **kwargs):
          _filter = kwargs.pop("filter_groups", None)
          _groups = kwargs.pop("groups", None)
          _inplace = kwargs.pop("inplace", False)
  
          out = self if _inplace else deepcopy(self)
  
          groups = self._group_names(
              _groups, _filter
          )  # pylint: disable=protected-access
          for group in groups:
              xr_data = getattr(out, group)
              xr_data = func(
                  xr_data, *args, **kwargs
              )  # pylint: disable=not-callable
              setattr(out, group, xr_data)
  
          return None if _inplace else out
  
      description_default = """{method_name} method is extended from xarray.Dataset methods.
  
      {description}
  
      For more info see :meth:`xarray:xarray.Dataset.{method_name}`.
      In addition to the arguments available in the original method, the following
      ones are added by ArviZ to adapt the method to being called on an ``InferenceData`` object.
      """.format(
          description=description,
          method_name=func.__name__,  # pylint: disable=no-member
      )
      params = """
      Other Parameters
      ----------------
      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, default=None
          If `None` (default), interpret groups as the real group or metagroup names.
          If "like", interpret groups as substrings of the real group or metagroup names.
          If "regex", interpret groups as regular expressions on the real group or
          metagroup names. A la `pandas.filter`.
      inplace: bool, optional
          If ``True``, modify the InferenceData object inplace,
          otherwise, return the modified copy.
      """
  
      if not isinstance(see_also, str):
          see_also = "\n".join(see_also)
      see_also_basic = """
      See Also
      --------
      xarray.Dataset.{method_name}
      {custom_see_also}
      """.format(
          method_name=func.__name__,
          custom_see_also=see_also,  # pylint: disable=no-member
      )
      wrapped.__doc__ = (
          description_default + params + examples + see_also_basic
          if doc is None
          else doc
      )
  
      return wrapped
  
imports: import datetime
  import functools
  import importlib
  import re
  import warnings
  from copy import deepcopy
  from typing import Any, Callable, Dict, List, Optional, Tuple, TypeVar, Union
  import numpy
  import xarray
  from ..None import __version__, utils
  from ..rcparams import rcParams
label_desc: Use image node_id 5 for calling a global function with example usage: _extend_xr_method(func, doc, description, examples, see_also) and returns: wrapped, unknown