code: def _compare_fn(
      img1: Tensor,
      img2: Tensor,
      net_type: str,
      normalize: bool = False,
      reduction: str = "mean",
  ) -> Tensor:
      """Comparison function for tm implementation."""
      ref = LPIPS_reference(net=net_type)
      res = ref(img1, img2, normalize=normalize).detach().cpu().numpy()
      if reduction == "mean":
          return res.mean()
      return res.sum()
  
imports: from functools import partial
  from typing import NamedTuple
  import pytest
  import torch
  from lpips import LPIPS
  from torch import Tensor
  from torchmetrics.functional.image.lpips import learned_perceptual_image_patch_similarity
  from torchmetrics.image.lpip import LearnedPerceptualImagePatchSimilarity
  from torchmetrics.utilities.imports import _LPIPS_AVAILABLE, _TORCHVISION_AVAILABLE
  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: _compare_fn(img1, img2, net_type, normalize, reduction) and returns: res, res