def forward(self, inputs: torch.Tensor, mask: torch.Tensor, span: torch.Tensor) -> torch.Tensor:
    (batch_size, seq_len, _) = inputs.size()
    offset = span[:, 0]
    position_range = util.get_range_vector(seq_len, util.get_device_of(inputs)).repeat((batch_size, 1))
    relative_positions = (((1 + self._n_position) + position_range) - offset.unsqueeze(dim=1))
    relative_positions = (relative_positions * mask.long())
    return self._embedding(relative_positions)
def forward(self, inputs: torch.Tensor, mask: torch.Tensor, span: torch.Tensor) -> torch.Tensor:
    (batch_size, seq_len, _) = inputs.size()
    offset = span[:, 0]
    position_range = util.get_range_vector(seq_len, util.get_device_of(inputs)).repeat((batch_size, 1))
    relative_positions = (((1 + self._n_position) + position_range) - offset.unsqueeze(dim=1))
    relative_positions = (relative_positions * mask.long())
    return self._embedding(relative_positions)