You should use the training dataset statistics only.
To get the stats for this dataset, you could load the complete dataset in a single tensor (if it fits into your memory) and calculate the stats or iterate the dataset and calculate the mean and std from the running stats.
The transform error is raised, since a tensor is expected but you’ve passed a dict so I guess the image tensor might be wrapped inside the dict and you would have to access it.