class_docstr: NDArray trace object
  
  Parameters
  ----------
  name: str
      Name of backend. This has no meaning for the NDArray backend.
  model: Model
      If None, the model is taken from the `with` context.
  vars: list of variables
      Sampling values will be stored for these variables. If None,
      `model.unobserved_RVs` is used.
class_docstr_tok: ["NDArray","trace","object","Parameters","--","--","--","--","--","name",":","str","Name","of","backend",".","This","has","no","meaning","for","the","NDArray","backend",".","model",":","Model","If","None",",","the","model","is","taken","from","the","`","with","`","context",".","vars",":","list","of","variables","Sampling","values","will","be","stored","for","these","variables",".","If","None",",","`","model.unobserved_RVs","`","is","used","."]
code: def _slice(self, idx: slice):
      # Slicing directly instead of using _slice_as_ndarray to
      # support stop value in slice (which is needed by
      # iter_sample).
  
      # Only the first `draw_idx` value are valid because of preallocation
      idx = slice(*idx.indices(len(self)))
  
      sliced = NDArray(model=self.model, vars=self.vars)
      sliced.chain = self.chain
      sliced.samples = {
          varname: values[idx]
          for varname, values in self.samples.items()
      }
      sliced.sampler_vars = self.sampler_vars
      sliced.draw_idx = (idx.stop - idx.start) // idx.step
  
      if self._stats is None:
          return sliced
      sliced._stats = []
      for vars in self._stats:
          var_sliced: Dict[str, np.ndarray] = {}
          sliced._stats.append(var_sliced)
          for key, vals in vars.items():
              var_sliced[key] = vals[idx]
  
      return sliced
  
file_path: pymc/pymc/backends/ndarray.py
imports: from typing import Any, Dict, List, Optional
  import numpy
  from pymc.backends import base
  from pymc.backends.base import MultiTrace
  from pymc.model import Model, modelcontext
label_desc: Use image node_id 8 for calling the NDArray obj's underlying member method code with example usage: obj._slice(idx) and returns: sliced, sliced