code: def _fit_candidate_model(
      y,
      X,
      order,
      seasonal_order,
      start_params,
      trend,
      method,
      maxiter,
      fit_params,
      suppress_warnings,
      trace,
      error_action,
      out_of_sample_size,
      scoring,
      scoring_args,
      with_intercept,
      information_criterion,
      **kwargs,
  ):
      """Instantiate and fit a candidate model
  
      1. Initialize a model
      2. Fit model
      3. Perform a root test
      4. Return model, information criterion
      """
      start = time.time()
      fit_time = np.nan
      ic = np.inf
  
      # Fit outside try block, so if there is a type error in user input we
      # don't mask it with a warning or worse
      fit = ARIMA(
          order=order,
          seasonal_order=seasonal_order,
          start_params=start_params,
          trend=trend,
          method=method,
          maxiter=maxiter,
          suppress_warnings=suppress_warnings,
          out_of_sample_size=out_of_sample_size,
          scoring=scoring,
          scoring_args=scoring_args,
          with_intercept=with_intercept,
          **kwargs,
      )
  
      try:
          fit.fit(y, X=X, **fit_params)
  
      # for non-stationarity errors or singular matrices, return None
      except (LinAlgError, ValueError) as v:
          if error_action == "raise":
              raise v
  
          elif error_action in ("warn", "trace"):
              warning_str = (
                  "Error fitting %s "
                  "(if you do not want to see these warnings, run "
                  'with error_action="ignore").' % str(fit)
              )
  
              if error_action == "trace":
                  warning_str += (
                      "\nTraceback:\n" + traceback.format_exc()
                  )
  
              warnings.warn(warning_str, ModelFitWarning)
  
      else:
          fit_time = time.time() - start
          ic = getattr(
              fit, information_criterion
          )()  # aic, bic, aicc, etc.
  
          # check the roots of the new model, and set IC to inf if the
          # roots are near non-invertible
          ic = _root_test(fit, ic, trace)
  
      # log the model fit
      if trace:
          print(
              "{model}   : {ic_name}={ic:.3f}, Time={time:.2f} sec".format(
                  model=str(fit),
                  ic_name=information_criterion.upper(),
                  ic=ic,
                  time=fit_time,
              )
          )
  
      return fit, fit_time, ic
  
imports: from numpy.linalg import LinAlgError
  import numpy
  from datetime import datetime
  from joblib import Parallel, delayed
  from sklearn.utils import check_random_state
  import abc
  import functools
  import time
  import warnings
  import traceback
  from .arima import ARIMA
  from ..warnings import ModelFitWarning
  from ._context import ContextType, ContextStore
  from .None import _validation
  from ..compat import statsmodels
label_desc: Use image node_id 2 for calling a global function with example usage: _fit_candidate_model(y, X, order, seasonal_order, start_params, trend, method, maxiter, fit_params, suppress_warnings, trace, error_action, out_of_sample_size, scoring, scoring_args, with_intercept, information_criterion) and returns: fit,  fit_time,  ic