You can just use np.prod. it works with any thing that is “array-like”, including tuples, lists, and torch.Size.
import numpy as np; import torch

t = torch.zeros((3, 4))
print(np.prod(t.shape))
# prints "12"