code: def rotate_sample(
      img: torch.Tensor,
      geoms: np.ndarray,
      angle: float,
      expand: bool = False,
  ) -> Tuple[torch.Tensor, np.ndarray]:
      """Rotate image around the center, interpolation=NEAREST, pad with 0 (black)
  
      Args:
      ----
          img: image to rotate
          geoms: array of geometries of shape (N, 4) or (N, 4, 2)
          angle: angle in degrees. +: counter-clockwise, -: clockwise
          expand: whether the image should be padded before the rotation
  
      Returns:
      -------
          A tuple of rotated img (tensor), rotated geometries of shape (N, 4, 2)
      """
      rotated_img = F.rotate(
          img, angle=angle, fill=0, expand=expand
      )  # Interpolation NEAREST by default
      rotated_img = rotated_img[
          :3
      ]  # when expand=True, it expands to RGBA channels
      # Get absolute coords
      _geoms = deepcopy(geoms)
      if _geoms.shape[1:] == (4,):
          if np.max(_geoms) <= 1:
              _geoms[:, [0, 2]] *= img.shape[-1]
              _geoms[:, [1, 3]] *= img.shape[-2]
      elif _geoms.shape[1:] == (4, 2):
          if np.max(_geoms) <= 1:
              _geoms[..., 0] *= img.shape[-1]
              _geoms[..., 1] *= img.shape[-2]
      else:
          raise AssertionError("invalid format for arg `geoms`")
  
      # Rotate the boxes: xmin, ymin, xmax, ymax or polygons --> (4, 2) polygon
      rotated_geoms: np.ndarray = rotate_abs_geoms(
          _geoms,
          angle,
          img.shape[1:],
          expand,
      ).astype(np.float32)
  
      # Always return relative boxes to avoid label confusions when resizing is performed aferwards
      rotated_geoms[..., 0] = (
          rotated_geoms[..., 0] / rotated_img.shape[2]
      )
      rotated_geoms[..., 1] = (
          rotated_geoms[..., 1] / rotated_img.shape[1]
      )
  
      return rotated_img, np.clip(rotated_geoms, 0, 1)
  
file_path: doctr/doctr/transforms/functional/pytorch.py
imports: from copy import deepcopy
  from typing import Tuple
  import numpy
  import torch
  from torchvision.transforms import functional
  from doctr.utils.geometry import rotate_abs_geoms
  from .base import create_shadow_mask, crop_boxes
label_desc: Use image node_id 2 for calling a global function with example usage: rotate_sample(img, geoms, angle, expand) and returns: rotated_img,  np