class_docstr: Base Preparer class for nlp
class_docstr_tok: ["Base","Preparer","class","for","nlp"]
code: def __init__(self, config):
      super().__init__(config)
      self.all_modes = (utils.INFER, utils.EVAL, utils.TRAIN)
      self.infer_no_label = self.config["data"][utils.INFER].get(
          "infer_no_label", False
      )
      self.model_config = self.config["model"]
      self.task_config = self.config["data"]["task"]
      self.batch_size = self.task_config["batch_size"]
      self.num_parallel_calls = self.task_config["num_parallel_calls"]
      self.vocab_min_frequency = self.task_config["vocab_min_frequency"]
      self.use_custom_vocab = self.task_config.get(
          "use_custom_vocab", False
      )
      self.text_vocab_file_path = self.task_config["text_vocab"]
      self.label_vocab_file_paths = self.task_config["label_vocab"]
      if not isinstance(self.label_vocab_file_paths, list):
          self.label_vocab_file_paths = [self.label_vocab_file_paths]
      self.output_num = len(self.label_vocab_file_paths)
      self.multi_output = bool(self.output_num > 1)
      self.multi_text = False
      self.session_conf = get_session_conf(self.config)
      self.init_feed_dict = {}
  
imports: import os
  import math
  from pathlib import Path
  from absl import logging
  import delta.compat
  import numpy
  from delta import utils
  from delta.data.preprocess.utils import prepare_embedding
  from delta.utils.solver.utils.solver_utils import get_session_conf
  from delta.data.preprocess.utils import prepare_vocab
  from delta.data.preprocess.utils import prepare_vocab_from_config
  from delta.data.preprocess.utils import get_pre_process_text_ds_iter
  from delta.data.utils.common_utils import get_file_len
label_desc: Use image node_id 1 to create a new TextPreparer object from inherited base classes: Preparer with example: obj = TextPreparer(config)