class_docstr: Computes the image-text retrieval metrics for a list of images and their captions
  using the distance between their embeddings.
  
  Expects predictions to contain two keys:
      image (Tensor): [batch, hidden_dim]
      text (Tensor): [batch * num_captions, hidden_dim]
  
  Computes the following metrics:
      image2text
          recall@1, recall@5, recall@10, mean_rank, median_rank
      text2image
          recall@1, recall@5, recall@10, mean_rank, median_rank
  
  NOTE: each image MUST have the same number of captions.
class_docstr_tok: ["Computes","the","image-text","retrieval","metrics","for","a","list","of","images","and","their","captions","using","the","distance","between","their","embeddings",".","Expects","predictions","to","contain","two","keys",":","image","(","Tensor",")",":","[","batch",",","hidden_dim","]","text","(","Tensor",")",":","[","batch","*","num_captions",",","hidden_dim","]","Computes","the","following","metrics",":","image2text","recall","@","1",",","recall","@","5",",","recall","@","10",",","mean_rank",",","median_rank","text2image","recall","@","1",",","recall","@","5",",","recall","@","10",",","mean_rank",",","median_rank","NOTE",":","each","image","MUST","have","the","same","number","of","captions","."]
code: def _rank_metrics(self, ranks: torch.LongTensor) -> Dict[str, Number]:
      return {
          "recall@1": 100 * (ranks < 1).float().mean().item(),
          "recall@5": 100 * (ranks < 5).float().mean().item(),
          "recall@10": 100 * (ranks < 10).float().mean().item(),
          "mean_rank": 1 + ranks.float().mean().item(),
          "median_rank": 1 + ranks.median().item(),
      }
  
imports: import argparse
  from numbers import Number
  from typing import Any, Dict, Tuple, Union
  import torch
  from torch import Tensor
  from metrics import METRICS_REGISTRY
  from metrics.metric_base import BaseMetric
  from metrics.retrieval_cmc import DISTANCE_REGISTRY
  from utils import logger
  from utils.tensor_utils import all_gather_list
label_desc: Use image node_id 9 for calling the ImageTextRetrievalMetric obj's underlying member method code with example usage: obj._rank_metrics(ranks) and returns: dict