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 tensorflow as tf
  
      scaled_data = self._process_input(data)
  
      if self._grads[label] is None:
          logging.info("Start to get _grads[{}]".format(label))
          self._grads[label] = tf.gradients(
              self._logits[:, label], self._input
          )[0]
          logging.info("Finish to get _grads[{}]".format(label))
  
      grads = self._session.run(
          self._grads[label], feed_dict={self._input: scaled_data}
      )
  
      grads = grads[None, ...]
      grads = np.swapaxes(np.array(grads), 0, 1)
  
      return grads.reshape(data.shape)
  
file_path: AdvBox/adversarialbox/models/tensorflow.py
imports: from __future__ import absolute_import
  from builtins import str
  from builtins import range
  import numpy
  import os
  from .base import Model
  import logging
label_desc: Use image node_id 4 for calling the TensorflowModel obj's underlying member method code with example usage: obj.gradient(data, label) and returns: grads