code: def generate_folds(dpath):
      """
      Generate Data Folds based on the scene id.
      """
      datafile = os.path.join(dpath, "friends-corpus/utterances.jsonl")
      train_datafile = os.path.join(dpath, "train.jsonl")
      valid_datafile = os.path.join(dpath, "valid.jsonl")
      test_datafile = os.path.join(dpath, "test.jsonl")
  
      # Load the dataset
      conversations = defaultdict(list)
      with jsonlines.open(datafile) as reader:
          for utterance in reader:
              text = utterance["text"]
              speaker = utterance["speaker"]
              conversation_id = utterance["conversation_id"]
  
              if speaker != "TRANSCRIPT_NOTE":
                  conversations[conversation_id].append(
                      {
                          "text": text,
                          "speaker": speaker,
                          "conversation_id": conversation_id,
                      }
                  )
  
      # Split the dataset into 80% train, 10% valid, 10% test
      train, valid_and_test = train_test_split(
          list(conversations.keys()),
          test_size=0.2,
          random_state=RANDOM_SEED,
      )
      valid, test = train_test_split(
          valid_and_test, test_size=0.5, random_state=RANDOM_SEED
      )
  
      # Save the data folds into separate files
      with jsonlines.open(train_datafile, mode="w") as writer:
          for conversation_id in train:
              for utterance in conversations[conversation_id]:
                  writer.write(utterance)
  
      with jsonlines.open(valid_datafile, mode="w") as writer:
          for conversation_id in valid:
              for utterance in conversations[conversation_id]:
                  writer.write(utterance)
  
      with jsonlines.open(test_datafile, mode="w") as writer:
          for conversation_id in test:
              for utterance in conversations[conversation_id]:
                  writer.write(utterance)
  
imports: import parlai.core.build_data
  from parlai.core.build_data import DownloadableFile
  import os
  import jsonlines
  from collections import defaultdict
  from sklearn.model_selection import train_test_split
label_desc: Use image node_id 1 for calling a global function with example usage: generate_folds(dpath) without return types