class_docstr: Searches for the best model using a random search
code: def __init__(
      self,
      y,
      X,
      fit_partial,
      d,
      D,
      m,
      max_order,
      max_p,
      max_q,
      max_P,
      max_Q,
      random,
      random_state,
      n_fits,
      n_jobs,
      seasonal,
      trace,
      with_intercept,
      sarimax_kwargs,
  ):
      # NOTE: pre-1.5.2, we started at start_p, start_q, etc. However, when
      # using stepwise=FALSE in R, hyndman starts at 0. He only uses start_*
      # when stepwise=TRUE.
  
      # generate the set of (p, q, P, Q) FIRST, since it is contingent
      # on whether or not the user is interested in a seasonal ARIMA result.
      # This will reduce the search space for non-seasonal ARIMA models.
      # loop p, q. Make sure to loop at +1 interval,
      # since max_{p|q} is inclusive.
      if seasonal:
          gen = (
              ((p, d, q), (P, D, Q, m))
              for p in range(0, max_p + 1)
              for q in range(0, max_q + 1)
              for P in range(0, max_P + 1)
              for Q in range(0, max_Q + 1)
              if p + q + P + Q <= max_order
          )
      else:
          # otherwise it's not seasonal and we don't need the seasonal pieces
          gen = (
              ((p, d, q), (0, 0, 0, 0))
              for p in range(0, max_p + 1)
              for q in range(0, max_q + 1)
              if p + q <= max_order
          )
  
      # if we are fitting a random search rather than an exhaustive one, we
      # will scramble up the generator (as a list) and only fit n_fits ARIMAs
      if random:
          random_state = check_random_state(random_state)
  
          # make a list to scramble... `gen` may have a ragged nested
          # sequence, so we have to explicitly use dtype='object', otherwise
          # it will raise a ValueError on numpy >= 1.24
          gen = random_state.permutation(
              np.array(list(gen), dtype="object")
          )[
              :n_fits
          ]  # noqa: E501
  
      self.gen = gen
      self.n_jobs = n_jobs
      self.trace = trace
  
      # New partial containing y, X
      self.fit_partial = functools.partial(
          fit_partial,
          y=y,
          X=X,
          with_intercept=with_intercept,
          **sarimax_kwargs,
      )
  
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 1 to create a new _RandomFitWrapper object from inherited base classes: _SolverMixin with example: obj = _RandomFitWrapper(y, X, fit_partial, d, D, m, max_order, max_p, max_q, max_P, max_Q, random, random_state, n_fits, n_jobs, seasonal, trace, with_intercept, sarimax_kwargs)