code: def _preprocess_data(
      X,
      y,
      fit_intercept,
      normalize=False,
      copy=True,
      sample_weight=None,
      return_mean=False,
  ):
      """
      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
      return_mean=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.
      """
  
      if isinstance(sample_weight, numbers.Number):
          sample_weight = None
  
      X = check_array(
          X, copy=copy, accept_sparse=["csr", "csc"], dtype=FLOAT_DTYPES
      )
  
      if fit_intercept:
          if sp.issparse(X):
              X_offset, X_var = mean_variance_axis(X, axis=0)
              if not return_mean:
                  X_offset = np.zeros(X.shape[1])
  
              if normalize:
                  # TODO: f_normalize could be used here as well but the function
                  # inplace_csr_row_normalize_l2 must be changed such that it
                  # can return also the norms computed internally
  
                  # transform variance to norm in-place
                  X_var *= X.shape[0]
                  X_scale = np.sqrt(X_var, X_var)
                  del X_var
                  X_scale[X_scale == 0] = 1
                  inplace_column_scale(X, 1.0 / X_scale)
              else:
                  X_scale = np.ones(X.shape[1])
  
          else:
              X_offset = np.average(X, axis=0, weights=sample_weight)
              X -= X_offset
              if normalize:
                  X, X_scale = f_normalize(
                      X, axis=0, copy=False, return_norm=True
                  )
              else:
                  X_scale = np.ones(X.shape[1])
          y_offset = np.average(y, axis=0, weights=sample_weight)
          y = y - y_offset
      else:
          X_offset = np.zeros(X.shape[1])
          X_scale = np.ones(X.shape[1])
          y_offset = (
              0.0
              if y.ndim == 1
              else np.zeros(y.shape[1], dtype=X.dtype)
          )
  
      return X, y, X_offset, y_offset, X_scale
  
imports: from __future__ import division
  from abc import ABCMeta, abstractmethod
  import numbers
  import warnings
  import numpy
  import scipy.sparse
  from scipy import linalg
  from scipy import sparse
  from ..externals import six
  from ..externals.joblib import Parallel, delayed
  from ..base import BaseEstimator, ClassifierMixin, RegressorMixin
  from ..utils import check_array, check_X_y, deprecated, as_float_array
  from ..utils.validation import FLOAT_DTYPES
  from ..utils import check_random_state
  from ..utils.extmath import safe_sparse_dot
  from ..utils.sparsefuncs import mean_variance_axis, inplace_column_scale
  from ..utils.fixes import sparse_lsqr
  from ..utils.seq_dataset import ArrayDataset, CSRDataset
  from ..utils.validation import check_is_fitted
  from ..exceptions import NotFittedError
  from ..preprocessing.data import normalize
label_desc: Use image node_id 4 for calling a global function with example usage: _preprocess_data(X, y, fit_intercept, normalize, copy, sample_weight, return_mean) and returns: X,  y,  X_offset,  y_offset,  X_scale