class_docstr: Task class for text classification.
class_docstr_tok: ["Task","class","for","text","classification","."]
docstr: Data set function
docstr_tok: ["Data","set","function"]
code: def dataset(self):
      """Data set function"""
  
      data_set = self.generate_data()
      logging.debug("data_set: {}".format(data_set))
      if self.mode == "train":
          if self.need_shuffle:
              # shuffle batch size and repeat
              logging.debug("shuffle and repeat dataset ...")
              data_set = data_set.apply(
                  tf.data.experimental.shuffle_and_repeat(
                      buffer_size=self.shuffle_buffer_size, count=None
                  )
              )
          else:
              logging.debug("repeat dataset ...")
              data_set = data_set.repeat(count=None)
  
      feature_shape = self.feature_spec()
      logging.debug("feature_shape: {}".format(feature_shape))
      data_set = data_set.padded_batch(
          batch_size=self.batch_size, padded_shapes=feature_shape
      )
  
      data_set = data_set.prefetch(self.num_prefetch_batch)
  
      iterator = tf.data.make_initializable_iterator(data_set)
  
      # pylint: disable=unused-variable
      if self.infer_without_label:
          if self.use_dense:
              (input_x, input_x_len), input_dense = iterator.get_next()
          else:
              input_x, input_x_len = iterator.get_next()
      else:
          if self.use_dense:
              (
                  (input_x, input_x_len),
                  input_dense,
                  input_y,
              ) = iterator.get_next()
          else:
              (input_x, input_x_len), input_y = iterator.get_next()
  
      input_x_dict = collections.OrderedDict([("input_x", input_x)])
      return_dict = {
          "input_x_dict": input_x_dict,
          "input_x_len": input_x_len,
          "iterator": iterator,
      }
  
      if self.use_dense:
          input_x_dict["input_dense"] = input_dense
  
      if not self.infer_without_label:
          return_dict["input_y_dict"] = collections.OrderedDict(
              [("input_y", input_y)]
          )
  
      return return_dict
  
file_path: delta/delta/data/task/text_cls_task.py
imports: import collections
  import delta.compat
  from absl import logging
  from delta.data.task.base_text_task import TextTask
  from delta.data.utils.common_utils import load_npy
  from delta.data.utils.common_utils import get_file_len
  from delta.data.preprocess.text_ops import process_one_label_dataset
  from delta.data.preprocess.text_ops import load_dense_dataset
  from delta.data.preprocess.utils import load_vocab_dict
  from delta.data.preprocess.text_ops import load_textline_dataset
  from delta import utils
  from delta.utils.register import registers
  from delta.layers.utils import compute_sen_lens
label_desc: Use image node_id 5 for calling the TextClsTask obj's underlying member method code with example usage: obj.dataset() and returns: return_dict