class_docstr: Stanford Dogs dataset.
class_docstr_tok: ["Stanford","Dogs","dataset","."]
docstr: Generate dog images, labels, bbox attributes given the directory path.
  
  Args:
    archive: object that iterates over the zip file_names : list of train/test
      image file names obtained from mat file annotation_files : dict of image
      file names and their xml object
  
  Yields:
    Image path, Image file name, its corresponding label and
    bounding box values
docstr_tok: ["Generate","dog","images",",","labels",",","bbox","attributes","given","the","directory","path",".","Args",":","archive",":","object","that","iterates","over","the","zip","file_names",":","list","of","train\/test","image","file","names","obtained","from","mat","file","annotation_files",":","dict","of","image","file","names","and","their","xml","object","Yields",":","Image","path",",","Image","file","name",",","its","corresponding","label","and","bounding","box","values"]
code: def _generate_examples(self, archive, file_names, annotation_files):
      """Generate dog images, labels, bbox attributes given the directory path.
  
      Args:
        archive: object that iterates over the zip file_names : list of train/test
          image file names obtained from mat file annotation_files : dict of image
          file names and their xml object
  
      Yields:
        Image path, Image file name, its corresponding label and
        bounding box values
      """
      bbox_attrib = ["xmin", "xmax", "ymin", "ymax", "width", "height"]
  
      for fname, fobj in archive:
          res = _NAME_RE.match(fname)
          if not res or (os.path.split(fname)[-1] not in file_names):
              continue
  
          label = res.group(1)[:-1].lower()
          file_name = res.group(2)
          attributes = collections.defaultdict(list)
          for element in annotation_files[
              file_name.split(".")[0]
          ].iter():
              # Extract necessary Bbox attributes from XML file
              if element.tag.strip() in bbox_attrib:
                  attributes[element.tag.strip()].append(
                      float(element.text.strip())
                  )
  
          # BBox attributes in range of 0.0 to 1.0
          def normalize_bbox(bbox_side, image_side):
              return min(bbox_side / image_side, 1.0)
  
          def build_box(attributes, n):
              return tfds.features.BBox(
                  ymin=normalize_bbox(
                      attributes["ymin"][n], attributes["height"][0]
                  ),
                  xmin=normalize_bbox(
                      attributes["xmin"][n], attributes["width"][0]
                  ),
                  ymax=normalize_bbox(
                      attributes["ymax"][n], attributes["height"][0]
                  ),
                  xmax=normalize_bbox(
                      attributes["xmax"][n], attributes["width"][0]
                  ),
              )
  
          yield fname, {
              "image": fobj,
              "image/filename": fname,
              "label": label,
              "objects": [
                  {"bbox": build_box(attributes, n)}
                  for n in range(len(attributes["xmin"]))
              ],
          }
  
file_path: datasets/tensorflow_datasets/datasets/stanford_dogs/stanford_dogs_dataset_builder.py
imports: import collections
  import os
  import re
  import xml.etree.ElementTree
  from tensorflow_datasets.core.utils.lazy_imports_utils import tensorflow
  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(archive, file_names, annotation_files) and returns: min, tfds