the actual computation is log \mathbf{E} \Big[  -B*torch.exp(X)  \Big] = torch.log( torch.mean (  -B*torch.exp(X)  )) .
And yes both B and X are tensors and output of two different neural networks. ex: B = NN_1(b)+some_additional_calculation and X = NN_2(x)+some_additional_calculation