#!/usr/bin/env python3# Copyright (c) Facebook, Inc. and its affiliates.## This source code is licensed under the MIT license found in the# LICENSE file in the root directory of this source tree.importtorchfromtypingimportList,Dictfrom.base_decoderimportBaseDecoderclassViterbiDecoder(BaseDecoder):defdecode(self,emissions:torch.FloatTensor,)->List[List[Dict[str,torch.LongTensor]]]:defget_pred(e):toks=e.argmax(dim=-1).unique_consecutive()returntoks[toks!=self.blank]return[[{"tokens":get_pred(x),"score":0}]forxinemissions]