code: def time_warp(x, max_time_warp=80, inplace=False, mode="PIL"):
      """time warp for spec augment
  
      move random center frame by the random width ~ uniform(-window, window)
      :param numpy.ndarray x: spectrogram (time, freq)
      :param int max_time_warp: maximum time frames to warp
      :param bool inplace: overwrite x with the result
      :param str mode: "PIL" (default, fast, not differentiable) or "sparse_image_warp"
          (slow, differentiable)
      :returns numpy.ndarray: time warped spectrogram (time, freq)
      """
      from PIL import Image
      from PIL.Image import BICUBIC
  
      window = max_time_warp
      if mode == "PIL":
          t = x.shape[0]
          if t - window <= window:
              return x
          # NOTE: randrange(a, b) emits a, a + 1, ..., b - 1
          center = random.randrange(window, t - window)
          warped = (
              random.randrange(center - window, center + window) + 1
          )  # 1 ... t - 1
  
          left = Image.fromarray(x[:center]).resize(
              (x.shape[1], warped), BICUBIC
          )
          right = Image.fromarray(x[center:]).resize(
              (x.shape[1], t - warped), BICUBIC
          )
          if inplace and x.flags.writeable:
              x[:warped] = left
              x[warped:] = right
              return x
          return numpy.concatenate((left, right), 0)
      elif mode == "sparse_image_warp":
          import torch
  
          from espnet.utils import spec_augment
  
          # TODO(karita): make this differentiable again
          return spec_augment.time_warp(
              torch.from_numpy(x), window
          ).numpy()
      else:
          raise NotImplementedError(
              "unknown resize mode: "
              + mode
              + ", choose one from (PIL, sparse_image_warp)."
          )
  
file_path: espnet/espnet/transform/spec_augment.py
imports: import random
  import numpy
  from espnet.transform.functional import FuncTrans
label_desc: Use image node_id 1 for calling a global function with example usage: time_warp(x, max_time_warp, inplace, mode) and returns: numpy, x, x, spec_augment