class_docstr: This version of opensubtitles creates all possible dialog examples.
class_docstr_tok: ["This","version","of","opensubtitles","creates","all","possible","dialog","examples","."]
code: def setup_data(self, path):
      def rebuild(entries):
          if len(entries) == 0:
              return []
          # flip the first example
          flipped = [(SILENCE_TOKEN, [entries[0][0]], 0)]
          # flip the rest
          flipped += [
              (entries[i][1][0], [entries[i + 1][0]], 0)
              for i in range(len(entries) - 1)
          ]
          return flipped
  
      # this shows conversations in both directions
      # we skip examples for which no label is present
      alternate = []
      for entry, new in super().setup_data(path):
          if new:
              for i, e in enumerate(rebuild(alternate)):
                  if e[1]:
                      yield e, i == 0
              alternate.clear()
          else:
              alternate.append(entry)
          if entry[1]:
              yield entry, new
  
      # flip the last episode
      if alternate:
          for i, e in enumerate(rebuild(alternate)):
              if e[1]:
                  yield e, i == 0
          alternate.clear()
  
imports: from parlai.core.teachers import FbDeprecatedDialogTeacher
  from .build_2009 import build
  from .build_2018 import build
  import copy
  import os
label_desc: Use image node_id 2 for calling the FullTeacher obj's underlying member method code with example usage: obj.setup_data(path) and returns: flipped, list