code: def test_convert_records_to_coco_style_annotations(
      coco_mask_records,
      coco_records,
      expected_records,
      coco_record_id_map,
  ):
      annotations = coco_records["annotations"]
      expected_annotations = expected_records["annotations"]
  
      assert len(expected_annotations) == len(annotations)
      assert annotations[0].keys() == expected_annotations[0].keys()
  
      ## check if two unordered lists of dicts are approximate the same ##
  
      # the annotations ids don't matter and don't match
      for i in range(len(annotations)):
          del annotations[i]["id"]
          del expected_annotations[i]["id"]
  
      # use record_id_map to convert to ids used by the parser
      # for annotation in expected_annotations:
      #     annotation["image_id"] = coco_record_id_map[annotation["image_id"]]
  
      # # convert label ids
      # original_cocoid2label = {o["id"]: o["name"] for o in expected_records["categories"]}
      # class_map = coco_mask_records[0].detection.class_map
  
      # sort items so we compare each annotation with it's corresponded pair
      sorted_annotations = sorted(
          sorted(d.items()) for d in annotations
      )
      sorted_expectation = sorted(
          sorted(d.items()) for d in expected_annotations
      )
  
      # check each (key, value) individually (so we can use almost_equal)
      for annotation, expected_annotation in zip(
          sorted_annotations, sorted_expectation
      ):
          # remember that each annotation is now in the form: (key, value)
          for (k1, v1), (k2, v2) in zip(
              annotation, expected_annotation
          ):
              assert k1[0] == k2[0]
              if k1 == "segmentation":
                  # TODO: Skipping segmentation check
                  pass
              # elif k1 == "category_id":
              #     assert class_map.get_by_id(v1) == original_cocoid2label[v2]
              else:
                  np.testing.assert_almost_equal(v1, v2)
  
file_path: icevision/tests/data/test_convert_records_to_coco_style.py
imports: import pytest
  import icevision
  from icevision.all import *
label_desc: Use image node_id 4 for calling a global function with example usage: test_convert_records_to_coco_style_annotations(coco_mask_records, coco_records, expected_records, coco_record_id_map) without return types