class_docstr: Translate from one (source) language to another (target) language.
  
  Args:
      src_dict (~fairseq.data.Dictionary): dictionary for the source language
      tgt_dict (~fairseq.data.Dictionary): dictionary for the target language
  
  .. note::
  
      The translation task is compatible with :mod:`fairseq-train`,
      :mod:`fairseq-generate` and :mod:`fairseq-interactive`.
class_docstr_tok: ["Translate","from","one","(","source",")","language","to","another","(","target",")","language",".","Args",":","src_dict","(","~fairseq.data.Dictionary",")",":","dictionary","for","the","source","language","tgt_dict","(","~fairseq.data.Dictionary",")",":","dictionary","for","the","target","language","..","note",":",":","The","translation","task","is","compatible","with",":","mod",":","`","fairseq-train","`",",",":","mod",":","`","fairseq-generate","`","and",":","mod",":","`","fairseq-interactive","`","."]
docstr: Setup the task (e.g., load dictionaries).
  
  Args:
      args (argparse.Namespace): parsed command-line arguments
docstr_tok: ["Setup","the","task","(","e.g.",",","load","dictionaries",")",".","Args",":","args","(","argparse.Namespace",")",":","parsed","command-line","arguments"]
code: def setup_task(cls, cfg: TranslationConfig, **kwargs):
      """Setup the task (e.g., load dictionaries).
  
      Args:
          args (argparse.Namespace): parsed command-line arguments
      """
  
      paths = utils.split_paths(cfg.data)
      assert len(paths) > 0
      # find language pair automatically
      if cfg.source_lang is None or cfg.target_lang is None:
          (
              cfg.source_lang,
              cfg.target_lang,
          ) = data_utils.infer_language_pair(paths[0])
      if cfg.source_lang is None or cfg.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(cfg.source_lang))
      )
      tgt_dict = cls.load_dictionary(
          os.path.join(paths[0], "dict.{}.txt".format(cfg.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(
              cfg.source_lang, len(src_dict)
          )
      )
      logger.info(
          "[{}] dictionary: {} types".format(
              cfg.target_lang, len(tgt_dict)
          )
      )
  
      return cls(cfg, src_dict, tgt_dict)
  
imports: from dataclasses import dataclass, field
  import itertools
  import json
  import logging
  import os
  from typing import Optional
  from argparse import Namespace
  from omegaconf import II
  import numpy
  from fairseq import utils
  from fairseq.logging import metrics
  from fairseq.data import AppendTokenDataset, ConcatDataset, LanguagePairDataset, PrependTokenDataset, StripTokenDataset, TruncateDataset, data_utils, encoders, indexed_dataset
  from fairseq.data.indexed_dataset import get_available_dataset_impl
  from fairseq.dataclass import ChoiceEnum, FairseqDataclass
  from fairseq.tasks import FairseqTask, register_task
label_desc: Use image node_id 2 for calling the TranslationTask obj's underlying member method code with example usage: obj.setup_task(cls, cfg) and returns: cls