class_docstr: Mixin abstract base class defining additional functionality for estimators providing loss gradients. An estimator
  of this type can be combined with white-box attacks. This mixin abstract base class has to be mixed in with
  class `BaseEstimator`.
class_docstr_tok: ["Mixin","abstract","base","class","defining","additional","functionality","for","estimators","providing","loss","gradients",".","An","estimator","of","this","type","can","be","combined","with","white-box","attacks",".","This","mixin","abstract","base","class","has","to","be","mixed","in","with","class","`","BaseEstimator","`","."]
docstr: Apply the backward pass to the gradients through all normalization and preprocessing defences that have been
  applied to `x` and `y` in the forward pass. This function has to be applied to all gradients w.r.t. `x`
  calculated by the estimator.
  
  :param x: Features, where first dimension is the number of samples.
  :type x: Format as expected by the `model`
  :param gradients: Gradients before backward pass through normalization and preprocessing defences.
  :type gradients: Format as expected by the `model`
  :return: Gradients after backward pass through normalization and preprocessing defences.
  :rtype: Format as expected by the `model`
code: def _apply_preprocessing_gradient(self, x, gradients, fit=False):
      """
      Apply the backward pass to the gradients through all normalization and preprocessing defences that have been
      applied to `x` and `y` in the forward pass. This function has to be applied to all gradients w.r.t. `x`
      calculated by the estimator.
  
      :param x: Features, where first dimension is the number of samples.
      :type x: Format as expected by the `model`
      :param gradients: Gradients before backward pass through normalization and preprocessing defences.
      :type gradients: Format as expected by the `model`
      :return: Gradients after backward pass through normalization and preprocessing defences.
      :rtype: Format as expected by the `model`
      """
      if self.preprocessing_operations:
          for preprocess in self.preprocessing_operations[::-1]:
              if fit:
                  if preprocess.apply_fit:
                      gradients = preprocess.estimate_gradient(
                          x, gradients
                      )
              else:
                  if preprocess.apply_predict:
                      gradients = preprocess.estimate_gradient(
                          x, gradients
                      )
  
      return gradients
  
imports: from abc import ABC, abstractmethod
  from typing import Any, Dict, List, Optional, Tuple, Union, TYPE_CHECKING
  import numpy
  from tqdm.auto import trange
  from art.config import ART_NUMPY_DTYPE
label_desc: Use image node_id 2 for calling the LossGradientsMixin obj's underlying member method code with example usage: obj._apply_preprocessing_gradient(x, gradients, fit) and returns: gradients