code: def _get_scores(
      log_probs,
      sequence_lengths,
      length_penalty_weight,
      coverage_penalty_weight,
      finished,
      accumulated_attention_probs,
  ):
      """Calculates scores for beam search hypotheses.
  
      Args:
        log_probs: The log probabilities with shape
          `[batch_size, beam_width, vocab_size]`.
        sequence_lengths: The array of sequence lengths.
        length_penalty_weight: Float weight to penalize length. Disabled with
          0.0.
        coverage_penalty_weight: Float weight to penalize the coverage of source
          sentence. Disabled with 0.0.
        finished: A boolean tensor of shape `[batch_size, beam_width]` that
          specifies which elements in the beam are finished already.
        accumulated_attention_probs: Accumulated attention probabilities up to
          the current time step, with shape `[batch_size, beam_width, max_time]`
          if coverage_penalty_weight is not 0.0.
  
      Returns:
        The scores normalized by the length_penalty and coverage_penalty.
  
      Raises:
        ValueError: accumulated_attention_probs is None when coverage penalty is
          enabled.
      """
      length_penalty_ = _length_penalty(
          sequence_lengths=sequence_lengths,
          penalty_factor=length_penalty_weight,
      )
      length_penalty_ = tf.cast(length_penalty_, dtype=log_probs.dtype)
      scores = log_probs / length_penalty_
  
      coverage_penalty_weight = tf.convert_to_tensor(
          coverage_penalty_weight, name="coverage_penalty_weight"
      )
      if coverage_penalty_weight.shape.ndims != 0:
          raise ValueError(
              "coverage_penalty_weight should be a scalar, "
              "but saw shape: %s" % coverage_penalty_weight.shape
          )
  
      if tf.get_static_value(coverage_penalty_weight) == 0.0:
          return scores
  
      if accumulated_attention_probs is None:
          raise ValueError(
              "accumulated_attention_probs can be None only if coverage penalty "
              "is disabled."
          )
  
      # Add source sequence length mask before computing coverage penalty.
      accumulated_attention_probs = tf.where(
          tf.equal(accumulated_attention_probs, 0.0),
          tf.ones_like(accumulated_attention_probs),
          accumulated_attention_probs,
      )
  
      # coverage penalty =
      #     sum over `max_time` {log(min(accumulated_attention_probs, 1.0))}
      coverage_penalty = tf.reduce_sum(
          tf.math.log(tf.minimum(accumulated_attention_probs, 1.0)), 2
      )
      # Apply coverage penalty to finished predictions.
      coverage_penalty *= tf.cast(finished, tf.float32)
      weighted_coverage_penalty = (
          coverage_penalty * coverage_penalty_weight
      )
      # Reshape from [batch_size, beam_width] to [batch_size, beam_width, 1]
      weighted_coverage_penalty = tf.expand_dims(
          weighted_coverage_penalty, 2
      )
      return scores + weighted_coverage_penalty
  
imports: import collections
  import numpy
  import tensorflow
  from tensorflow_addons import options
  from tensorflow_addons.seq2seq import attention_wrapper
  from tensorflow_addons.seq2seq import decoder
  from tensorflow_addons.utils import keras_utils
  from tensorflow_addons.utils.resource_loader import LazySO
  from tensorflow_addons.utils.types import FloatTensorLike, TensorLike, Number
  from typeguard import typechecked
  from typing import Callable, Optional
label_desc: Use image node_id 12 for calling a global function with example usage: _get_scores(log_probs, sequence_lengths, length_penalty_weight, coverage_penalty_weight, finished, accumulated_attention_probs) and returns: unknown, scores