code: def crf_binary_score(
      tag_indices: TensorLike,
      sequence_lengths: TensorLike,
      transition_params: TensorLike,
  ) -> tf.Tensor:
      """Computes the binary scores of tag sequences.
  
      Args:
        tag_indices: A [batch_size, max_seq_len] matrix of tag indices.
        sequence_lengths: A [batch_size] vector of true sequence lengths.
        transition_params: A [num_tags, num_tags] matrix of binary potentials.
      Returns:
        binary_scores: A [batch_size] vector of binary scores.
      """
      tag_indices = tf.cast(tag_indices, dtype=tf.int32)
      sequence_lengths = tf.cast(sequence_lengths, dtype=tf.int32)
  
      num_tags = tf.shape(transition_params)[0]
      num_transitions = tf.shape(tag_indices)[1] - 1
  
      # Truncate by one on each side of the sequence to get the start and end
      # indices of each transition.
      start_tag_indices = tf.slice(
          tag_indices, [0, 0], [-1, num_transitions]
      )
      end_tag_indices = tf.slice(
          tag_indices, [0, 1], [-1, num_transitions]
      )
  
      # Encode the indices in a flattened representation.
      flattened_transition_indices = (
          start_tag_indices * num_tags + end_tag_indices
      )
      flattened_transition_params = tf.reshape(transition_params, [-1])
  
      # Get the binary scores based on the flattened representation.
      binary_scores = tf.gather(
          flattened_transition_params, flattened_transition_indices
      )
  
      masks = tf.sequence_mask(
          sequence_lengths,
          maxlen=tf.shape(tag_indices)[1],
          dtype=binary_scores.dtype,
      )
      truncated_masks = tf.slice(masks, [0, 1], [-1, -1])
      binary_scores = tf.reduce_sum(binary_scores * truncated_masks, 1)
      return binary_scores
  
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 7 for calling a global function with example usage: crf_binary_score(tag_indices, sequence_lengths, transition_params) and returns: binary_scores