class_docstr: Wrapper class for importing Keras regression models.
class_docstr_tok: ["Wrapper","class","for","importing","Keras","regression","models","."]
docstr: Compute the gradient of the loss function w.r.t. `x`.
  
  :param x: Sample input with shape as expected by the model.
  :param y: Target values (class labels) one-hot-encoded of shape (nb_samples, nb_classes) or indices of shape
            (nb_samples,).
  :param training_mode: `True` for model set to training mode and `'False` for model set to evaluation mode.
  :return: Array of gradients of the same shape as `x`.
docstr_tok: ["Compute","the","gradient","of","the","loss","function","w.r.t",".","`","x","`",".",":","param","x",":","Sample","input","with","shape","as","expected","by","the","model",".",":","param","y",":","Target","values","(","class","labels",")","one-hot-encoded","of","shape","(","nb_samples",",","nb_classes",")","or","indices","of","shape","(","nb_samples",",",")",".",":","param","training_mode",":","`","True","`","for","model","set","to","training","mode","and","`","'False","`","for","model","set","to","evaluation","mode",".",":","return",":","Array","of","gradients","of","the","same","shape","as","`","x","`","."]
code: def loss_gradient(  # pylint: disable=W0221
      self,
      x: np.ndarray,
      y: np.ndarray,
      training_mode: bool = False,
      **kwargs,
  ) -> np.ndarray:
      """
      Compute the gradient of the loss function w.r.t. `x`.
  
      :param x: Sample input with shape as expected by the model.
      :param y: Target values (class labels) one-hot-encoded of shape (nb_samples, nb_classes) or indices of shape
                (nb_samples,).
      :param training_mode: `True` for model set to training mode and `'False` for model set to evaluation mode.
      :return: Array of gradients of the same shape as `x`.
      """
      # Check shape of preprocessed `x` because of custom function for `_loss_gradients`
      x_preprocessed, y_preprocessed = self._apply_preprocessing(
          x, y, fit=False
      )
      shape_match = [
          i is None or i == j
          for i, j in zip(self._input_shape, x_preprocessed.shape[1:])
      ]
      if not all(shape_match):  # pragma: no cover
          raise ValueError(
              f"Error when checking x: expected preprocessed x to have shape {self._input_shape} but got array with "
              f"shape {x_preprocessed.shape[1:]}"
          )
  
      # Compute gradients
      gradients = self._loss_gradients(
          [x_preprocessed, y_preprocessed, int(training_mode)]
      )[0]
      assert gradients.shape == x_preprocessed.shape
      gradients = self._apply_preprocessing_gradient(x, gradients)
      assert gradients.shape == x.shape
  
      return gradients
  
imports: from __future__ import absolute_import, division, print_function, unicode_literals
  import logging
  import os
  import time
  from typing import Any, Callable, Dict, Iterator, List, Optional, Tuple, Union, TYPE_CHECKING
  import numpy
  import six
  from art import config
  from art.estimators.keras import KerasEstimator
  from art.estimators.regression.regressor import RegressorMixin
label_desc: Use image node_id 8 for calling the KerasRegressor obj's underlying member method code with example usage: obj.loss_gradient(x, y, training_mode) and returns: gradients