class_docstr: This module uses the "forward-backward" algorithm to compute
  the log-likelihood of its inputs assuming a conditional random field model.
  
  See, e.g. http://www.cs.columbia.edu/~mcollins/fb.pdf
  
  This is a weighted version of `ConditionalRandomField` which accepts a `label_weights`
  parameter to be used in the loss function in order to give different weights for each
  token depending on its label. The method implemented here is based on the paper
  *Weighted conditional random fields for supervised interpatient heartbeat
  classification* proposed by De Lannoy et. al (2019).
  See https://perso.uclouvain.be/michel.verleysen/papers/ieeetbe12gdl.pdf for more details.
  
  There are two other sample weighting methods implemented. You can find more details
  about them in: https://eraldoluis.github.io/2022/05/10/weighted-crf.html
  
  # Parameters
  
  num_tags : `int`, required
      The number of tags.
  label_weights : `List[float]`, required
      A list of weights to be used in the loss function in order to
      give different weights for each token depending on its label.
      `len(label_weights)` must be equal to `num_tags`. This is useful to
      deal with highly unbalanced datasets. The method implemented here was based on
      the paper *Weighted conditional random fields for supervised interpatient heartbeat
      classification* proposed by De Lannoy et. al (2019).
      See https://perso.uclouvain.be/michel.verleysen/papers/ieeetbe12gdl.pdf
  constraints : `List[Tuple[int, int]]`, optional (default = `None`)
      An optional list of allowed transitions (from_tag_id, to_tag_id).
      These are applied to `viterbi_tags()` but do not affect `forward()`.
      These should be derived from `allowed_transitions` so that the
      start and end transitions are handled correctly for your tag type.
  include_start_end_transitions : `bool`, optional (default = `True`)
      Whether to include the start and end transition parameters.
code: def __init__(
      self,
      num_tags: int,
      label_weights: List[float],
      constraints: List[Tuple[int, int]] = None,
      include_start_end_transitions: bool = True,
  ) -> None:
      super().__init__(
          num_tags, constraints, include_start_end_transitions
      )
  
      if label_weights is None:
          raise ConfigurationError("label_weights must be given")
  
      self.register_buffer("label_weights", torch.Tensor(label_weights))
  
file_path: allennlp/allennlp/modules/conditional_random_field/conditional_random_field_wlannoy.py
imports: from typing import List, Tuple
  import torch
  from allennlp.common.checks import ConfigurationError
  from allennlp.modules.conditional_random_field.conditional_random_field import ConditionalRandomField
label_desc: Use image node_id 1 to create a new ConditionalRandomFieldWeightLannoy object from inherited base classes: ConditionalRandomField with example: obj = ConditionalRandomFieldWeightLannoy(num_tags, label_weights, constraints, include_start_end_transitions)