code: def build_vocabs(
      args: argparse.Namespace, dictionary_cls=Dictionary
  ) -> Dict[str, Dictionary]:
      """
      Builds vocabs or loads them from existing vocab files. If args.task
      is pytorch_translate_semi_supervised, we use the monolingual corpora in
      addition to the parallel corpora for building source and target vocabs.
      """
      source_files = [args.train_source_text_file]
      target_files = [args.train_target_text_file]
  
      if args.task == constants.SEMI_SUPERVISED_TASK and getattr(
          args, "add_monolingual_data_for_vocab_building", None
      ):
          if getattr(args, "train_mono_source_text_file", None):
              source_files.append(args.train_mono_source_text_file)
          if getattr(args, "train_mono_target_text_file", None):
              target_files.append(args.train_mono_target_text_file)
  
      source_dict = dictionary_cls.build_vocab_file_if_nonexistent(
          corpus_files=source_files,
          vocab_file=args.source_vocab_file,
          max_vocab_size=args.source_max_vocab_size,
          tokens_with_penalty=None,
      )
  
      use_char_source = (args.char_source_vocab_file != "") or getattr(
          args, "arch", ""
      ) in constants.ARCHS_FOR_CHAR_SOURCE
  
      embed_bytes = getattr(args, "embed_bytes", False)
      char_source_dict = None
      if use_char_source:
          char_source_dict = (
              dictionary_cls.build_vocab_file_if_nonexistent(
                  corpus_files=source_files,
                  vocab_file=args.char_source_vocab_file,
                  max_vocab_size=args.char_source_max_vocab_size,
                  tokens_with_penalty=None,
                  is_char_vocab=True,
                  embed_bytes=embed_bytes,
              )
          )
  
      target_dict = dictionary_cls.build_vocab_file_if_nonexistent(
          corpus_files=target_files,
          vocab_file=args.target_vocab_file,
          max_vocab_size=args.target_max_vocab_size,
          tokens_with_penalty=args.penalized_target_tokens_file,
      )
  
      use_char_target = (args.char_target_vocab_file != "") or getattr(
          args, "arch", ""
      ) in constants.ARCHS_FOR_CHAR_TARGET
  
      char_target_dict = None
      if use_char_target:
          char_target_dict = (
              dictionary_cls.build_vocab_file_if_nonexistent(
                  corpus_files=target_files,
                  vocab_file=args.char_target_vocab_file,
                  max_vocab_size=args.char_target_max_vocab_size,
                  tokens_with_penalty=None,
                  is_char_vocab=True,
                  embed_bytes=embed_bytes,
              )
          )
      return {
          "source_dict": source_dict,
          "char_source_dict": char_source_dict,
          "target_dict": target_dict,
          "char_target_dict": char_target_dict,
      }
  
imports: import argparse
  import os
  import tempfile
  from typing import Dict, List, Optional
  from pytorch_translate import constants, multilingual_utils, options, utils
  from pytorch_translate.data import char_data, data
  from pytorch_translate.data.dictionary import Dictionary
label_desc: Use image node_id 7 for calling a global function with example usage: build_vocabs(args, dictionary_cls) and returns: dict