code: def __init__(
      self, cfg: SpeechUnitLmCriterionConfig, task: FairseqTask
  ):
      super().__init__(task)
      self.sentence_avg = cfg.sentence_avg
      self.weights = torch.tensor(
          [float(w) for w in cfg.loss_weights.split(";")]
      )
      assert self.weights.size(0) == 3
      assert (self.weights >= 0.0).all()
  
      self.dur_loss_fn = nll_loss if cfg.discrete_duration else mae_loss
      self.f0_loss_fn = nll_loss if cfg.discrete_f0 else mae_loss
  
file_path: fairseq/fairseq/criterions/speech_ulm_criterion.py
imports: import torch
  from dataclasses import dataclass, field
  import torch.nn.functional
  from fairseq.logging import metrics
  from fairseq.tasks import FairseqTask
  from fairseq.criterions import FairseqCriterion, register_criterion
  from fairseq.dataclass import FairseqDataclass
  from omegaconf import II
label_desc: Use image node_id 1 to create a new SpeechUnitLmCriterion object from inherited base classes: FairseqCriterion with example: obj = SpeechUnitLmCriterion(cfg, task)