class_docstr: Record for converting generated string to information record
  <type, arg1_type, arg1_span, arg2_type, arg2_span>
class_docstr_tok: ["Record","for","converting","generated","string","to","information","record","<","type",",","arg1_type",",","arg1_span",",","arg2_type",",","arg2_span",">"]
docstr: Find Role's offset using closest matched with trigger word.
  :param instance:
  :return:
docstr_tok: ["Find","Role","'s","offset","using","closest","matched","with","trigger","word",".",":","param","instance",":",":","return",":"]
code: def record_to_offset_closest_role(self, instance, token_list):
      """
      Find Role's offset using closest matched with trigger word.
      :param instance:
      :return:
      """
      relation_list = list()
  
      for record in instance:
          relation_type = record["type"]
  
          if len(record["roles"]) < 2:
              continue
  
          arg1_type, arg1_text = record["roles"][0]
          arg2_type, arg2_text = record["roles"][1]
          arg1_matched_list = match_sublist(
              token_list, self.span_to_token(arg1_text)
          )
          arg2_matched_list = match_sublist(
              token_list, self.span_to_token(arg2_text)
          )
  
          if len(arg1_matched_list) == 0:
              logger.warning(
                  "[Cannot reconstruct]: %s %s\n"
                  % (arg1_text, token_list)
              )
              break
          if len(arg2_matched_list) == 0:
              logger.warning(
                  "[Cannot reconstruct]: %s %s\n"
                  % (arg2_text, token_list)
              )
              break
  
          distance_tuple = list()
          for arg1_match in arg1_matched_list:
              for arg2_match in arg2_matched_list:
                  distance = abs(arg1_match[0] - arg2_match[0])
                  distance_tuple += [(distance, arg1_match, arg2_match)]
          distance_tuple.sort()
  
          relation = [
              relation_type,
              arg1_type,
              get_index_tuple(distance_tuple[0][1]),
              arg2_type,
              get_index_tuple(distance_tuple[0][2]),
          ]
          if (
              self._map_config.de_duplicate
              and tuple(relation) in relation_list
          ):
              continue
          relation_list += [tuple(relation)]
  
      return relation_list
  
imports: from asyncio.log import logger
  import sys
  from typing import Tuple
  import numpy
  import logging
label_desc: Use image node_id 4 for calling the RelationRecord obj's underlying member method code with example usage: obj.record_to_offset_closest_role(instance, token_list) and returns: relation_list