code: def posterize_image(image: torch.Tensor, bits: int) -> torch.Tensor:
      if image.is_floating_point():
          levels = 1 << bits
          return (
              image.mul(levels)
              .floor_()
              .clamp_(0, levels - 1)
              .mul_(1.0 / levels)
          )
      else:
          num_value_bits = _num_value_bits(image.dtype)
          if bits >= num_value_bits:
              return image
  
          mask = ((1 << bits) - 1) << (num_value_bits - bits)
          return image & mask
  
imports: from typing import List
  import PIL.Image
  import torch
  from torch.nn.functional import conv2d
  from torchvision import tv_tensors
  from torchvision.transforms import _functional_pil
  from torchvision.transforms._functional_tensor import _max_value
  from torchvision.utils import _log_api_usage_once
  from ._misc import _num_value_bits, to_dtype_image
  from ._type_conversion import pil_to_tensor, to_pil_image
  from ._utils import _get_kernel, _register_kernel_internal
label_desc: Use image node_id 28 for calling a global function with example usage: posterize_image(image, bits) and returns: image, unknown, image