code: def orth_ttr(
          order, dist, normed=False, sort="GR", retall=False,
          cross_truncation=1., **kws):
      polynomials, norms, _, _ = chaospy.quad.generate_stieltjes(
          dist=dist, order=numpy.max(order), retall=True, **kws)
      if normed:
          for idx, poly in enumerate(polynomials):
              polynomials[idx] = poly / numpy.sqrt(norms[:, idx])
          norms = norms**0
      dim = len(dist)
      if dim > 1:
          mv_polynomials = []
          mv_norms = []
          indices = chaospy.bertran.bindex(
              start=0, stop=order, dim=dim, sort=sort,
              cross_truncation=cross_truncation,
          )
          for index in indices:
              poly = polynomials[index[0]][0]
              for idx in range(1, dim):
                  poly = poly * polynomials[index[idx]][idx]
              mv_polynomials.append(poly)
          if retall:
              for index in indices:
                  mv_norms.append(
                      numpy.prod([norms[idx, index[idx]] for idx in range(dim)]))
      else:
          mv_norms = norms[0]
          mv_polynomials = polynomials
      polynomials = chaospy.poly.flatten(chaospy.poly.Poly(mv_polynomials))
      if retall:
          return polynomials, numpy.array(mv_norms)
      return polynomials