code: def invert_colors(
      img: torch.Tensor, min_val: float = 0.6
  ) -> torch.Tensor:
      """Invert the colors of an image
  
      Args:
      ----
          img : torch.Tensor, the image to invert
          min_val : minimum value of the random shift
  
      Returns:
      -------
          the inverted image
      """
      out = F.rgb_to_grayscale(img, num_output_channels=3)
      # Random RGB shift
      shift_shape = (
          [img.shape[0], 3, 1, 1] if img.ndim == 4 else [3, 1, 1]
      )
      rgb_shift = min_val + (1 - min_val) * torch.rand(shift_shape)
      # Inverse the color
      if out.dtype == torch.uint8:
          out = (out.to(dtype=rgb_shift.dtype) * rgb_shift).to(dtype=torch.uint8)  # type: ignore[attr-defined]
      else:
          out = out * rgb_shift.to(dtype=out.dtype)  # type: ignore[attr-defined]
      # Inverse the color
      out = 255 - out if out.dtype == torch.uint8 else 1 - out
      return out
  
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 1 for calling a global function with example usage: invert_colors(img, min_val) and returns: out