Im sorry for the confusion.
here is what i want:
consider tensor A:
A =Variable(torch.rand(1,2,3,3))
print(A)

Variable containing:
(0 ,0 ,.,.) = 
  0.5396  0.1361  0.7871
  0.5187  0.1430  0.2143
  0.5917  0.0184  0.5073

(0 ,1 ,.,.) = 
  0.8257  0.2010  0.5715
  0.3362  0.3824  0.5582
  0.8907  0.3006  0.5311
[torch.FloatTensor of size 1x2x3x3]

I would like to apply softmax to each channel, therefor the results of each channel be like this:
channel 1:

(torch.exp(A[0,0,:,:].view(-1))/torch.exp(A[0,0,:,:].view(-1)).sum()).view(3,3)


Variable containing:
 0.1260  0.0841  0.1613
 0.1234  0.0847  0.0910
 0.1327  0.0748  0.1220
[torch.FloatTensor of size 3x3]


so

(torch.exp(A[0,0,:,:].view(-1))/torch.exp(A[0,0,:,:].view(-1)).sum()).view(3,3).sum()
Variable containing:
 1
[torch.FloatTensor of size 1]

and channel 2:

 (torch.exp(A[0,1,:,:].view(-1))/torch.exp(A[0,1,:,:].view(-1)).sum()).view(3,3)


Variable containing:
 0.1485  0.0795  0.1152
 0.0910  0.0953  0.1136
 0.1585  0.0878  0.1106
[torch.FloatTensor of size 3x3]

and therefore

(torch.exp(A[0,1,:,:].view(-1))/torch.exp(A[0,1,:,:].view(-1)).sum()).view(3,3).sum()


Variable containing:
 1
[torch.FloatTensor of size 1]