code: def testSetFinal(self):
      with self.test_session():
          sequences = np.arange(40, dtype=np.float32).reshape(4, 5, 2)
          lengths = np.array([0, 1, 2, 5])
          final_values = np.arange(40, 48, dtype=np.float32).reshape(
              4, 2
          )
          expected_result = sequences.copy()
          for i, l in enumerate(lengths):
              expected_result[i, l:] = 0.0
              expected_result[i, max(0, l - 1)] = final_values[i]
          expected_result[
              range(4), np.maximum(0, lengths - 1)
          ] = final_values
  
          self.assertAllEqual(
              expected_result,
              lstm_utils.set_final(
                  sequences, lengths, final_values, time_major=False
              ).eval(),
          )
  
          self.assertAllEqual(
              np.transpose(expected_result, [1, 0, 2]),
              lstm_utils.set_final(
                  np.transpose(sequences, [1, 0, 2]),
                  lengths,
                  final_values,
                  time_major=True,
              ).eval(),
          )
  
file_path: magenta/magenta/models/music_vae/lstm_utils_test.py
imports: from magenta.models.music_vae import lstm_utils
  import numpy
  import tensorflow.compat.v1
label_desc: Use image node_id 2 for calling the LstmUtilsTest obj's underlying member method code with example usage: obj.testSetFinal() without return types