def noisereduce_audio(
    audio: Union[torch.Tensor, str, bytes],
    input_sr: int = None,
    output_sr: int = None,
    model=None,
    device: str = "cuda",
    verbose: bool = True,
    save_path: Optional[Union[str, callable]] = None,
    **noisereduce_options
) -> torch.Tensor:
    """
    Remove noise from ``audio`` with noisereduce.

    For list of options, see repo: https://github.com/timsainb/noisereduce.
    """
    if model is None:
        model = load_noisereduce_model()
    if noisereduce_options.get("sr", input_sr) != input_sr:
        raise ValueError('Specified conflicting ``input_sr`` and ``sr``.')
    if isinstance(audio, (str, bytes)):
        audio = torch.from_numpy(load_audio(audio, model.samplerate))
        input_sr = model.samplerate
    elif input_sr != model.samplerate:
        if input_sr is None:
            raise ValueError('No ``input_sr`` specified for audio tensor.')
        audio = resample(audio, input_sr, model.samplerate)
    audio_dims = audio.dim()
    assert audio_dims <= 2
    if dims_missing := 2 - audio_dims:
        audio = audio[[None]*dims_missing]
    if audio.shape[-2] == 1:
        audio = audio.repeat_interleave(2, -2)

    noisereduce_options.pop('progress', None)  # not implemented
    denoised_audio = model(audio=audio, device=device, **noisereduce_options).nan_to_num().mean(dim=0)

    if 'cuda' in str(device):
        torch.cuda.empty_cache()

    if output_sr is not None and input_sr != output_sr:
        denoised_audio = resample(denoised_audio, input_sr, output_sr)

    if save_path is not None:
        if isinstance(save_path, str):
            from .output import save_audio_tensor
            save_audio_tensor(denoised_audio, save_path, output_sr or input_sr, verbose=verbose)
        else:
            save_path(denoised_audio, output_sr)

    return denoised_audio

    Remove noise from ``audio`` with noisereduce.

    For list of options, see repo: https://github.com/timsainb/noisereduce.
    
stable_whisper/audio/noisereduce.py