code: def _init_trace(
      *,
      expected_length: int,
      chain_number: int,
      stats_dtypes: List[Dict[str, type]],
      trace: Optional[BaseTrace],
      model: Model,
  ) -> BaseTrace:
      """Initializes a trace backend for a chain."""
      strace: BaseTrace
      if trace is None:
          strace = NDArray(model=model)
      elif isinstance(trace, BaseTrace):
          if len(trace) > 0:
              raise ValueError(
                  "Continuation of traces is no longer supported."
              )
          strace = copy(trace)
      else:
          raise NotImplementedError(f"Unsupported `trace`: {trace}")
  
      strace.setup(expected_length, chain_number, stats_dtypes)
      return strace
  
file_path: pymc/pymc/backends/__init__.py
imports: from copy import copy
  from typing import Dict, List, Mapping, Optional, Sequence, Tuple, Union
  import numpy
  from typing_extensions import TypeAlias
  from pymc.backends.arviz import predictions_to_inference_data, to_inference_data
  from pymc.backends.base import BaseTrace, IBaseTrace
  from pymc.backends.ndarray import NDArray
  from pymc.model import Model
  from pymc.step_methods.compound import BlockedStep, CompoundStep
label_desc: Use image node_id 1 for calling a global function with example usage: _init_trace() and returns: strace