class_docstr: A task for training multiple translation models simultaneously.
  
  We iterate round-robin over batches from multiple language pairs, ordered
  according to the `--lang-pairs` argument.
  
  The training loop is roughly:
  
      for i in range(len(epoch)):
          for lang_pair in args.lang_pairs:
              batch = next_batch_for_lang_pair(lang_pair)
              loss = criterion(model_for_lang_pair(lang_pair), batch)
              loss.backward()
          optimizer.step()
  
  In practice, `next_batch_for_lang_pair` is abstracted in a FairseqDataset
  (e.g., `RoundRobinZipDatasets`) and `model_for_lang_pair` is a model that
  implements the `FairseqMultiModel` interface.
  
  During inference it is required to specify a single `--source-lang` and
  `--target-lang`, which indicates the inference langauge direction.
  `--lang-pairs`, `--encoder-langtok`, `--decoder-langtok` have to be set to
  the same value as training.
class_docstr_tok: ["A","task","for","training","multiple","translation","models","simultaneously",".","We","iterate","round-robin","over","batches","from","multiple","language","pairs",",","ordered","according","to","the","`","--","lang-pairs","`","argument",".","The","training","loop","is","roughly",":","for","i","in","range","(","len","(","epoch",")",")",":","for","lang_pair","in","args.lang_pairs",":","batch","=","next_batch_for_lang_pair","(","lang_pair",")","loss","=","criterion","(","model_for_lang_pair","(","lang_pair",")",",","batch",")","loss.backward","(",")","optimizer.step","(",")","In","practice",",","`","next_batch_for_lang_pair","`","is","abstracted","in","a","FairseqDataset","(","e.g.",",","`","RoundRobinZipDatasets","`",")","and","`","model_for_lang_pair","`","is","a","model","that","implements","the","`","FairseqMultiModel","`","interface",".","During","inference","it","is","required","to","specify","a","single","`","--","source-lang","`","and","`","--","target-lang","`",",","which","indicates","the","inference","langauge","direction",".","`","--","lang-pairs","`",",","`","--","encoder-langtok","`",",","`","--","decoder-langtok","`","have","to","be","set","to","the","same","value","as","training","."]
code: def update_args(cls, args):
      args.left_pad_source = utils.eval_bool(args.left_pad_source)
      args.left_pad_target = utils.eval_bool(args.left_pad_target)
  
      if args.lang_pairs is None:
          raise ValueError(
              "--lang-pairs is required. List all the language pairs in the training objective."
          )
      if isinstance(args.lang_pairs, str):
          args.lang_pairs = args.lang_pairs.split(",")
  
imports: import contextlib
  import logging
  import os
  from collections import OrderedDict
  from argparse import ArgumentError
  import torch
  from fairseq import options, utils
  from fairseq.logging import metrics
  from fairseq.data import Dictionary, LanguagePairDataset, RoundRobinZipDatasets, TransformEosLangPairDataset
  from fairseq.models import FairseqMultiModel
  from fairseq.tasks.translation import load_langpair_dataset
  from .None import LegacyFairseqTask, register_task
label_desc: Use image node_id 4 for calling the MultilingualTranslationTask obj's underlying member method code with example usage: obj.update_args(cls, args) without return types