class_docstr: Task for joint training speech and text to text.
class_docstr_tok: ["Task","for","joint","training","speech","and","text","to","text","."]
docstr: Setup the task (e.g., load dictionaries).
docstr_tok: ["Setup","the","task","(","e.g.",",","load","dictionaries",")","."]
code: def setup_task(cls, args, **kwargs):
      """Setup the task (e.g., load dictionaries)."""
      data_cfg = S2TJointDataConfig(Path(args.data) / args.config_yaml)
      tgt_dict_path = Path(args.data) / data_cfg.vocab_filename
      src_dict_path = Path(args.data) / data_cfg.src_vocab_filename
      if (not os.path.isfile(src_dict_path)) or (
          not os.path.isfile(tgt_dict_path)
      ):
          raise FileNotFoundError(
              "Dict not found: {}".format(args.data)
          )
      src_dict = Dictionary.load(src_dict_path.as_posix())
      tgt_dict = Dictionary.load(tgt_dict_path.as_posix())
  
      print("| src dictionary: {} types".format(len(src_dict)))
      print("| tgt dictionary: {} types".format(len(tgt_dict)))
  
      if args.parallel_text_data != "":
          if not os.path.isabs(args.parallel_text_data):
              args.parallel_text_data = os.path.join(
                  args.data, args.parallel_text_data
              )
  
          if args.langpairs is None:
              raise Exception(
                  "Could not infer language pair, please provide it explicitly"
              )
      infer_tgt_lang_id = None
      if (
          args.infer_target_lang != ""
          and data_cfg.prepend_tgt_lang_tag_no_change
      ):
          tgt_lang_tag = SpeechToTextDataset.LANG_TAG_TEMPLATE.format(
              args.infer_target_lang
          )
          infer_tgt_lang_id = tgt_dict.index(tgt_lang_tag)
          assert infer_tgt_lang_id != tgt_dict.unk()
      return cls(
          args, src_dict, tgt_dict, infer_tgt_lang_id=infer_tgt_lang_id
      )
  
imports: import logging
  import os
  from argparse import Namespace
  from pathlib import Path
  import torch
  from fairseq.data import encoders, Dictionary, ResamplingDataset, TransformEosLangPairDataset, ConcatDataset
  from fairseq.data.iterators import GroupedEpochBatchIterator
  from fairseq.data.audio.multi_modality_dataset import MultiModalityDataset, LangPairMaskDataset, ModalityDatasetItem
  from fairseq.data.audio.speech_to_text_dataset import SpeechToTextDataset, SpeechToTextDatasetCreator
  from fairseq.data.audio.speech_to_text_joint_dataset import S2TJointDataConfig, SpeechToTextJointDatasetCreator
  from fairseq.tasks import register_task
  from fairseq.tasks.speech_to_text import SpeechToTextTask
  from fairseq.tasks.translation import load_langpair_dataset
label_desc: Use image node_id 3 for calling the SpeechTextJointToTextTask obj's underlying member method code with example usage: obj.setup_task(cls, args) and returns: cls