docstr: Creates a DataPairCorpus for the Multi-Genre Natural Language Inference Corpus (MNLI) from GLUE benchmark.
  
  see https://gluebenchmark.com/tasks
  Entailment annotations are: entailment, contradiction, neutral.
  This corpus includes two dev sets mathced/mismatched and two unlabeled test sets: eval_dataset_matched,
  eval_dataset_mismatched.
docstr_tok: ["Creates","a","DataPairCorpus","for","the","Multi-Genre","Natural","Language","Inference","Corpus","(","MNLI",")","from","GLUE","benchmark",".","see","https",":","\/\/gluebenchmark.com\/tasks","Entailment","annotations","are",":","entailment",",","contradiction",",","neutral",".","This","corpus","includes","two","dev","sets","mathced\/mismatched","and","two","unlabeled","test","sets",":","eval_dataset_matched",",","eval_dataset_mismatched","."]
code: def __init__(
      self,
      label_type="entailment",
      evaluate_on_matched: bool = True,
      base_path: Optional[Union[str, Path]] = None,
      max_tokens_per_doc=-1,
      max_chars_per_doc=-1,
      use_tokenizer=True,
      in_memory: bool = True,
      sample_missing_splits: bool = True,
  ) -> None:
      """Creates a DataPairCorpus for the Multi-Genre Natural Language Inference Corpus (MNLI) from GLUE benchmark.
  
      see https://gluebenchmark.com/tasks
      Entailment annotations are: entailment, contradiction, neutral.
      This corpus includes two dev sets mathced/mismatched and two unlabeled test sets: eval_dataset_matched,
      eval_dataset_mismatched.
      """
      base_path = (
          flair.cache_root / "datasets"
          if not base_path
          else Path(base_path)
      )
  
      dataset_name = "glue"
  
      data_folder = base_path / dataset_name
  
      data_file = data_folder / "MNLI/train.tsv"
  
      # if data is not downloaded yet, download it
      if not data_file.is_file():
          # get the zip file
          zipped_data_path = cached_path(
              "https://dl.fbaipublicfiles.com/glue/data/MNLI.zip",
              Path("datasets") / dataset_name,
          )
  
          unpack_file(
              zipped_data_path, data_folder, mode="zip", keep=False
          )
  
          # reorder dev datasets to have same columns as in train set: 8, 9, and 11
          # dev sets include 5 different annotations but we will only keep the gold label
          for dev_filename in ["dev_matched.tsv", "dev_mismatched.tsv"]:
              temp_file = str("temp_" + dev_filename)
              os.rename(
                  str(data_folder / "MNLI" / dev_filename),
                  str(data_folder / "MNLI" / temp_file),
              )
  
              with open(
                  data_folder / "MNLI" / dev_filename,
                  "a",
                  encoding="utf-8",
              ) as out_file, open(
                  data_folder / "MNLI" / temp_file, encoding="utf-8"
              ) as in_file:
                  for line in in_file:
                      fields = line.split("\t")
                      reordered_columns = "\t".join(
                          fields[column_id] for column_id in range(11)
                      )
                      reordered_columns += "\t" + fields[15]
                      out_file.write(reordered_columns)
              os.remove(str(data_folder / "MNLI" / temp_file))
  
          # rename test file to eval_dataset, since it has no labels
          os.rename(
              str(data_folder / "MNLI/test_matched.tsv"),
              str(data_folder / "MNLI/eval_dataset_matched.tsv"),
          )
          os.rename(
              str(data_folder / "MNLI/test_mismatched.tsv"),
              str(data_folder / "MNLI/eval_dataset_mismatched.tsv"),
          )
  
      matched_suffix = (
          "matched" if evaluate_on_matched else "mismatched"
      )
  
      dev_dataset = "dev_" + matched_suffix + ".tsv"
      eval_dataset = "eval_dataset_" + matched_suffix + ".tsv"
  
      self.evaluate_on_matched = evaluate_on_matched
  
      super().__init__(
          data_folder / "MNLI",
          train_file=data_file,
          dev_file=dev_dataset,
          label_type=label_type,
          columns=[8, 9, 11],
          skip_first_line=True,
          use_tokenizer=use_tokenizer,
          max_tokens_per_doc=max_tokens_per_doc,
          max_chars_per_doc=max_chars_per_doc,
          in_memory=in_memory,
          sample_missing_splits=sample_missing_splits,
      )
  
      self.eval_dataset = DataPairDataset(
          data_folder / "MNLI" / eval_dataset,
          label_type=label_type,
          columns=[8, 9, 11],
          use_tokenizer=use_tokenizer,
          max_tokens_per_doc=max_tokens_per_doc,
          max_chars_per_doc=max_chars_per_doc,
          in_memory=in_memory,
          skip_first_line=True,
          label=False,
      )
  
imports: import logging
  import os
  from pathlib import Path
  from typing import List, Optional, Union
  import flair
  from flair.data import Corpus, DataPair, FlairDataset, Sentence, TextPair, _iter_dataset
  from flair.datasets.base import find_train_dev_test_files
  from flair.file_utils import cached_path, unpack_file, unzip_file
label_desc: Use image node_id 1 to create a new GLUE_MNLI object from inherited base classes: DataPairCorpus with example: obj = GLUE_MNLI(label_type, evaluate_on_matched, base_path, max_tokens_per_doc, max_chars_per_doc, use_tokenizer, in_memory, sample_missing_splits)