class_docstr: Wraps an McBackend ``Chain`` as an ``IBaseTrace``.
class_docstr_tok: ["Wraps","an","McBackend","``","Chain","``","as","an","``","IBaseTrace","``","."]
code: def get_sampler_stats(
      self,
      stat_name: str,
      sampler_idx: Optional[int] = None,
      burn=0,
      thin=1,
  ) -> np.ndarray:
      slc = slice(burn, None, thin)
      # When there's just one sampler, default to remove the sampler dimension
      if sampler_idx is None and self._statsbj.n_samplers == 1:
          sampler_idx = 0
      # Fetching for a specific sampler is easy
      if sampler_idx is not None:
          return self._get_stats(
              flat_statname(sampler_idx, stat_name), slc
          )
      # To fetch for all samplers, we must collect the arrays one by one.
      stats_dict = {
          stat.name: self._get_stats(stat.name, slc)
          for stat in self._chain.rmeta.sample_stats
          if stat_name in stat.name
      }
      if not stats_dict:
          raise KeyError(f"No stat '{stat_name}' was recorded.")
      stats_list = self._statsbj.rmap(stats_dict)
      stats_arrays = []
      is_ragged = False
      for sd in stats_list:
          if not sd:
              is_ragged = True
              continue
          else:
              stats_arrays.append(tuple(sd.values())[0])
  
      if is_ragged:
          _log.debug(
              "Stat '%s' was not recorded by all samplers.", stat_name
          )
      if len(stats_arrays) == 1:
          return stats_arrays[0]
      return np.array(stats_arrays).T
  
imports: import base64
  import logging
  import pickle
  from typing import Any, Dict, List, Mapping, Optional, Sequence, Tuple, Union, cast
  import hagelkorn
  import mcbackend
  import numpy
  from mcbackend.npproto.utils import ndarray_from_numpy
  from pytensor.compile.sharedvalue import SharedVariable
  from pytensor.graph.basic import Constant
  from pymc.backends.base import IBaseTrace
  from pymc.model import Model
  from pymc.pytensorf import PointFunc
  from pymc.step_methods.compound import BlockedStep, CompoundStep, StatsBijection, check_step_emits_tune, flat_statname, flatten_steps
label_desc: Use image node_id 6 for calling the ChainRecordAdapter obj's underlying member method code with example usage: obj.get_sampler_stats(stat_name, sampler_idx, burn, thin) and returns: np, self, stats_arrays