class_docstr: CMU Document Grounded Conversations Dataset (aka CMU_DoG)
  
  Paper: https://arxiv.org/pdf/1809.07358.pdf
  Source: https://github.com/festvox/datasets-CMU_DoG
class_docstr_tok: ["CMU","Document","Grounded","Conversations","Dataset","(","aka","CMU_DoG",")","Paper",":","https",":","\/\/arxiv.org\/pdf\/1809.07358.pdf","Source",":","https",":","\/\/github.com\/festvox\/datasets-CMU_DoG"]
code: def setup_data(self, datafile: str):
      datapath = _datapath(self.opt)
      with PathManager.open(
          os.path.join(datapath, f"conversations/{datafile}")
      ) as f:
          data = json.load(f)
      with PathManager.open(
          os.path.join(datapath, "wiki_data.json")
      ) as f:
          wiki_data = json.load(f)
  
      # Filter by rating
      data = {
          k: c
          for k, c in data.items()
          if c["rating"] in self.opt["cmu_dog_rating"]
      }
  
      def _can_see_info(turn, convo):
          # Sometimes only one participant has access to the article
          return turn["uid"] in convo["whoSawDoc"]
  
      num_eps = len(data)
      data = list(data.items())
      # loop through conversations
      for i in range(len(data) * 2):
          conv_idx = i % num_eps
          start_idx = i // num_eps
  
          _conv_id, conv_data = data[conv_idx]
  
          dialog = _collapse_multi_msgs(
              conv_data["history"],
              self.opt["cmu_dog_multi_msg_delimiter"],
          )
          movie_article = wiki_data[str(conv_data["wikiDocumentIdx"])]
  
          if self.opt[
              "cmu_dog_only_with_knowledge"
          ] and not _can_see_info(dialog[start_idx], conv_data):
              continue
  
          # loop through turns
          for idx in range(start_idx, len(dialog), 2):
              label_turn = dialog[idx]
              label = label_turn["text"].strip()
  
              # The section displayed changes across the conversation
              doc_idx = str(label_turn["docIdx"])
              gold_knowledge = _article_section_to_text(
                  movie_article[doc_idx],
                  self.opt["cmu_dog_fact_delimiter"],
              )
              section = (
                  movie_article[doc_idx]
                  if _can_see_info(label_turn, conv_data)
                  else None
              )
              section_text = _article_section_to_text(
                  section,
                  self.opt["cmu_dog_fact_delimiter"],
                  self.opt.get("cmu_dog_include_knowledge_keys").split(
                      ","
                  ),
              )
  
              # By default, start conversation with silence
              if idx == start_idx:
                  context = (
                      section_text
                      if self.opt["cmu_dog_provide_movie_context"]
                      else SILENCE
                  )
              else:
                  context = dialog[idx - 1]["text"].strip()
  
              yield Message(
                  {
                      "text": context,
                      "labels": [label],
                      "available_knowledge_raw": section,
                      "available_knowledge_text": section_text,
                      "title": movie_article["0"]["movieName"],
                      "checked_sentence": gold_knowledge,
                  }
              ), idx == start_idx
  
imports: import copy
  import json
  import os
  from enum import Enum
  from typing import List, Optional, Tuple
  from parlai.core.message import Message
  from parlai.core.metrics import F1Metric
  from parlai.core.mutators import EpisodeMutator, MessageMutator, register_mutator
  from parlai.core.opt import Opt
  from parlai.core.params import ParlaiParser
  from parlai.core.teachers import DialogTeacher
  from parlai.tasks.cmu_dog.build import build
  from parlai.tasks.wizard_of_wikipedia.agents import RareWordF1Calculator, TOKEN_KNOWLEDGE, TOKEN_END_KNOWLEDGE
  from parlai.utils.data import DatatypeHelper
  from parlai.utils.io import PathManager
  from parlai.utils.logging import logger
  from parlai.utils.typing import TShared
label_desc: Use image node_id 4 for calling the CMUDocumentGroundedConversationsTeacher obj's underlying member method code with example usage: obj.setup_data(datafile) and returns: unknown