code: def be2le_state_by_state(tpm):
      
      le = np.empty(tpm.shape)
      N = tpm.shape[0]
      n = int(log2(N))
      for i in range(N):
          le[i, :] = tpm[be2le(i, n), :]
      return le
docs: Convert a state-by-state TPM from big-endian to little-endian or vice
      versa.
  
      Args:
          tpm (np.ndarray): A state-by-state TPM.
  
      Returns:
          np.ndarray: The state-by-state TPM in the other indexing format.
  
      Example:
          >>> tpm = np.arange(16).reshape([4, 4])
          >>> be2le_state_by_state(tpm)
          array([[ 0.,  1.,  2.,  3.],
                 [ 8.,  9., 10., 11.],
                 [ 4.,  5.,  6.,  7.],
                 [12., 13., 14., 15.]])