class_docstr: Transformer model for machine translation.
class_docstr_tok: ["Transformer","model","for","machine","translation","."]
docstr: Generate input batches.
docstr_tok: ["Generate","input","batches","."]
code: def _batchify(self, data: List[str], batch_size: int):
      """
      Generate input batches.
      """
      pad_func = Pad(self.vocab_config["eos_id"])
  
      def _parse_batch(batch_ids):
          return pad_func(
              [ids + [self.vocab_config["eos_id"]] for ids in batch_ids]
          )
  
      examples = []
      for text in data:
          examples.append(self._convert_text_to_input(text))
  
      # Seperates data into some batches.
      one_batch = []
      for example in examples:
          one_batch.append(example)
          if len(one_batch) == batch_size:
              yield _parse_batch(one_batch)
              one_batch = []
      if one_batch:
          yield _parse_batch(one_batch)
  
file_path: PaddleHub/modules/text/machine_translation/transformer/en-de/module.py
imports: import os
  from typing import List
  import paddle
  import paddle.nn
  from paddlehub.env import MODULE_HOME
  from paddlehub.module.module import moduleinfo, serving
  import paddlenlp
  from paddlenlp.data import Pad, Vocab
  from paddlenlp.transformers import InferTransformerModel, position_encoding_init
  from transformer_en_de.utils import MTTokenizer, post_process_seq
label_desc: Use image node_id 4 for calling the MTTransformer obj's underlying member method code with example usage: obj._batchify(data, batch_size) and returns: pad_func