code: def load_data(
      stage: str = "train",
      task: str = "classification",
      target_label: str = "PerfectMatch",
      return_classes: bool = False,
      match_type: str = "question",
      mode: str = "both",
  ) -> typing.Union[matchzoo.DataPack, tuple]:
      """
      Load CQA-QL-16 data.
  
      :param stage: One of `train`, `dev`, and `test`.
          (default: `train`)
      :param task: Could be one of `ranking`, `classification` or instance
          of :class:`matchzoo.engine.BaseTask`. (default: `classification`)
      :param target_label: If `ranking`, choose one of classification
          label as the positive label. (default: `PerfectMatch`)
      :param return_classes: `True` to return classes for classification
          task, `False` otherwise.
      :param match_type: Matching text types. One of `question`,
          `answer`, and `external_answer`. (default: `question`)
      :param mode: Train data use method. One of `part1`, `part2`,
          and `both`. (default: `both`)
  
      :return: A DataPack unless `task` is `classification` and `return_classes`
          is `True`: a tuple of `(DataPack, classes)` in that case.
      """
      if stage not in ("train", "dev", "test"):
          raise ValueError(
              f"{stage} is not a valid stage."
              f"Must be one of `train`, `dev`, and `test`."
          )
  
      if match_type not in ("question", "answer", "external_answer"):
          raise ValueError(
              f"{match_type} is not a valid method. Must be one of"
              f" `question`, `answer`, `external_answer`."
          )
  
      if mode not in ("part1", "part2", "both"):
          raise ValueError(
              f"{mode} is not a valid method."
              f"Must be one of `part1`, `part2`, `both`."
          )
  
      data_root = _download_data(stage)
      data_pack = _read_data(data_root, stage, match_type, mode)
  
      if task == "ranking":
          if match_type in (
              "anwer",
              "external_answer",
          ) and target_label not in [
              "Good",
              "PotentiallyUseful",
              "Bad",
          ]:
              raise ValueError(
                  f"{target_label} is not a valid target label."
                  f"Must be one of `Good`, `PotentiallyUseful`,"
                  f" `Bad`."
              )
          elif match_type == "question" and target_label not in [
              "PerfectMatch",
              "Relevant",
              "Irrelevant",
          ]:
              raise ValueError(
                  f"{target_label} is not a valid target label."
                  f" Must be one of `PerfectMatch`, `Relevant`,"
                  f" `Irrelevant`."
              )
          binary = (data_pack.relation["label"] == target_label).astype(
              float
          )
          data_pack.relation["label"] = binary
          return data_pack
      elif task == "classification":
          if match_type in ("answer", "external_answer"):
              classes = ["Good", "PotentiallyUseful", "Bad"]
          else:
              classes = ["PerfectMatch", "Relevant", "Irrelevant"]
          label = data_pack.relation["label"].apply(classes.index)
          data_pack.relation["label"] = label
          data_pack.one_hot_encode_label(num_classes=3, inplace=True)
          if return_classes:
              return data_pack, classes
          else:
              return data_pack
      else:
          raise ValueError(
              f"{task} is not a valid task."
              f"Must be one of `Ranking` and `Classification`."
          )
  
file_path: MatchZoo/matchzoo/datasets/cqa_ql_16/load_data.py
imports: import xml
  import typing
  from pathlib import Path
  import keras
  import pandas
  import matchzoo
label_desc: Use image node_id 1 for calling a global function with example usage: load_data(stage, task, target_label, return_classes, match_type, mode) and returns: data_pack, data_pack,  classes, data_pack