code: def _compare_fn(preds, target, model_name_or_path):
      processor = _CLIPProcessor.from_pretrained(model_name_or_path)
      model = _CLIPModel.from_pretrained(model_name_or_path)
      inputs = processor(
          text=target,
          images=[p.cpu() for p in preds],
          return_tensors="pt",
          padding=True,
      )
      outputs = model(**inputs)
      logits_per_image = outputs.logits_per_image
      return logits_per_image.diag().mean().detach()
  
imports: from functools import partial
  from typing import List, NamedTuple
  import matplotlib
  import matplotlib.pyplot
  import pytest
  import torch
  from torch import Tensor
  from torchmetrics.functional.multimodal.clip_score import clip_score
  from torchmetrics.multimodal.clip_score import CLIPScore
  from torchmetrics.utilities.imports import _TRANSFORMERS_GREATER_EQUAL_4_10
  from transformers import CLIPModel
  from transformers import CLIPProcessor
  from unittests.helpers import seed_all
  from unittests.helpers.testers import MetricTester
  from unittests.text.helpers import skip_on_connection_issues
label_desc: Use image node_id 1 for calling a global function with example usage: _compare_fn(preds, target, model_name_or_path) and returns: logits_per_image