class_docstr: The base class for Transformer models.
class_docstr_tok: ["The","base","class","for","Transformer","models","."]
docstr: Predicts the data labels.
  Args:
      data (obj:`List(List(str))`): The processed data whose each element is the list of a single text or a pair of texts.
      max_seq_len (:obj:`int`, `optional`, defaults to :int:`None`):
          If set to a number, will limit the total sequence returned so that it has a maximum length.
      split_char(obj:`str`, defaults to ''): The char used to split input tokens in token-cls task.
      batch_size(obj:`int`, defaults to 1): The number of batch.
      use_gpu(obj:`bool`, defaults to `False`): Whether to use gpu to run or not.
      return_prob(obj:`bool`, defaults to `False`): Whether to return label probabilities.
  Returns:
      results(obj:`list`): All the predictions labels.
docstr_tok: ["Predicts","the","data","labels",".","Args",":","data","(","obj",":","`","List","(","List","(","str",")",")","`",")",":","The","processed","data","whose","each","element","is","the","list","of","a","single","text","or","a","pair","of","texts",".","max_seq_len","(",":","obj",":","`","int","`",",","`","optional","`",",","defaults","to",":","int",":","`","None","`",")",":","If","set","to","a","number",",","will","limit","the","total","sequence","returned","so","that","it","has","a","maximum","length",".","split_char","(","obj",":","`","str","`",",","defaults","to","'\u0002","'",")",":","The","char","used","to","split","input","tokens","in","token-cls","task",".","batch_size","(","obj",":","`","int","`",",","defaults","to","1",")",":","The","number","of","batch",".","use_gpu","(","obj",":","`","bool","`",",","defaults","to","`","False","`",")",":","Whether","to","use","gpu","to","run","or","not",".","return_prob","(","obj",":","`","bool","`",",","defaults","to","`","False","`",")",":","Whether","to","return","label","probabilities",".","Returns",":","results","(","obj",":","`","list","`",")",":","All","the","predictions","labels","."]
code: def predict(
      self,
      data: List[List[str]],
      max_seq_len: int = 128,
      split_char: str = "\002",
      batch_size: int = 1,
      use_gpu: bool = False,
      return_prob: bool = False,
  ):
      """
      Predicts the data labels.
      Args:
          data (obj:`List(List(str))`): The processed data whose each element is the list of a single text or a pair of texts.
          max_seq_len (:obj:`int`, `optional`, defaults to :int:`None`):
              If set to a number, will limit the total sequence returned so that it has a maximum length.
          split_char(obj:`str`, defaults to '\002'): The char used to split input tokens in token-cls task.
          batch_size(obj:`int`, defaults to 1): The number of batch.
          use_gpu(obj:`bool`, defaults to `False`): Whether to use gpu to run or not.
          return_prob(obj:`bool`, defaults to `False`): Whether to return label probabilities.
      Returns:
          results(obj:`list`): All the predictions labels.
      """
      if (
          self.task not in self._tasks_supported
          and self.task is not None
      ):  # None for getting embedding
          raise RuntimeError(
              f"Unknown task {self.task}, current tasks supported:\n"
              "1. seq-cls: sequence classification;\n"
              "2. token-cls: sequence labeling;\n"
              "3. text-matching: text matching;\n"
              "4. None: embedding"
          )
  
      paddle.set_device("gpu") if use_gpu else paddle.set_device("cpu")
  
      batches = self._batchify(
          data, max_seq_len, batch_size, split_char
      )
      results = []
      batch_probs = []
  
      self.eval()
      for batch in batches:
          if self.task == "text-matching":
              (
                  query_input_ids,
                  query_segment_ids,
                  title_input_ids,
                  title_segment_ids,
              ) = batch
              query_input_ids = paddle.to_tensor(query_input_ids)
              query_segment_ids = paddle.to_tensor(query_segment_ids)
              title_input_ids = paddle.to_tensor(title_input_ids)
              title_segment_ids = paddle.to_tensor(title_segment_ids)
              probs = self(
                  query_input_ids=query_input_ids,
                  query_token_type_ids=query_segment_ids,
                  title_input_ids=title_input_ids,
                  title_token_type_ids=title_segment_ids,
              )
  
              idx = paddle.argmax(probs, axis=1).numpy()
              idx = idx.tolist()
              labels = [self.label_map[i] for i in idx]
          else:
              input_ids, segment_ids = batch
              input_ids = paddle.to_tensor(input_ids)
              segment_ids = paddle.to_tensor(segment_ids)
              if self.task == "seq-cls":
                  probs = self(input_ids, segment_ids)
                  idx = paddle.argmax(probs, axis=1).numpy()
                  idx = idx.tolist()
                  labels = [self.label_map[i] for i in idx]
              elif self.task == "token-cls":
                  probs = self(input_ids, segment_ids)
                  batch_ids = paddle.argmax(
                      probs, axis=2
                  ).numpy()  # (batch_size, max_seq_len)
                  batch_ids = batch_ids.tolist()
                  # token labels
                  labels = [
                      [self.label_map[i] for i in token_ids]
                      for token_ids in batch_ids
                  ]
              elif self.task == None:
                  output = self(input_ids, segment_ids)
                  if len(output) == 1:
                      results.append(output.squeeze(0).numpy().tolist())
                  else:
                      sequence_output, pooled_output = output
                      results.append(
                          [
                              pooled_output.squeeze(0).numpy().tolist(),
                              sequence_output.squeeze(0)
                              .numpy()
                              .tolist(),
                          ]
                      )
          if self.task:
              # save probs only when return prob
              if return_prob:
                  batch_probs.extend(probs.numpy().tolist())
              results.extend(labels)
  
      if self.task and return_prob:
          return results, batch_probs
      return results
  
imports: import copy
  import functools
  import inspect
  import io
  import json
  import os
  import six
  from typing import List, Tuple, Union
  import paddle
  import paddle.nn
  from packaging.version import Version
  from paddle.dataset.common import DATA_HOME
  from paddle.utils.download import get_path_from_url
  from paddlehub.module.module import serving, RunModule, runnable
  from paddlehub.utils.log import logger
  from paddlehub.utils.utils import reseg_token_label
  import paddlenlp
  from paddlenlp.embeddings.token_embedding import EMBEDDING_HOME, EMBEDDING_URL_ROOT
  from paddlenlp.data import JiebaTokenizer
  from paddlehub.compat.module.nlp_module import DataFormatError
label_desc: Use image node_id 7 for calling the TransformerModule obj's underlying member method code with example usage: obj.predict(data, max_seq_len, split_char, batch_size, use_gpu, return_prob) and returns: results, results,  batch_probs