You could deal with different shaped input using adaptive pooling layers, e.g. AdaptiveMaxPool1d 104.
You could place this layer before a Linear layer, which needs a fixed input shape like @dragen explained.