(img: Tensor, bits: int)
return F_t.posterize(img, bits)
Posterize an image by reducing the number of bits for each color channel.

    Args:
        img (PIL Image or Tensor): Image to have its colors posterized.
            If img is torch Tensor, it should be of type torch.uint8 and
            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".
        bits (int): The number of bits to keep for each channel (0-8).
    Returns:
        PIL Image or Tensor: Posterized image.
Posterize an image by reducing the number of bits for each color channel.
Posterize an image by reducing the number of bits for each color channel .
def posterize(img: Tensor, bits: int) -> Tensor:
    """Posterize an image by reducing the number of bits for each color channel.

    Args:
        img (PIL Image or Tensor): Image to have its colors posterized.
            If img is torch Tensor, it should be of type torch.uint8 and
            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".
        bits (int): The number of bits to keep for each channel (0-8).
    Returns:
        PIL Image or Tensor: Posterized image.
    """
    if not (0 <= bits <= 8):
        raise ValueError(
            'The number if bits should be between 0 and 8. Got {}'.format(
                bits))

    if not isinstance(img, torch.Tensor):
        return F_pil.posterize(img, bits)

    return F_t.posterize(img, bits)
def posterize ( img : Tensor , bits : int ) -> Tensor : if not ( 0 <= bits <= 8 ) : raise ValueError ( 'The number if bits should be between 0 and 8. Got {}' . format ( bits ) ) if not isinstance ( img , torch . Tensor ) : return F_pil . posterize ( img , bits ) return F_t . posterize ( img , bits )