docstr: Test that spectral_ops.stft has a working gradient.
docstr_tok: ["Test","that","spectral_ops.stft","has","a","working","gradient","."]
code: def test_gradients(self):
      """Test that spectral_ops.stft has a working gradient."""
      # TODO(rjryan): Update gradient tests for Eager.
      if context.executing_eagerly():
          return
      with self.session() as sess:
          signal_length = 512
  
          # An all-zero signal has all zero gradients with respect to the sum of the
          # magnitude STFT.
          empty_signal = array_ops.zeros(
              [signal_length], dtype=dtypes.float32
          )
          empty_signal_gradient = sess.run(
              self._compute_stft_gradient(empty_signal)
          )
          self.assertTrue((empty_signal_gradient == 0.0).all())
  
          # A sinusoid will have non-zero components of its gradient with respect to
          # the sum of the magnitude STFT.
          sinusoid = math_ops.sin(
              2 * np.pi * math_ops.linspace(0.0, 1.0, signal_length)
          )
          sinusoid_gradient = self.evaluate(
              self._compute_stft_gradient(sinusoid)
          )
          self.assertFalse((sinusoid_gradient == 0.0).all())
  
imports: import itertools
  from absl.testing import parameterized
  import numpy
  from tensorflow.python.eager import context
  from tensorflow.python.framework import dtypes
  from tensorflow.python.framework import test_util
  from tensorflow.python.ops import array_ops
  from tensorflow.python.ops import gradient_checker_v2
  from tensorflow.python.ops import gradients_impl
  from tensorflow.python.ops import math_ops
  from tensorflow.python.ops.signal import spectral_ops
  from tensorflow.python.ops.signal import window_ops
  from tensorflow.python.platform import test
label_desc: Use image node_id 13 for calling the SpectralOpsTest obj's underlying member method code with example usage: obj.test_gradients() without return types