code: def export_to_coco(
      class_map,
      annotations,
      image_list,
      dataset_path,
      output_path,
      classes=MLPERF_CLASSES,
  ):
      output_path.parent.mkdir(parents=True, exist_ok=True)
      cats = [
          {"id": i, "name": c, "supercategory": None}
          for i, c in enumerate(classes)
      ]
      categories_map = pd.DataFrame(
          [(i, c) for i, c in enumerate(classes)],
          columns=["category_id", "category_name"],
      )
      class_map = class_map.merge(
          categories_map,
          left_on="DisplayName",
          right_on="category_name",
          how="inner",
      )
      annotations = annotations[
          np.isin(annotations["ImageID"], image_list)
      ]
      annotations = annotations.merge(
          class_map, on="LabelName", how="inner"
      )
      annotations["image_id"] = pd.factorize(
          annotations["ImageID"].tolist()
      )[0]
      annotations[["height", "width"]] = annotations.apply(
          lambda x: extract_dims(dataset_path / f"{x['ImageID']}.jpg"),
          axis=1,
          result_type="expand",
      )
  
      # Images
      imgs = [
          {
              "id": int(id + 1),
              "file_name": f"{image_id}.jpg",
              "height": row["height"],
              "width": row["width"],
              "license": None,
              "coco_url": None,
          }
          for (id, image_id), row in (
              annotations.groupby(["image_id", "ImageID"])
              .first()
              .iterrows()
          )
      ]
  
      # Annotations
      annots = []
      for i, row in annotations.iterrows():
          xmin, ymin, xmax, ymax, img_w, img_h = [
              row[k]
              for k in [
                  "XMin",
                  "YMin",
                  "XMax",
                  "YMax",
                  "width",
                  "height",
              ]
          ]
          x, y, w, h = (
              xmin * img_w,
              ymin * img_h,
              (xmax - xmin) * img_w,
              (ymax - ymin) * img_h,
          )
          coco_annot = {
              "id": int(i) + 1,
              "image_id": int(row["image_id"] + 1),
              "category_id": int(row["category_id"]),
              "bbox": [x, y, w, h],
              "area": w * h,
          }
          coco_annot.update(
              {
                  k: row[k]
                  for k in [
                      "IsOccluded",
                      "IsInside",
                      "IsDepiction",
                      "IsTruncated",
                      "IsGroupOf",
                  ]
              }
          )
          coco_annot["iscrowd"] = int(row["IsGroupOf"])
          annots.append(coco_annot)
  
      info = {"dataset": "openimages_mlperf", "version": "v6"}
      coco_annotations = {
          "info": info,
          "licenses": [],
          "categories": cats,
          "images": imgs,
          "annotations": annots,
      }
      with open(output_path, "w") as fp:
          json.dump(coco_annotations, fp)
  
file_path: tinygrad/extra/datasets/openimages.py
imports: import os
  import math
  import json
  import numpy
  from PIL import Image
  import pathlib
  import boto3, botocore
  from tinygrad.helpers import fetch
  from tqdm import tqdm
  import pandas
  import concurrent.futures
label_desc: Use image node_id 3 for calling a global function with example usage: export_to_coco(class_map, annotations, image_list, dataset_path, output_path, classes) without return types