class_docstr: PyMC model-fitting backend.
class_docstr_tok: ["PyMC","model-fitting","backend","."]
code: def _run_mcmc(
      self,
      draws=1000,
      tune=1000,
      discard_tuned_samples=True,
      omit_offsets=True,
      include_mean=False,
      init="auto",
      n_init=50000,
      chains=None,
      cores=None,
      random_seed=None,
      sampler_backend="mcmc",
      **kwargs,
  ):
      with self.model:
          if sampler_backend == "mcmc":
              try:
                  idata = pm.sample(
                      draws=draws,
                      tune=tune,
                      discard_tuned_samples=discard_tuned_samples,
                      init=init,
                      n_init=n_init,
                      chains=chains,
                      cores=cores,
                      random_seed=random_seed,
                      **kwargs,
                  )
              except (RuntimeError, ValueError):
                  if (
                      "ValueError: Mass matrix contains"
                      in traceback.format_exc()
                      and init == "auto"
                  ):
                      _log.info(
                          "\nThe default initialization using init='auto' has failed, trying to "
                          "recover by switching to init='adapt_diag'",
                      )
                      idata = pm.sample(
                          draws=draws,
                          tune=tune,
                          discard_tuned_samples=discard_tuned_samples,
                          init="adapt_diag",
                          n_init=n_init,
                          chains=chains,
                          cores=cores,
                          random_seed=random_seed,
                          **kwargs,
                      )
                  else:
                      raise
          elif sampler_backend == "nuts_numpyro":
              import pymc.sampling_jax  # pylint: disable=import-outside-toplevel
  
              if not chains:
                  # sample_numpyro_nuts does not handle chains = None like pm.sample does
                  chains = 4
              idata = pymc.sampling_jax.sample_numpyro_nuts(
                  draws=draws,
                  tune=tune,
                  chains=chains,
                  random_seed=random_seed,
                  **kwargs,
              )
          elif sampler_backend == "nuts_blackjax":
              import pymc.sampling_jax  # pylint: disable=import-outside-toplevel
  
              # sample_blackjax_nuts does not handle chains = None like pm.sample does
              if not chains:
                  chains = 4
              idata = pymc.sampling_jax.sample_blackjax_nuts(
                  draws=draws,
                  tune=tune,
                  chains=chains,
                  random_seed=random_seed,
                  **kwargs,
              )
          else:
              raise ValueError(
                  f"sampler_backend value {sampler_backend} is not valid. Please choose one of"
                  f"'mcmc', 'nuts_numpyro' or 'nuts_blackjax'"
              )
      idata = self._clean_results(idata, omit_offsets, include_mean)
      return idata
  
imports: import functools
  import logging
  import traceback
  from copy import deepcopy
  from importlib.metadata import version
  import numpy
  import pymc
  import pytensor.tensor
  from pytensor.tensor.special import softmax
  from bambi.backend.links import cloglog, identity, inverse_squared, logit, probit, arctan_2
  from bambi.backend.model_components import ConstantComponent, DistributionalComponent
  from bambi.utils import get_aliased_name
label_desc: Use image node_id 6 for calling the PyMCModel obj's underlying member method code with example usage: obj._run_mcmc(draws, tune, discard_tuned_samples, omit_offsets, include_mean, init, n_init, chains, cores, random_seed, sampler_backend) and returns: idata