docstr:     Do the inference.
  Parameters
  ----------
  raw_contents: list
      The raw inputs. Example: ["sentence1", "sentence2"]
  batch_size: int, default=1
      The batch size of the inference.
  Returns
  -------
  Inference_results: object
      It will be the post-processed results. Examples: ["output1", "output2"]
docstr_tok: ["Do","the","inference",".","Parameters","--","--","--","--","--","raw_contents",":","list","The","raw","inputs",".","Example",":","[","``","sentence1","''",",","``","sentence2","''","]","batch_size",":","int",",","default=1","The","batch","size","of","the","inference",".","Returns","--","--","--","-","Inference_results",":","object","It","will","be","the","post-processed","results",".","Examples",":","[","``","output1","''",",","``","output2","''","]"]
code: def predict(self, raw_contents: list, batch_size=1):
      """
          Do the inference.
      Parameters
      ----------
      raw_contents: list
          The raw inputs. Example: ["sentence1", "sentence2"]
      batch_size: int, default=1
          The batch size of the inference.
      Returns
      -------
      Inference_results: object
          It will be the post-processed results. Examples: ["output1", "output2"]
      """
      # step 1: construct graph
      if len(raw_contents) == 0:
          warnings.warn("The input ``raw_contents`` is empty.")
          return []
  
      if batch_size <= 0:
          raise ValueError("``batch_size`` should be > 0")
  
      if len(raw_contents) < batch_size:
          batch_size = len(raw_contents)
  
      ret_collect = []
  
      for i in range(math.ceil(len(raw_contents) / batch_size)):
          data_collect = raw_contents[
              i * batch_size : (i + 1) * batch_size
          ]
  
          data_items = []
          vocab_model = copy.deepcopy(self.vocab_model)
          device = next(self.parameters()).device
          data_items = self.preprocess(raw_contents=data_collect)
  
          collate_data = self.dataset.collate_fn(data_items)
          collate_data = all_to_cuda(collate_data, device)
  
          # forward
          if self.use_copy:
              oov_dict = self.prepare_ext_vocab(
                  collate_data["graph_data"],
                  vocab_model.in_word_vocab,
                  device,
              )
              ref_dict = oov_dict
          else:
              oov_dict = None
              ref_dict = self.vocab_model.out_word_vocab
          # print(collate_data)
          ret = self.model.inference_forward(
              collate_data,
              self.beam_size,
              topk=self.topk,
              oov_dict=oov_dict,
          )
          ret = self.model.post_process(
              decode_results=ret, vocab=ref_dict
          )
          ret_collect.extend(ret)
      return ret_collect
  
file_path: graph4nlp/graph4nlp/pytorch/inference_wrapper/generator_inference_wrapper_for_tree.py
imports: import copy
  import math
  import warnings
  import torch
  from graph4nlp.pytorch.data.dataset import Text2TreeDataItem, Text2TreeDataset
  from graph4nlp.pytorch.modules.utils.generic_utils import all_to_cuda
  from .base import InferenceWrapperBase
label_desc: Use image node_id 3 for calling the GeneratorInferenceWrapper obj's underlying member method code with example usage: obj.predict(raw_contents, batch_size) and returns: ret_collect, list