class_docstr: Wraps an McBackend ``Chain`` as an ``IBaseTrace``.
class_docstr_tok: ["Wraps","an","McBackend","``","Chain","``","as","an","``","IBaseTrace","``","."]
code: def _slice(self, idx: slice) -> "IBaseTrace":
      # Get the integer indices
      start, stop, step = idx.indices(len(self))
      indices = np.arange(start, stop, step)
  
      # Create a NumPyChain for the sliced data
      nchain = mcb.backends.numpy.NumPyChain(
          self._chain.cmeta, self._chain.rmeta, preallocate=len(indices)
      )
  
      # Copy at selected indices and append them to the new chain.
      # This may be slow, but NumPyChain currently don't have a batch-insert or slice API.
      vnames = [v.name for v in nchain.variables.values()]
      snames = [s.name for s in nchain.sample_stats.values()]
      for i in indices:
          draw = self._chain.get_draws_at(i, var_names=vnames)
          stats = self._chain.get_stats_at(i, stat_names=snames)
          nchain.append(draw, stats)
      return ChainRecordAdapter(nchain, self._point_fn, self._statsbj)
  
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 7 for calling the ChainRecordAdapter obj's underlying member method code with example usage: obj._slice(idx) and returns: ChainRecordAdapter