code: def calculate_metrics(scores, corr_idxs, filter_list):
      """Calculate metrics according to scores."""
      logs = []
      for i in range(scores.shape[0]):
          rank = (scores[i] > scores[i][corr_idxs[i]]).astype("float32")
          if filter_list is not None:
              mask = paddle.ones(rank.shape, dtype="float32")
              mask[filter_list[i]] = 0.0
              rank = rank * mask
          rank = paddle.sum(rank) + 1
          logs.append(
              {
                  "MRR": 1.0 / rank,
                  "MR": float(rank),
                  "HITS@1": 1.0 if rank <= 1 else 0.0,
                  "HITS@3": 1.0 if rank <= 3 else 0.0,
                  "HITS@10": 1.0 if rank <= 10 else 0.0,
              }
          )
      return logs
  
imports: import os
  import csv
  import math
  import json
  import time
  import random
  import logging
  import functools
  import traceback
  from collections import defaultdict
  from _thread import start_new_thread
  from multiprocessing import Queue, Process
  import numpy
  from tqdm import tqdm
  import paddle
  import paddle.distributed
label_desc: Use image node_id 6 for calling a global function with example usage: calculate_metrics(scores, corr_idxs, filter_list) and returns: logs