I don’t know how DatasetDeepPhysHDF5 is implemented, but would assume that it might be a custom torch.utils.data.Dataset, which wraps the HFD dataset internally, and is thus not implementing the keys() operation. You could check it via print(type(trainset)) and check which methods are implemented for this class.
If my guess is correct, you might be able to access the internal HDF dataset and call keys() on it directly.