code: def test_map() -> None:
      opts = argparse.Namespace()
      setattr(opts, "stats.coco_map.iou_types", ["bbox", "segm"])
      setattr(opts, "dataset.root_val", "tests/data/coco")
      evaluator = coco_map.COCOEvaluator(opts)
  
      # Read annotations from the annotations file.
      annotations_file = (
          "tests/data/coco/annotations/instances_val2017.json"
      )
      with open(annotations_file) as f:
          annotations = json.load(f)
  
      predictions = {
          "detections": [
              get_detection_pred_tuple_from_annotations(
                  annotations, [0], evaluator.coco_id_to_contiguous_id
              ),
              get_detection_pred_tuple_from_annotations(
                  annotations, [1], evaluator.coco_id_to_contiguous_id
              ),
          ]
      }
  
      # These targets correspond to the first two annotations in our .json file.
      targets = [
          {
              "image_id": torch.tensor(37777),
              "image_width": torch.tensor(352),
              "image_height": torch.tensor(230),
          },
          {
              "image_id": torch.tensor(397133),
              "image_width": torch.tensor(640),
              "image_height": torch.tensor(427),
          },
      ]
  
      evaluator.update(predictions, targets)
  
      results = evaluator.summarize_coco_results()
      assert results == {
          "bbox": 99.99999999999997,
          "segm": 99.99999999999997,
      }
  
file_path: ml-cvnets/tests/metrics/test_coco_map.py
imports: import argparse
  import json
  import os
  from typing import Dict, List, Tuple
  import numpy
  import torch
  from pycocotools import mask
  from cvnets.models.detection import DetectionPredTuple
  from metrics import coco_map
  from metrics.stats import Statistics
label_desc: Use image node_id 4 for calling a global function with example usage: test_map() without return types