class_docstr: Tranformer Module base class can be used by BERT, ERNIE, RoBERTa and so on.
class_docstr_tok: ["Tranformer","Module","base","class","can","be","used","by","BERT",",","ERNIE",",","RoBERTa","and","so","on","."]
docstr: get pooled_output and sequence_output for input texts.
  Warnings: this method depends on Paddle Inference Library, it may not work properly in PaddlePaddle <= 1.6.2.
  Args:
      texts (list): each element is a text sample, each sample include text_a and text_b where text_b can be omitted.
                    for example: [[sample0_text_a, sample0_text_b], [sample1_text_a, sample1_text_b], ...]
      max_seq_len (int): the max sequence length.
      use_gpu (bool): use gpu or not, default False.
      batch_size (int): the data batch size, default 1.
  Returns:
      pooled_outputs(list): its element is a numpy array, the first feature of each text sample.
      sequence_outputs(list): its element is a numpy array, the whole features of each text sample.
docstr_tok: ["get","pooled_output","and","sequence_output","for","input","texts",".","Warnings",":","this","method","depends","on","Paddle","Inference","Library",",","it","may","not","work","properly","in","PaddlePaddle","<","=","1.6.2",".","Args",":","texts","(","list",")",":","each","element","is","a","text","sample",",","each","sample","include","text_a","and","text_b","where","text_b","can","be","omitted",".","for","example",":","[","[","sample0_text_a",",","sample0_text_b","]",",","[","sample1_text_a",",","sample1_text_b","]",",","...","]","max_seq_len","(","int",")",":","the","max","sequence","length",".","use_gpu","(","bool",")",":","use","gpu","or","not",",","default","False",".","batch_size","(","int",")",":","the","data","batch","size",",","default","1",".","Returns",":","pooled_outputs","(","list",")",":","its","element","is","a","numpy","array",",","the","first","feature","of","each","text","sample",".","sequence_outputs","(","list",")",":","its","element","is","a","numpy","array",",","the","whole","features","of","each","text","sample","."]
code: def get_embedding(
      self,
      texts: List[str],
      max_seq_len: int = 512,
      use_gpu: bool = False,
      batch_size: int = 1,
  ):
      """
      get pooled_output and sequence_output for input texts.
      Warnings: this method depends on Paddle Inference Library, it may not work properly in PaddlePaddle <= 1.6.2.
      Args:
          texts (list): each element is a text sample, each sample include text_a and text_b where text_b can be omitted.
                        for example: [[sample0_text_a, sample0_text_b], [sample1_text_a, sample1_text_b], ...]
          max_seq_len (int): the max sequence length.
          use_gpu (bool): use gpu or not, default False.
          batch_size (int): the data batch size, default 1.
      Returns:
          pooled_outputs(list): its element is a numpy array, the first feature of each text sample.
          sequence_outputs(list): its element is a numpy array, the whole features of each text sample.
      """
      if (
          not hasattr(self, "emb_job")
          or self.emb_job["batch_size"] != batch_size
          or self.emb_job["use_gpu"] != use_gpu
      ):
          inputs, outputs, program = self.context(
              trainable=True, max_seq_len=max_seq_len
          )
  
          reader = ClassifyReader(
              dataset=None,
              vocab_path=self.get_vocab_path(),
              max_seq_len=max_seq_len,
              sp_model_path=self.get_spm_path()
              if hasattr(self, "get_spm_path")
              else None,
              word_dict_path=self.get_word_dict_path()
              if hasattr(self, "word_dict_path")
              else None,
          )
  
          feed_list = [
              inputs["input_ids"].name,
              inputs["position_ids"].name,
              inputs["segment_ids"].name,
              inputs["input_mask"].name,
          ]
  
          pooled_feature, seq_feature = (
              outputs["pooled_output"],
              outputs["sequence_output"],
          )
  
          config = RunConfig(
              use_data_parallel=False,
              use_cuda=use_gpu,
              batch_size=batch_size,
          )
  
          self.emb_job = {}
          self.emb_job["task"] = TransformerEmbeddingTask(
              pooled_feature=pooled_feature,
              seq_feature=seq_feature,
              feed_list=feed_list,
              data_reader=reader,
              config=config,
          )
          self.emb_job["batch_size"] = batch_size
          self.emb_job["use_gpu"] = use_gpu
  
      return self.emb_job["task"].predict(
          data=texts, return_result=True, accelerate_mode=True
      )
  
imports: import argparse
  import ast
  import os
  import re
  from typing import Any
  from typing import List
  from typing import Text
  from typing import Tuple
  import numpy
  import paddle
  import six
  from paddle.framework import core
  from paddlehub.compat import paddle_utils
  from paddlehub.compat.task.config import RunConfig
  from paddlehub.compat.task.reader import ClassifyReader
  from paddlehub.compat.task.transformer_emb_task import TransformerEmbeddingTask
  from paddlehub.module.module import RunModule
  from paddlehub.module.module import runnable
  from paddlehub.utils.parser import txt_parser
  from paddlehub.utils.utils import sys_stdin_encoding
label_desc: Use image node_id 5 for calling the TransformerModule obj's underlying member method code with example usage: obj.get_embedding(texts, max_seq_len, use_gpu, batch_size) and returns: self