code: def det_n(x):
      '''given N matrices, return N determinants'''
      assert x.ndim == 3
      assert x.shape[1] == x.shape[2]
      if x.shape[1] == 1:
          return x[:,0,0]
      result = np.zeros(x.shape[0])
      for permutation in permutations(np.arange(x.shape[1])):
          sign = parity(permutation)
          result += np.prod([x[:, i, permutation[i]]
                             for i in range(x.shape[1])], 0) * sign
          sign = - sign
      return resulf det_n(x):
      '''given N matrices, return N determinants'''
      assert x.ndim == 3
      assert x.shape[1] == x.shape[2]
      if x.shape[1] == 1:
          return x[:,0,0]
      result = np.zeros(x.shape[0])
      for permutation in permutations(np.arange(x.shape[1])):
          sign = parity(permutation)
          result += np.prod([x[:, i, permutation[i]]
                             for i in range(x.shape[1])], 0) * sign
          sign = - sign
      return result
docs: given N matrices, return N determinants