def forward(self, source, padding_mask, tbc=True, **kwargs):
    w2v_args = {'source': source, 'padding_mask': padding_mask, 'mask': (self.apply_mask and self.training)}
    ft = (self.freeze_finetune_updates <= self.num_updates)
    with (torch.no_grad() if (not ft) else contextlib.ExitStack()):
        (x, padding_mask) = self.w2v_model.extract_features(**w2v_args)
        if tbc:
            x = x.transpose(0, 1)
    x = self.final_dropout(x)
    if self.proj:
        x = self.proj(x)
    return {'encoder_out': x, 'encoder_padding_mask': padding_mask, 'padding_mask': padding_mask}
def forward(self, source, padding_mask, tbc=True, **kwargs):
    w2v_args = {'source': source, 'padding_mask': padding_mask, 'mask': (self.apply_mask and self.training)}
    ft = (self.freeze_finetune_updates <= self.num_updates)
    with (torch.no_grad() if (not ft) else contextlib.ExitStack()):
        (x, padding_mask) = self.w2v_model.extract_features(**w2v_args)
        if tbc:
            x = x.transpose(0, 1)
    x = self.final_dropout(x)
    if self.proj:
        x = self.proj(x)
    return {'encoder_out': x, 'encoder_padding_mask': padding_mask, 'padding_mask': padding_mask}