code: def forward(self, input, target):
          
  
          n, k = input.shape
          losses = input.new_zeros(n)
  
          for i in range(k):
              cls_idx = input.new_full((n,), i, dtype=torch.long)
              loss = F.cross_entropy(input, cls_idx, reduction="none")
              if self.weight is not None:
                  loss = loss * self.weight[i]
              losses += target[:, i].float() * loss
  
          if self.reduction == "mean":
              losses = losses.mean()
          elif self.reduction == "sum":
              losses = losses.sum()
          elif self.reduction != "none":
              raise ValueError(f"Unrecognized reduction: {self.reduction}")
  
          return losses
docs: Calculate the loss
  
          :param input: prediction logits
          :param target: target probabilities
          :return: loss