code: def _measure(
      measure_len_ws: int,
      samples: Tensor,
      spectrum: Tensor,
      noise_spectrum: Tensor,
      spectrum_window: Tensor,
      spectrum_start: int,
      spectrum_end: int,
      cepstrum_window: Tensor,
      cepstrum_start: int,
      cepstrum_end: int,
      noise_reduction_amount: float,
      measure_smooth_time_mult: float,
      noise_up_time_mult: Tensor,
      noise_down_time_mult: Tensor,
      boot_count: int,
  ) -> float:
      device = samples.device
  
      if spectrum.size(-1) != noise_spectrum.size(-1):
          raise ValueError(
              "Expected spectrum size to match noise spectrum size in final dimension."
              f"Found: spectrum size: {spectrum.size()}, noise_spectrum size: {noise_spectrum.size()}"
          )
  
      dft_len_ws = spectrum.size()[-1]
  
      dftBuf = torch.zeros(dft_len_ws, device=device)
  
      dftBuf[:measure_len_ws] = (
          samples * spectrum_window[:measure_len_ws]
      )
  
      # lsx_safe_rdft((int)p->dft_len_ws, 1, c->dftBuf);
      _dftBuf = torch.fft.rfft(dftBuf)
  
      mult: float = (
          boot_count / (1.0 + boot_count)
          if boot_count >= 0
          else measure_smooth_time_mult
      )
  
      _d = _dftBuf[spectrum_start:spectrum_end].abs()
      spectrum[spectrum_start:spectrum_end].mul_(mult).add_(
          _d * (1 - mult)
      )
      _d = spectrum[spectrum_start:spectrum_end] ** 2
  
      _zeros = torch.zeros(spectrum_end - spectrum_start, device=device)
      _mult = (
          _zeros
          if boot_count >= 0
          else torch.where(
              _d > noise_spectrum[spectrum_start:spectrum_end],
              noise_up_time_mult,  # if
              noise_down_time_mult,  # else,
          )
      )
  
      noise_spectrum[spectrum_start:spectrum_end].mul_(_mult).add_(
          _d * (1 - _mult)
      )
      _d = torch.sqrt(
          torch.max(
              _zeros,
              _d
              - noise_reduction_amount
              * noise_spectrum[spectrum_start:spectrum_end],
          ),
      )
  
      _cepstrum_Buf: Tensor = torch.zeros(
          dft_len_ws >> 1, device=device
      )
      _cepstrum_Buf[spectrum_start:spectrum_end] = _d * cepstrum_window
      _cepstrum_Buf[spectrum_end : dft_len_ws >> 1].zero_()
  
      # lsx_safe_rdft((int)p->dft_len_ws >> 1, 1, c->dftBuf);
      _cepstrum_Buf = torch.fft.rfft(_cepstrum_Buf)
  
      result: float = float(
          torch.sum(
              _cepstrum_Buf[cepstrum_start:cepstrum_end].abs().pow(2)
          )
      )
      result = (
          math.log(result / (cepstrum_end - cepstrum_start))
          if result > 0
          else -math.inf
      )
      return max(0, 21 + result)
  
imports: import math
  import warnings
  from typing import Optional
  import torch
  from torch import Tensor
  from torchaudio._extension import _IS_TORCHAUDIO_EXT_AVAILABLE
label_desc: Use image node_id 29 for calling a global function with example usage: _measure(measure_len_ws, samples, spectrum, noise_spectrum, spectrum_window, spectrum_start, spectrum_end, cepstrum_window, cepstrum_start, cepstrum_end, noise_reduction_amount, measure_smooth_time_mult, noise_up_time_mult, noise_down_time_mult, boot_count) and returns: max