def forward(self, inputs, gsrm_word_pos, gsrm_slf_attn_bias1, gsrm_slf_attn_bias2):
    (b, t, c) = inputs.shape
    pvam_features = torch.reshape(inputs, ((- 1), c))
    word_out = self.fc0(pvam_features)
    word_ids = torch.argmax(F.softmax(word_out), dim=1)
    word_ids = torch.reshape(word_ids, shape=((- 1), t, 1))
    '\n        This module is achieved through bi-transformers,\n        ngram_feature1 is the froward one, ngram_fetaure2 is the backward one\n        '
    pad_idx = self.char_num
    word1 = word_ids.float()
    pad1 = nn.ConstantPad1d((1, 0), value=(1.0 * pad_idx))
    word1 = pad1(word1.permute(0, 2, 1)).permute(0, 2, 1)
    word1 = word1.long()
    word1 = word1[:, :(- 1), :]
    word2 = word_ids
    enc_inputs_1 = [word1, gsrm_word_pos, gsrm_slf_attn_bias1]
    enc_inputs_2 = [word2, gsrm_word_pos, gsrm_slf_attn_bias2]
    gsrm_feature1 = self.wrap_encoder0(enc_inputs_1)
    gsrm_feature2 = self.wrap_encoder1(enc_inputs_2)
    pad = nn.ConstantPad1d((0, 1), value=0.0)
    gsrm_feature2 = pad(gsrm_feature2.permute(0, 2, 1)).permute(0, 2, 1)
    gsrm_feature2 = gsrm_feature2[:, 1:]
    gsrm_features = (gsrm_feature1 + gsrm_feature2)
    gsrm_out = self.mul(gsrm_features)
    (b, t, c) = gsrm_out.shape
    gsrm_out = torch.reshape(gsrm_out, ((- 1), c))
    return (gsrm_features, word_out, gsrm_out)
def forward(self, inputs, gsrm_word_pos, gsrm_slf_attn_bias1, gsrm_slf_attn_bias2):
    (b, t, c) = inputs.shape
    pvam_features = torch.reshape(inputs, ((- 1), c))
    word_out = self.fc0(pvam_features)
    word_ids = torch.argmax(F.softmax(word_out), dim=1)
    word_ids = torch.reshape(word_ids, shape=((- 1), t, 1))
    '\n        This module is achieved through bi-transformers,\n        ngram_feature1 is the froward one, ngram_fetaure2 is the backward one\n        '
    pad_idx = self.char_num
    word1 = word_ids.float()
    pad1 = nn.ConstantPad1d((1, 0), value=(1.0 * pad_idx))
    word1 = pad1(word1.permute(0, 2, 1)).permute(0, 2, 1)
    word1 = word1.long()
    word1 = word1[:, :(- 1), :]
    word2 = word_ids
    enc_inputs_1 = [word1, gsrm_word_pos, gsrm_slf_attn_bias1]
    enc_inputs_2 = [word2, gsrm_word_pos, gsrm_slf_attn_bias2]
    gsrm_feature1 = self.wrap_encoder0(enc_inputs_1)
    gsrm_feature2 = self.wrap_encoder1(enc_inputs_2)
    pad = nn.ConstantPad1d((0, 1), value=0.0)
    gsrm_feature2 = pad(gsrm_feature2.permute(0, 2, 1)).permute(0, 2, 1)
    gsrm_feature2 = gsrm_feature2[:, 1:]
    gsrm_features = (gsrm_feature1 + gsrm_feature2)
    gsrm_out = self.mul(gsrm_features)
    (b, t, c) = gsrm_out.shape
    gsrm_out = torch.reshape(gsrm_out, ((- 1), c))
    return (gsrm_features, word_out, gsrm_out)