code: def add_puncs(
      self, texts: Union[str, List[str]], max_length=256, device="cpu"
  ):
      assert isinstance(texts, str) or (
          isinstance(texts, list) and isinstance(texts[0], str)
      ), "Input data should be str or List[str], but got {}".format(
          type(texts)
      )
  
      if isinstance(texts, str):
          texts = [texts]
  
      input_ids = []
      seg_ids = []
      seq_len = []
      for i in range(len(texts)):
          clean_text = self._clean_text(texts[i], self.punc_list)
          assert (
              len(clean_text) > 0
          ), f"Invalid input string: {texts[i]}"
  
          tokenized_input = self.tokenizer(
              list(clean_text),
              return_length=True,
              is_split_into_words=True,
              max_seq_len=max_length,
          )
  
          input_ids.append(tokenized_input["input_ids"])
          seg_ids.append(tokenized_input["token_type_ids"])
          seq_len.append(tokenized_input["seq_len"])
  
      paddle.set_device(device)
      with paddle.no_grad():
          pad_func_for_input_ids = Pad(
              axis=0, pad_val=self.tokenizer.pad_token_id, dtype="int64"
          )
          pad_func_for_seg_ids = Pad(
              axis=0,
              pad_val=self.tokenizer.pad_token_type_id,
              dtype="int64",
          )
          input_ids = paddle.to_tensor(
              pad_func_for_input_ids(input_ids)
          )
          seg_ids = paddle.to_tensor(pad_func_for_seg_ids(seg_ids))
          logits = self.model(input_ids, seg_ids)
          preds = paddle.argmax(logits, axis=-1)
  
      tokens = []
      labels = []
      for i in range(len(input_ids)):
          tokens.append(
              self.tokenizer.convert_ids_to_tokens(
                  input_ids[i, 1 : seq_len[i] - 1].tolist()
              )
          )
          labels.append(
              preds[i, 1 : seq_len[i] - 1].tolist()
          )  # Remove predictions of special tokens.
  
      punc_texts = []
      for token, label in zip(tokens, labels):
          assert len(token) == len(label)
          text = ""
          for t, l in zip(token, label):
              text += t
              if l != 0:  # Non punc.
                  text += self.punc_list[l]
          punc_texts.append(text)
  
      return punc_texts
  
file_path: PaddleHub/modules/text/punctuation_restoration/auto_punc/module.py
imports: import os
  import re
  from typing import List, Union
  import numpy
  import paddle
  from paddlehub.env import MODULE_HOME
  from paddlehub.module.module import moduleinfo, serving
  from paddlehub.utils.log import logger
  from paddlenlp.transformers import ErnieTokenizer, ErnieForTokenClassification
  from paddlenlp.data import Pad
label_desc: Use image node_id 5 for calling the Ernie obj's underlying member method code with example usage: obj.add_puncs(texts, max_length, device) and returns: punc_texts