class_docstr: WMT '17 machine-translation data, via TFDS.
class_docstr_tok: ["WMT","'17","machine-translation","data",",","via","TFDS","."]
code: def __init__(
      self,
      version: str = "de-en",
      reverse: bool = False,
      split: str = "validation",
      max_examples: Optional[int] = None,
  ):
      lang_keys = version.split("-")
      assert len(lang_keys) == 2
      if reverse:
          source_key = lang_keys[1]
          target_key = lang_keys[0]
      else:
          source_key = lang_keys[0]
          target_key = lang_keys[1]
  
      # Pre-load dataset
      ds_name = "wmt17_translate/" + version
      ds = tfds.load(ds_name, download=True, try_gcs=True, split=split)
      ds_np = list(tfds.as_numpy(ds))
      # pylint: disable=g-complex-comprehension
      self._examples = [
          {
              "source": six.ensure_text(d[source_key]),
              "source_language": source_key,
              "target": six.ensure_text(d[target_key]),
              "target_language": target_key,
          }
          for d in ds_np
      ]
      # pylint: enable=g-complex-comprehension
      self._examples = self._examples[: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 WMT17Data object from inherited base classes: lit_dataset with example: obj = WMT17Data(version, reverse, split, max_examples)