code: def _wrap_reduction(x, y, sk_fn, reduction):
      x = x.view(-1, extra_dim).numpy()
      y = y.view(-1, extra_dim).numpy()
      res = sk_fn(x, y)
      if reduction == "sum":
          return res.sum(axis=-1)
      if reduction == "mean":
          return res.mean(axis=-1)
      return res
  
file_path: torchmetrics/tests/unittests/pairwise/test_pairwise_distance.py
imports: from functools import partial
  from typing import NamedTuple
  import pytest
  import torch
  from sklearn.metrics.pairwise import cosine_similarity, euclidean_distances, linear_kernel, manhattan_distances, pairwise_distances
  from torch import Tensor
  from torchmetrics.functional import pairwise_cosine_similarity, pairwise_euclidean_distance, pairwise_linear_similarity, pairwise_manhattan_distance, pairwise_minkowski_distance
  from unittests import BATCH_SIZE, NUM_BATCHES
  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: _wrap_reduction(x, y, sk_fn, reduction) and returns: res, res, res