class_docstr: Abstract data loader.
class_docstr_tok: ["Abstract","data","loader","."]
docstr: Parses into TodStructuredEpisode.
docstr_tok: ["Parses","into","TodStructuredEpisode","."]
code: def setup_episodes(self, fold):
      """
      Parses into TodStructuredEpisode.
      """
      domains = self.opt.get("msre2e_domains", DOMAINS)
      chunks = self._load_data(fold, domains)
      domains_cnt = Counter()
      episodes = []
      for utterances in chunks:
          if len(utterances) < 1:
              continue
          domain = utterances[0]["domain"]
          domains_cnt[domain] += 1
          idx = 0
          rounds = []
          goal_calls = []
          if (
              len(utterances) > 0
              and utterances[0]["speaker"] == "agent"
          ):
              (
                  idx,
                  sys_utt,
                  api_resp,
              ) = self._get_utterance_and_api_call_for_speaker(
                  "agent", utterances, idx
              )
              r = tod.TodStructuredRound(
                  user_utt=tod.CONST_SILENCE,
                  api_resp_machine=api_resp,
                  sys_utt=sys_utt,
              )
              rounds.append(r)
  
          cum_api_call = {}
          while idx < len(utterances):
              (
                  idx,
                  user_utt,
                  api_call,
              ) = self._get_utterance_and_api_call_for_speaker(
                  "user", utterances, idx
              )
              (
                  idx,
                  sys_utt,
                  api_resp,
              ) = self._get_utterance_and_api_call_for_speaker(
                  "agent", utterances, idx
              )
              if not self.opt["use_cumulative_api_calls"]:
                  r = tod.TodStructuredRound(
                      user_utt=user_utt,
                      api_call_machine=api_call,
                      api_resp_machine=api_resp,
                      sys_utt=sys_utt,
                  )
              else:
                  cum_api_call.update(api_call)
                  r = tod.TodStructuredRound(
                      user_utt=user_utt,
                      api_call_machine=copy.deepcopy(cum_api_call)
                      if len(api_resp) > 0
                      else {},
                      api_resp_machine=api_resp
                      if len(api_resp) > 0
                      else {},
                      sys_utt=sys_utt,
                  )
  
              rounds.append(r)
              if len(api_call) > 0:
                  goal_calls.append(api_call)
  
          episode = tod.TodStructuredEpisode(
              domain=domain,
              api_schemas_machine=SLOT_NAMES[domain],
              goal_calls_machine=goal_calls,
              rounds=rounds,
              delex=self.opt.get("delex", False),
          )
          episodes.append(episode)
      return episodes
  
imports: from parlai.core.params import ParlaiParser
  import copy
  import os
  import csv
  from collections import Counter
  from parlai.core.opt import Opt
  import parlai.core.tod.tod_core
  from parlai.utils.misc import warn_once
  from typing import Optional
  from parlai.utils.data import DatatypeHelper
  from parlai.utils.io import PathManager
  import parlai.tasks.msr_e2e.build
  import parlai.core.tod.tod_agents
label_desc: Use image node_id 6 for calling the MsrE2EParser obj's underlying member method code with example usage: obj.setup_episodes(fold) and returns: episodes