How could I create a module with learnable parameters when one set of parameters is from Dataset class

So, I have a model with some parameters that I need to train. And also, there are some parameters in the class Dataset( which do some preprocessing. I need to train them as well with the model’s parameters. So, can you please let me know if what I am doing is correct:
params = list(model.parameters())
opt = torch.optim.Adam(params,lr=1e-4)

One more question. As Dataset class will generate both the train_ds and val_ds, I only need to train the parameters of the Dataset class when getting train_ds. And to get val_ds, I need to use the trained parameters of the Dataset. So, how do I create the train_ds and val_ds? Should I initially create both of them and then train the model with tarin_ds, and then create them again and use the val_ds for testing?