code: def _fast_r2_score(y_true, y_pred, multiclass=False):
      """
      Evaluates the r-squared value between the observed and estimated responses.
      Equivalent to sklearn.metrics.r2_score but without the robust error
      checking, thus leading to a much faster implementation (at the cost of
      this error checking). For multi-class responses, returns the mean
      r-squared value across each column in the response matrix.
  
      Parameters
      ----------
      y_true: array-like of shape (n_samples, n_targets)
          Observed responses.
      y_pred: array-like of shape (n_samples, n_targets)
          Predicted responses.
      multiclass: bool
          Whether or not the responses are multi-class.
  
      Returns
      -------
      Scalar quantity, measuring the r-squared value.
      """
      numerator = ((y_true - y_pred) ** 2).sum(axis=0, dtype=np.float64)
      denominator = ((y_true - np.mean(y_true, axis=0)) ** 2).sum(
          axis=0, dtype=np.float64
      )
      if multiclass:
          return np.mean(1 - numerator / denominator)
      else:
          return 1 - numerator / denominator
  
imports: import copy
  import numpy
  import pandas
  from sklearn.base import BaseEstimator, RegressorMixin, ClassifierMixin
  from sklearn.utils import check_array
  from sklearn.utils.validation import check_is_fitted
  from sklearn.metrics import r2_score, roc_auc_score, log_loss
  from sklearn.ensemble import RandomForestRegressor, RandomForestClassifier
  from sklearn.preprocessing import OneHotEncoder
  from imodels.importance.block_transformers import MDIPlusDefaultTransformer, TreeTransformer, CompositeTransformer, IdentityTransformer
  from imodels.importance.ppms import PartialPredictionModelBase, GlmClassifierPPM, RidgeRegressorPPM, LogisticClassifierPPM
  from imodels.importance.mdi_plus import ForestMDIPlus, _get_default_sample_split, _validate_sample_split, _get_sample_split_data
label_desc: Use image node_id 1 for calling a global function with example usage: _fast_r2_score(y_true, y_pred, multiclass) and returns: np, unknown