class_docstr: OneCommon teacher that loads the data from https://github.com/Alab-NII/Reference-
  Resolution.
class_docstr_tok: ["OneCommon","teacher","that","loads","the","data","from","https",":","\/\/github.com\/Alab-NII\/Reference-","Resolution","."]
code: def observe(self, observation):
      if "metrics" not in observation:
          observation["metrics"] = {}
  
      # Selection accuracy
      if (
          "output" in observation
          and observation["output"] is not None
          and "output" in self.expected
          and self.expected["output"] is not None
      ):
          obs_out = int(observation["output"])
          exp_out = int(self.expected["output"])
          observation["metrics"]["target_sel_accuracy"] = float(
              obs_out == exp_out
          )
  
      # Reference accuracy
      if (
          "referents" in observation
          and observation["referents"] is not None
          and len(observation["referents"]) > 0
          and "referents" in self.expected
          and self.expected["referents"] is not None
          and len(self.expected["referents"]) > 0
      ):
          obs_refs = observation["referents"]
          exp_refs = self.expected["referents"]
          assert len(obs_refs) == len(exp_refs)
  
          exact_match = 0.0
          equal_cnt = total_cnt = 0.0
          for obs_ref, exp_ref in zip(obs_refs, exp_refs):
              for obs_tgt, exp_tgt in zip(
                  obs_ref["target"], exp_ref["target"]
              ):
                  # Expected sorted referents
                  equal_cnt += float(int(obs_tgt) == int(exp_tgt))
                  total_cnt += 1.0
              if equal_cnt == total_cnt:
                  exact_match += 1.0
  
          observation["metrics"][
              "referent_exact_match"
          ] = exact_match / len(exp_refs)
          observation["metrics"]["referent_accuracy"] = (
              equal_cnt / total_cnt
          )
  
      return super().observe(observation)
  
file_path: ParlAI/parlai/tasks/onecommon/agents.py
imports: from parlai.core.teachers import FixedDialogTeacher
  from parlai.utils.io import PathManager
  from .build import build
  import os
label_desc: Use image node_id 6 for calling the OneCommonTeacher obj's underlying member method code with example usage: obj.observe(observation) and returns: super