code: def explained_variance_2d(y_pred, y_true):
      """
      Computes fraction of variance that ypred explains about y, for 2D arrays.
      Returns 1 - Var[y-ypred] / Var[y]
  
      interpretation:
          ev=0  =>  might as well have predicted zero
          ev=1  =>  perfect prediction
          ev<0  =>  worse than just predicting zero
  
      :param y_pred: (np.ndarray) the prediction
      :param y_true: (np.ndarray) the expected value
      :return: (float) explained variance of ypred and y
      """
      assert y_true.ndim == 2 and y_pred.ndim == 2
      var_y = np.var(y_true, axis=0)
      explained_var = 1 - np.var(y_true - y_pred) / var_y
      explained_var[var_y < 1e-10] = 0
      return explained_var
  
file_path: stable-baselines/stable_baselines/common/math_util.py
imports: import numpy
  import scipy.signal
label_desc: Use image node_id 4 for calling a global function with example usage: explained_variance_2d(y_pred, y_true) and returns: explained_var