def get_activation(act):
    """Return activation function."""
    # Lazy load to avoid unused import
    from modules.wenet_extractor.transformer.swish import Swish

    activation_funcs = {
        "hardtanh": torch.nn.Hardtanh,
        "tanh": torch.nn.Tanh,
        "relu": torch.nn.ReLU,
        "selu": torch.nn.SELU,
        "swish": getattr(torch.nn, "SiLU", Swish),
        "gelu": torch.nn.GELU,
    }

    return activation_funcs[act]()
Return activation function.
modules/wenet_extractor/utils/common.py