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.
      """
      chunks, api_schema_raw = self._load_data(fold)
      api_schemas_machine = self._parse_to_api_schema(api_schema_raw)
      episodes = []
      for _, row in chunks.iterrows():
          utterances = row["utterances"][:]
          idx = 0
          rounds = []
          goal_calls = []
          if (
              len(utterances) > 0
              and utterances[0]["speaker"] == "assistant"
          ):
              (
                  idx,
                  sys_utt,
                  api_call,
                  api_resp,
              ) = self._get_utterance_and_apis_for_speaker(
                  "assistant", utterances, idx
              )
  
              turns = self._get_turns_from_parsed(
                  SILENCE_TOKEN, api_call, api_resp, sys_utt
              )
              for t in turns:
                  rounds.append(t)
  
          while idx < len(utterances):
              (
                  idx,
                  user_utt,
                  calls_user,
                  responses_user,
              ) = self._get_utterance_and_apis_for_speaker(
                  "user", utterances, idx
              )
              (
                  idx,
                  sys_utt,
                  calls_system,
                  responses_system,
              ) = self._get_utterance_and_apis_for_speaker(
                  "assistant", utterances, idx
              )
              api_calls = calls_user + calls_system
              api_resps = responses_user + responses_system
              goal_calls += api_calls
              turns = self._get_turns_from_parsed(
                  user_utt, api_calls, api_resps, sys_utt
              )
              for t in turns:
                  rounds.append(t)
  
          episode = tod.TodStructuredEpisode(
              api_schemas_machine=api_schemas_machine,
              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 parlai.core.opt import Opt
  import parlai.core.tod.tod_core
  import json
  from typing import Optional
  from parlai.utils.data import DatatypeHelper
  from parlai.utils.io import PathManager
  import parlai.tasks.taskmaster3.build
  import parlai.core.tod.tod_agents
label_desc: Use image node_id 8 for calling the Taskmaster3Parser obj's underlying member method code with example usage: obj.setup_episodes(fold) and returns: episodes