code: def cross_entropy_with_oh_targets(outputs, targets, reduction="mean"):
      """Calculates cross-entropy with temperature scaling,
      targets can also be soft targets but they must sum to 1"""
      outputs = stable_softmax(outputs)
      ce = -(targets * outputs.log()).sum(1)
      if reduction == "mean":
          ce = ce.mean()
      elif reduction == "none":
          return ce
      else:
          raise NotImplementedError("reduction must be mean or none")
      return ce
  
imports: import copy
  from collections import defaultdict
  from typing import List
  import torch
  import torch.nn.functional
  from avalanche.models import MultiTaskModule, avalanche_forward
label_desc: Use image node_id 2 for calling a global function with example usage: cross_entropy_with_oh_targets(outputs, targets, reduction) and returns: ce, ce