code: def equalize(img: Tensor) -> Tensor:
      """Equalize the histogram of an image by applying
      a non-linear mapping to the input in order to create a uniform
      distribution of grayscale values in the output.
  
      Args:
          img (PIL Image or Tensor): Image on which equalize 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.
              The tensor dtype must be ``torch.uint8`` and values are expected to be in ``[0, 255]``.
              If img is PIL Image, it is expected to be in mode "P", "L" or "RGB".
  
      Returns:
          PIL Image or Tensor: An image that was equalized.
      """
      if not torch.jit.is_scripting() and not torch.jit.is_tracing():
          _log_api_usage_once(equalize)
      if not isinstance(img, torch.Tensor):
          return F_pil.equalize(img)
  
      return F_t.equalize(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 41 for calling a global function with example usage: equalize(img) and returns: F_t, F_pil