code: def crop_and_pad(
      img: np.ndarray,
      crop_params: Optional[Sequence[int]],
      pad_params: Optional[Sequence[int]],
      pad_value: Optional[float],
      rows: int,
      cols: int,
      interpolation: int,
      pad_mode: int,
      keep_size: bool,
  ) -> np.ndarray:
      if crop_params is not None and any(i != 0 for i in crop_params):
          img = crop(img, *crop_params)
      if pad_params is not None and any(i != 0 for i in pad_params):
          img = FGeometric.pad_with_params(
              img,
              pad_params[0],
              pad_params[1],
              pad_params[2],
              pad_params[3],
              border_mode=pad_mode,
              value=pad_value,
          )
  
      if keep_size:
          resize_fn = _maybe_process_in_chunks(
              cv2.resize,
              dsize=(cols, rows),
              interpolation=interpolation,
          )
          img = resize_fn(img)
  
      return img
  
imports: from typing import Optional, Sequence, Tuple
  import cv2
  import numpy
  from albumentations.augmentations.utils import _maybe_process_in_chunks, preserve_channel_dim
  from ...core.bbox_utils import denormalize_bbox, normalize_bbox
  from ...core.transforms_interface import BoxInternalType, KeypointInternalType
  from ..geometric import functional
label_desc: Use image node_id 14 for calling a global function with example usage: crop_and_pad(img, crop_params, pad_params, pad_value, rows, cols, interpolation, pad_mode, keep_size) and returns: img