The intent here looks like some kind of differentiable neural architecture search (e.g., DARTS: Differentiable Architecture Search – Google Research 1)
However, the shape parameters to layer declarations like max_pool1d are not differentiable; the output of the model doesn’t directly depend on them! For example, it is similar to writing y = a + b + c and expecting to take a derivative to optimize how many variables we are using in our equation. One workaround (as shown in the DARTS paper) is to consider a model with several weighted branches (where the weights are differentiable and learnable), where each branch has a different maxpool_1d configuration. The weights of each branch are updated during the architecture search training process and the branch(es) with the highest weight(s) are chosen.