code: def autocontrast(img: Tensor) -> Tensor:
      """Maximize contrast of an image by remapping its
      pixels per channel so that the lowest becomes black and the lightest
      becomes white.
  
      Args:
          img (PIL Image or Tensor): Image on which autocontrast is applied.
              If img is torch Tensor, it is expected to be in [..., 1 or 3, H, W] format,
              where ... means it can have an arbitrary number of leading dimensions.
              If img is PIL Image, it is expected to be in mode "L" or "RGB".
  
      Returns:
          PIL Image or Tensor: An image that was autocontrasted.
      """
      if not torch.jit.is_scripting() and not torch.jit.is_tracing():
          _log_api_usage_once(autocontrast)
      if not isinstance(img, torch.Tensor):
          return F_pil.autocontrast(img)
  
      return F_t.autocontrast(img)
  
imports: import math
  import numbers
  import sys
  import warnings
  from enum import Enum
  from typing import Any, List, Optional, Tuple, Union
  import numpy
  import torch
  from PIL import Image
  from torch import Tensor
  from ..utils import _log_api_usage_once
  from .None import _functional_pil, _functional_tensor
label_desc: Use image node_id 40 for calling a global function with example usage: autocontrast(img) and returns: F_t, F_pil