class_docstr: Helper functions to compute specgrams.
class_docstr_tok: ["Helper","functions","to","compute","specgrams","."]
docstr: Converts specgrams to stfts.
  
  Args:
    specgrams: Tensor of log magnitudes and instantaneous frequencies,
      shape [batch, time, freq, 2].
  
  Returns:
    stfts: Complex64 tensor of stft, shape [batch, time, freq, 1].
docstr_tok: ["Converts","specgrams","to","stfts",".","Args",":","specgrams",":","Tensor","of","log","magnitudes","and","instantaneous","frequencies",",","shape","[","batch",",","time",",","freq",",","2","]",".","Returns",":","stfts",":","Complex64","tensor","of","stft",",","shape","[","batch",",","time",",","freq",",","1","]","."]
code: def specgrams_to_stfts(self, specgrams):
      """Converts specgrams to stfts.
  
      Args:
        specgrams: Tensor of log magnitudes and instantaneous frequencies,
          shape [batch, time, freq, 2].
  
      Returns:
        stfts: Complex64 tensor of stft, shape [batch, time, freq, 1].
      """
      logmag = specgrams[:, :, :, 0]
      p = specgrams[:, :, :, 1]
  
      mag = tf.exp(logmag)
  
      if self._ifreq:
          phase_angle = tf.cumsum(p * np.pi, axis=-2)
      else:
          phase_angle = p * np.pi
  
      return spectral_ops.polar2rect(mag, phase_angle)[
          :, :, :, tf.newaxis
      ]
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  from magenta.models.gansynth.lib import spectral_ops
  import numpy
  import tensorflow.compat.v1
label_desc: Use image node_id 8 for calling the SpecgramsHelper obj's underlying member method code with example usage: obj.specgrams_to_stfts(specgrams) and returns: spectral_ops