code: def gen_poly(points, order, syms):
      """Generates a polynomial using a Vandermonde system"""
      num_pts = len(points)
      if num_pts == 0:
          raise ValueError("Must provide points")
      dim = len(points[0]) - 1
      if dim > len(syms):
          raise ValueError(
              "Must provide at least %d symbols for the polynomial"
              % dim
          )
      V, tmp_syms, terms = vandermonde(order, dim)
      if num_pts < V.shape[0]:
          raise ValueError(
              "Must provide %d points for order %d, dimension "
              "%d polynomial, given %d points"
              % (V.shape[0], order, dim, num_pts)
          )
      elif num_pts > V.shape[0]:
          print(
              "gen_poly given %d points but only requires %d, "
              "continuing using the first %d points"
              % (num_pts, V.shape[0], V.shape[0])
          )
          num_pts = V.shape[0]
  
      subs_dict = {}
      for j in range(dim):
          for i in range(num_pts):
              subs_dict[tmp_syms[i][j]] = points[i][j]
      V_pts = V.subs(subs_dict)
      V_inv = V_pts.inv()
  
      coeffs = V_inv.multiply(
          Matrix([points[i][-1] for i in range(num_pts)])
      )
  
      f = 0
      for j, term in enumerate(terms):
          t = 1
          for k in term:
              t *= syms[k]
          f += coeffs[j] * t
      return f
  
imports: from sympy import Matrix, pprint, Rational, symbols, Symbol, zeros
label_desc: Use image node_id 4 for calling a global function with example usage: gen_poly(points, order, syms) and returns: f