def mask(self, src_tokens, x):
    x = x.transpose(0, 1)
    encoder_padding_mask = src_tokens.eq(self.padding_idx)
    if (not encoder_padding_mask.any()):
        encoder_padding_mask = None
    for layer in self.mask_layers:
        x = layer(x, encoder_padding_mask)
    if self.layer_norm:
        x = self.mask_layer_norm(x)
    x = self.t_layer(x).squeeze((- 1))
    if (encoder_padding_mask is not None):
        x = x.masked_fill(encoder_padding_mask.transpose(0, 1), value=torch.tensor(float('-inf')))
    return self.output_mask(x).transpose(0, 1)
def mask(self, src_tokens, x):
    x = x.transpose(0, 1)
    encoder_padding_mask = src_tokens.eq(self.padding_idx)
    if (not encoder_padding_mask.any()):
        encoder_padding_mask = None
    for layer in self.mask_layers:
        x = layer(x, encoder_padding_mask)
    if self.layer_norm:
        x = self.mask_layer_norm(x)
    x = self.t_layer(x).squeeze((- 1))
    if (encoder_padding_mask is not None):
        x = x.masked_fill(encoder_padding_mask.transpose(0, 1), value=torch.tensor(float('-inf')))
    return self.output_mask(x).transpose(0, 1)