code: def correlation(
      y_true: np.ndarray, y_pred: np.ndarray, corr_type: str = "pearson"
  ) -> float:
      """
      Calculate given correlation type between ``y_true`` and ``y_pred``.
  
      ``y_pred`` can be multi-dimensional. If ``y_pred`` is 1-dimensional, it
      may either contain probabilities, most-likely classification labels, or
      regressor predictions. In that case, we simply return the correlation
      between ``y_true`` and ``y_pred``. If ``y_pred`` is multi-dimensional,
      it contains probabilties for multiple classes in which case, we infer the
      most likely labels and then compute the correlation between those and
      ``y_true``.
  
      Parameters
      ----------
      y_true : numpy.ndarray
          The true/actual/gold labels for the data.
      y_pred : numpy.ndarray
          The predicted/observed labels for the data.
      corr_type : str, default="pearson"
          Which type of correlation to compute. Possible
          choices are "pearson", "spearman", and "kendall_tau".
  
      Returns
      -------
      float
          correlation value if well-defined, else 0.0
      """
      # get the correlation function to use based on the given type
      corr_func = pearsonr
      if corr_type == "spearman":
          corr_func = spearmanr
      elif corr_type == "kendall_tau":
          corr_func = kendalltau
  
      # convert to numpy array in case we are passed a list
      y_pred = np.array(y_pred)
  
      # multi-dimensional -> probability array -> get label
      if y_pred.ndim > 1:
          labels = np.argmax(y_pred, axis=1)
          ret_score = corr_func(y_true, labels)[0]
      # 1-dimensional -> probabilities/labels -> use as is
      else:
          ret_score = corr_func(y_true, y_pred)[0]
      return ret_score
  
file_path: skll/skll/metrics.py
imports: import copy
  import sys
  from importlib import import_module
  from inspect import signature
  from pathlib import Path
  from typing import Optional, Union
  import numpy
  from scipy.stats import kendalltau, pearsonr, spearmanr
  from sklearn.metrics import confusion_matrix, f1_score, fbeta_score, get_scorer, get_scorer_names, make_scorer
  from skll.types import PathOrStr
label_desc: Use image node_id 2 for calling a global function with example usage: correlation(y_true, y_pred, corr_type) and returns: ret_score