class_docstr: Generator loss function from OASIS paper.
  
  This applies a spatially-distributed non-saturating GAN generator loss.
  Effectively, it takes a spatially-varying target map and calculates the
  crossentropy over the targets.
  
  This loss was introduced in the following paper:
  
  You Only Need Adversarial Supervision for Semantic Image Synthesis
  Vadim Sushko, Edgar Schönfeld, Dan Zhang, Juergen Gall, Bernt Schiele,
  Anna Khoreva
class_docstr_tok: ["Generator","loss","function","from","OASIS","paper",".","This","applies","a","spatially-distributed","non-saturating","GAN","generator","loss",".","Effectively",",","it","takes","a","spatially-varying","target","map","and","calculates","the","crossentropy","over","the","targets",".","This","loss","was","introduced","in","the","following","paper",":","You","Only","Need","Adversarial","Supervision","for","Semantic","Image","Synthesis","Vadim","Sushko",",","Edgar","Sch\u00f6nfeld",",","Dan","Zhang",",","Juergen","Gall",",","Bernt","Schiele",",","Anna","Khoreva"]
docstr: Calculate OASIS discriminator loss.
  
  Args:
      logits: The 4-D map of logits for the variables. The dimensions are
          expected to be ``(batch, num_classes+1, ny, nx).
      target: A 3-D map of spatially-varying ground truth labels.
  
  Returns:
      The OASIS generator loss value.
docstr_tok: ["Calculate","OASIS","discriminator","loss",".","Args",":","logits",":","The","4-D","map","of","logits","for","the","variables",".","The","dimensions","are","expected","to","be","``","(","batch",",","num_classes+1",",","ny",",","nx",")",".","target",":","A","3-D","map","of","spatially-varying","ground","truth","labels",".","Returns",":","The","OASIS","generator","loss","value","."]
code: def __call__(self, logits: Tensor, target: Tensor) -> Tensor:
      """
      Calculate OASIS discriminator loss.
  
      Args:
          logits: The 4-D map of logits for the variables. The dimensions are
              expected to be ``(batch, num_classes+1, ny, nx).
          target: A 3-D map of spatially-varying ground truth labels.
  
      Returns:
          The OASIS generator loss value.
      """
      _verify_logit_target_shape(logits, target)
      if target.dtype != torch.long:
          raise ValueError("Expected target to have dtype torch.long.")
  
      batch_size, num_classes, _, _ = logits.shape
  
      target = target.view(batch_size, -1)
      return F.cross_entropy(
          logits.view(batch_size, num_classes, -1), target + 1
      )
  
file_path: NeuralCompression/neuralcompression/loss_fn/_oasis_loss.py
imports: import torch
  import torch.nn.functional
  from torch import Tensor
  from ._gan_losses import DiscriminatorLoss, GeneratorLoss
label_desc: Use image node_id 1 for calling the OASISGeneratorLoss obj's underlying member method code with example usage: obj.__call__(logits, target) and returns: F