code: def _log_reg_scoring_path(
      X,
      y,
      train,
      test,
      pos_class=None,
      Cs=10,
      scoring=None,
      fit_intercept=False,
      max_iter=100,
      tol=1e-4,
      class_weight=None,
      verbose=0,
      solver="lbfgs",
      penalty="l2",
      dual=False,
      intercept_scaling=1.0,
      multi_class="ovr",
      random_state=None,
      max_squared_sum=None,
      sample_weight=None,
  ):
      """Computes scores across logistic_regression_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 labels.
  
      train : list of indices
          The indices of the train set.
  
      test : list of indices
          The indices of the test set.
  
      pos_class : int, None
          The class with respect to which we perform a one-vs-all fit.
          If None, then it is assumed that the given problem is binary.
  
      Cs : list of floats | int
          Each of the values in Cs describes the inverse of
          regularization strength. If Cs is as an int, then a grid of Cs
          values are chosen in a logarithmic scale between 1e-4 and 1e4.
          If not provided, then a fixed set of values for Cs are used.
  
      scoring : callable or None, optional, default: None
          A string (see model evaluation documentation) or
          a scorer callable object / function with signature
          ``scorer(estimator, X, y)``. For a list of scoring functions
          that can be used, look at :mod:`sklearn.metrics`. The
          default scoring option used is accuracy_score.
  
      fit_intercept : bool
          If False, then the bias term is set to zero. Else the last
          term of each coef_ gives us the intercept.
  
      max_iter : int
          Maximum number of iterations for the solver.
  
      tol : float
          Tolerance for stopping criteria.
  
      class_weight : dict or 'balanced', optional
          Weights associated with classes in the form ``{class_label: weight}``.
          If not given, all classes are supposed to have weight one.
  
          The "balanced" mode uses the values of y to automatically adjust
          weights inversely proportional to class frequencies in the input data
          as ``n_samples / (n_classes * np.bincount(y))``
  
          Note that these weights will be multiplied with sample_weight (passed
          through the fit method) if sample_weight is specified.
  
      verbose : int
          For the liblinear and lbfgs solvers set verbose to any positive
          number for verbosity.
  
      solver : {'lbfgs', 'newton-cg', 'liblinear', 'sag'}
          Decides which solver to use.
  
      penalty : str, 'l1' or 'l2'
          Used to specify the norm used in the penalization. The 'newton-cg',
          'sag' and 'lbfgs' solvers support only l2 penalties.
  
      dual : bool
          Dual or primal formulation. Dual formulation is only implemented for
          l2 penalty with liblinear solver. Prefer dual=False when
          n_samples > n_features.
  
      intercept_scaling : float, default 1.
          Useful only when the solver 'liblinear' is used
          and self.fit_intercept is set to True. In this case, x becomes
          [x, self.intercept_scaling],
          i.e. a "synthetic" feature with constant value equals to
          intercept_scaling is appended to the instance vector.
          The intercept becomes intercept_scaling * synthetic feature weight
          Note! the synthetic feature weight is subject to l1/l2 regularization
          as all other features.
          To lessen the effect of regularization on synthetic feature weight
          (and therefore on the intercept) intercept_scaling has to be increased.
  
      multi_class : str, {'ovr', 'multinomial'}
          Multiclass option can be either 'ovr' or 'multinomial'. If the option
          chosen is 'ovr', then a binary problem is fit for each label. Else
          the loss minimised is the multinomial loss fit across
          the entire probability distribution. Works only for the 'lbfgs' and
          'newton-cg' solver.
  
      random_state : int seed, RandomState instance, or None (default)
          The seed of the pseudo random number generator to use when
          shuffling the data. Used only in solvers 'sag' and 'liblinear'.
  
      max_squared_sum : float, default None
          Maximum squared sum of X over samples. Used only in SAG solver.
          If None, it will be computed, going through all the samples.
          The value should be precomputed to speed up cross validation.
  
      sample_weight : array-like, shape(n_samples,) optional
          Array of weights that are assigned to individual samples.
          If not provided, then each sample is given unit weight.
  
      Returns
      -------
      coefs : ndarray, shape (n_cs, n_features) or (n_cs, n_features + 1)
          List of coefficients for the Logistic Regression model. If
          fit_intercept is set to True then the second dimension will be
          n_features + 1, where the last item represents the intercept.
  
      Cs : ndarray
          Grid of Cs used for cross-validation.
  
      scores : ndarray, shape (n_cs,)
          Scores obtained for each Cs.
  
      n_iter : array, shape(n_cs,)
          Actual number of iteration for each Cs.
      """
      _check_solver_option(solver, multi_class, penalty, dual)
  
      X_train = X[train]
      X_test = X[test]
      y_train = y[train]
      y_test = y[test]
  
      if sample_weight is not None:
          sample_weight = sample_weight[train]
  
      coefs, Cs, n_iter = logistic_regression_path(
          X_train,
          y_train,
          Cs=Cs,
          fit_intercept=fit_intercept,
          solver=solver,
          max_iter=max_iter,
          class_weight=class_weight,
          pos_class=pos_class,
          multi_class=multi_class,
          tol=tol,
          verbose=verbose,
          dual=dual,
          penalty=penalty,
          intercept_scaling=intercept_scaling,
          random_state=random_state,
          check_input=False,
          max_squared_sum=max_squared_sum,
          sample_weight=sample_weight,
      )
  
      log_reg = LogisticRegression(fit_intercept=fit_intercept)
  
      # The score method of Logistic Regression has a classes_ attribute.
      if multi_class == "ovr":
          log_reg.classes_ = np.array([-1, 1])
      elif multi_class == "multinomial":
          log_reg.classes_ = np.unique(y_train)
      else:
          raise ValueError(
              "multi_class should be either multinomial or ovr, "
              "got %d" % multi_class
          )
  
      if pos_class is not None:
          mask = y_test == pos_class
          y_test = np.ones(y_test.shape, dtype=np.float64)
          y_test[~mask] = -1.0
  
      scores = list()
  
      if isinstance(scoring, six.string_types):
          scoring = SCORERS[scoring]
      for w in coefs:
          if multi_class == "ovr":
              w = w[np.newaxis, :]
          if fit_intercept:
              log_reg.coef_ = w[:, :-1]
              log_reg.intercept_ = w[:, -1]
          else:
              log_reg.coef_ = w
              log_reg.intercept_ = 0.0
  
          if scoring is None:
              scores.append(log_reg.score(X_test, y_test))
          else:
              scores.append(scoring(log_reg, X_test, y_test))
      return coefs, Cs, np.array(scores), n_iter
  
imports: import numbers
  import warnings
  import numpy
  from scipy import optimize, sparse
  from .base import LinearClassifierMixin, SparseCoefMixin, BaseEstimator
  from .sag import sag_solver
  from ..feature_selection.from_model import _LearntSelectorMixin
  from ..preprocessing import LabelEncoder, LabelBinarizer
  from ..svm.base import _fit_liblinear
  from ..utils import check_array, check_consistent_length, compute_class_weight
  from ..utils import check_random_state
  from ..utils.extmath import logsumexp, log_logistic, safe_sparse_dot, softmax, squared_norm
  from ..utils.extmath import row_norms
  from ..utils.optimize import newton_cg
  from ..utils.validation import check_X_y
  from ..exceptions import NotFittedError
  from ..utils.fixes import expit
  from ..utils.multiclass import check_classification_targets
  from ..externals.joblib import Parallel, delayed
  from ..model_selection import check_cv
  from ..externals import six
  from ..metrics import SCORERS
label_desc: Use image node_id 10 for calling a global function with example usage: _log_reg_scoring_path(X, y, train, test, pos_class, Cs, scoring, fit_intercept, max_iter, tol, class_weight, verbose, solver, penalty, dual, intercept_scaling, multi_class, random_state, max_squared_sum, sample_weight) and returns: coefs,  Cs,  np,  n_iter