class_docstr: Base class for MLP classification and regression.
  
  Warning: This class should not be used directly.
  Use derived classes instead.
  
  .. versionadded:: 0.18
code: def _fit(self, X, y, incremental=False):
      # Make sure self.hidden_layer_sizes is a list
      hidden_layer_sizes = self.hidden_layer_sizes
      if not hasattr(hidden_layer_sizes, "__iter__"):
          hidden_layer_sizes = [hidden_layer_sizes]
      hidden_layer_sizes = list(hidden_layer_sizes)
  
      # Validate input parameters.
      self._validate_hyperparameters()
      if np.any(np.array(hidden_layer_sizes) <= 0):
          raise ValueError(
              "hidden_layer_sizes must be > 0, got %s."
              % hidden_layer_sizes
          )
  
      X, y = self._validate_input(X, y, incremental)
      n_samples, n_features = X.shape
  
      # Ensure y is 2D
      if y.ndim == 1:
          y = y.reshape((-1, 1))
  
      self.n_outputs_ = y.shape[1]
  
      layer_units = (
          [n_features] + hidden_layer_sizes + [self.n_outputs_]
      )
  
      # check random state
      self._random_state = check_random_state(self.random_state)
  
      if not hasattr(self, "coefs_") or (
          not self.warm_start and not incremental
      ):
          # First time training the model
          self._initialize(y, layer_units)
  
      # lbfgs does not support mini-batches
      if self.solver == "lbfgs":
          batch_size = n_samples
      elif self.batch_size == "auto":
          batch_size = min(200, n_samples)
      else:
          if self.batch_size < 1 or self.batch_size > n_samples:
              warnings.warn(
                  "Got `batch_size` less than 1 or larger than "
                  "sample size. It is going to be clipped"
              )
          batch_size = np.clip(self.batch_size, 1, n_samples)
  
      # Initialize lists
      activations = [X]
      activations.extend(
          np.empty((batch_size, n_fan_out))
          for n_fan_out in layer_units[1:]
      )
      deltas = [np.empty_like(a_layer) for a_layer in activations]
  
      coef_grads = [
          np.empty((n_fan_in_, n_fan_out_))
          for n_fan_in_, n_fan_out_ in zip(
              layer_units[:-1], layer_units[1:]
          )
      ]
  
      intercept_grads = [
          np.empty(n_fan_out_) for n_fan_out_ in layer_units[1:]
      ]
  
      # Run the Stochastic optimization solver
      if self.solver in _STOCHASTIC_SOLVERS:
          self._fit_stochastic(
              X,
              y,
              activations,
              deltas,
              coef_grads,
              intercept_grads,
              layer_units,
              incremental,
          )
  
      # Run the LBFGS solver
      elif self.solver == "lbfgs":
          self._fit_lbfgs(
              X,
              y,
              activations,
              deltas,
              coef_grads,
              intercept_grads,
              layer_units,
          )
      return self
  
imports: import numpy
  from abc import ABCMeta, abstractmethod
  from scipy.optimize import fmin_l_bfgs_b
  import warnings
  from ..base import BaseEstimator, ClassifierMixin, RegressorMixin
  from ._base import ACTIVATIONS, DERIVATIVES, LOSS_FUNCTIONS
  from ._stochastic_optimizers import SGDOptimizer, AdamOptimizer
  from ..model_selection import train_test_split
  from ..externals import six
  from ..preprocessing import LabelBinarizer
  from ..utils import gen_batches, check_random_state
  from ..utils import shuffle
  from ..utils import check_array, check_X_y, column_or_1d
  from ..exceptions import ConvergenceWarning
  from ..utils.extmath import safe_sparse_dot
  from ..utils.validation import check_is_fitted
  from ..utils.multiclass import _check_partial_fit_first_call, unique_labels
  from ..utils.multiclass import type_of_target
label_desc: Use image node_id 9 for calling the BaseMultilayerPerceptron obj's underlying member method code with example usage: obj._fit(X, y, incremental) and returns: self