code: def convert_bbox_to_albumentations(
      bbox: BoxType,
      source_format: str,
      rows: int,
      cols: int,
      check_validity: bool = False,
  ) -> BoxType:
      """Convert a bounding box from a format specified in `source_format` to the format used by albumentations:
      normalized coordinates of top-left and bottom-right corners of the bounding box in a form of
      `(x_min, y_min, x_max, y_max)` e.g. `(0.15, 0.27, 0.67, 0.5)`.
  
      Args:
          bbox: A bounding box tuple.
          source_format: format of the bounding box. Should be 'coco', 'pascal_voc', or 'yolo'.
          check_validity: Check if all boxes are valid boxes.
          rows: Image height.
          cols: Image width.
  
      Returns:
          tuple: A bounding box `(x_min, y_min, x_max, y_max)`.
  
      Note:
          The `coco` format of a bounding box looks like `(x_min, y_min, width, height)`, e.g. (97, 12, 150, 200).
          The `pascal_voc` format of a bounding box looks like `(x_min, y_min, x_max, y_max)`, e.g. (97, 12, 247, 212).
          The `yolo` format of a bounding box looks like `(x, y, width, height)`, e.g. (0.3, 0.1, 0.05, 0.07);
          where `x`, `y` coordinates of the center of the box, all values normalized to 1 by image height and width.
  
      Raises:
          ValueError: if `target_format` is not equal to `coco` or `pascal_voc`, or `yolo`.
          ValueError: If in YOLO format all labels not in range (0, 1).
  
      """
      if source_format not in {"coco", "pascal_voc", "yolo"}:
          raise ValueError(
              f"Unknown source_format {source_format}. Supported formats are: 'coco', 'pascal_voc' and 'yolo'"
          )
  
      if source_format == "coco":
          (x_min, y_min, width, height), tail = bbox[:4], bbox[4:]
          x_max = x_min + width
          y_max = y_min + height
      elif source_format == "yolo":
          # https://github.com/pjreddie/darknet/blob/f6d861736038da22c9eb0739dca84003c5a5e275/scripts/voc_label.py#L12
          _bbox = np.array(bbox[:4])
          if check_validity and np.any((_bbox <= 0) | (_bbox > 1)):
              raise ValueError(
                  "In YOLO format all coordinates must be float and in range (0, 1]"
              )
  
          (x, y, w, h), tail = bbox[:4], bbox[4:]
  
          w_half, h_half = w / 2, h / 2
          x_min = x - w_half
          y_min = y - h_half
          x_max = x_min + w
          y_max = y_min + h
      else:
          (x_min, y_min, x_max, y_max), tail = bbox[:4], bbox[4:]
  
      bbox = (x_min, y_min, x_max, y_max) + tuple(tail)  # type: ignore
  
      if source_format != "yolo":
          bbox = normalize_bbox(bbox, rows, cols)
      if check_validity:
          check_bbox(bbox)
      return bbox
  
imports: from __future__ import division
  from typing import Any, Dict, List, Optional, Sequence, Tuple, TypeVar, cast
  import numpy
  from .transforms_interface import BoxInternalType, BoxType
  from .utils import DataProcessor, Params
label_desc: Use image node_id 7 for calling a global function with example usage: convert_bbox_to_albumentations(bbox, source_format, rows, cols, check_validity) and returns: bbox