code: def create_mv_rule(tensorprod_rule, dim):
      
      def mv_rule(order, sparse=False, part=None):
          """
          Multidimensional integration rule.
  
          Args:
              order (int, numpy.ndarray) : order of integration rule. If numpy.ndarray,
                  order along each axis.
              sparse (bool) : use Smolyak sparse grid.
  
          Returns:
              (numpy.ndarray, numpy.ndarray) abscissas and weights.
          """
          if sparse:
              order = numpy.ones(dim, dtype=int)*order
              tensorprod_rule_ = lambda order, part=part:\
                  tensorprod_rule(order, part=part)
              return chaospy.quad.sparse_grid(tensorprod_rule_, order)
  
          return tensorprod_rule(order, part=part)
  
      return mv_rule
docs: Convert tensor product rule into a multivariate quadrature generator.