code: def orth_gs(order, dist, normed=False, sort="GR", cross_truncation=1., **kws):
      logger = logging.getLogger(__name__)
      dim = len(dist)
      if isinstance(order, int):
          if order == 0:
              return chaospy.poly.Poly(1, dim=dim)
          basis = chaospy.poly.basis(
              0, order, dim, sort, cross_truncation=cross_truncation)
      else:
          basis = order
      basis = list(basis)
      polynomials = [basis[0]]
      if normed:
          for idx in range(1, len(basis)):
              for idy in range(idx):
                  orth = chaospy.descriptives.E(
                      basis[idx]*polynomials[idy], dist, **kws)
                  basis[idx] = basis[idx] - polynomials[idy]*orth
              norms = chaospy.descriptives.E(polynomials[-1]**2, dist, **kws)
              if norms <= 0:
                  logger.warning("Warning: Polynomial cutoff at term %d", idx)
                  break
              basis[idx] = basis[idx] / numpy.sqrt(norms)
              polynomials.append(basis[idx])
      else:
          norms = [1.]
          for idx in range(1, len(basis)):
              for idy in range(idx):
                  orth = chaospy.descriptives.E(
                      basis[idx]*polynomials[idy], dist, **kws)
                  basis[idx] = basis[idx] - polynomials[idy] * orth / norms[idy]
              norms.append(
                  chaospy.descriptives.E(polynomials[-1]**2, dist, **kws))
              if norms[-1] <= 0:
                  logger.warning("Warning: Polynomial cutoff at term %d", idx)
                  break
              polynomials.append(basis[idx])
      return chaospy.poly.Poly(polynomials, dim=dim, shape=(len(polynomials),))