class_docstr: A mapping from symbols to consecutive integers
class_docstr_tok: ["A","mapping","from","symbols","to","consecutive","integers"]
code: def build_vocab_file(
      cls,
      corpus_files: List[str],
      vocab_file: str,
      max_vocab_size: int,
      tokens_with_penalty: Optional[str] = None,
      is_char_vocab: bool = False,
      embed_bytes: bool = False,
      padding_factor: int = 8,
  ) -> (
      "Dictionary"
  ):  # https://www.python.org/dev/peps/pep-0484/#forward-references
      d = cls()
  
      tokenize = char_tokenize_line if is_char_vocab else tokenize_line
      embed_bytes = embed_bytes and is_char_vocab
  
      # if we are embedding byte ids then no need to add these to the dict
      # the ids an be obtained directly from the character
      if not embed_bytes:
          for corpus_file in corpus_files:
              add_file_to_dictionary(
                  filename=corpus_file, dict=d, tokenize=tokenize
              )
  
      # Set indices to receive penalty
      if tokens_with_penalty:
          # Assume input tokens are unique
          lexicon = []
          with PathManager.open(
              tokens_with_penalty, "r", encoding="utf-8"
          ) as f:
              for line in f:
                  tokens = line.strip().split()
                  if len(tokens) == 1:
                      lexicon.append(tokens[0])
  
          for token, token_index in d.indices.items():
              if token in lexicon:
                  d.lexicon_indices.add(token_index)
  
      nwords = (
          -1 if max_vocab_size <= 0 else max_vocab_size + d.nspecial
      )
      d.finalize(nwords=nwords, padding_factor=padding_factor)
      d.save(vocab_file)
      print(f"Generated new vocab file saved at {vocab_file}.")
      if max_vocab_size < 0:
          print("No maximum vocab sized enforced.")
      else:
          print(f"Maximum vocab size {max_vocab_size}")
      return d
  
imports: import os
  import re
  from typing import Dict, List, Optional, Set
  from fairseq.data import dictionary
  from fairseq.file_io import PathManager
  from pytorch_translate import vocab_constants
label_desc: Use image node_id 3 for calling the Dictionary obj's underlying member method code with example usage: obj.build_vocab_file(cls, corpus_files, vocab_file, max_vocab_size, tokens_with_penalty, is_char_vocab, embed_bytes, padding_factor) and returns: d