MCPcopy Create free account
hub / github.com/AnswerDotAI/ModernBERT / test_roundtrip

Function test_roundtrip

tests/test_padding.py:50–56  ·  view source on GitHub ↗
(sample_data)

Source from the content-addressed store, hash-verified

48
49
50def test_roundtrip(sample_data):
51 inputs, attention_mask, _, labels = sample_data
52 unpadded_inputs, indices, _, _, _, unpadded_labels = unpad_input(inputs, attention_mask, labels=labels)
53 padded_inputs, padded_labels = pad_input(unpadded_inputs, indices, batch=2, seqlen=4, labels=unpadded_labels)
54
55 assert torch.allclose(inputs[attention_mask.bool()], padded_inputs[attention_mask.bool()])
56 assert torch.all(labels == padded_labels)
57
58
59def test_token_input():

Callers

nothing calls this directly

Calls 2

unpad_inputFunction · 0.90
pad_inputFunction · 0.90

Tested by

no test coverage detected