code: def select_n_jobs_backtesting(
      forecaster, refit: Union[bool, int]
  ) -> int:
      """
      Select the optimal number of jobs to use in the backtesting process. This
      selection is based on heuristics and is not guaranteed to be optimal.
  
      The number of jobs is chosen as follows:
  
      - If `refit` is an integer, then n_jobs=1. This is because parallelization doesn't
      work with intermittent refit.
      - If forecaster is 'ForecasterAutoreg' or 'ForecasterAutoregCustom' and
      regressor is a linear regressor, then n_jobs=1.
      - If forecaster is 'ForecasterAutoreg' or 'ForecasterAutoregCustom',
      regressor is not a linear regressor and refit=`True`, then
      n_jobs=cpu_count().
      - If forecaster is 'ForecasterAutoreg' or 'ForecasterAutoregCustom',
      regressor is not a linear regressor and refit=`False`, then
      n_jobs=1.
      - If forecaster is 'ForecasterAutoregDirect' or 'ForecasterAutoregMultiVariate'
      and refit=`True`, then n_jobs=cpu_count().
      - If forecaster is 'ForecasterAutoregDirect' or 'ForecasterAutoregMultiVariate'
      and refit=`False`, then n_jobs=1.
      - If forecaster is 'ForecasterAutoregMultiSeries' or
      'ForecasterAutoregMultiSeriesCustom', then n_jobs=cpu_count().
      - If forecaster is 'ForecasterSarimax' or 'ForecasterEquivalentDate',
      then n_jobs=1.
  
      Parameters
      ----------
      forecaster : Forecaster
          Forecaster model. ForecasterAutoreg, ForecasterAutoregCustom,
          ForecasterAutoregDirect, ForecasterAutoregMultiSeries,
          ForecasterAutoregMultiSeriesCustom, ForecasterAutoregMultiVariate.
      refit : bool, int
          If the forecaster is refitted during the backtesting process.
  
      Returns
      -------
      n_jobs : int
          The number of jobs to run in parallel.
  
      """
  
      forecaster_name = type(forecaster).__name__
  
      if isinstance(forecaster.regressor, sklearn.pipeline.Pipeline):
          regressor_name = type(forecaster.regressor[-1]).__name__
      else:
          regressor_name = type(forecaster.regressor).__name__
  
      linear_regressors = [
          regressor_name
          for regressor_name in dir(sklearn.linear_model)
          if not regressor_name.startswith("_")
      ]
  
      refit = False if refit == 0 else refit
      if not isinstance(refit, bool) and refit != 1:
          n_jobs = 1
      else:
          if forecaster_name in [
              "ForecasterAutoreg",
              "ForecasterAutoregCustom",
          ]:
              if regressor_name in linear_regressors:
                  n_jobs = 1
              else:
                  n_jobs = joblib.cpu_count() if refit else 1
          elif forecaster_name in [
              "ForecasterAutoregDirect",
              "ForecasterAutoregMultiVariate",
          ]:
              n_jobs = 1
          elif forecaster_name in [
              "ForecasterAutoregMultiSeries",
              "ForecasterAutoregMultiSeriesCustom",
          ]:
              n_jobs = joblib.cpu_count()
          elif forecaster_name in [
              "ForecasterSarimax",
              "ForecasterEquivalentDate",
          ]:
              n_jobs = 1
          else:
              n_jobs = 1
  
      return n_jobs
  
imports: from typing import Union, Any, Optional, Tuple, Callable
  import warnings
  import importlib
  import joblib
  import numpy
  import pandas
  import sklearn
  import sklearn.pipeline
  import sklearn.linear_model
  from sklearn.compose import ColumnTransformer
  from sklearn.exceptions import NotFittedError
  import inspect
  from copy import deepcopy
  import skforecast
  from ..exceptions import MissingValuesExogWarning
  from ..exceptions import DataTypeWarning
  from ..exceptions import IgnoredArgumentWarning
  from ..exceptions import SkforecastVersionWarning
label_desc: Use image node_id 26 for calling a global function with example usage: select_n_jobs_backtesting(forecaster, refit) and returns: n_jobs