torch.Tensor with uncertain length of one dimension

I am programming a custom optimizer, and the legth of first dimension is not certain because last batch have no enough data to bulid a batch. So the initialization of weights with fixed batch_size do not satisfy the last batch for torch.matmul.
So, I wonder whether I can create a tensor where the lenght of some dimension could be variable, like variable length list.