code: def test_viterbi_with_allowed_transitions(self):
      scores = np.array(
          [[10.0, 12.0, 6.0, 4.0], [13.0, 12.0, 11.0, 10.0]]
      )
      # pyformat: disable
      # pylint: disable=bad-whitespace
      # pylint: disable=bad-continuation
      transition_params = np.array(
          [
              [-1.0, 1.0, -2.0, 2.0],
              [3.0, -3.0, 4.0, -4.0],
              [5.0, 100.0, 10.0, 200.0],
              [-7.0, 7.0, -8.0, 8.0],
          ]
      )
  
      allowed_transitions = np.array(
          [
              [True, True, True, True],
              [True, True, True, True],
              [True, False, True, False],
              [True, True, True, True],
          ]
      )
      # pyformat: enable
      # pylint: enable=bad-whitespace
      # pylint: enable=bad-continuation
  
      # STEP 1:
      #   Starting scores are {10.0, 12.0, 6.0, 4.0}
      #   Raw scores are: {13.0, 12.0, 11.0, 10.0}
      #
      # Final state 0: (13.0) Weighted scores are {12.0, 16.0, 18.0, 6.0}
      #      New totals are {22, 28, 24, 10} [max 28 from 1]
      #
      # Final state 1: (12.0) Weighted scores are {13.0, 9.0, X, 19.0},
      #      New totals are {23, 21, X, 23} [max 23 from 3]
      #
      # Final state 2: (11.0) Weighted scores are {9, 15, 21, 3},
      #      New totals are {19, 27, 27, 7} [max 27 from 2]
      #
      # Final state 3: (10.0) Weighted scores are {12, 6, X, 18},
      #      New totals are {19, 18, X, 22} [max 22 from 3]
      #
      #   Top scores are [28, 26, 27, 25] from [1, 3, 2, 3].
      #   Final state is [0] with a sequence of [1->0].
  
      sequence, score = viterbi_decode.decode(
          scores, transition_params, allowed_transitions
      )
      self.assertAlmostEqual(28.0, score)
      self.assertEqual([1, 0], sequence)
  
file_path: text/tensorflow_text/python/numpy/viterbi_decode_test.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  from absl.testing import absltest
  import numpy
  from tensorflow_text.python.numpy import viterbi_decode
label_desc: Use image node_id 2 for calling the ViterbiDecodeTest obj's underlying member method code with example usage: obj.test_viterbi_with_allowed_transitions() without return types