class_docstr: Margin-based loss which requires a gold structure Y to score at least
  `cost(Y, Y')` above a hypothesis structure `Y'`. The cost function used is
  variable, but should reflect the underlying semantics of the task (e.g.,
  BLEU in machine translation).
class_docstr_tok: ["Margin-based","loss","which","requires","a","gold","structure","Y","to","score","at","least","`","cost","(","Y",",","Y","'",")","`","above","a","hypothesis","structure","`","Y","'","`",".","The","cost","function","used","is","variable",",","but","should","reflect","the","underlying","semantics","of","the","task","(","e.g.",",","BLEU","in","machine","translation",")","."]
code: def __init__(self, config, ignore_index=1, *args, **kwargs):
      super().__init__(config, ignore_index)
  
      self.cost_scale = config.cost_scale
      self.cost_fn = get_cost_fn(config.cost_fn)
  
      self.label_loss_fn = create_loss(
          config.label_loss, ignore_index=ignore_index
      )
  
file_path: pytext/pytext/loss/structured_loss.py
imports: from enum import Enum
  from typing import Union
  import torch
  import torch.nn.functional
  from pytext.config import ConfigBase
  from pytext.config.component import create_loss
  from .loss import HingeLoss, Loss, NLLLoss
label_desc: Use image node_id 1 to create a new StructuredMarginLoss object from inherited base classes: StructuredLoss with example: obj = StructuredMarginLoss(config, ignore_index)