Working with datamodules : how to access datamodule attributes from model?

I am using pl datamodules and am aware of a couple data hooks available the model class, for example “model.train_dataloader()”, and although this helps with calculating quantities such as total training steps by looking at the length of the datamodule’s train_dataloader(), I often would like to access other datamodule attributes from my model at other points of the training / evaluation pipelines.

I saw there is a “datamodule” attribute in the model which does not seem to get initialized with anything, but I haven’t understood if this is a recommended way to accomplish what I am trying to do, (access arbitrary datamodule attributes from my model at arbitrary stages in the training / evaluation pipelines), or if that datamodule attribute of the model is intended for some other use?

Ok so this was a newbie mistake. It turns out I was seeing datamodule attribute un-initialized since I was passed a dataloader into instead of passing in the datamodule.

Passing in the datamodule, I can access arbitrary datamodule attributes as expected.