class_docstr: Creates a criterion that measures cross-entropy loss between the
  prediction :math:`x` and the target :math:`y`. It is useful when
  training a classification problem with `C` classes.
  
  The prediction `x` is expected to contain raw, unnormalized scores for each class.
  
  The prediction `x` has to be a Tensor of size either :math:`(N, C)` or
  :math:`(N, C, d_1, d_2, ..., d_K)`, where :math:`N` is the size of the minibatch,
  and with :math:`K \geq 1` for the `K`-dimensional case (described later).
  
  This criterion expects a class index in the range :math:`[0, C-1]` as the
  target `y` for each value of a 1D tensor of size `N`.
  
  The loss can be described as:
  
  .. math::
      \text{loss}(x, class) = -\log \left(
      \frac{\exp(x[class])}{\sum_j \exp(x[j])} \right )
      = -x[class] + \log \left (\sum_j \exp(x[j]) \right)
  
  The losses are averaged across observations for each batch
  
  Can also be used for higher dimension inputs, such as 2D images, by providing
  an input of size :math:`(N, C, d_1, d_2, ..., d_K)` with :math:`K \geq 1`,
  where :math:`K` is the number of dimensions, and a target of appropriate shape.
class_docstr_tok: ["Creates","a","criterion","that","measures","cross-entropy","loss","between","the","prediction",":","math",":","`","x","`","and","the","target",":","math",":","`","y","`",".","It","is","useful","when","training","a","classification","problem","with","`","C","`","classes",".","The","prediction","`","x","`","is","expected","to","contain","raw",",","unnormalized","scores","for","each","class",".","The","prediction","`","x","`","has","to","be","a","Tensor","of","size","either",":","math",":","`","(","N",",","C",")","`","or",":","math",":","`","(","N",",","C",",","d_1",",","d_2",",","...",",","d_K",")","`",",","where",":","math",":","`","N","`","is","the","size","of","the","minibatch",",","and","with",":","math",":","`","K","\\geq","1","`","for","the","`","K","`","-dimensional","case","(","described","later",")",".","This","criterion","expects","a","class","index","in","the","range",":","math",":","`","[","0",",","C-1","]","`","as","the","target","`","y","`","for","each","value","of","a","1D","tensor","of","size","`","N","`",".","The","loss","can","be","described","as",":","..","math",":",":","\\text","{","loss","}","(","x",",","class",")","=","-\\log","\\left","(","\\frac","{","\\exp","(","x","[","class","]",")","}","{","\\sum_j","\\exp","(","x","[","j","]",")","}","\\right",")","=","-x","[","class","]","+","\\log","\\left","(","\\sum_j","\\exp","(","x","[","j","]",")","\\right",")","The","losses","are","averaged","across","observations","for","each","batch","Can","also","be","used","for","higher","dimension","inputs",",","such","as","2D","images",",","by","providing","an","input","of","size",":","math",":","`","(","N",",","C",",","d_1",",","d_2",",","...",",","d_K",")","`","with",":","math",":","`","K","\\geq","1","`",",","where",":","math",":","`","K","`","is","the","number","of","dimensions",",","and","a","target","of","appropriate","shape","."]
code: def forward(self, x, y):
      x = x.squeeze()
      y = y.squeeze()
      assert (
          x.size() == y.size()
      ), "input and target must have the same size"
      return x.cross_entropy(y, skip_forward=self.skip_forward)
  
imports: import crypten
  import torch
  from .module import Module
label_desc: Use image node_id 1 for calling the CrossEntropyLoss obj's underlying member method code with example usage: obj.forward(x, y) and returns: x