code: def crf_log_likelihood(
      inputs: TensorLike,
      tag_indices: TensorLike,
      sequence_lengths: TensorLike,
      transition_params: Optional[TensorLike] = None,
  ) -> Tuple[tf.Tensor, tf.Tensor]:
      """Computes the log-likelihood of tag sequences in a CRF.
  
      Args:
        inputs: A [batch_size, max_seq_len, num_tags] tensor of unary potentials
            to use as input to the CRF layer.
        tag_indices: A [batch_size, max_seq_len] matrix of tag indices for which
            we compute the log-likelihood.
        sequence_lengths: A [batch_size] vector of true sequence lengths.
        transition_params: A [num_tags, num_tags] transition matrix,
            if available.
      Returns:
        log_likelihood: A [batch_size] `Tensor` containing the log-likelihood of
          each example, given the sequence of tag indices.
        transition_params: A [num_tags, num_tags] transition matrix. This is
            either provided by the caller or created in this function.
      """
      inputs = tf.convert_to_tensor(inputs)
  
      num_tags = inputs.shape[2]
  
      # cast type to handle different types
      tag_indices = tf.cast(tag_indices, dtype=tf.int32)
      sequence_lengths = tf.cast(sequence_lengths, dtype=tf.int32)
  
      # TODO(windqaq): re-evaluate if `transition_params` can be `None`.
      if transition_params is None:
          initializer = tf.keras.initializers.GlorotUniform()
          transition_params = tf.Variable(
              initializer([num_tags, num_tags]), "transitions"
          )
      transition_params = tf.cast(transition_params, inputs.dtype)
      sequence_scores = crf_sequence_score(
          inputs, tag_indices, sequence_lengths, transition_params
      )
      log_norm = crf_log_norm(
          inputs, sequence_lengths, transition_params
      )
  
      # Normalize the scores to get the log-likelihood per example.
      log_likelihood = sequence_scores - log_norm
      return log_likelihood, transition_params
  
imports: import warnings
  import numpy
  import tensorflow
  from tensorflow_addons.rnn.abstract_rnn_cell import AbstractRNNCell
  from tensorflow_addons.utils.types import TensorLike
  from typeguard import typechecked
  from typing import Optional, Tuple
label_desc: Use image node_id 5 for calling a global function with example usage: crf_log_likelihood(inputs, tag_indices, sequence_lengths, transition_params) and returns: log_likelihood,  transition_params