class_docstr: Class for importing MXNet Gluon 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`.
      """
      import mxnet as mx
  
      # Apply preprocessing
      x_preprocessed, y_preprocessed = self._apply_preprocessing(
          x, y, fit=False
      )
      y_preprocessed = mx.nd.array(
          [np.argmax(y_preprocessed, axis=1)], ctx=self.ctx
      ).T
      x_preprocessed = mx.nd.array(
          x_preprocessed.astype(config.ART_NUMPY_DTYPE), ctx=self.ctx
      )
      x_preprocessed.attach_grad()
  
      with mx.autograd.record(train_mode=training_mode):
          preds = self._model(x_preprocessed)
          loss = self.loss(preds, y_preprocessed)
  
      loss.backward()
  
      # Compute gradients
      grads = x_preprocessed.grad.asnumpy()
      grads = self._apply_preprocessing_gradient(x, grads)
      assert grads.shape == x.shape
  
      return grads
  
imports: from __future__ import absolute_import, division, print_function, unicode_literals
  import logging
  import os
  from typing import List, Optional, Tuple, Union, TYPE_CHECKING
  import numpy
  import six
  from art import config
  from art.estimators.mxnet import MXEstimator
  from art.estimators.classification.classifier import ClassGradientsMixin, ClassifierMixin
  from art.utils import check_and_transform_label_format
label_desc: Use image node_id 10 for calling the MXClassifier obj's underlying member method code with example usage: obj.loss_gradient(x, y, training_mode) and returns: grads