class_docstr: DatasetBuilder for gref dataset.
docstr: Yields examples.
code: def _generate_examples(self, image_dir, gref_aligned_json):
      """Yields examples."""
      gref_anns = json.loads(gref_aligned_json.read_text())
  
      categories_id2name = {
          c["id"]: c["name"] for c in gref_anns["categories"]
      }
      self.info.features["objects"]["label_name"].names = [
          c["name"] for c in gref_anns["categories"]
      ]
      gref_anns = _combine_gref_anns(gref_anns)
      for image_id, image_ann in gref_anns:
          image_path = image_dir / image_ann["file_name"]
          example = {
              "image": image_path,
              "image/id": image_id,
              "objects": [],
          }
          for inst in image_ann["instances"]:
              # build instance dictionary
              example["objects"].append(
                  {
                      "id": inst["annotation_id"],
                      "area": inst["area"],
                      "bbox": _build_bbox(image_ann, *inst["bbox"]),
                      "label": inst["category_id"],  # 1-index.
                      "label_name": categories_id2name[
                          inst["category_id"]
                      ],
                      "refexp": inst["refexps"],
                  }
              )
          yield image_id, example
  
file_path: datasets/tensorflow_datasets/vision_language/gref/gref.py
imports: from __future__ import annotations
  import collections
  import json
  import numpy
  import tensorflow_datasets.public_api
label_desc: Use image node_id 3 for calling the Gref obj's underlying member method code with example usage: obj._generate_examples(image_dir, gref_aligned_json) without return types