code: def score_candidates(
      x, y, candidate_inds, fwd_mean, bwd_mean, margin, dist="cosine"
  ):
      # Adapted From: https://github.com/google-research/xtreme/blob/
      #               522434d1aece34131d997a97ce7e9242a51a688a/third_party/utils_retrieve.py
      scores = np.zeros(candidate_inds.shape)
      for i in range(scores.shape[0]):
          for j in range(scores.shape[1]):
              k = candidate_inds[i, j]
              scores[i, j] = score(
                  x[i], y[k], fwd_mean[i], bwd_mean[k], margin, dist
              )
      return scores
  
imports: import hashlib
  import numpy
  import torch
  from dataclasses import dataclass
  from typing import List
  from jiant.tasks.core import BaseExample, BaseTokenizedExample, BaseDataRow, BatchMixin, Task, TaskTypes
  from jiant.tasks.lib.templates.shared import construct_single_input_tokens_and_segment_ids, create_input_set_from_tokens_and_segments
  from jiant.utils.python.io import read_file, read_file_lines
label_desc: Use image node_id 7 for calling a global function with example usage: score_candidates(x, y, candidate_inds, fwd_mean, bwd_mean, margin, dist) and returns: scores