Solved by KFrank in post #2 
              
              
                Hi Learned! 

Yes, you can use torch.distributions.Categorical, provided you 
adjust your distributions tensor so that its last dimension is the distribution 
dimension. 
Here is an example script: 
import torch
print (torch.__version__)

_ = torch.random.manual_seed (2021)

N = 2
C = 3
H = 5
W = 7
…