code: def autocontrast(img: Tensor) -> Tensor:
      _assert_image_tensor(img)
  
      if img.ndim < 3:
          raise TypeError(
              f"Input image tensor should have at least 3 dimensions, but found {img.ndim}"
          )
  
      _assert_channels(img, [1, 3])
  
      bound = _max_value(img.dtype)
      dtype = (
          img.dtype if torch.is_floating_point(img) else torch.float32
      )
  
      minimum = img.amin(dim=(-2, -1), keepdim=True).to(dtype)
      maximum = img.amax(dim=(-2, -1), keepdim=True).to(dtype)
      scale = bound / (maximum - minimum)
      eq_idxs = torch.isfinite(scale).logical_not()
      minimum[eq_idxs] = 0
      scale[eq_idxs] = 1
  
      return ((img - minimum) * scale).clamp(0, bound).to(img.dtype)
  
imports: import warnings
  from typing import List, Optional, Tuple, Union
  import torch
  from torch import Tensor
  from torch.nn.functional import conv2d, grid_sample, interpolate, pad
label_desc: Use image node_id 43 for calling a global function with example usage: autocontrast(img) and returns: unknown