class_docstr: Searches for the best model using the stepwise algorithm.
  
  The stepwise algorithm fluctuates the more sensitive pieces of the ARIMA
  (the seasonal components) first, adjusting towards the direction of the
  smaller {A|B|HQ}IC(c), and continues to step down as long as the error
  shrinks. As long as the error term decreases and the best parameters have
  not shifted to a point where they can no longer change, ``k`` will
  increase, and the models will continue to be fit until the ``max_k`` is
  reached.
  
  References
  ----------
  .. [1] R's auto-arima stepwise source code: https://github.com/robjhyndman/forecast/blob/30308a4e314ff29338291462e81bf68ff0c5f86d/R/newarima2.R#L366
  .. [2] https://robjhyndman.com/hyndsight/arma-roots/
docstr: Do a fit and determine whether the model is better
docstr_tok: ["Do","a","fit","and","determine","whether","the","model","is","better"]
code: def _do_fit(self, order, seasonal_order, constant=None):
      """Do a fit and determine whether the model is better"""
      if not self.seasonal:
          seasonal_order = (0, 0, 0, 0)
      seasonal_order = sm_compat.check_seasonal_order(seasonal_order)
  
      # we might be fitting without a constant
      if constant is None:
          constant = self.with_intercept
  
      if (order, seasonal_order, constant) not in self.results_dict:
          # increment the number of fits
          self.k += 1
  
          fit, fit_time, new_ic = self._fit_arima(
              order=order,
              seasonal_order=seasonal_order,
              with_intercept=constant,
          )
  
          # use the orders as a key to be hashed for
          # the dictionary (pointing to fit)
          self.results_dict[(order, seasonal_order, constant)] = fit
  
          # cache this so we can lookup best model IC downstream
          self.ic_dict[(order, seasonal_order, constant)] = new_ic
          self.fit_time_dict[
              (order, seasonal_order, constant)
          ] = fit_time
  
          # Determine if the new fit is better than the existing fit
          if fit is None or np.isinf(new_ic):
              return False
  
          # no benchmark model
          if self.bestfit is None:
              self.bestfit = fit
              self.bestfit_key = (order, seasonal_order, constant)
  
              if self.trace > 1:
                  print("First viable model found (%.3f)" % new_ic)
              return True
  
          # otherwise there's a current best
          current_ic = self.ic_dict[self.bestfit_key]
          if new_ic < current_ic:
              if self.trace > 1:
                  print(
                      "New best model found (%.3f < %.3f)"
                      % (new_ic, current_ic)
                  )
  
              self.bestfit = fit
              self.bestfit_key = (order, seasonal_order, constant)
              return True
  
      # we've seen this model before
      return False
  
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 the _StepwiseFitWrapper obj's underlying member method code with example usage: obj._do_fit(order, seasonal_order, constant) and returns: False, False, True, True