code: def build(opt):
      dpath = os.path.join(opt["datapath"], "TriviaQA")
      version = "4"  # build changes, not upstream changes
  
      if not build_data.built(dpath, version_string=version):
          print("[building data: " + dpath + "]")
          if build_data.built(dpath):
              # An older version exists, so remove these outdated files.
              build_data.remove_dir(dpath)
          build_data.make_dir(dpath)
  
          # Download the data.
          for downloadable_file in RESOURCES:
              downloadable_file.download_file(dpath)
  
          # Make *-union-noevidence-*.json
          for section in [
              "verified-{}-dev.json",
              "{}-train.json",
              "{}-dev.json",
          ]:
              section = os.path.join(dpath, "qa", section)
              q2as = {}
              with PathManager.open(section.format("web")) as data_file:
                  for datapoint in json.load(data_file)["Data"]:
                      question = datapoint["Question"]
                      answers = datapoint["Answer"]["Aliases"]
                      prime_answer = datapoint["Answer"]["Value"]
                      assert question not in q2as
                      q2as[question] = (prime_answer, answers)
              with PathManager.open(
                  section.format("wikipedia")
              ) as data_file:
                  for datapoint in json.load(data_file)["Data"]:
                      question = datapoint["Question"]
                      answers = datapoint["Answer"]["Aliases"]
                      prime_answer = datapoint["Answer"]["Value"]
                      if question not in q2as:
                          q2as[question] = (prime_answer, answers)
                      else:
                          old_prime_answer, old_answers = q2as[question]
                          if old_prime_answer != prime_answer:
                              assert (
                                  old_prime_answer,
                                  prime_answer,
                              ) == (
                                  "Tony (Manero).",
                                  "Tony",
                              )
                          q2as[question] = (
                              old_prime_answer,
                              old_answers + answers,
                          )
              with PathManager.open(
                  section.format("noevidence-union"), "wt"
              ) as data_file:
                  json.dump(
                      {
                          "Data": [
                              {
                                  "Question": question,
                                  "Answer": {
                                      "Value": prime_answer,
                                      "Aliases": sorted(
                                          list(
                                              set(
                                                  a.replace(
                                                      " (disambiguation)",
                                                      "",
                                                  )
                                                  for a in answers
                                              )
                                          )
                                      ),
                                  },
                              }
                              for question, (
                                  prime_answer,
                                  answers,
                              ) in q2as.items()
                          ]
                      },
                      data_file,
                  )
  
          # Mark the data as built.
          build_data.mark_done(dpath, version_string=version)
  
imports: import parlai.core.build_data
  import json
  import os
  from parlai.core.build_data import DownloadableFile
  from parlai.utils.io import PathManager
label_desc: Use image node_id 1 for calling a global function with example usage: build(opt) without return types