How to extend model with Pad layer?

I have input vectors with different size: [1,0,1], [1,0,1,1,1,1]…
Is there a way to add additional NN layer that Pads vectors on the right side with 2?

[1,0,1] -> [1,0,1,2,2,2,2,2] 
[1,0,1,1,1,1] ->  [1,0,1,1,1,1,2,2]
MAX_STRING_SIZE = 8
model = torch.nn.Sequential(
    torch.nn.Linear(MAX_STRING_SIZE, 1),
    torch.nn.Sigmoid()
)

torch.nn.functional. pad ( input , pad , mode=‘constant’ , value=2 )

you can also try

tensor1 = torch.Tensor([1,0,2])
max_seq_len = 7
tensor2 = torch.ones(max_seq_len)*2
tensor1 = torch.cat((tensor1,tensor2))[:max_seq_len]

change the max_seq_len to get padding till different sizes

How to use it with batches?
tensor1 = torch.Tensor([[1,0,2],[1,0,2,1,0,2]])