class_docstr: Class with Conditional Random Field from PyTorch-CRF library
  with modified training function
code: def forward(self, tags_batch: torch.LongTensor, y_masks: np.ndarray):
      seq_lengths = np.sum(y_masks, axis=1)
      for seq_len, tags_list in zip(seq_lengths, tags_batch):
          if seq_len > 1:
              for i in range(seq_len - 1):
                  self.stats[int(tags_list[i])][
                      int(tags_list[i + 1])
                  ] += 1.0
      with torch.no_grad():
          self.transitions.copy_(
              torch.where(self.stats > 0, self.zeros, self.neg)
          )
  
imports: import numpy
  import torch
  from torch import nn
  from torchcrf import CRF
label_desc: Use image node_id 2 for calling the CRF obj's underlying member method code with example usage: obj.forward(tags_batch, y_masks) without return types