code: def unwrap(p, discont=np.pi, axis=-1):
      """Unwrap a cyclical phase tensor.
  
      Args:
        p: Phase tensor.
        discont: Float, size of the cyclic discontinuity.
        axis: Axis of which to unwrap.
  
      Returns:
        unwrapped: Unwrapped tensor of same size as input.
      """
      dd = diff(p, axis=axis)
      ddmod = tf.mod(dd + np.pi, 2.0 * np.pi) - np.pi
      idx = tf.logical_and(tf.equal(ddmod, -np.pi), tf.greater(dd, 0))
      ddmod = tf.where(idx, tf.ones_like(ddmod) * np.pi, ddmod)
      ph_correct = ddmod - dd
      idx = tf.less(tf.abs(dd), discont)
      ddmod = tf.where(idx, tf.zeros_like(ddmod), dd)
      ph_cumsum = tf.cumsum(ph_correct, axis=axis)
  
      shape = p.get_shape().as_list()
      shape[axis] = 1
      ph_cumsum = tf.concat(
          [tf.zeros(shape, dtype=p.dtype), ph_cumsum], axis=axis
      )
      unwrapped = p + ph_cumsum
      return unwrapped
  
file_path: magenta/magenta/models/gansynth/lib/spectral_ops.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import numpy
  import tensorflow.compat.v1
label_desc: Use image node_id 5 for calling a global function with example usage: unwrap(p, discont, axis) and returns: unwrapped