code: def matrix2lha(M):
      
      l = []
      ind = np.indices(M.shape).reshape(M.ndim, M.size).T
      for i in ind:
          l.append([j+1 for j in i] + [M[tuple(i)]])
      return l
docs: Inverse function to lha2matrix: return a LHA-like list given a tensor.