As of torchvision version 0.13, the class labels are accessible from the weights class for each pretrained model (as in the documentation):
from torchvision.models import ResNet50_Weights
weights = ResNet50_Weights.DEFAULT
category_name = weights.meta["categories"][class_id]