code: def bbox_flip(
      bbox: BoxInternalType, d: int, rows: int, cols: int
  ) -> BoxInternalType:
      """Flip a bounding box either vertically, horizontally or both depending on the value of `d`.
  
      Args:
          bbox: A bounding box `(x_min, y_min, x_max, y_max)`.
          d: dimension. 0 for vertical flip, 1 for horizontal, -1 for transpose
          rows: Image rows.
          cols: Image cols.
  
      Returns:
          A bounding box `(x_min, y_min, x_max, y_max)`.
  
      Raises:
          ValueError: if value of `d` is not -1, 0 or 1.
  
      """
      if d == 0:
          bbox = bbox_vflip(bbox, rows, cols)
      elif d == 1:
          bbox = bbox_hflip(bbox, rows, cols)
      elif d == -1:
          bbox = bbox_hflip(bbox, rows, cols)
          bbox = bbox_vflip(bbox, rows, cols)
      else:
          raise ValueError(
              "Invalid d value {}. Valid values are -1, 0 and 1".format(
                  d
              )
          )
      return bbox
  
imports: import math
  from typing import List, Optional, Sequence, Tuple, Union
  import cv2
  import numpy
  import skimage.transform
  from scipy.ndimage import gaussian_filter
  from albumentations.augmentations.utils import _maybe_process_in_chunks, angle_2pi_range, clipped, preserve_channel_dim, preserve_shape
  from ...None import random_utils
  from ...core.bbox_utils import denormalize_bbox, normalize_bbox
  from ...core.transforms_interface import BoxInternalType, FillValueType, ImageColorType, KeypointInternalType
label_desc: Use image node_id 41 for calling a global function with example usage: bbox_flip(bbox, d, rows, cols) and returns: bbox