code: def perspective(
      img: np.ndarray,
      matrix: np.ndarray,
      max_width: int,
      max_height: int,
      border_val: Union[int, float, List[int], List[float], np.ndarray],
      border_mode: int,
      keep_size: bool,
      interpolation: int,
  ):
      h, w = img.shape[:2]
      perspective_func = _maybe_process_in_chunks(
          cv2.warpPerspective,
          M=matrix,
          dsize=(max_width, max_height),
          borderMode=border_mode,
          borderValue=border_val,
          flags=interpolation,
      )
      warped = perspective_func(img)
  
      if keep_size:
          return resize(warped, h, w, interpolation=interpolation)
  
      return warped
  
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 17 for calling a global function with example usage: perspective(img, matrix, max_width, max_height, border_val, border_mode, keep_size, interpolation) and returns: warped, resize