class_docstr: Joint loss over labels and length of sequences for non-autoregressive modeling.
code: def __init__(self, config, ignore_index=1):
      self.beta = config.beta
      self.assert_valid_targets = config.assert_valid_targets
      self.label_type = config.label_type
      self.length_type = config.length_type
  
      # We can't use a structured loss for optimizing lengths.
      if isinstance(config.length_loss.label_loss, StructuredLoss):
          raise ValueError(
              "StructuredLoss can't be used as a length loss"
          )
  
      self.label_loss_fn = create_loss(
          config.label_loss, ignore_index=ignore_index
      )
      self.length_loss_fn = create_loss(
          config.length_loss, ignore_index=ignore_index
      )
      self.disable_label_loss = config.disable_label_loss
  
imports: from typing import Union
  import torch
  from pytext.config import ConfigBase
  from pytext.config.component import create_loss
  from .loss import HingeLoss, Loss, maybe_log_normalize, NLLLoss, SourceType
  from .regularizer import AdaptiveRegularizer, EntropyRegularizer, UniformRegularizer
  from .structured_loss import StructuredLoss, StructuredMarginLoss
label_desc: Use image node_id 1 to create a new NARSequenceLoss object from inherited base classes: Loss with example: obj = NARSequenceLoss(config, ignore_index)