游雁
2023-02-14 1d4ab65c8bfebaecbcb0eec0064bae9a321cad75
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
from abc import ABC
from abc import abstractmethod
from typing import Tuple
 
import torch
 
from funasr.modules.scorers.scorer_interface import BatchScorerInterface
 
 
class AbsPunctuation(torch.nn.Module, BatchScorerInterface, ABC):
    """The abstract class
 
    To share the loss calculation way among different models,
    We uses delegate pattern here:
    The instance of this class should be passed to "LanguageModel"
 
    >>> from funasr.punctuation.abs_model import AbsPunctuation
    >>> punc = AbsPunctuation()
    >>> model = ESPnetPunctuationModel(punc=punc)
 
    This "model" is one of mediator objects for "Task" class.
 
    """
 
    @abstractmethod
    def forward(self, input: torch.Tensor, hidden: torch.Tensor) -> Tuple[torch.Tensor, torch.Tensor]:
        raise NotImplementedError