class_docstr: Implement the thermometer encoding defence approach.
  
  | Paper link: https://openreview.net/forum?id=S18Su--CW
  
  | 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 thermometer encoding to sample `x`. The new axis with the encoding is added as last dimension.
  
  :param x: Sample to encode with shape `(batch_size, width, height, depth)`.
  :param y: Labels of the sample `x`. This function does not affect them in any way.
  :return: Encoded sample with shape `(batch_size, width, height, depth x num_space)`.
docstr_tok: ["Apply","thermometer","encoding","to","sample","`","x","`",".","The","new","axis","with","the","encoding","is","added","as","last","dimension",".",":","param","x",":","Sample","to","encode","with","shape","`","(","batch_size",",","width",",","height",",","depth",")","`",".",":","param","y",":","Labels","of","the","sample","`","x","`",".","This","function","does","not","affect","them","in","any","way",".",":","return",":","Encoded","sample","with","shape","`","(","batch_size",",","width",",","height",",","depth","x","num_space",")","`","."]
code: def __call__(
      self, x: np.ndarray, y: Optional[np.ndarray] = None
  ) -> Tuple[np.ndarray, Optional[np.ndarray]]:
      """
      Apply thermometer encoding to sample `x`. The new axis with the encoding is added as last dimension.
  
      :param x: Sample to encode with shape `(batch_size, width, height, depth)`.
      :param y: Labels of the sample `x`. This function does not affect them in any way.
      :return: Encoded sample with shape `(batch_size, width, height, depth x num_space)`.
      """
      # First normalize the input to be in [0, 1]:
      np.clip(x, self.clip_values[0], self.clip_values[1], out=x)
      x = (x - self.clip_values[0]) / (
          self.clip_values[1] - self.clip_values[0]
      )
  
      # Now apply the encoding:
      channel_index = 1 if self.channels_first else x.ndim - 1
      result = np.apply_along_axis(self._perchannel, channel_index, x)
      np.clip(result, 0, 1, out=result)
      return result.astype(ART_NUMPY_DTYPE), y
  
file_path: adversarial-robustness-toolbox/art/defences/preprocessor/thermometer_encoding.py
imports: from __future__ import absolute_import, division, print_function, unicode_literals
  import logging
  from typing import Optional, Tuple, TYPE_CHECKING
  import numpy
  from art.config import ART_NUMPY_DTYPE
  from art.defences.preprocessor.preprocessor import Preprocessor
  from art.utils import to_categorical
label_desc: Use image node_id 2 for calling the ThermometerEncoding obj's underlying member method code with example usage: obj.__call__(x, y) and returns: result,  y