code: def normalize_bbox(
      bbox: BBox,
      img_shape: Union[np.ndarray, Sequence[float]],
  ) -> BBox:
      """Normalizes a bbox in the YXYX format.
  
      The x coordinates are normalized using the image's height, while the y
      coordinates using the image width.
  
      Args:
        bbox: The input BBox in YXYX format.
        img_shape: 2-dimensions np.ndarray or iterable with (imgage_heigth,
          image_width).
  
      Returns:
        Normalized BBox.
  
      Raises:
        ValueError if the img_shape shape or length is different than 2, or if any
        of the image shapes is zero.
      """
      if (
          isinstance(img_shape, np.ndarray) and img_shape.shape != (2,)
      ) or (isinstance(img_shape, Sequence) and len(img_shape) != 2):
          raise ValueError(
              f"Expected 2-dimensional img_shape, got {img_shape}."
          )
  
      height, width = img_shape[0], img_shape[1]
      if height == 0 or width == 0:
          raise ValueError(
              f"Valid image shapes cannot be zero, but got: {img_shape}."
          )
  
      return BBox(
          ymin=bbox.ymin / height,
          xmin=bbox.xmin / width,
          ymax=bbox.ymax / height,
          xmax=bbox.xmax / width,
      )
  
file_path: datasets/tensorflow_datasets/core/features/bounding_boxes_utils.py
imports: import collections
  from collections.abc import Sequence
  import enum
  from typing import Union
  import numpy
label_desc: Use image node_id 2 for calling a global function with example usage: normalize_bbox(bbox, img_shape) and returns: BBox