docstr: Forward computations from the mixture to the separated signals.
docstr_tok: ["Forward","computations","from","the","mixture","to","the","separated","signals","."]
code: def compute_forward(self, mix, targets, stage, noise=None):
      """Forward computations from the mixture to the separated signals."""
  
      # Unpack lists and put tensors in the right device
      mix, mix_lens = mix
      mix, mix_lens = mix.to(self.device), mix_lens.to(self.device)
  
      # Convert targets to tensor
      targets = torch.cat(
          [
              targets[i][0].unsqueeze(-1)
              for i in range(self.hparams.num_spks)
          ],
          dim=-1,
      ).to(self.device)
  
      # Add speech distortions
      if stage == sb.Stage.TRAIN:
          with torch.no_grad():
              if (
                  self.hparams.use_speedperturb
                  or self.hparams.use_rand_shift
              ):
                  mix, targets = self.add_speed_perturb(
                      targets, mix_lens
                  )
  
                  if "whamr" in self.hparams.data_folder:
                      try:
                          targets_rev = [
                              self.hparams.reverb(
                                  targets[:, :, i], None
                              )
                              for i in range(self.hparams.num_spks)
                          ]
                      except Exception:
                          print("reverb error, not adding reverb")
                          targets_rev = [
                              targets[:, :, i]
                              for i in range(self.hparams.num_spks)
                          ]
  
                      targets_rev = torch.stack(targets_rev, dim=-1)
                      mix = targets_rev.sum(-1)
  
                      # if we do not dereverberate, we set the targets to be reverberant
                      if not self.hparams.dereverberate:
                          targets = targets_rev
                  else:
                      mix = targets.sum(-1)
  
                  noise = noise.to(self.device)
                  len_noise = noise.shape[1]
                  len_mix = mix.shape[1]
                  min_len = min(len_noise, len_mix)
  
                  # add the noise
                  mix = mix[:, :min_len] + noise[:, :min_len]
  
                  # fix the length of targets also
                  targets = targets[:, :min_len, :]
  
              if self.hparams.use_wavedrop:
                  mix = self.hparams.drop_chunk(mix, mix_lens)
                  mix = self.hparams.drop_freq(mix)
  
              if self.hparams.limit_training_signal_len:
                  mix, targets = self.cut_signals(mix, targets)
  
      # Separation
      if self.use_freq_domain:
          mix_w = self.compute_feats(mix)
          est_mask = self.modules.masknet(mix_w)
  
          sep_h = mix_w * est_mask
          est_source = self.hparams.resynth(torch.expm1(sep_h), mix)
      else:
          mix_w = self.hparams.Encoder(mix)
          est_mask = self.modules.masknet(mix_w)
  
          mix_w = torch.stack([mix_w] * self.hparams.num_spks)
          sep_h = mix_w * est_mask
          est_source = torch.cat(
              [
                  self.hparams.Decoder(sep_h[i]).unsqueeze(-1)
                  for i in range(self.hparams.num_spks)
              ],
              dim=-1,
          )
  
      # T changed after conv1d in encoder, fix it here
      T_origin = mix.size(1)
      T_est = est_source.size(1)
      est_source = est_source.squeeze(-1)
      if T_origin > T_est:
          est_source = F.pad(est_source, (0, T_origin - T_est))
      else:
          est_source = est_source[:, :T_origin]
  
      return [est_source, sep_h], targets.squeeze(-1)
  
imports: import os
  import sys
  import torch
  import torch.nn.functional
  import torchaudio
  import speechbrain
  import speechbrain.nnet.schedulers
  from speechbrain.utils.distributed import run_on_main
  from hyperpyyaml import load_hyperpyyaml
  import numpy
  from tqdm import tqdm
  import csv
  import logging
  from speechbrain.processing.features import spectral_magnitude
  from speechbrain.utils.metric_stats import MetricStats
  from pesq import pesq
  from speechbrain.core import AMPConfig
label_desc: Use image node_id 1 for calling the Separation obj's underlying member method code with example usage: obj.compute_forward(mix, targets, stage, noise) and returns: list,  targets