docstr: Calculate the gradient of the cross-entropy loss w.r.t the image.
  Args:
      data(numpy.ndarray): input data with shape (size, height, width,
      channels).
      label(int): Label used to calculate the gradient.
  Return:
      numpy.ndarray: gradient of the cross-entropy loss w.r.t the image
          with the shape (height, width, channel).
docstr_tok: ["Calculate","the","gradient","of","the","cross-entropy","loss","w.r.t","the","image",".","Args",":","data","(","numpy.ndarray",")",":","input","data","with","shape","(","size",",","height",",","width",",","channels",")",".","label","(","int",")",":","Label","used","to","calculate","the","gradient",".","Return",":","numpy.ndarray",":","gradient","of","the","cross-entropy","loss","w.r.t","the","image","with","the","shape","(","height",",","width",",","channel",")","."]
code: def gradient(self, data, label):
      """
      Calculate the gradient of the cross-entropy loss w.r.t the image.
      Args:
          data(numpy.ndarray): input data with shape (size, height, width,
          channels).
          label(int): Label used to calculate the gradient.
      Return:
          numpy.ndarray: gradient of the cross-entropy loss w.r.t the image
              with the shape (height, width, channel).
      """
  
      import keras.backend as k
  
      k.set_learning_phase(0)
  
      scaled_data = self._process_input(data.copy())
  
      grads_logits = k.gradients(self._logits[:, label], self._input)[0]
      self._grads = k.function([self._input], [grads_logits])
  
      grads = self._grads([scaled_data])
  
      grads = np.swapaxes(np.array(grads), 0, 1)
  
      return grads.reshape(data.shape)
  
file_path: AdvBox/adversarialbox/models/keras.py
imports: from __future__ import absolute_import
  from builtins import str
  import numpy
  import os
  import sys
  from .base import Model
  from adversarialbox.defences.feature_squeezing import FeatureFqueezingDefence
  import logging
label_desc: Use image node_id 4 for calling the KerasModel obj's underlying member method code with example usage: obj.gradient(data, label) and returns: grads