code: def apply_specaugment(spec: tf.Tensor, spec_augment_params=None):
      """Performs SpecAugment on the inputs.
  
      SpecAugment is a data augmentation technique from arXiv:1904.08779,
      that combines three transformations:
       - a time warping of up to max(time_warp_max_frames,
       time_warp_max_ratio*input_length) frames.
       - a masking of sampled frequencies with zeros along the entire time axis
       (freq_mask)
       - a masking of sampled timesteps with zeros along the entire frequency axis
       (time_mask)
  
      Args:
        spec: input mel spectrogram of shape [num_clips, time, freq, num_channels]
          or [time, freq, num_channels].
        spec_augment_params: dictionary containing the following -
          freq_mask_max_bins (int), max number of consecutive mel bins to mask in a
          band. - freq_mask_count (int), number of frequency bands to mask. -
          time_mask_max_frames (int), max number of consecutive time frames to mask.
          - time_mask_count (int), number of time bands to mask. -
          time_mask_max_ratio (float), max time mask ratio. - time_warp_max_frames
          (int), max numer of time frames to warp. - time_warp_max_ratio (int), max
          ratio of the time warp.
  
      Returns:
        Augmented mel spectrogram of shape (num_time_bins, num_freq_bins, channels)
        or
          (num_clips, num_time_bins, num_freq_bins, channels).
      """
      spec_augment_params_obj = (
          spectrum_augmenter.SpectrumAugmenter.Params()
      )
      spec_augment_params_obj.freq_mask_max_bins = (
          spec_augment_params.freq_mask_max_bins
      )
      spec_augment_params_obj.freq_mask_count = (
          spec_augment_params.freq_mask_count
      )
      spec_augment_params_obj.time_mask_max_frames = (
          spec_augment_params.time_mask_max_frames
      )
      spec_augment_params_obj.time_mask_count = (
          spec_augment_params.time_mask_count
      )
      spec_augment_params_obj.time_warp_max_frames = (
          spec_augment_params.time_warp_max_frames
      )
      spec_augment_params_obj.time_warp_max_ratio = (
          spec_augment_params.time_warp_max_ratio
      )
      spec_augment_params_obj.time_mask_max_ratio = (
          spec_augment_params.time_mask_max_ratio
      )
      spec_augment_params_obj.name = "specaugment"
      spec_augment_layer = spec_augment_params_obj.Instantiate()
  
      squeeze_axis = []
      if spec.shape.ndims == 3:
          spec = spec[None, :, :, :]
          squeeze_axis = [0]
      elif spec.shape.ndims != 4:
          raise ValueError(
              "Spectrogram shape must have 3 or 4 dimensions"
          )
  
      outputs, _ = spec_augment_layer.FPropDefaultTheta(
          spec, tf.zeros(tf.shape(spec)[:2])
      )
      if squeeze_axis:
          outputs = tf.squeeze(outputs, axis=squeeze_axis)
      return outputs
  
imports: from absl import logging
  from dmvr import builders
  from dmvr import processors
  from lingvo.core import spectrum_augmenter
  import tensorflow
label_desc: Use image node_id 1 for calling a global function with example usage: apply_specaugment(spec, spec_augment_params) and returns: outputs