class_docstr: Translate from one (source) language to another (target) language.
  .. note::
  
      The translation task is compatible with :mod:`fairseq-train`,
      :mod:`fairseq-generate` and :mod:`fairseq-interactive`.
  
  The translation task provides the following additional command-line
  arguments:
  
  .. argparse::
      :ref: fairseq.tasks.translation_parser
      :prog:
docstr: Setup the task (e.g., load dictionaries and ShardIterator).
  
  Args:
      args (argparse.Namespace): parsed command-line arguments
code: def setup_task(cls, args, **kwargs):
      """Setup the task (e.g., load dictionaries and ShardIterator).
  
      Args:
          args (argparse.Namespace): parsed command-line arguments
      """
      args.left_pad_source = utils.eval_bool(args.left_pad_source)
      args.left_pad_target = utils.eval_bool(args.left_pad_target)
      shard_itr = ShardIterator.build(args)
      paths = utils.split_paths(args.data)
      assert len(paths) > 0
      # find language pair automatically
      if args.source_lang is None or args.target_lang is None:
          (
              args.source_lang,
              args.target_lang,
          ) = data_utils.infer_language_pair(paths[0])
      if args.source_lang is None or args.target_lang is None:
          raise Exception(
              "Could not infer language pair, please provide it explicitly"
          )
  
      # load dictionaries
      src_dict = cls.load_dictionary(
          os.path.join(paths[0], "dict.{}.txt".format(args.source_lang))
      )
      tgt_dict = cls.load_dictionary(
          os.path.join(paths[0], "dict.{}.txt".format(args.target_lang))
      )
      assert src_dict.pad() == tgt_dict.pad()
      assert src_dict.eos() == tgt_dict.eos()
      assert src_dict.unk() == tgt_dict.unk()
      logger.info(
          "[{}] dictionary: {} types".format(
              args.source_lang, len(src_dict)
          )
      )
      logger.info(
          "[{}] dictionary: {} types".format(
              args.target_lang, len(tgt_dict)
          )
      )
  
      return cls(args, src_dict, tgt_dict, shard_itr)
  
imports: import itertools
  import json
  import logging
  import os
  import shutil
  import subprocess
  from pathlib import Path
  from argparse import Namespace
  import numpy
  from fairseq import metrics, options, utils
  from fairseq.data import AppendTokenDataset, ConcatDataset, LanguagePairDataset, PrependTokenDataset, StripTokenDataset, TruncateDataset, data_utils, encoders, indexed_dataset
  import torch.distributed
  from fairseq.tasks import LegacyFairseqTask, register_task
  from fairseq.tasks.translation import TranslationTask
label_desc: Use image node_id 3 for calling the LSTranslationTask obj's underlying member method code with example usage: obj.setup_task(cls, args) and returns: cls