code: def get_attention_probs(next_cell_state, coverage_penalty_weight):
      """Get attention probabilities from the cell state.
  
      Args:
        next_cell_state: The next state from the cell, e.g. an instance of
          AttentionWrapperState if the cell is attentional.
        coverage_penalty_weight: Float weight to penalize the coverage of source
          sentence. Disabled with 0.0.
  
      Returns:
        The attention probabilities with shape
          `[batch_size, beam_width, max_time]` if coverage penalty is enabled.
          Otherwise, returns None.
  
      Raises:
        ValueError: If no cell is attentional but coverage penalty is enabled.
      """
      if coverage_penalty_weight == 0.0:
          return None
  
      # Attention probabilities of each attention layer. Each with shape
      # `[batch_size, beam_width, max_time]`.
      probs_per_attn_layer = []
      if isinstance(
          next_cell_state, attention_wrapper.AttentionWrapperState
      ):
          probs_per_attn_layer = [
              attention_probs_from_attn_state(next_cell_state)
          ]
      elif isinstance(next_cell_state, tuple):
          for state in next_cell_state:
              if isinstance(
                  state, attention_wrapper.AttentionWrapperState
              ):
                  probs_per_attn_layer.append(
                      attention_probs_from_attn_state(state)
                  )
  
      if not probs_per_attn_layer:
          raise ValueError(
              "coverage_penalty_weight must be 0.0 if no cell is attentional."
          )
  
      if len(probs_per_attn_layer) == 1:
          attention_probs = probs_per_attn_layer[0]
      else:
          # Calculate the average attention probabilities from all attention
          # layers.
          attention_probs = [
              tf.expand_dims(prob, -1) for prob in probs_per_attn_layer
          ]
          attention_probs = tf.concat(attention_probs, -1)
          attention_probs = tf.reduce_mean(attention_probs, -1)
  
      return attention_probs
  
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 11 for calling a global function with example usage: get_attention_probs(next_cell_state, coverage_penalty_weight) and returns: attention_probs, None