class_docstr: The interface of a mixin class.
docstr: Initialize the generic parts of the backend engine.
  
  Every subclass of BackendEngine needs to import its requirements, set
  self.model_class to the type that predictor_model and adversary_model
  should be, and set up the optimizers after the init. The generic
  steps that are performed in this method is to type-check the models
  and set up the losses.
docstr_tok: ["Initialize","the","generic","parts","of","the","backend","engine",".","Every","subclass","of","BackendEngine","needs","to","import","its","requirements",",","set","self.model_class","to","the","type","that","predictor_model","and","adversary_model","should","be",",","and","set","up","the","optimizers","after","the","init",".","The","generic","steps","that","are","performed","in","this","method","is","to","type-check","the","models","and","set","up","the","losses","."]
code: def __init__(self, base, X, Y, A):
      """
      Initialize the generic parts of the backend engine.
  
      Every subclass of BackendEngine needs to import its requirements, set
      self.model_class to the type that predictor_model and adversary_model
      should be, and set up the optimizers after the init. The generic
      steps that are performed in this method is to type-check the models
      and set up the losses.
      """
      self.base = base
  
      n_X_features = X.shape[1]  # FIXME: what if X.ndim > 2?
      n_Y_features = base._y_transform.n_features_out_
      n_A_features = base._sf_transform.n_features_out_
  
      # Set up models
      if base.warm_start and hasattr(base, "backendEngine_"):
          self.predictor_model = base.backendEngine_.predictor_model
          self.adversary_model = base.backendEngine_.adversary_model
      else:
          self.predictor_model = self.__init_model__(
              base.predictor_model,
              base.predictor_loss_,
              n_X_features,
              n_Y_features,
              "predictor",
          )
          self.adversary_model = self.__init_model__(
              base.adversary_model,
              base.adversary_loss_,
              n_Y_features * (2 if base.pass_y_ else 1),
              n_A_features,
              "adversary",
          )
  
      if hasattr(self, "__move_model__"):
          self.__move_model__()
  
      # Set up losses
      self.predictor_loss = self.__init_loss__(
          base.predictor_loss_, "predictor"
      )
      self.adversary_loss = self.__init_loss__(
          base.adversary_loss_, "adversary"
      )
  
      # Set up optimizers
      self.predictor_optimizer = self.__init_optimizers__(
          base.predictor_optimizer, self.predictor_model, "predictor"
      )
      self.adversary_optimizer = self.__init_optimizers__(
          base.adversary_optimizer, self.adversary_model, "adversary"
      )
  
file_path: fairlearn/fairlearn/adversarial/_backend_engine.py
imports: from ._constants import _KWARG_ERROR_MESSAGE, _NOT_IMPLEMENTED, _DIST_TYPE_NOT_IMPLEMENTED, _NO_LOSS, _LIST_MODEL_UNSUPPORTED
  from sklearn.utils import shuffle
  from numpy import ndarray
label_desc: Use image node_id 1 to create a new BackendEngine object  with example: obj = BackendEngine(base, X, Y, A)