code: def chains_and_samples(
      data: Union[xarray.Dataset, arviz.InferenceData]
  ) -> Tuple[int, int]:
      """Extract and return number of chains and samples in xarray or arviz traces."""
      dataset: xarray.Dataset
      if isinstance(data, xarray.Dataset):
          dataset = data
      elif isinstance(data, arviz.InferenceData):
          dataset = data["posterior"]
      else:
          raise ValueError(
              "Argument must be xarray Dataset or arviz InferenceData. Got %s",
              data.__class__,
          )
  
      coords = dataset.coords
      nchains = coords["chain"].sizes["chain"]
      nsamples = coords["draw"].sizes["draw"]
      return nchains, nsamples
  
imports: import functools
  import warnings
  from typing import Any, Dict, List, NewType, Optional, Sequence, Tuple, Union, cast
  import arviz
  import cloudpickle
  import numpy
  import xarray
  from cachetools import LRUCache, cachedmethod
  from pytensor import Variable
  from pytensor.compile import SharedVariable
  from pytensor.graph.utils import ValidatingScratchpad
  from pymc.exceptions import BlockModelAccessError
label_desc: Use image node_id 11 for calling a global function with example usage: chains_and_samples(data) and returns: nchains,  nsamples