code: def single_index(idxm):
      
      if -1 in idxm:
          return 0
      order = int(sum(idxm))
      dim = len(idxm)
      if order == 0:
          return 0
      return terms(order-1, dim) + single_index(idxm[1:])
docs: Multi-index to single integer notation.
  
      Uses graded reverse lexicographical notation.
  
      Parameters
      ----------
      idxm : numpy.ndarray
          Index in multi-index notation
  
      Returns
      -------
      idx : int
          Integer index of `idxm`
  
      Examples
      --------
      >>> for idx in range(3):
      ...     print(chaospy.bertran.single_index(numpy.eye(3)[idx]))
      1
      2
      3