code: def add_packet_loss_noise(
      wave_tensor, max_num_bursts, max_length_rate
  ):
      """Simulate burst packet loss noise deterministically to the input `wave_tensor`.
  
      Args:
        wave_tensor: The input waveform signals to add noise to.
        max_num_bursts: The number of burst losses to simulate.
        max_length_rate: The maximum ratio of each burst loss length to the input
          signal length. The ratio is uniformly sampled for each burst loss in range
          (0, max_rength_rate].
  
      Returns:
        Noise injected waveform signals.
      """
      positive_sum = tf.cast(
          tf.reduce_sum(tf.maximum(wave_tensor, 0)), tf.int32
      )
      negative_sum = tf.cast(
          tf.reduce_sum(tf.maximum(-wave_tensor, 0)), tf.int32
      )
  
      max_length = tf.cast(
          tf.round(
              tf.cast(tf.size(wave_tensor), tf.float32)
              * max_length_rate
          ),
          tf.int32,
      )
  
      mask_lengths = tf.random.stateless_uniform(
          [max_num_bursts],
          [positive_sum, negative_sum],
          1,
          max_length + 1,
          dtype=tf.int32,
      )
  
      mask_start_idxs = tf.math.floormod(
          tf.abs(
              tf.random.stateless_uniform(
                  [max_num_bursts],
                  [positive_sum + 1, negative_sum + 1],
                  None,
                  None,
                  dtype=tf.int32,
              )
          ),
          tf.size(wave_tensor) - mask_lengths,
      )
  
      mask_end_idxs = mask_start_idxs + mask_lengths
  
      timestamps = tf.repeat(
          tf.range(tf.size(wave_tensor))[None, :], max_num_bursts, 0
      )
  
      time_mask = tf.logical_and(
          tf.greater_equal(timestamps, mask_start_idxs[:, None]),
          tf.less(timestamps, mask_end_idxs[:, None]),
      )
      time_mask = tf.cast(tf.reduce_any(time_mask, 0), tf.float32)
  
      noised_wave_tensor = wave_tensor * (1 - time_mask)
  
      return noised_wave_tensor
  
imports: import functools
  from typing import Any, Dict, Optional, Sequence
  from absl import logging
  from dmvr import builders
  from dmvr import processors
  from dmvr import tokenizers
  import numpy
  from scenic.projects.mbt.datasets.dataset_utils import _decode_spectrogram
  from scenic.projects.mbt.datasets.dataset_utils import apply_specaugment
  import tensorflow
label_desc: Use image node_id 9 for calling a global function with example usage: add_packet_loss_noise(wave_tensor, max_num_bursts, max_length_rate) and returns: noised_wave_tensor