code: def test_crf_log_likelihood(dtype):
      inputs = np.array(
          [[4, 5, -3], [3, -1, 3], [-1, 2, 1], [0, 0, 0]], dtype=dtype
      )
      transition_params = np.array(
          [[-3, 5, -2], [3, 4, 1], [1, 2, 1]], dtype=dtype
      )
      sequence_lengths = np.array(3, dtype=np.int32)
  
      num_words = inputs.shape[0]
      num_tags = inputs.shape[1]
      all_sequence_log_likelihoods = []
  
      # Make sure all probabilities sum to 1.
      for tag_indices in itertools.product(
          range(num_tags), repeat=sequence_lengths
      ):
          tag_indices = list(tag_indices)
          tag_indices.extend([0] * (num_words - sequence_lengths))
          sequence_log_likelihood, _ = crf_log_likelihood(
              inputs=tf.expand_dims(inputs, 0),
              tag_indices=tf.expand_dims(tag_indices, 0),
              sequence_lengths=tf.expand_dims(sequence_lengths, 0),
              transition_params=tf.constant(transition_params),
          )
          all_sequence_log_likelihoods.append(sequence_log_likelihood)
      total_log_likelihood = tf.reduce_logsumexp(
          all_sequence_log_likelihoods
      )
      np.testing.assert_allclose(
          total_log_likelihood, 0.0, rtol=1e-6, atol=1e-6
      )
  
      # check if `transition_params = None` raises an error
      crf_log_likelihood(
          inputs=tf.expand_dims(inputs, 0),
          tag_indices=tf.expand_dims(tag_indices, 0),
          sequence_lengths=tf.expand_dims(sequence_lengths, 0),
      )
  
file_path: rasa/tests/utils/tensorflow/test_crf.py
imports: import itertools
  import pytest
  import numpy
  import tensorflow
  from rasa.utils.tensorflow.crf import crf_sequence_score, crf_unary_score, crf_binary_score, crf_log_norm, crf_log_likelihood
label_desc: Use image node_id 8 for calling a global function with example usage: test_crf_log_likelihood(dtype) without return types