docstr: This code is for word-level knowledge distillation. Most of the algorithm
  is inspired from the Kim and Rush (2016) paper:
  http://www.aclweb.org/anthology/D16-1139
docstr_tok: ["This","code","is","for","word-level","knowledge","distillation",".","Most","of","the","algorithm","is","inspired","from","the","Kim","and","Rush","(","2016",")","paper",":","http",":","\/\/www.aclweb.org\/anthology\/D16-1139"]
code: def __init__(self, args, task):
      """
      This code is for word-level knowledge distillation. Most of the algorithm
      is inspired from the Kim and Rush (2016) paper:
      http://www.aclweb.org/anthology/D16-1139
      """
      super().__init__(args, task)
      self.kd_weight = getattr(args, "kd_weight", 0)
      if self.kd_weight < 0 or self.kd_weight > 1:
          raise ValueError(
              f"--kd-weight ({self.kd_weight}) must be in [0, 1]"
          )
  
file_path: translate/pytorch_translate/research/knowledge_distillation/knowledge_distillation_loss.py
imports: import math
  import torch
  import torch.nn.functional
  from fairseq import utils
  from fairseq.criterions import LegacyFairseqCriterion, register_criterion
  from pytorch_translate import utils
label_desc: Use image node_id 1 to create a new KnowledgeDistillationCriterion object from inherited base classes: LegacyFairseqCriterion with example: obj = KnowledgeDistillationCriterion(args, task)