class_docstr: Task class for text sequence to sequence.
class_docstr_tok: ["Task","class","for","text","sequence","to","sequence","."]
docstr: Generate data for offline training.
docstr_tok: ["Generate","data","for","offline","training","."]
code: def generate_data(self):
      """Generate data for offline training."""
  
      column_num = 1
      src_path = self.src_paths_after_pre_process
      target_path = self.tgt_paths_after_pre_process
  
      src_ds = load_textline_dataset([src_path], column_num)
  
      src_ds = src_ds[0]
  
      input_pipeline_func = self.get_input_pipeline(for_export=False)
  
      src_ds = src_ds.map(
          input_pipeline_func,
          num_parallel_calls=self.num_parallel_calls,
      )
  
      src_size_ds = src_ds.map(
          lambda x: compute_sen_lens(x, padding_token=utils.PAD_IDX),
          num_parallel_calls=self.num_parallel_calls,
      )
  
      # src_ds = src_ds.map(
      #     self.exclude_padding, num_parallel_calls=self.num_parallel_calls)
  
      if self.infer_without_label:
          data_set = tf.data.Dataset.zip((src_ds, src_size_ds))
  
      else:
          tgt = load_textline_dataset([target_path], column_num)
          tgt = tgt[0]
          tgt_out_ds = tgt.map(lambda x: x + " " + self.END_TOKEN)
          tgt_in_ds = tgt.map(lambda x: self.START_TOKEN + " " + x)
  
          tgt_in_ds = tgt_in_ds.map(
              lambda batch: self.text_pipeline_func(
                  batch, self.max_dec_len, self.text_vocab_file_path
              ),
              num_parallel_calls=self.num_parallel_calls,
          )
  
          tgt_in_size_ds = tgt_in_ds.map(
              lambda x: compute_sen_lens(
                  x, padding_token=utils.PAD_IDX
              ),
              num_parallel_calls=self.num_parallel_calls,
          )
  
          # tgt_in_ds = tgt_in_ds.map(
          #     self.exclude_padding, num_parallel_calls=self.num_parallel_calls)
  
          inp_ds = tf.data.Dataset.zip(
              (src_ds, src_size_ds, tgt_in_ds, tgt_in_size_ds)
          )
  
          if self.use_label_vocab:
              target_vocab_file_path = self.label_vocab_file_paths[0]
          else:
              target_vocab_file_path = self.text_vocab_file_path
          tgt_out_ds = tgt_out_ds.map(
              lambda batch: self.text_pipeline_func(
                  batch, self.max_dec_len, target_vocab_file_path
              ),
              num_parallel_calls=self.num_parallel_calls,
          )
  
          # tgt_out_ds = tgt_out_ds.map(
          #     self.exclude_padding, num_parallel_calls=self.num_parallel_calls)
          data_set = tf.data.Dataset.zip((inp_ds, tgt_out_ds))
  
      vocab_dict = load_vocab_dict(self.text_vocab_file_path)
      vocab_size = len(vocab_dict)
      label_vocab_dict = load_vocab_dict(self.label_vocab_file_paths[0])
      label_vocab_size = len(label_vocab_dict)
      data_size = get_file_len(self.src_paths_after_pre_process)
      self.config["data"]["vocab_size"] = vocab_size
      self.config["data"]["label_vocab_size"] = label_vocab_size
      self.config["data"]["{}_data_size".format(self.mode)] = data_size
  
      return data_set
  
imports: import collections
  import os
  import delta.compat
  from absl import logging
  from delta import utils
  from delta.data.preprocess.text_ops import tokenize_sentence
  from delta.data.preprocess.utils import load_vocab_dict
  from delta.data.task.base_text_task import TextTask
  from delta.data.preprocess.text_ops import load_textline_dataset
  from delta.data.utils.common_utils import get_file_len
  from delta.layers.utils import compute_sen_lens
  from delta.utils.register import registers
label_desc: Use image node_id 5 for calling the TextS2STask obj's underlying member method code with example usage: obj.generate_data() and returns: data_set