code: def to_word_align(
      src,
      tgt,
      subword_align,
      subword_align_scores,
      m_src="joiner",
      m_tgt="joiner",
  ):
      """Convert subword alignment to word alignment.
  
      Args:
          src (string): tokenized sentence in source language.
          tgt (string): tokenized sentence in target language.
          subword_align (string): align_pharaoh correspond to src-tgt.
          m_src (string): tokenization mode used in src,
              can be ["joiner", "spacer"].
          m_tgt (string): tokenization mode used in tgt,
              can be ["joiner", "spacer"].
  
      Returns:
          word_align (string): converted alignments correspand to
              detokenized src-tgt.
      """
      assert m_src in [
          "joiner",
          "spacer",
      ], "Invalid value for argument m_src!"
      assert m_tgt in [
          "joiner",
          "spacer",
      ], "Invalid value for argument m_tgt!"
  
      src, tgt = src.strip().split(), tgt.strip().split()
      subword_align = {
          (int(a), int(b))
          for a, b in (x.split("-") for x in subword_align.split())
      }
  
      subword_align_scores = dict(
          (int(a), float(b))
          for a, b in (
              x.split("-") for x in subword_align_scores.split()
          )
      )
  
      src_map = (
          subword_map_by_spacer(src)
          if m_src == "spacer"
          else subword_map_by_joiner(src)
      )
  
      tgt_map = (
          subword_map_by_spacer(tgt)
          if m_tgt == "spacer"
          else subword_map_by_joiner(tgt)
      )
  
      word_align = list(
          {
              "{}-{}".format(src_map[a], tgt_map[b])
              for a, b in subword_align
          }
      )
  
      word_align_scores = list(
          {
              "{}-{}".format(tgt_map[a], subword_align_scores[a])
              for a in subword_align_scores.keys()
          }
      )
  
      word_align.sort(
          key=lambda x: int(x.split("-")[-1])
      )  # sort by tgt_id
      word_align.sort(
          key=lambda x: int(x.split("-")[0])
      )  # sort by src_id
  
      word_align_scores.sort(key=lambda x: int(x.split("-")[0]))
  
      return " ".join(word_align), " ".join(word_align_scores)
  
file_path: OpenNMT-py/onmt/utils/alignment.py
imports: import torch
  from itertools import accumulate
  from onmt.constants import SubwordMarker
label_desc: Use image node_id 4 for calling a global function with example usage: to_word_align(src, tgt, subword_align, subword_align_scores, m_src, m_tgt) and returns: str,  str