class_docstr: Model wrapper for joint entity and relation extraction.
class_docstr_tok: ["Model","wrapper","for","joint","entity","and","relation","extraction","."]
code: def decoding(self, output, stored_info):
      (
          output_ids,
          pairing_decisions,
          typing_decisions,
          antecedent_decisions,
      ) = (
          output["output_ids"].tolist(),
          output["pairing"],
          output["typing"],
          output["linking"],
      )
      subtoken_map = stored_info["subtoken_map"]
      sentence_idx = (
          stored_info["sentence_idx"]
          if "sentence_idx" in stored_info
          else None
      )
  
      mapping = self.get_mapping_to_input_sequence(output_ids)
      entities, relations, start_ind = [], [], []
      # reconstructing mention_indices and antecedent_indices
      for i in range(len(output_ids)):
          if output_ids[i] == self.tz.pad_token_id:
              break
          if output_ids[i] == self.mention_start_id:
              start_ind.append(i)
          if output_ids[i] == self.mention_end_id:
              this_type = int(typing_decisions[i])
              entity = (
                  subtoken_map[
                      mapping[start_ind[pairing_decisions[i]]]
                  ],
                  subtoken_map[mapping[i]],
                  this_type,
                  sentence_idx[mapping[i]]
                  if sentence_idx is not None
                  else 0,
              )
              entities.append(entity)
  
              this_rel_types = antecedent_decisions[i].tolist()
              for ent_id, rel_type in enumerate(this_rel_types):
                  if rel_type != -1:
                      relations.append(
                          (
                              entities[ent_id][:2],
                              entity[:2],
                              int(rel_type),
                              entities[ent_id][2],
                              entity[2],
                          )
                      )
                      if entities[ent_id][-1] != entity[-1]:
                          relations = relations[:-1]
  
      result_dict = {
          "predicted_entities": [x[:3] for x in entities],
          "predicted_relations": [x for x in relations],
      }
      return result_dict
  
file_path: DeepKE/src/deepke/triple_extraction/ASP/models/model_ere.py
imports: import sys
  import os
  import torch
  import torch.nn
  import logging
  from transformers import T5Tokenizer
  from .t5_ere import T5ERE
label_desc: Use image node_id 7 for calling the EREModel obj's underlying member method code with example usage: obj.decoding(output, stored_info) and returns: result_dict