code: def test_shape_inference(self):
      if context.executing_eagerly():
          return
      signal = array_ops.zeros((1, 1), dtype=dtypes.int32)
      frame_length = 2
      frame_step = 1
      # Shape inference is able to detect the rank and inner-most dimension
      # if frame_length is known at graph definition time.
      result = shape_ops.frame(
          signal, frame_length, frame_step, pad_end=True, pad_value=99
      )
      self.assertEqual([1, 1, 2], result.shape.as_list())
  
      result = shape_ops.frame(
          signal, frame_length, frame_step, pad_end=False
      )
      self.assertEqual([1, 0, 2], result.shape.as_list())
  
      # If frame_length is not known, rank and (known) outer and inner dimensions
      # are inferred.
      signal = array_ops.zeros([1, 2, 3, 4], dtype=dtypes.int32)
      frame_length = array_ops.placeholder_with_default(
          ops.convert_to_tensor(0, dtypes.int32), shape=[]
      )
      frame_step = 1
      result = shape_ops.frame(
          signal,
          frame_length,
          frame_step,
          pad_end=True,
          pad_value=99,
          axis=1,
      )
      self.assertEqual([1, 2, None, 3, 4], result.shape.as_list())
  
      result = shape_ops.frame(
          signal, frame_length, frame_step, pad_end=False, axis=1
      )
      self.assertEqual([1, None, None, 3, 4], result.shape.as_list())
  
      # If frame_length and inner-most dimension is known, rank, inner dimensions,
      # and known outer dimensions are inferred.
      signal = array_ops.placeholder_with_default(
          array_ops.zeros((0, 5, 0, 20, 5, 3), dtype=dtypes.int32),
          shape=[None, 5, None, 20, 5, 3],
      )
      frame_length = 4
      frame_step = 3
      result = shape_ops.frame(
          signal,
          frame_length,
          frame_step,
          pad_end=True,
          pad_value=99,
          axis=3,
      )
      self.assertEqual(
          [None, 5, None, 7, 4, 5, 3], result.shape.as_list()
      )
  
      result = shape_ops.frame(
          signal, frame_length, frame_step, pad_end=False, axis=3
      )
      self.assertEqual(
          [None, 5, None, 6, 4, 5, 3], result.shape.as_list()
      )
  
      # Test that shape inference is consistent with actual returned shapes for
      # small values of signal_length, frame_length, frame_step, and pad_end in
      # [True, False].
      frame_step = 1
      for signal_length in range(2):
          signal = [0] * signal_length
          for frame_length in range(2):
              for pad_end in [False, True]:
                  op = shape_ops.frame(
                      signal,
                      frame_length,
                      frame_step,
                      pad_end=pad_end,
                      pad_value=99,
                  )
                  result = self.evaluate(op)
                  self.assertEqual(
                      op.shape.as_list(), list(result.shape)
                  )
  
imports: import numpy
  from tensorflow.python.eager import context
  from tensorflow.python.framework import constant_op
  from tensorflow.python.framework import dtypes
  from tensorflow.python.framework import ops
  from tensorflow.python.framework import tensor_shape
  from tensorflow.python.framework import test_util
  from tensorflow.python.kernel_tests.signal import test_util
  from tensorflow.python.ops import array_ops
  from tensorflow.python.ops import math_ops
  from tensorflow.python.ops.signal import shape_ops
  from tensorflow.python.platform import test
label_desc: Use image node_id 5 for calling the FrameTest obj's underlying member method code with example usage: obj.test_shape_inference() without return types