class_docstr: The implementation of Biaffine Dependency Parser.
  
  References:
      - Timothy Dozat and Christopher D. Manning. 2017.
        `Deep Biaffine Attention for Neural Dependency Parsing`_.
  
  .. _Deep Biaffine Attention for Neural Dependency Parsing:
      https://openreview.net/forum?id=Hk95PK9le
class_docstr_tok: ["The","implementation","of","Biaffine","Dependency","Parser",".","References",":","-","Timothy","Dozat","and","Christopher","D.","Manning",".","2017",".","`","Deep","Biaffine","Attention","for","Neural","Dependency","Parsing","`","_",".","..","_Deep","Biaffine","Attention","for","Neural","Dependency","Parsing",":","https",":","\/\/openreview.net\/forum","?","id=Hk95PK9le"]
docstr: Args:
      data (list[list] or str):
          The data for prediction, both a list of instances and filename are allowed.
      pred (str):
          If specified, the predicted results will be saved to the file. Default: ``None``.
      buckets (int):
          The number of buckets that sentences are assigned to. Default: 32.
      batch_size (int):
          The number of tokens in each batch. Default: 5000.
      prob (bool):
          If ``True``, outputs the probabilities. Default: ``False``.
      tree (bool):
          If ``True``, ensures to output well-formed trees. Default: ``False``.
      proj (bool):
          If ``True``, ensures to output projective trees. Default: ``False``.
      verbose (bool):
          If ``True``, increases the output verbosity. Default: ``True``.
      kwargs (dict):
          A dict holding the unconsumed arguments that can be used to update the configurations for prediction.
  
  Returns:
      A :class:`~underthesea.utils.Dataset` object that stores the predicted results.
docstr_tok: ["Args",":","data","(","list","[","list","]","or","str",")",":","The","data","for","prediction",",","both","a","list","of","instances","and","filename","are","allowed",".","pred","(","str",")",":","If","specified",",","the","predicted","results","will","be","saved","to","the","file",".","Default",":","``","None","``",".","buckets","(","int",")",":","The","number","of","buckets","that","sentences","are","assigned","to",".","Default",":","32.","batch_size","(","int",")",":","The","number","of","tokens","in","each","batch",".","Default",":","5000.","prob","(","bool",")",":","If","``","True","``",",","outputs","the","probabilities",".","Default",":","``","False","``",".","tree","(","bool",")",":","If","``","True","``",",","ensures","to","output","well-formed","trees",".","Default",":","``","False","``",".","proj","(","bool",")",":","If","``","True","``",",","ensures","to","output","projective","trees",".","Default",":","``","False","``",".","verbose","(","bool",")",":","If","``","True","``",",","increases","the","output","verbosity",".","Default",":","``","True","``",".","kwargs","(","dict",")",":","A","dict","holding","the","unconsumed","arguments","that","can","be","used","to","update","the","configurations","for","prediction",".","Returns",":","A",":","class",":","`","~underthesea.utils.Dataset","`","object","that","stores","the","predicted","results","."]
code: def predict(
      self,
      data,
      buckets=8,
      batch_size=5000,
      pred=None,
      prob=False,
      tree=True,
      proj=False,
  ):
      r"""
      Args:
          data (list[list] or str):
              The data for prediction, both a list of instances and filename are allowed.
          pred (str):
              If specified, the predicted results will be saved to the file. Default: ``None``.
          buckets (int):
              The number of buckets that sentences are assigned to. Default: 32.
          batch_size (int):
              The number of tokens in each batch. Default: 5000.
          prob (bool):
              If ``True``, outputs the probabilities. Default: ``False``.
          tree (bool):
              If ``True``, ensures to output well-formed trees. Default: ``False``.
          proj (bool):
              If ``True``, ensures to output projective trees. Default: ``False``.
          verbose (bool):
              If ``True``, increases the output verbosity. Default: ``True``.
          kwargs (dict):
              A dict holding the unconsumed arguments that can be used to update the configurations for prediction.
  
      Returns:
          A :class:`~underthesea.utils.Dataset` object that stores the predicted results.
      """
      self.transform.eval()
      if prob:
          self.transform.append(Field("probs"))
  
      logger.debug("Loading the data")
      dataset = Dataset(self.transform, data)
      dataset.build(batch_size, buckets)
      logger.debug(f"\n{dataset}")
  
      logger.debug("Making predictions on the dataset")
      start = datetime.now()
      loader = dataset.loader
      self.eval()
  
      arcs, rels, probs = [], [], []
      for words, feats in loader:
          mask = words.ne(self.WORD.pad_index)
          # ignore the first token of each sentence
          mask[:, 0] = 0
          lens = mask.sum(1).tolist()
          s_arc, s_rel = self.forward(words, feats)
          arc_preds, rel_preds = self.decode(
              s_arc, s_rel, mask, tree, proj
          )
          arcs.extend(arc_preds[mask].split(lens))
          rels.extend(rel_preds[mask].split(lens))
          if prob:
              arc_probs = s_arc.softmax(-1)
              probs.extend(
                  [
                      prob[1 : i + 1, : i + 1].cpu()
                      for i, prob in zip(lens, arc_probs.unbind())
                  ]
              )
      arcs = [seq.tolist() for seq in arcs]
      rels = [self.REL.vocab[seq.tolist()] for seq in rels]
      preds = {"arcs": arcs, "rels": rels}
      if prob:
          preds["probs"] = probs
  
      elapsed = datetime.now() - start
  
      for name, value in preds.items():
          setattr(dataset, name, value)
      if pred is not None:
          logger.debug(f"Saving predicted results to {pred}")
          self.transform.save(pred, dataset.sentences)
      logger.debug(
          f"{elapsed}s elapsed, {len(dataset) / elapsed.total_seconds():.2f} Sents/s"
      )
  
      return dataset
  
imports: import os
  from datetime import datetime
  from underthesea.utils import logger
  from underthesea.utils.sp_data import Dataset
  from underthesea.utils.sp_field import Field
  from underthesea.utils.sp_fn import ispunct
  from underthesea.utils.sp_init import PRETRAINED
  from underthesea.utils.sp_metric import AttachmentMetric
  import torch
  import torch.nn
  from torch.nn.utils.rnn import pack_padded_sequence, pad_packed_sequence
  from underthesea.transforms.conll import CoNLL
  from underthesea.modules.base import CharLSTM, IndependentDropout, BiLSTM, SharedDropout, MLP, Biaffine
  from underthesea.modules.bert import BertEmbedding
  from underthesea.utils.sp_alg import eisner, mst
  import underthesea.modules.nn
  from underthesea.utils.util_deep_learning import device
label_desc: Use image node_id 3 for calling the DependencyParser obj's underlying member method code with example usage: obj.predict(data, buckets, batch_size, pred, prob, tree, proj) and returns: dataset