If I understand your code correctly, you are trying to change the shape of a subtensor in input_ids, while the other tensors would keep their shape?
If so, this won’t be possible, since the tensor won’t be able to be represented as a single tensor anymore.
Here is a code snippet to illustrate this error:
x = torch.randn(5, 10)
x[0] = torch.ones(10) # works since same dim1
print(x)

x[0] = torch.ones(11) # error

You would have to pad all tensors to the same length or split the original tensor into different ones.