code: def _apply_D_loss(scores_fake, scores_real, loss_func):
      """Compute D loss func and normalize loss values"""
      loss = 0
      real_loss = 0
      fake_loss = 0
      if isinstance(scores_fake, list):
          # multi-scale loss
          for score_fake, score_real in zip(scores_fake, scores_real):
              total_loss, real_loss, fake_loss = loss_func(
                  score_fake=score_fake, score_real=score_real
              )
              loss += total_loss
              real_loss += real_loss
              fake_loss += fake_loss
          # normalize loss values with number of scales
          loss /= len(scores_fake)
          real_loss /= len(scores_real)
          fake_loss /= len(scores_fake)
      else:
          # single scale loss
          total_loss, real_loss, fake_loss = loss_func(
              scores_fake, scores_real
          )
          loss = total_loss
      return loss, real_loss, fake_loss
  
imports: import torch
  from torch import nn
  from torch.nn import functional
label_desc: Use image node_id 2 for calling a global function with example usage: _apply_D_loss(scores_fake, scores_real, loss_func) and returns: loss,  real_loss,  fake_loss