code: def _ref_metric(preds, target, reduction):
      sk_preds = preds.numpy()
      sk_target = target.numpy()
      result_array = sk_cosine(sk_target, sk_preds)
      col = np.diagonal(result_array)
      col_sum = col.sum()
      if reduction == "sum":
          return col_sum
      if reduction == "mean":
          return col_sum / len(col)
      return col
  
file_path: torchmetrics/tests/unittests/regression/test_cosine_similarity.py
imports: from functools import partial
  import numpy
  import pytest
  import torch
  from sklearn.metrics.pairwise import cosine_similarity
  from torchmetrics.functional.regression.cosine_similarity import cosine_similarity
  from torchmetrics.regression.cosine_similarity import CosineSimilarity
  from unittests import BATCH_SIZE, NUM_BATCHES, _Input
  from unittests.helpers import seed_all
  from unittests.helpers.testers import MetricTester
label_desc: Use image node_id 1 for calling a global function with example usage: _ref_metric(preds, target, reduction) and returns: col, col_sum, unknown