code: def match_evaluation(
      model, text_feats, code_feats, tokenizer, device, top_k, img2txt
  ):
      start_time = time.time()
  
      text_ids, text_atts, text_embeds, text_outputs = text_feats
      code_ids, code_atts, code_embeds, _ = code_feats
      code_ids[:, 0] = tokenizer.enc_token_id
  
      sims_matrix = text_embeds @ code_embeds.t()
      score_matrix_i2t = torch.full(
          (text_ids.size(0), code_ids.size(0)), -100.0
      ).to(device)
  
      for i, sims in enumerate(
          tqdm(
              sims_matrix,
              desc=f"Evaluate text-code matching with top {top_k} candidates:",
          )
      ):
          topk_sim, topk_idx = sims.topk(k=top_k, dim=0)
          encoder_output = (
              text_outputs[i].repeat(top_k, 1, 1).to(device)
          )
          encoder_att = text_atts[i].repeat(top_k, 1).to(device)
          code_ids[:, 0] = tokenizer.enc_token_id
          output = model.decoder(
              code_ids[topk_idx],
              attention_mask=code_atts[topk_idx],
              encoder_hidden_states=encoder_output,
              encoder_attention_mask=encoder_att,
              return_dict=True,
          )
          output_vec = get_eos_vec(
              output.last_hidden_state,
              code_ids[topk_idx],
              tokenizer.eos_token_id,
          )
          score = model.itm_head(output_vec)[:, 1]
          score_matrix_i2t[i, topk_idx] = score + topk_sim
  
      total_time = time.time() - start_time
      total_time_str = str(datetime.timedelta(seconds=int(total_time)))
      print("Evaluation time {}".format(total_time_str))
  
      scores_i2t = score_matrix_i2t.cpu().numpy()
  
      ranks = np.ones(scores_i2t.shape[0]) * -1
      for index, score in enumerate(scores_i2t):
          inds = np.argsort(score)[::-1]
          ranks[index] = np.where(inds == img2txt[index])[0][0]
  
      # Compute metrics
      tr1 = 100.0 * len(np.where(ranks < 1)[0]) / len(ranks)
      tr5 = 100.0 * len(np.where(ranks < 5)[0]) / len(ranks)
      tr10 = 100.0 * len(np.where(ranks < 10)[0]) / len(ranks)
      mrr = 100.0 * np.mean(1 / (ranks + 1))
  
      eval_result = {"r1": tr1, "r5": tr5, "r10": tr10, "mrr": mrr}
      return eval_result
  
file_path: codet5/CodeT5+/code_retrieval/eval_match_retrieval.py
imports: import argparse
  import os
  import pprint
  import json
  import time
  import datetime
  import numpy
  from tqdm import tqdm
  import torch
  from transformers import AutoTokenizer, AutoModel
  from data_utils import create_dataset, create_loader
label_desc: Use image node_id 3 for calling a global function with example usage: match_evaluation(model, text_feats, code_feats, tokenizer, device, top_k, img2txt) and returns: eval_result