def forward(self, x, encoder_out=None, encoder_padding_mask=None, bert_encoder_out=None, bert_encoder_padding_mask=None, incremental_state=None, prev_self_attn_state=None, prev_attn_state=None, self_attn_mask=None, self_attn_padding_mask=None):
    '\n        Args:\n            x (Tensor): input to the layer of shape `(seq_len, batch, embed_dim)`\n            encoder_padding_mask (ByteTensor): binary ByteTensor of shape\n                `(batch, src_len)` where padding elements are indicated by ``1``.\n\n        Returns:\n            encoded output of shape `(batch, src_len, embed_dim)`\n        '
    residual = x
    x = self.maybe_layer_norm(self.self_attn_layer_norm, x, before=True)
    if (prev_self_attn_state is not None):
        if (incremental_state is None):
            incremental_state = {}
        (prev_key, prev_value) = prev_self_attn_state
        saved_state = {'prev_key': prev_key, 'prev_value': prev_value}
        self.self_attn._set_input_buffer(incremental_state, saved_state)
    (x, attn) = self.self_attn(query=x, key=x, value=x, key_padding_mask=self_attn_padding_mask, incremental_state=incremental_state, need_weights=False, attn_mask=self_attn_mask)
    x = F.dropout(x, p=self.dropout, training=self.training)
    x = (residual + x)
    x = self.maybe_layer_norm(self.self_attn_layer_norm, x, after=True)
    if (self.encoder_attn is not None):
        residual = x
        x = self.maybe_layer_norm(self.encoder_attn_layer_norm, x, before=True)
        if (prev_attn_state is not None):
            if (incremental_state is None):
                incremental_state = {}
            (prev_key, prev_value) = prev_attn_state
            saved_state = {'prev_key': prev_key, 'prev_value': prev_value}
            self.encoder_attn._set_input_buffer(incremental_state, saved_state)
        (x1, attn) = self.encoder_attn(query=x, key=encoder_out, value=encoder_out, key_padding_mask=encoder_padding_mask, incremental_state=incremental_state, static_kv=True, need_weights=((not self.training) and self.need_attn))
        (x2, _) = self.bert_attn(query=x, key=bert_encoder_out, value=bert_encoder_out, key_padding_mask=bert_encoder_padding_mask, incremental_state=incremental_state, static_kv=True, need_weights=((not self.training) and self.need_attn))
        x1 = F.dropout(x1, p=self.dropout, training=self.training)
        x2 = F.dropout(x2, p=self.dropout, training=self.training)
        ratios = self.get_ratio()
        x = ((residual + (ratios[0] * x1)) + (ratios[1] * x2))
        x = self.maybe_layer_norm(self.encoder_attn_layer_norm, x, after=True)
    residual = x
    x = self.maybe_layer_norm(self.final_layer_norm, x, before=True)
    x = self.activation_fn(self.fc1(x))
    x = F.dropout(x, p=self.activation_dropout, training=self.training)
    x = self.fc2(x)
    x = F.dropout(x, p=self.dropout, training=self.training)
    x = (residual + x)
    x = self.maybe_layer_norm(self.final_layer_norm, x, after=True)
    if (self.onnx_trace and (incremental_state is not None)):
        saved_state = self.self_attn._get_input_buffer(incremental_state)
        self_attn_state = (saved_state['prev_key'], saved_state['prev_value'])
        return (x, attn, self_attn_state)
    return (x, attn)
Args:
    x (Tensor): input to the layer of shape `(seq_len, batch, embed_dim)`
    encoder_padding_mask (ByteTensor): binary ByteTensor of shape
        `(batch, src_len)` where padding elements are indicated by ``1``.

Returns:
    encoded output of shape `(batch, src_len, embed_dim)`
def forward(self, x, encoder_out=None, encoder_padding_mask=None, bert_encoder_out=None, bert_encoder_padding_mask=None, incremental_state=None, prev_self_attn_state=None, prev_attn_state=None, self_attn_mask=None, self_attn_padding_mask=None):
    '\n        Args:\n            x (Tensor): input to the layer of shape `(seq_len, batch, embed_dim)`\n            encoder_padding_mask (ByteTensor): binary ByteTensor of shape\n                `(batch, src_len)` where padding elements are indicated by ``1``.\n\n        Returns:\n            encoded output of shape `(batch, src_len, embed_dim)`\n        '
    residual = x
    x = self.maybe_layer_norm(self.self_attn_layer_norm, x, before=True)
    if (prev_self_attn_state is not None):
        if (incremental_state is None):
            incremental_state = {}
        (prev_key, prev_value) = prev_self_attn_state
        saved_state = {'prev_key': prev_key, 'prev_value': prev_value}
        self.self_attn._set_input_buffer(incremental_state, saved_state)
    (x, attn) = self.self_attn(query=x, key=x, value=x, key_padding_mask=self_attn_padding_mask, incremental_state=incremental_state, need_weights=False, attn_mask=self_attn_mask)
    x = F.dropout(x, p=self.dropout, training=self.training)
    x = (residual + x)
    x = self.maybe_layer_norm(self.self_attn_layer_norm, x, after=True)
    if (self.encoder_attn is not None):
        residual = x
        x = self.maybe_layer_norm(self.encoder_attn_layer_norm, x, before=True)
        if (prev_attn_state is not None):
            if (incremental_state is None):
                incremental_state = {}
            (prev_key, prev_value) = prev_attn_state
            saved_state = {'prev_key': prev_key, 'prev_value': prev_value}
            self.encoder_attn._set_input_buffer(incremental_state, saved_state)
        (x1, attn) = self.encoder_attn(query=x, key=encoder_out, value=encoder_out, key_padding_mask=encoder_padding_mask, incremental_state=incremental_state, static_kv=True, need_weights=((not self.training) and self.need_attn))
        (x2, _) = self.bert_attn(query=x, key=bert_encoder_out, value=bert_encoder_out, key_padding_mask=bert_encoder_padding_mask, incremental_state=incremental_state, static_kv=True, need_weights=((not self.training) and self.need_attn))
        x1 = F.dropout(x1, p=self.dropout, training=self.training)
        x2 = F.dropout(x2, p=self.dropout, training=self.training)
        ratios = self.get_ratio()
        x = ((residual + (ratios[0] * x1)) + (ratios[1] * x2))
        x = self.maybe_layer_norm(self.encoder_attn_layer_norm, x, after=True)
    residual = x
    x = self.maybe_layer_norm(self.final_layer_norm, x, before=True)
    x = self.activation_fn(self.fc1(x))
    x = F.dropout(x, p=self.activation_dropout, training=self.training)
    x = self.fc2(x)
    x = F.dropout(x, p=self.dropout, training=self.training)
    x = (residual + x)
    x = self.maybe_layer_norm(self.final_layer_norm, x, after=True)
    if (self.onnx_trace and (incremental_state is not None)):
        saved_state = self.self_attn._get_input_buffer(incremental_state)
        self_attn_state = (saved_state['prev_key'], saved_state['prev_value'])
        return (x, attn, self_attn_state)
    return (x, attn)