code: def d1_loss(d_outputs, reduction="mean"):
      """Calculates the loss of the discriminator when the inputs are clean"""
      output = 0.5 * ((d_outputs - 1) ** 2)
      if reduction == "mean":
          return output.mean()
      elif reduction == "batch":
          return output.view(output.size(0), -1).mean(1)
  
file_path: speechbrain/speechbrain/lobes/models/segan_model.py
imports: import torch
  import torch.nn
  import torch.utils.data
  import torch.nn.functional
  from math import floor
label_desc: Use image node_id 1 for calling a global function with example usage: d1_loss(d_outputs, reduction) and returns: output, output