class_docstr: Extension of fairseq.data.LanguagePairDataset where each example
  has a score from a ensemble of teacher models.
class_docstr_tok: ["Extension","of","fairseq.data.LanguagePairDataset","where","each","example","has","a","score","from","a","ensemble","of","teacher","models","."]
docstr: Args:
      task: The task for which the teacher models are expected to make
          prediction.
      teacher_models: A list of preloaded teacher models.
      top_k_teacher_tokens: The number of top word-level prediction that
          want to save from the teacher predictions.
      top_k_teacher_scores: A dictionary for memoization that is passed
          between the dataset and PytorchKnowledgeDistillationTask.
      top_k_teacher_scores:  A  dictionary for memoization indices of scores;
          similar to the previous argument, it is passed between the dataset
          and PytorchKnowledgeDistillationTask.
docstr_tok: ["Args",":","task",":","The","task","for","which","the","teacher","models","are","expected","to","make","prediction",".","teacher_models",":","A","list","of","preloaded","teacher","models",".","top_k_teacher_tokens",":","The","number","of","top","word-level","prediction","that","want","to","save","from","the","teacher","predictions",".","top_k_teacher_scores",":","A","dictionary","for","memoization","that","is","passed","between","the","dataset","and","PytorchKnowledgeDistillationTask",".","top_k_teacher_scores",":","A","dictionary","for","memoization","indices","of","scores",";","similar","to","the","previous","argument",",","it","is","passed","between","the","dataset","and","PytorchKnowledgeDistillationTask","."]
code: def __init__(
      self,
      src,
      src_sizes,
      src_dict,
      tgt=None,
      tgt_sizes=None,
      tgt_dict=None,
      top_k_probs_binary_file: Optional[str] = None,
      teacher_models: List[Any] = None,
      top_k_teacher_scores: Dict[int, np.ndarray] = None,
      top_k_teacher_indices: Dict[int, np.ndarray] = None,
      top_k_teacher_tokens=8,
      **kwargs,
  ):
      """
      Args:
          task: The task for which the teacher models are expected to make
              prediction.
          teacher_models: A list of preloaded teacher models.
          top_k_teacher_tokens: The number of top word-level prediction that
              want to save from the teacher predictions.
          top_k_teacher_scores: A dictionary for memoization that is passed
              between the dataset and PytorchKnowledgeDistillationTask.
          top_k_teacher_scores:  A  dictionary for memoization indices of scores;
              similar to the previous argument, it is passed between the dataset
              and PytorchKnowledgeDistillationTask.
      """
      super().__init__(
          src, src_sizes, src_dict, tgt, tgt_sizes, tgt_dict, **kwargs
      )
      self.src_dict = src_dict
  
      self.top_k_probs_binary_file = top_k_probs_binary_file
      self.teacher_models = teacher_models
      self.top_k_teacher_tokens = top_k_teacher_tokens
      self.top_k_teacher_scores = top_k_teacher_scores
      self.top_k_teacher_indices = top_k_teacher_indices
  
      self.all_sen_ids_memoized = False
  
      if self.top_k_probs_binary_file is not None:
          npz = np.load(self.top_k_probs_binary_file)
          flat_scores = npz["top_k_scores"]
          flat_indices = npz["top_k_indices"]
  
          offset = 0
          for i, length in enumerate(tgt_sizes):
              scores = flat_scores[offset : offset + length, :]
              indices = flat_indices[offset : offset + length, :]
              offset += length
              self.top_k_teacher_scores[i] = torch.Tensor(scores)
              self.top_k_teacher_indices[i] = torch.LongTensor(indices)
  
file_path: translate/pytorch_translate/research/knowledge_distillation/teacher_score_data.py
imports: import math
  from typing import Any, Dict, List, Optional
  import numpy
  import torch
  import torch.nn.functional
  from fairseq import data, utils
  from pytorch_translate import utils
label_desc: Use image node_id 1 to create a new TeacherDataset object from inherited base classes: data.language_pair_dataset with example: obj = TeacherDataset(src, src_sizes, src_dict, tgt, tgt_sizes, tgt_dict, top_k_probs_binary_file, teacher_models, top_k_teacher_scores, top_k_teacher_indices, top_k_teacher_tokens)