mtp/machamp/models/sentence_decoder.py
def make_output_human_readable(
        self, predictions: torch.Tensor
    ) -> Dict[str, torch.Tensor]:
        """
        Does a simple argmax over the probabilities, converts index to string label, and
        add `"label"` key to the dictionary with the result.
        """
        if predictions.dim() == 2:
            predictions_list = [predictions[i] for i in range(predictions.shape[0])]
        else:
            predictions_list = [predictions]
        classes = []
        for prediction in predictions_list:
            label_idx = prediction.argmax(dim=-1).item()
            label_str = self.vocab.get_index_to_token_vocabulary(self.task).get(
                label_idx, str(label_idx)
            )
            classes.append(label_str)
        return classes

        Does a simple argmax over the probabilities, converts index to string label, and
        add `"label"` key to the dictionary with the result.
        
Does a simple argmax over the probabilities, converts index to string label, and
add `"label"` key to the dictionary with the result.
Does a simple argmax over the probabilities converts index to string label and add ` " label " ` key to the dictionary with the result .
def make_output_human_readable(
        self, predictions: torch.Tensor
    ) -> Dict[str, torch.Tensor]:
        if predictions.dim() == 2:
            predictions_list = [predictions[i] for i in range(predictions.shape[0])]
        else:
            predictions_list = [predictions]
        classes = []
        for prediction in predictions_list:
            label_idx = prediction.argmax(dim=-1).item()
            label_str = self.vocab.get_index_to_token_vocabulary(self.task).get(
                label_idx, str(label_idx)
            )
            classes.append(label_str)
        return classes
def make_output_human_readable ( self , predictions : torch . Tensor ) -> Dict [ str , torch . Tensor ] : if predictions . dim ( ) == 2 : predictions_list = [ predictions [ i ] for i in range ( predictions . shape [ 0 ] ) ] else : predictions_list = [ predictions ] classes = [ ] for prediction in predictions_list : label_idx = prediction . argmax ( dim = - 1 ) . item ( ) label_str = self . vocab . get_index_to_token_vocabulary ( self . task ) . get ( label_idx , str ( label_idx ) ) classes . append ( label_str ) return classes
Does a simple argmax over the probabilities, converts index to string label, and
add `"label"` key to the dictionary with the result.
Does a simple argmax over the probabilities converts index to string label and add ` " label " ` key to the dictionary with the result .
"""
        Does a simple argmax over the probabilities, converts index to string label, and
        add `"label"` key to the dictionary with the result.
        """
self
predictions
torch.Tensor