class_docstr: Helper container which encapsulates standard slot metrics in task oriented learning
  (jga, slot_p, slot_r, etc).
  
  Due to differences in dialogue representations between tasks, the input is pre-
  parsed ground truth and predicted slot dictionaries.
class_docstr_tok: ["Helper","container","which","encapsulates","standard","slot","metrics","in","task","oriented","learning","(","jga",",","slot_p",",","slot_r",",","etc",")",".","Due","to","differences","in","dialogue","representations","between","tasks",",","the","input","is","pre-","parsed","ground","truth","and","predicted","slot","dictionaries","."]
code: def __init__(
      self,
      teacher_slots: Dict[str, str],
      predicted_slots: Dict[str, str],
      prefixes: Optional[List] = None,
      shared: Dict[str, Any] = None,
  ) -> None:
      super().__init__(shared=shared)
      self.prefixes = prefixes if prefixes else []
      self.add_with_prefixes(
          "jga", AverageMetric(teacher_slots == predicted_slots)
      )
      if len(teacher_slots) > 0:
          self.add_with_prefixes(
              "jga_noempty",
              AverageMetric(teacher_slots == predicted_slots),
          )
      else:
          self.add_with_prefixes(
              "jga_empty",
              AverageMetric(teacher_slots == predicted_slots),
          )
  
      # precision
      for pred_slot_name, pred_value in predicted_slots.items():
          slot_p = AverageMetric(
              teacher_slots.get(pred_slot_name) == pred_value
          )
          self.add_with_prefixes("slot_p", slot_p)
          self.add_with_prefixes("slot_f1", SlotF1Metric(slot_p=slot_p))
      # recall
      for teacher_slot_name, teacher_value in teacher_slots.items():
          slot_r = AverageMetric(
              predicted_slots.get(teacher_slot_name) == teacher_value
          )
          self.add_with_prefixes("slot_r", slot_r)
          self.add_with_prefixes("slot_f1", SlotF1Metric(slot_r=slot_r))
  
file_path: ParlAI/parlai/core/tod/teacher_metrics.py
imports: from typing import Optional, List, Dict, Any
  from parlai.core.metrics import AverageMetric, BleuMetric, F1Metric, Metric, Metrics
label_desc: Use image node_id 1 to create a new SlotMetrics object from inherited base classes: Metrics with example: obj = SlotMetrics(teacher_slots, predicted_slots, prefixes, shared)