code: def _preprocess_data(
      X,
      y,
      fit_intercept,
      normalize=False,
      copy=True,
      copy_y=True,
      sample_weight=None,
      check_input=True,
  ):
      """Center and scale data.
  
      Centers data to have mean zero along axis 0. If fit_intercept=False or if
      the X is a sparse matrix, no centering is done, but normalization can still
      be applied. The function returns the statistics necessary to reconstruct
      the input data, which are X_offset, y_offset, X_scale, such that the output
  
          X = (X - X_offset) / X_scale
  
      X_scale is the L2 norm of X - X_offset. If sample_weight is not None,
      then the weighted mean of X and y is zero, and not the mean itself. If
      fit_intercept=True, the mean, eventually weighted, is returned, independently
      of whether X was centered (option used for optimization with sparse data in
      coordinate_descend).
  
      This is here because nearly all linear models will want their data to be
      centered. This function also systematically makes y consistent with X.dtype
  
      Returns
      -------
      X_out : {ndarray, sparse matrix} of shape (n_samples, n_features)
          If copy=True a copy of the input X is triggered, otherwise operations are
          inplace.
          If input X is dense, then X_out is centered.
          If normalize is True, then X_out is rescaled (dense and sparse case)
      y_out : {ndarray, sparse matrix} of shape (n_samples,) or (n_samples, n_targets)
          Centered version of y. Likely performed inplace on input y.
      X_offset : ndarray of shape (n_features,)
          The mean per column of input X.
      y_offset : float or ndarray of shape (n_features,)
      X_scale : ndarray of shape (n_features,)
          The standard deviation per column of input X.
      """
      if isinstance(sample_weight, numbers.Number):
          sample_weight = None
      if sample_weight is not None:
          sample_weight = np.asarray(sample_weight)
  
      if check_input:
          X = check_array(
              X,
              copy=copy,
              accept_sparse=["csr", "csc"],
              dtype=FLOAT_DTYPES,
          )
          y = check_array(
              y, dtype=X.dtype, copy=copy_y, ensure_2d=False
          )
      else:
          y = y.astype(X.dtype, copy=copy_y)
          if copy:
              if sp.issparse(X):
                  X = X.copy()
              else:
                  X = X.copy(order="K")
  
      if fit_intercept:
          if sp.issparse(X):
              X_offset, X_var = mean_variance_axis(
                  X, axis=0, weights=sample_weight
              )
          else:
              if normalize:
                  X_offset, X_var, _ = _incremental_mean_and_var(
                      X,
                      last_mean=0.0,
                      last_variance=0.0,
                      last_sample_count=0.0,
                      sample_weight=sample_weight,
                  )
              else:
                  X_offset = np.average(
                      X, axis=0, weights=sample_weight
                  )
  
              X_offset = X_offset.astype(X.dtype, copy=False)
              X -= X_offset
  
          if normalize:
              X_var = X_var.astype(X.dtype, copy=False)
              # Detect constant features on the computed variance, before taking
              # the np.sqrt. Otherwise constant features cannot be detected with
              # sample weights.
              constant_mask = _is_constant_feature(
                  X_var, X_offset, X.shape[0]
              )
              if sample_weight is None:
                  X_var *= X.shape[0]
              else:
                  X_var *= sample_weight.sum()
              X_scale = np.sqrt(X_var, out=X_var)
              X_scale[constant_mask] = 1.0
              if sp.issparse(X):
                  inplace_column_scale(X, 1.0 / X_scale)
              else:
                  X /= X_scale
          else:
              X_scale = np.ones(X.shape[1], dtype=X.dtype)
  
          y_offset = np.average(y, axis=0, weights=sample_weight)
          y -= y_offset
      else:
          X_offset = np.zeros(X.shape[1], dtype=X.dtype)
          X_scale = np.ones(X.shape[1], dtype=X.dtype)
          if y.ndim == 1:
              y_offset = X.dtype.type(0)
          else:
              y_offset = np.zeros(y.shape[1], dtype=X.dtype)
  
      return X, y, X_offset, y_offset, X_scale
  
imports: import numbers
  import warnings
  from abc import ABCMeta, abstractmethod
  from numbers import Integral
  import numpy
  import scipy.sparse
  from scipy import linalg, optimize, sparse
  from scipy.sparse.linalg import lsqr
  from scipy.special import expit
  from ..base import BaseEstimator, ClassifierMixin, MultiOutputMixin, RegressorMixin, _fit_context
  from ..preprocessing._data import _is_constant_feature
  from ..utils import check_array, check_random_state
  from ..utils._array_api import get_namespace
  from ..utils._seq_dataset import ArrayDataset32, ArrayDataset64, CSRDataset32, CSRDataset64
  from ..utils.extmath import _incremental_mean_and_var, safe_sparse_dot
  from ..utils.parallel import Parallel, delayed
  from ..utils.sparsefuncs import inplace_column_scale, mean_variance_axis
  from ..utils.validation import FLOAT_DTYPES, _check_sample_weight, check_is_fitted
label_desc: Use image node_id 3 for calling a global function with example usage: _preprocess_data(X, y, fit_intercept, normalize, copy, copy_y, sample_weight, check_input) and returns: X,  y,  X_offset,  y_offset,  X_scale