code: def _check_static_batch_beam_maybe(shape, batch_size, beam_width):
      """Raises an exception if dimensions are known statically and can not be
      reshaped to [batch_size, beam_size, -1]."""
      reshaped_shape = tf.TensorShape([batch_size, beam_width, None])
      assert len(shape.dims) > 0
      if batch_size is None or shape[0] is None:
          return True  # not statically known => no check
      if shape[0] == batch_size * beam_width:
          return True  # flattened, matching
      has_second_dim = shape.ndims >= 2 and shape[1] is not None
      if (
          has_second_dim
          and shape[0] == batch_size
          and shape[1] == beam_width
      ):
          return True  # non-flattened, matching
      # Otherwise we could not find a match and warn:
      tf.get_logger().warn(
          "TensorArray reordering expects elements to be "
          "reshapable to %s which is incompatible with the "
          "current shape %s. Consider setting "
          "reorder_tensor_arrays to False to disable TensorArray "
          "reordering during the beam search." % (reshaped_shape, shape)
      )
      return False
  
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 7 for calling a global function with example usage: _check_static_batch_beam_maybe(shape, batch_size, beam_width) and returns: False, True, True, True