@torch.no_grad()
def sub_band_crm_mask(self, noisy, inference_args):
    pad_mode = inference_args['pad_mode']
    n_neighbor = inference_args['n_neighbor']
    noisy = noisy.cpu().numpy().reshape((- 1))
    noisy_D = self.librosa_stft(noisy)
    noisy_real = torch.tensor(noisy_D.real, device=self.device)
    noisy_imag = torch.tensor(noisy_D.imag, device=self.device)
    noisy_mag = torch.sqrt((torch.square(noisy_real) + torch.square(noisy_imag)))
    (n_freqs, n_frames) = noisy_mag.size()
    noisy_mag = noisy_mag.reshape(1, 1, n_freqs, n_frames)
    noisy_mag_padded = self._unfold(noisy_mag, pad_mode, n_neighbor)
    noisy_mag_padded = noisy_mag_padded.squeeze(0).squeeze(1)
    pred_crm = self.model(noisy_mag_padded).detach()
    pred_crm = pred_crm.permute(0, 2, 1).contiguous()
    lim = 9.99
    pred_crm = (((lim * (pred_crm >= lim)) - (lim * (pred_crm <= (- lim)))) + (pred_crm * (torch.abs(pred_crm) < lim)))
    pred_crm = ((- 10) * torch.log(((10 - pred_crm) / (10 + pred_crm))))
    enhanced_real = ((pred_crm[:, :, 0] * noisy_real) - (pred_crm[:, :, 1] * noisy_imag))
    enhanced_imag = ((pred_crm[:, :, 1] * noisy_real) + (pred_crm[:, :, 0] * noisy_imag))
    enhanced_real = enhanced_real.cpu().numpy()
    enhanced_imag = enhanced_imag.cpu().numpy()
    enhanced = self.librosa_istft((enhanced_real + (1j * enhanced_imag)), length=len(noisy))
    return enhanced
@torch.no_grad()
def sub_band_crm_mask(self, noisy, inference_args):
    pad_mode = inference_args['pad_mode']
    n_neighbor = inference_args['n_neighbor']
    noisy = noisy.cpu().numpy().reshape((- 1))
    noisy_D = self.librosa_stft(noisy)
    noisy_real = torch.tensor(noisy_D.real, device=self.device)
    noisy_imag = torch.tensor(noisy_D.imag, device=self.device)
    noisy_mag = torch.sqrt((torch.square(noisy_real) + torch.square(noisy_imag)))
    (n_freqs, n_frames) = noisy_mag.size()
    noisy_mag = noisy_mag.reshape(1, 1, n_freqs, n_frames)
    noisy_mag_padded = self._unfold(noisy_mag, pad_mode, n_neighbor)
    noisy_mag_padded = noisy_mag_padded.squeeze(0).squeeze(1)
    pred_crm = self.model(noisy_mag_padded).detach()
    pred_crm = pred_crm.permute(0, 2, 1).contiguous()
    lim = 9.99
    pred_crm = (((lim * (pred_crm >= lim)) - (lim * (pred_crm <= (- lim)))) + (pred_crm * (torch.abs(pred_crm) < lim)))
    pred_crm = ((- 10) * torch.log(((10 - pred_crm) / (10 + pred_crm))))
    enhanced_real = ((pred_crm[:, :, 0] * noisy_real) - (pred_crm[:, :, 1] * noisy_imag))
    enhanced_imag = ((pred_crm[:, :, 1] * noisy_real) + (pred_crm[:, :, 0] * noisy_imag))
    enhanced_real = enhanced_real.cpu().numpy()
    enhanced_imag = enhanced_imag.cpu().numpy()
    enhanced = self.librosa_istft((enhanced_real + (1j * enhanced_imag)), length=len(noisy))
    return enhanced