code: def test_get_vis_data_from_string(self):
      visualizer = visualization.AttentionVisualizer(
          hparams_set,
          model_name,
          self.data_dir,
          problem_name,
          beam_size=8,
      )
  
      input_sentence = "I have two dogs."
      with self.test_session() as sess:
          sess.run(tf.global_variables_initializer())
          (
              _,
              inp_text,
              out_text,
              att_mats,
          ) = visualizer.get_vis_data_from_string(sess, input_sentence)
  
      self.assertAllEqual(
          ["I_", "have_", "two_", "dogs_", "._", "<EOS>"], inp_text
      )
  
      hparams = trainer_lib.create_hparams(
          hparams_set, data_dir=self.data_dir, problem_name=problem_name
      )
  
      enc_atts, dec_atts, encdec_atts = att_mats
  
      self.assertAllEqual(hparams.num_hidden_layers, len(enc_atts))
  
      enc_atts = enc_atts[0]
      dec_atts = dec_atts[0]
      encdec_atts = encdec_atts[0]
  
      batch_size = 1
      num_heads = hparams.num_heads
      inp_len = len(inp_text)
      out_len = len(out_text)
  
      self.assertAllEqual(
          (batch_size, num_heads, inp_len, inp_len), enc_atts.shape
      )
      self.assertAllEqual(
          (batch_size, num_heads, out_len, out_len), dec_atts.shape
      )
      self.assertAllEqual(
          (batch_size, num_heads, out_len, inp_len), encdec_atts.shape
      )
  
file_path: tensor2tensor/tensor2tensor/visualization/visualization_test.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import os
  from tensor2tensor.utils import trainer_lib
  from tensor2tensor.visualization import visualization
  import tensorflow.compat.v1
label_desc: Use image node_id 4 for calling the VisualizationTest obj's underlying member method code with example usage: obj.test_get_vis_data_from_string() without return types