class_docstr: DatasetBuilder for lvis dataset.
class_docstr_tok: ["DatasetBuilder","for","lvis","dataset","."]
docstr: Yields examples.
docstr_tok: ["Yields","examples","."]
code: def _generate_examples(self, image_dirs, annotation_file):
      """Yields examples."""
      lvis_annotation = LvisAnnotation(annotation_file)
  
      def _process_example(image_info):
          # Search image dirs.
          filename = pathlib.Path(image_info["coco_url"]).name
          image = _find_image_in_dirs(image_dirs, filename)
          instances = lvis_annotation.get_annotations(
              img_id=image_info["id"]
          )
          instances = [
              x
              for x in instances
              if x["id"] not in _INVALID_ANNOTATIONS
          ]
          neg_category_ids = image_info.get("neg_category_ids", [])
          not_exhaustive_category_ids = image_info.get(
              "not_exhaustive_category_ids", []
          )
          example = {
              "image": image,
              "image/id": image_info["id"],
              "neg_category_ids": [i - 1 for i in neg_category_ids],
              "not_exhaustive_category_ids": [
                  i - 1 for i in not_exhaustive_category_ids
              ],
              "objects": [],
          }
          for inst in instances:
              example["objects"].append(
                  {
                      "id": inst["id"],
                      "area": inst["area"],
                      "bbox": _build_bbox(image_info, *inst["bbox"]),
                      "label": inst["category_id"] - 1,
                      "segmentation": _build_segmentation_mask(
                          image_info,
                          inst.get(
                              "segmentation", []
                          ),  # No segs in minival.
                      ),
                  }
              )
          return image_info["id"], example
  
      beam = tfds.core.lazy_imports.apache_beam
      return beam.Create(lvis_annotation.images) | beam.Map(
          _process_example
      )
  
imports: from __future__ import annotations
  import collections
  import json
  import pathlib
  from etils import epath
  import numpy
  import tensorflow_datasets.public_api
label_desc: Use image node_id 3 for calling the Builder obj's underlying member method code with example usage: obj._generate_examples(image_dirs, annotation_file) and returns: unknown, image_info,  example