code: def _mp_sample(
      *,
      draws: int,
      tune: int,
      step,
      chains: int,
      cores: int,
      random_seed: Sequence[RandomSeed],
      start: Sequence[PointType],
      progressbar: bool = True,
      traces: Sequence[IBaseTrace],
      model: Optional[Model] = None,
      callback: Optional[SamplingIteratorCallback] = None,
      mp_ctx=None,
      **kwargs,
  ) -> None:
      """Main iteration for multiprocess sampling.
  
      Parameters
      ----------
      draws : int
          The number of samples to draw
      tune : int
          Number of iterations to tune.
      step : function
          Step function
      chains : int
          The number of chains to sample.
      cores : int
          The number of chains to run in parallel.
      random_seed : list of random seeds
          Random seeds for each chain.
      start : list
          Starting points for each chain.
          Dicts must contain numeric (transformed) initial values for all (transformed) free variables.
      progressbar : bool
          Whether or not to display a progress bar in the command line.
      traces
          Recording backends for each chain.
      model : Model (optional if in ``with`` context)
      callback
          A function which gets called for every sample from the trace of a chain. The function is
          called with the trace and the current draw and will contain all samples for a single trace.
          the ``draw.chain`` argument can be used to determine which of the active chains the sample
          is drawn from.
          Sampling can be interrupted by throwing a ``KeyboardInterrupt`` in the callback.
      """
      import pymc.sampling.parallel as ps
  
      # We did draws += tune in pm.sample
      draws -= tune
  
      sampler = ps.ParallelSampler(
          draws=draws,
          tune=tune,
          chains=chains,
          cores=cores,
          seeds=random_seed,
          start_points=start,
          step_method=step,
          progressbar=progressbar,
          mp_ctx=mp_ctx,
      )
      try:
          try:
              with sampler:
                  for draw in sampler:
                      strace = traces[draw.chain]
                      strace.record(draw.point, draw.stats)
                      log_warning_stats(draw.stats)
                      if draw.is_last:
                          strace.close()
  
                      if callback is not None:
                          callback(trace=strace, draw=draw)
  
          except ps.ParallelSamplingError as error:
              strace = traces[error._chain]
              for strace in traces:
                  strace.close()
              raise
      except KeyboardInterrupt:
          pass
      finally:
          for strace in traces:
              strace.close()
  
imports: import logging
  import pickle
  import sys
  import time
  import warnings
  from typing import Any, Dict, Iterator, List, Literal, Mapping, Optional, Sequence, Set, Tuple, Type, Union, overload
  import numpy
  import pytensor.gradient
  from arviz import InferenceData, dict_to_dataset
  from arviz.data.base import make_attrs
  from fastprogress.fastprogress import progress_bar
  from pytensor.graph.basic import Variable
  from typing_extensions import Protocol, TypeAlias
  import pymc
  from pymc.backends import RunType, TraceOrBackend, init_traces
  from pymc.backends.arviz import coords_and_dims_for_inferencedata, find_constants, find_observations
  from pymc.backends.base import IBaseTrace, MultiTrace, _choose_chains
  from pymc.blocking import DictToArrayBijection
  from pymc.exceptions import SamplingError
  from pymc.initial_point import PointType, StartDict, make_initial_point_fns_per_chain
  from pymc.model import Model, modelcontext
  from pymc.sampling.parallel import Draw, _cpu_count
  from pymc.sampling.population import _sample_population
  from pymc.stats.convergence import log_warning_stats, log_warnings, run_convergence_checks
  from pymc.step_methods import NUTS, CompoundStep
  from pymc.step_methods.arraystep import BlockedStep, PopulationArrayStepShared
  from pymc.step_methods.hmc import quadpotential
  from pymc.util import RandomSeed, RandomState, _get_seeds_per_chain, drop_warning_stat, get_untransformed_name, is_transformed_name
  from pymc.vartypes import discrete_types
label_desc: Use image node_id 14 for calling a global function with example usage: _mp_sample() without return types