How to multiply neuron outputs in the same layer?

I want to get the product of the neuron outputs in the same layer, how to do effieciently?
for example, the last layer of my net has 16 neurons, hence the dimension of the output is (batch_size,16). I want to get the product of all 16 elements: (batch_size, product of all 16 elements ), how to achieve this ?
thanks

Maybe torch.prod works for you

Let var = torch.randn(10,5) then,
if you want to multiply the columns use torch.prod(1) the result will have dimension (10,1)
and if you want to multiply the rows use torch.prod(0) the result will have dimension (1,5)

Problem has been solved.
Thanks to all.