class_docstr: See `tf.keras.losses.CategoricalCrossentropy`.
docstr: Softmax grad reference:
  https://slowbreathing.github.io/articles/2019-05/softmax-and-cross-entropy
docstr_tok: ["Softmax","grad","reference",":","https",":","\/\/slowbreathing.github.io\/articles\/2019-05\/softmax-and-cross-entropy"]
code: def grad(self, y_true, y_pred):
      """
      Softmax grad reference:
      https://slowbreathing.github.io/articles/2019-05/softmax-and-cross-entropy
      """
      batch_size = y_true.shape.as_list()[0]
      batch_size_inv = 1 / batch_size
      if self.from_logits:
          y_pred = tfe.keras.activations.softmax(y_pred)
      grad = y_pred - y_true
      if not self.lazy_normalization:
          grad = grad * batch_size_inv
      return grad
  
imports: import tf_encrypted
label_desc: Use image node_id 2 for calling the CategoricalCrossentropy obj's underlying member method code with example usage: obj.grad(y_true, y_pred) and returns: grad