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("taskmaster2_domains", DOMAINS)
      chunks, ontologies = self._load_data(fold, domains)
      domains_cnt = Counter()
      episodes = []
      for _, row in chunks.iterrows():
          domains_cnt[row["domain"]] += 1
          utterances = row["utterances"][:]
  
          idx = 0
          rounds = []
          goal_calls = []
          if (
              len(utterances) > 0
              and utterances[0]["speaker"] == "ASSISTANT"
          ):
              (
                  idx,
                  sys_utt,
                  api_resp,
              ) = self._get_utterance_and_api_call_for_speaker(
                  "ASSISTANT", utterances, idx
              )
              r = tod.TodStructuredRound(
                  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(
                  "ASSISTANT", 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 = (
                      self.process_call_for_cumlative_standalone_api(
                          api_call, cum_api_call
                      )
                  )
                  r = tod.TodStructuredRound(
                      user_utt=user_utt,
                      api_call_machine=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=tod.SerializationHelpers.inner_list_join(
                  row["domain"]
              ),
              api_schemas_machine=self._get_onto_list(
                  ontologies, row["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 os
  import pandas
  from collections import Counter
  from parlai.core.opt import Opt
  import parlai.core.tod.tod_core
  from parlai.utils.misc import warn_once
  import json
  from typing import Optional
  from parlai.utils.data import DatatypeHelper
  from parlai.utils.io import PathManager
  import parlai.tasks.taskmaster2.build
  import parlai.core.tod.tod_agents
label_desc: Use image node_id 7 for calling the Taskmaster2Parser obj's underlying member method code with example usage: obj.setup_episodes(fold) and returns: episodes