code: def print_attention_text(attention_matrix: np.ndarray, source_tokens: List[str], target_tokens: List[str],
                           threshold: float):
      
      sys.stdout.write("  ")
      for _ in target_tokens:
          sys.stdout.write("---")
      sys.stdout.write("\n")
      for i, f_i in enumerate(source_tokens):  # type: ignore
          sys.stdout.write(" |")
          for j in range(len(target_tokens)):
              align_prob = attention_matrix[j, i]
              if align_prob > threshold:
                  sys.stdout.write("(*)")
              elif align_prob > 0.4:
                  sys.stdout.write("(?)")
              else:
                  sys.stdout.write("   ")
          sys.stdout.write(" | %s\n" % f_i)
      sys.stdout.write("  ")
      for _ in target_tokens:
          sys.stdout.write("---")
      sys.stdout.write("\n")
      for k in range(max(map(len, target_tokens))):
          sys.stdout.write("  ")
          for word in target_tokens:
              letter = word[k] if len(word) > k else " "
              sys.stdout.write(" %s " % letter)
          sys.stdout.write("\n")
      sys.stdout.write("\n")
docs: Prints the attention matrix to standard out.
  
      :param attention_matrix: The attention matrix.
      :param source_tokens: A list of source tokens.
      :param target_tokens: A list of target tokens.
      :param threshold: The threshold for including an alignment link in the result.