def forward(self, inputs, encoder_word_pos, gsrm_word_pos):
    (b, c, h, w) = inputs.shape
    conv_features = torch.reshape(inputs, shape=((- 1), c, (h * w)))
    conv_features = conv_features.permute(0, 2, 1)
    (b, t, c) = conv_features.shape
    enc_inputs = [conv_features, encoder_word_pos, None]
    word_features = self.wrap_encoder_for_feature(enc_inputs)
    (b, t, c) = word_features.shape
    word_features = self.fc0(word_features)
    word_features_ = torch.reshape(word_features, ((- 1), 1, t, c))
    word_features_ = torch.tile(word_features_, (1, self.max_length, 1, 1))
    word_pos_feature = self.emb(gsrm_word_pos)
    word_pos_feature_ = torch.reshape(word_pos_feature, ((- 1), self.max_length, 1, c))
    word_pos_feature_ = torch.tile(word_pos_feature_, (1, 1, t, 1))
    y = (word_pos_feature_ + word_features_)
    y = F.tanh(y)
    attention_weight = self.fc1(y)
    attention_weight = torch.reshape(attention_weight, shape=((- 1), self.max_length, t))
    attention_weight = F.softmax(attention_weight, dim=(- 1))
    pvam_features = torch.bmm(attention_weight, word_features)
    return pvam_features
def forward(self, inputs, encoder_word_pos, gsrm_word_pos):
    (b, c, h, w) = inputs.shape
    conv_features = torch.reshape(inputs, shape=((- 1), c, (h * w)))
    conv_features = conv_features.permute(0, 2, 1)
    (b, t, c) = conv_features.shape
    enc_inputs = [conv_features, encoder_word_pos, None]
    word_features = self.wrap_encoder_for_feature(enc_inputs)
    (b, t, c) = word_features.shape
    word_features = self.fc0(word_features)
    word_features_ = torch.reshape(word_features, ((- 1), 1, t, c))
    word_features_ = torch.tile(word_features_, (1, self.max_length, 1, 1))
    word_pos_feature = self.emb(gsrm_word_pos)
    word_pos_feature_ = torch.reshape(word_pos_feature, ((- 1), self.max_length, 1, c))
    word_pos_feature_ = torch.tile(word_pos_feature_, (1, 1, t, 1))
    y = (word_pos_feature_ + word_features_)
    y = F.tanh(y)
    attention_weight = self.fc1(y)
    attention_weight = torch.reshape(attention_weight, shape=((- 1), self.max_length, t))
    attention_weight = F.softmax(attention_weight, dim=(- 1))
    pvam_features = torch.bmm(attention_weight, word_features)
    return pvam_features