docstr: We know d(-log(p[i])/dlogit[k] = -id_mat[i,k] + p[k]
  so we initialize the gradient as neg_logprobs, so we can just exponentiate
  to get p[k], which is most of what we need...  neg_logprobs will be
  modified in place to become the gradient we want
docstr_tok: ["We","know","d","(","-log","(","p","[","i","]",")","\/dlogit","[","k","]","=","-id_mat","[","i",",","k","]","+","p","[","k","]","so","we","initialize","the","gradient","as","neg_logprobs",",","so","we","can","just","exponentiate","to","get","p","[","k","]",",","which","is","most","of","what","we","need","...","neg_logprobs","will","be","modified","in","place","to","become","the","gradient","we","want"]
code: def backward(cls, ctx, dneg_logprobs):
      """We know d(-log(p[i])/dlogit[k] = -id_mat[i,k] + p[k]
      so we initialize the gradient as neg_logprobs, so we can just exponentiate
      to get p[k], which is most of what we need...  neg_logprobs will be
      modified in place to become the gradient we want
      """
      # load saved tensors
      neg_logprobs, indices = ctx.saved_tensors
      # run the kernel
      # neg_logprobs will be modified in place to become our gradient:
      n_cols = neg_logprobs.shape[-1]
      grid = lambda opt: (neg_logprobs.numel() // n_cols,)
      _backward[grid](neg_logprobs, indices, dneg_logprobs, n_cols)
      return neg_logprobs, None
  
file_path: triton/python/triton/ops/cross_entropy.py
imports: import torch
  from ..None import heuristics, jit
  from ..None import language
  from ..None import next_power_of_2
label_desc: Use image node_id 2 for calling the _cross_entropy obj's underlying member method code with example usage: obj.backward(cls, ctx, dneg_logprobs) and returns: neg_logprobs,  None