code: def _path_residuals(
      X,
      y,
      train,
      test,
      path,
      path_params,
      alphas=None,
      l1_ratio=1,
      X_order=None,
      dtype=None,
  ):
      """Returns the MSE for the models computed by 'path'
  
      Parameters
      ----------
      X : {array-like, sparse matrix}, shape (n_samples, n_features)
          Training data.
  
      y : array-like, shape (n_samples,) or (n_samples, n_targets)
          Target values
  
      train : list of indices
          The indices of the train set
  
      test : list of indices
          The indices of the test set
  
      path : callable
          function returning a list of models on the path. See
          enet_path for an example of signature
  
      path_params : dictionary
          Parameters passed to the path function
  
      alphas : array-like, optional
          Array of float that is used for cross-validation. If not
          provided, computed using 'path'
  
      l1_ratio : float, optional
          float between 0 and 1 passed to ElasticNet (scaling between
          l1 and l2 penalties). For ``l1_ratio = 0`` the penalty is an
          L2 penalty. For ``l1_ratio = 1`` it is an L1 penalty. For ``0
          < l1_ratio < 1``, the penalty is a combination of L1 and L2
  
      X_order : {'F', 'C', or None}, optional
          The order of the arrays expected by the path function to
          avoid memory copies
  
      dtype : a numpy dtype or None
          The dtype of the arrays expected by the path function to
          avoid memory copies
      """
      X_train = X[train]
      y_train = y[train]
      X_test = X[test]
      y_test = y[test]
      fit_intercept = path_params["fit_intercept"]
      normalize = path_params["normalize"]
  
      if y.ndim == 1:
          precompute = path_params["precompute"]
      else:
          # No Gram variant of multi-task exists right now.
          # Fall back to default enet_multitask
          precompute = False
  
      (
          X_train,
          y_train,
          X_offset,
          y_offset,
          X_scale,
          precompute,
          Xy,
      ) = _pre_fit(
          X_train,
          y_train,
          None,
          precompute,
          normalize,
          fit_intercept,
          copy=False,
      )
  
      path_params = path_params.copy()
      path_params["Xy"] = Xy
      path_params["X_offset"] = X_offset
      path_params["X_scale"] = X_scale
      path_params["precompute"] = precompute
      path_params["copy_X"] = False
      path_params["alphas"] = alphas
  
      if "l1_ratio" in path_params:
          path_params["l1_ratio"] = l1_ratio
  
      # Do the ordering and type casting here, as if it is done in the path,
      # X is copied and a reference is kept here
      X_train = check_array(X_train, "csc", dtype=dtype, order=X_order)
      alphas, coefs, _ = path(X_train, y_train, **path_params)
      del X_train, y_train
  
      if y.ndim == 1:
          # Doing this so that it becomes coherent with multioutput.
          coefs = coefs[np.newaxis, :, :]
          y_offset = np.atleast_1d(y_offset)
          y_test = y_test[:, np.newaxis]
  
      if normalize:
          nonzeros = np.flatnonzero(X_scale)
          coefs[:, nonzeros] /= X_scale[nonzeros][:, np.newaxis]
  
      intercepts = y_offset[:, np.newaxis] - np.dot(X_offset, coefs)
      if sparse.issparse(X_test):
          n_order, n_features, n_alphas = coefs.shape
          # Work around for sparse matrices since coefs is a 3-D numpy array.
          coefs_feature_major = np.rollaxis(coefs, 1)
          feature_2d = np.reshape(coefs_feature_major, (n_features, -1))
          X_test_coefs = safe_sparse_dot(X_test, feature_2d)
          X_test_coefs = X_test_coefs.reshape(
              X_test.shape[0], n_order, -1
          )
      else:
          X_test_coefs = safe_sparse_dot(X_test, coefs)
      residues = X_test_coefs - y_test[:, :, np.newaxis]
      residues += intercepts
      this_mses = ((residues**2).mean(axis=0)).mean(axis=0)
  
      return this_mses
  
imports: import sys
  import warnings
  from abc import ABCMeta, abstractmethod
  import numpy
  from scipy import sparse
  from .base import LinearModel, _pre_fit
  from ..base import RegressorMixin
  from .base import _preprocess_data
  from ..utils import check_array, check_X_y, deprecated
  from ..utils.validation import check_random_state
  from ..model_selection import check_cv
  from ..externals.joblib import Parallel, delayed
  from ..externals import six
  from ..externals.six.moves import xrange
  from ..utils.extmath import safe_sparse_dot
  from ..utils.validation import check_is_fitted
  from ..utils.validation import column_or_1d
  from ..exceptions import ConvergenceWarning
  from .None import cd_fast
label_desc: Use image node_id 4 for calling a global function with example usage: _path_residuals(X, y, train, test, path, path_params, alphas, l1_ratio, X_order, dtype) and returns: this_mses