class_docstr: WMT '14 machine-translation data, via TFDS.
class_docstr_tok: ["WMT","'14","machine-translation","data",",","via","TFDS","."]
docstr: Initializes a Dataset wrapper for the WMT-14 dataset.
  
  More information on the WMT 14 dataset can be found at the links below.
  
  * [WMT 14 website](https://www.statmt.org/wmt14/translation-task.html)
  * [TFDS docs](https://www.tensorflow.org/datasets/catalog/wmt14_translate)
  * [Bojar et al. 2014](https://aclanthology.org/W14-3302/)
  
  Args:
    version: An identifier for the dataset comprising two different [ISO
      639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) language
      codes separated by a `-`. WMT14 supports a limited subset of languages,
      valid versions include `cs-en`, `de-en`, `fr-en`, `hi-en`, and `ru-en`.
    reverse: If true, invert the source and target languages.
    split: The subset of the data to dowload from TFDS.
    filepath: If provided, the dataset will be loaded from disk instead of
      downloaded from TFDS. This is useful for containerized demos where the
      process of downloading and processing the dataset with TFDS can cause
      the container to timeout and restart on a pseudo-inifinite loop.
    max_examples: The maximum number of examples to load in.
  
  Raises:
    ValueError: Invalid version identifier.
docstr_tok: ["Initializes","a","Dataset","wrapper","for","the","WMT-14","dataset",".","More","information","on","the","WMT","14","dataset","can","be","found","at","the","links","below",".","*","[","WMT","14","website","]","(","https",":","\/\/www.statmt.org\/wmt14\/translation-task.html",")","*","[","TFDS","docs","]","(","https",":","\/\/www.tensorflow.org\/datasets\/catalog\/wmt14_translate",")","*","[","Bojar","et","al",".","2014","]","(","https",":","\/\/aclanthology.org\/W14-3302\/",")","Args",":","version",":","An","identifier","for","the","dataset","comprising","two","different","[","ISO","639-1","]","(","https",":","\/\/en.wikipedia.org\/wiki\/List_of_ISO_639-1_codes",")","language","codes","separated","by","a","`","-","`",".","WMT14","supports","a","limited","subset","of","languages",",","valid","versions","include","`","cs-en","`",",","`","de-en","`",",","`","fr-en","`",",","`","hi-en","`",",","and","`","ru-en","`",".","reverse",":","If","true",",","invert","the","source","and","target","languages",".","split",":","The","subset","of","the","data","to","dowload","from","TFDS",".","filepath",":","If","provided",",","the","dataset","will","be","loaded","from","disk","instead","of","downloaded","from","TFDS",".","This","is","useful","for","containerized","demos","where","the","process","of","downloading","and","processing","the","dataset","with","TFDS","can","cause","the","container","to","timeout","and","restart","on","a","pseudo-inifinite","loop",".","max_examples",":","The","maximum","number","of","examples","to","load","in",".","Raises",":","ValueError",":","Invalid","version","identifier","."]
code: def __init__(
      self,
      version: str = "fr-en",
      reverse: bool = False,
      split: str = "validation",
      filepath: Optional[str] = None,
      max_examples: Optional[int] = None,
  ):
      """Initializes a Dataset wrapper for the WMT-14 dataset.
  
      More information on the WMT 14 dataset can be found at the links below.
  
      * [WMT 14 website](https://www.statmt.org/wmt14/translation-task.html)
      * [TFDS docs](https://www.tensorflow.org/datasets/catalog/wmt14_translate)
      * [Bojar et al. 2014](https://aclanthology.org/W14-3302/)
  
      Args:
        version: An identifier for the dataset comprising two different [ISO
          639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) language
          codes separated by a `-`. WMT14 supports a limited subset of languages,
          valid versions include `cs-en`, `de-en`, `fr-en`, `hi-en`, and `ru-en`.
        reverse: If true, invert the source and target languages.
        split: The subset of the data to dowload from TFDS.
        filepath: If provided, the dataset will be loaded from disk instead of
          downloaded from TFDS. This is useful for containerized demos where the
          process of downloading and processing the dataset with TFDS can cause
          the container to timeout and restart on a pseudo-inifinite loop.
        max_examples: The maximum number of examples to load in.
  
      Raises:
        ValueError: Invalid version identifier.
      """
      if version not in _VALID_WMT14_LANG_PAIRS:
          raise ValueError(
              f"Invalid version, {version}. Expected one of "
              f"{str(_VALID_WMT14_LANG_PAIRS)}."
          )
  
      lang_keys = version.split("-")
      if reverse:
          source_key = lang_keys[1]
          target_key = lang_keys[0]
      else:
          source_key = lang_keys[0]
          target_key = lang_keys[1]
  
      # Load dataset
      if filepath:
          self._examples = self._load_datapoints(
              filepath, source_key, target_key
          )
      else:
          ds_name = f"{self.tfds_name}/{version}"
          ds = tfds.load(
              ds_name, download=True, try_gcs=True, split=split
          )
          ds_np = list(tfds.as_numpy(ds))
          self._examples = [
              self._record_to_dict(d, source_key, target_key)
              for d in ds_np
          ][:max_examples]
  
file_path: lit/lit_nlp/examples/datasets/mt.py
imports: from collections.abc import Mapping
  from typing import Any, Optional
  from lit_nlp.api import dataset
  from lit_nlp.api import types
  from lit_nlp.lib import file_cache
  import pandas
  import six
  import tensorflow_datasets
label_desc: Use image node_id 1 to create a new WMT14Data object from inherited base classes: lit_dataset with example: obj = WMT14Data(version, reverse, split, filepath, max_examples)