class_docstr: Implement the JPEG compression defence approach.
  
  For input images or videos with 3 color channels the compression is applied in mode `RGB`
  (3x8-bit pixels, true color), for all other numbers of channels the compression is applied for each channel with
  mode `L` (8-bit pixels, black and white).
  
  | Paper link: https://arxiv.org/abs/1705.02900, https://arxiv.org/abs/1608.00853
  
  
  | Please keep in mind the limitations of defences. For more information on the limitations of this defence,
      see https://arxiv.org/abs/1802.00420 . For details on how to evaluate classifier security in general, see
      https://arxiv.org/abs/1902.06705
docstr: Apply JPEG compression to image input.
docstr_tok: ["Apply","JPEG","compression","to","image","input","."]
code: def _compress(self, x: np.ndarray, mode: str) -> np.ndarray:
      """
      Apply JPEG compression to image input.
      """
      from PIL import Image
  
      tmp_jpeg = BytesIO()
      x_image = Image.fromarray(x, mode=mode)
      x_image.save(tmp_jpeg, format="jpeg", quality=self.quality)
      x_jpeg = np.array(Image.open(tmp_jpeg))
      tmp_jpeg.close()
      return x_jpeg
  
file_path: adversarial-robustness-toolbox/art/defences/preprocessor/jpeg_compression.py
imports: from __future__ import absolute_import, division, print_function, unicode_literals
  from io import BytesIO
  import logging
  from typing import Optional, Tuple, TYPE_CHECKING
  import numpy
  from tqdm.auto import tqdm
  from art.config import ART_NUMPY_DTYPE
  from art.defences.preprocessor.preprocessor import Preprocessor
label_desc: Use image node_id 2 for calling the JpegCompression obj's underlying member method code with example usage: obj._compress(x, mode) and returns: x_jpeg