code: def bbox_piecewise_affine(
      bbox: BoxInternalType,
      matrix: Optional[skimage.transform.PiecewiseAffineTransform],
      h: int,
      w: int,
      keypoints_threshold: float,
  ) -> BoxInternalType:
      if matrix is None:
          return bbox
      x1, y1, x2, y2 = denormalize_bbox(bbox, h, w)[:4]
      keypoints = [
          (x1, y1),
          (x2, y1),
          (x2, y2),
          (x1, y2),
      ]
      dist_maps = to_distance_maps(keypoints, h, w, True)
      dist_maps = piecewise_affine(dist_maps, matrix, 0, "constant", 0)
      keypoints = from_distance_maps(
          dist_maps, True, {"x": -1, "y": -1}, keypoints_threshold
      )
      keypoints = [
          i for i in keypoints if 0 <= i[0] < w and 0 <= i[1] < h
      ]
      keypoints_arr = np.array(keypoints)
      x1 = keypoints_arr[:, 0].min()
      y1 = keypoints_arr[:, 1].min()
      x2 = keypoints_arr[:, 0].max()
      y2 = keypoints_arr[:, 1].max()
      return normalize_bbox((x1, y1, x2, y2), h, w)
  
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 32 for calling a global function with example usage: bbox_piecewise_affine(bbox, matrix, h, w, keypoints_threshold) and returns: normalize_bbox, bbox