code: def pitch_shift(
      spectrogram: tf.Tensor,
      semitone_shift: float = 0.0,
      method: tf.image.ResizeMethod = tf.image.ResizeMethod.BILINEAR,
  ) -> tf.Tensor:
      """
      Pitch shift a spectrogram preserving shape in tensorflow. Note that
      this is an approximation in the frequency domain.
  
      Parameters:
          spectrogram (tf.Tensor):
              Input spectrogram to be pitch shifted as tensor.
          semitone_shift (float):
              (Optional) Pitch shift in semitone, default to `0.0`.
          method (tf.image.ResizeMethod):
              (Optional) Interpolation method, default to `BILINEAR`.
  
      Returns:
          tf.Tensor:
              Pitch shifted spectrogram (same shape as spectrogram).
      """
      factor = 2 ** (semitone_shift / 12.0)
      T = tf.shape(spectrogram)[0]
      F = tf.shape(spectrogram)[1]
      F_ps = tf.cast(tf.cast(F, tf.float32) * factor, tf.int32)[0]
      ps_spec = tf.image.resize_images(
          spectrogram, [T, F_ps], method=method, align_corners=True
      )
      paddings = [[0, 0], [0, tf.maximum(0, F - F_ps)], [0, 0]]
      return tf.pad(ps_spec[:, :F, :], paddings, "CONSTANT")
  
imports: import tensorflow
  from tensorflow.signal import hann_window, stft
label_desc: Use image node_id 4 for calling a global function with example usage: pitch_shift(spectrogram, semitone_shift, method) and returns: tf