(self, feats, tags)
return feat_score + start_score + trans_score + stop_score
Parameters:
            feats: Input features [batch size, sequence length, number of tags]
            tags: Target tag indices [batch size, sequence length]. Should be between
                    0 and num_tags
        Returns: Sequence score of shape [batch size]
Parameters:
            feats: Input features [batch size, sequence length, number of tags]
            tags: Target tag indices [batch size, sequence length]. Should be between
                    0 and num_tags
        Returns: Sequence score of shape [batch size]
Parameters : feats : Input features [ batch size sequence length number of tags ] tags : Target tag indices [ batch size sequence length ] . Should be between 0 and num_tags Returns : Sequence score of shape [ batch size ]
def _sequence_score(self, feats, tags):
        """
        Parameters:
            feats: Input features [batch size, sequence length, number of tags]
            tags: Target tag indices [batch size, sequence length]. Should be between
                    0 and num_tags
        Returns: Sequence score of shape [batch size]
        """

        batch_size = feats.shape[0]

        # Compute feature scores
        feat_score = feats.gather(2, tags.unsqueeze(-1)).squeeze(-1).sum(dim=-1)

        # Compute transition scores
        # Unfold to get [from, to] tag index pairs
        tags_pairs = tags.unfold(1, 2, 1)

        # Use advanced indexing to pull out required transition scores
        indices = tags_pairs.permute(2, 0, 1).chunk(2)
        trans_score = self.transitions[indices].squeeze(0).sum(dim=-1)

        # Compute start and stop scores
        start_score = self.start_transitions[tags[:, 0]]
        stop_score = self.stop_transitions[tags[:, -1]]

        return feat_score + start_score + trans_score + stop_score
def _sequence_score ( self , feats , tags ) : batch_size = feats . shape [ 0 ] # Compute feature scores feat_score = feats . gather ( 2 , tags . unsqueeze ( - 1 ) ) . squeeze ( - 1 ) . sum ( dim = - 1 ) # Compute transition scores # Unfold to get [from, to] tag index pairs tags_pairs = tags . unfold ( 1 , 2 , 1 ) # Use advanced indexing to pull out required transition scores indices = tags_pairs . permute ( 2 , 0 , 1 ) . chunk ( 2 ) trans_score = self . transitions [ indices ] . squeeze ( 0 ) . sum ( dim = - 1 ) # Compute start and stop scores start_score = self . start_transitions [ tags [ : , 0 ] ] stop_score = self . stop_transitions [ tags [ : , - 1 ] ] return feat_score + start_score + trans_score + stop_score