Thanks for the reply @spanev
I should edit the question, I want to calculate the mean along the second axis. The first array (first row) in tensor Avg(A) is calculated by averaging two non-zero arrays in tensor A. As such:
[2, 3, 4]  =  Avg( ([1, 2, 3], [3, 4, 5]) )
[2.5, 3.5, 4.5]  =  Avg( ([5, 6, 7], [0, 1, 2]) )