code: def _apply(func, stc_true, stc_est, per_sample):
      """Apply metric to stcs.
  
      Applies a metric to each pair of columns of stc_true and stc_est
      if per_sample is True. Otherwise it applies it to stc_true and stc_est
      directly.
      """
      if per_sample:
          metric = np.empty(
              stc_true.data.shape[1]
          )  # one value per time point
          for i in range(stc_true.data.shape[1]):
              metric[i] = func(
                  stc_true.data[:, i : i + 1],
                  stc_est.data[:, i : i + 1],
              )
      else:
          metric = func(stc_true.data, stc_est.data)
      return metric
  
imports: from functools import partial
  import numpy
  from scipy.spatial.distance import cdist
  from ...utils import _check_option, _validate_type, fill_doc
label_desc: Use image node_id 4 for calling a global function with example usage: _apply(func, stc_true, stc_est, per_sample) and returns: metric