docstr: Instantiates a Parallel Corpus from OPUS.
  
  see http://opus.nlpl.eu/
  :param dataset: Name of the dataset (one of "tatoeba")
  :param l1: Language code of first language in pair ("en", "de", etc.)
  :param l2: Language code of second language in pair ("en", "de", etc.)
  :param use_tokenizer: Whether or not to use in-built tokenizer
  :param max_tokens_per_doc: If set, shortens sentences to this maximum number of tokens
  :param max_chars_per_doc: If set, shortens sentences to this maximum number of characters
  :param in_memory: If True, keeps dataset fully in memory
docstr_tok: ["Instantiates","a","Parallel","Corpus","from","OPUS",".","see","http",":","\/\/opus.nlpl.eu\/",":","param","dataset",":","Name","of","the","dataset","(","one","of","``","tatoeba","''",")",":","param","l1",":","Language","code","of","first","language","in","pair","(","``","en","''",",","``","de","''",",","etc",".",")",":","param","l2",":","Language","code","of","second","language","in","pair","(","``","en","''",",","``","de","''",",","etc",".",")",":","param","use_tokenizer",":","Whether","or","not","to","use","in-built","tokenizer",":","param","max_tokens_per_doc",":","If","set",",","shortens","sentences","to","this","maximum","number","of","tokens",":","param","max_chars_per_doc",":","If","set",",","shortens","sentences","to","this","maximum","number","of","characters",":","param","in_memory",":","If","True",",","keeps","dataset","fully","in","memory"]
code: def __init__(
      self,
      dataset: str,
      l1: str,
      l2: str,
      use_tokenizer: bool = True,
      max_tokens_per_doc=-1,
      max_chars_per_doc=-1,
      in_memory: bool = True,
      **corpusargs,
  ) -> None:
      """Instantiates a Parallel Corpus from OPUS.
  
      see http://opus.nlpl.eu/
      :param dataset: Name of the dataset (one of "tatoeba")
      :param l1: Language code of first language in pair ("en", "de", etc.)
      :param l2: Language code of second language in pair ("en", "de", etc.)
      :param use_tokenizer: Whether or not to use in-built tokenizer
      :param max_tokens_per_doc: If set, shortens sentences to this maximum number of tokens
      :param max_chars_per_doc: If set, shortens sentences to this maximum number of characters
      :param in_memory: If True, keeps dataset fully in memory
      """
      if l1 > l2:
          l1, l2 = l2, l1
  
      # check if dataset is supported
      supported_datasets = ["tatoeba", "subtitles"]
      if dataset not in supported_datasets:
          log.error(f"Dataset must be one of: {supported_datasets}")
  
      # set file names
      if dataset == "tatoeba":
          link = f"https://object.pouta.csc.fi/OPUS-Tatoeba/v20190709/moses/{l1}-{l2}.txt.zip"
  
          l1_file = (
              flair.cache_root
              / "datasets"
              / dataset
              / f"{l1}-{l2}"
              / f"Tatoeba.{l1}-{l2}.{l1}"
          )
          l2_file = (
              flair.cache_root
              / "datasets"
              / dataset
              / f"{l1}-{l2}"
              / f"Tatoeba.{l1}-{l2}.{l2}"
          )
  
      # set file names
      if dataset == "subtitles":
          link = f"https://object.pouta.csc.fi/OPUS-OpenSubtitles/v2018/moses/{l1}-{l2}.txt.zip"
  
          l1_file = (
              flair.cache_root
              / "datasets"
              / dataset
              / f"{l1}-{l2}"
              / f"OpenSubtitles.{l1}-{l2}.{l1}"
          )
          l2_file = (
              flair.cache_root
              / "datasets"
              / dataset
              / f"{l1}-{l2}"
              / f"OpenSubtitles.{l1}-{l2}.{l2}"
          )
  
      # download and unzip in file structure if necessary
      if not l1_file.exists():
          path = cached_path(
              link, Path("datasets") / dataset / f"{l1}-{l2}"
          )
          unzip_file(
              path,
              flair.cache_root
              / Path("datasets")
              / dataset
              / f"{l1}-{l2}",
          )
  
      # instantiate corpus
      super().__init__(
          l1_file,
          l2_file,
          name=f"{dataset}-{l1_file}-{l2_file}",
          use_tokenizer=use_tokenizer,
          max_tokens_per_doc=max_tokens_per_doc,
          max_chars_per_doc=max_chars_per_doc,
          in_memory=in_memory,
          **corpusargs,
      )
  
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 OpusParallelCorpus object from inherited base classes: ParallelTextCorpus with example: obj = OpusParallelCorpus(dataset, l1, l2, use_tokenizer, max_tokens_per_doc, max_chars_per_doc, in_memory)