class_docstr: Base Teacher that extract metadata for dialogues.
class_docstr_tok: ["Base","Teacher","that","extract","metadata","for","dialogues","."]
docstr: Process observation for metrics.
code: def observe(self, observation):
      """
      Process observation for metrics.
      """
      obs = super().observe(observation)
      if self.last_act is None:
          return obs
      has_update = False
      if (
          self.metrics_per_feedback is not None
          and self.last_act.get("last_nonperfect_feedback", None)
          is not None
      ):
          for key, value in observation["metrics"].items():
              if (
                  self.metrics_per_feedback == "all"
                  or key in self.metrics_per_feedback
              ):
                  self.metrics.add(
                      f"{self.last_act['last_nonperfect_feedback']}_{key}",
                      value,
                  )
                  has_update = True
  
      if has_update:
          updated_recent_metrics = self.metrics.report_recent()
          if updated_recent_metrics and "metrics" in obs:
              obs.pop("metrics")
              obs["metrics"] = updated_recent_metrics
      return obs
  
imports: import os
  import copy
  import json
  import random
  from typing import Optional
  from parlai.utils.misc import warn_once
  from parlai.utils.data import DatatypeHelper
  from parlai.core.opt import Opt
  from parlai.core.teachers import DialogTeacher
  from parlai.core.params import ParlaiParser
  from parlai.core.message import Message
  from parlai.utils.io import PathManager
  from parlai.tasks.wizard_of_internet import constants
  from .mutators import normalize_reply, get_knowledge_appended_context, get_knowledge_sentence_with_special_tokens_only
  from .build import build
  from .constants import FeedbackType, TITLE_PASSAGE_DELIMITER, OK_LABEL, NOT_OK_LABEL
label_desc: Use image node_id 7 for calling the FitsBaseTeacher obj's underlying member method code with example usage: obj.observe(observation) and returns: obs, obs