code: def _solve_sparse_cg(X, y, alpha, max_iter=None, tol=1e-3, verbose=0):
      n_samples, n_features = X.shape
      X1 = sp_linalg.aslinearoperator(X)
      coefs = np.empty((y.shape[1], n_features))
  
      if n_features > n_samples:
  
          def create_mv(curr_alpha):
              def _mv(x):
                  return X1.matvec(X1.rmatvec(x)) + curr_alpha * x
  
              return _mv
  
      else:
  
          def create_mv(curr_alpha):
              def _mv(x):
                  return X1.rmatvec(X1.matvec(x)) + curr_alpha * x
  
              return _mv
  
      for i in range(y.shape[1]):
          y_column = y[:, i]
  
          mv = create_mv(alpha[i])
          if n_features > n_samples:
              # kernel ridge
              # w = X.T * inv(X X^t + alpha*Id) y
              C = sp_linalg.LinearOperator(
                  (n_samples, n_samples), matvec=mv, dtype=X.dtype
              )
              coef, info = sp_linalg.cg(C, y_column, tol=tol)
              coefs[i] = X1.rmatvec(coef)
          else:
              # linear ridge
              # w = inv(X^t X + alpha*Id) * X.T y
              y_column = X1.rmatvec(y_column)
              C = sp_linalg.LinearOperator(
                  (n_features, n_features), matvec=mv, dtype=X.dtype
              )
              coefs[i], info = sp_linalg.cg(
                  C, y_column, maxiter=max_iter, tol=tol
              )
          if info < 0:
              raise ValueError("Failed with error code %d" % info)
  
          if max_iter is None and info > 0 and verbose:
              warnings.warn(
                  "sparse_cg did not converge after %d iterations."
                  % info
              )
  
      return coefs
  
imports: from abc import ABCMeta, abstractmethod
  import warnings
  import numpy
  from scipy import linalg
  from scipy import sparse
  from scipy.sparse import linalg
  from .base import LinearClassifierMixin, LinearModel, _rescale_data
  from .sag import sag_solver
  from ..base import RegressorMixin
  from ..utils.extmath import safe_sparse_dot
  from ..utils.extmath import row_norms
  from ..utils import check_X_y
  from ..utils import check_array
  from ..utils import check_consistent_length
  from ..utils import compute_sample_weight
  from ..utils import column_or_1d
  from ..preprocessing import LabelBinarizer
  from ..model_selection import GridSearchCV
  from ..externals import six
  from ..metrics.scorer import check_scoring
label_desc: Use image node_id 1 for calling a global function with example usage: _solve_sparse_cg(X, y, alpha, max_iter, tol, verbose) and returns: coefs, _mv, _mv, unknown, unknown