code: def sympy_poly_to_poly(
      poly: Poly, degree: int, num_variables: int
  ) -> Polynomial:
      terms = poly.terms()
      all_terms = generate_terms(degree, num_variables)
      all_powers = get_powers(all_terms)
      coeffs_dict = defaultdict(
          int,
          {
              tuple(sympy_power_to_power(power)): coeff
              for power, coeff in terms
          },
      )
      coeffs = [coeffs_dict[tuple(_)] for _ in all_powers]
      return Polynomial(
          degree=degree,
          num_variables=num_variables,
          coeffs=np.array(coeffs),
      )
  
imports: from collections import defaultdict
  from dataclasses import dataclass, field
  from itertools import combinations_with_replacement, product
  import math
  from math import comb
  import numpy
  import numpy.typing
  import random
  import sympy
  from sympy import Symbol, Poly, diff
  from sympy.parsing.sympy_parser import standard_transformations, implicit_multiplication_application
  from typing import List, Optional, Tuple, Dict
  from helm.benchmark.adaptation.adapters.adapter_factory import ADAPT_GENERATION
  from helm.benchmark.adaptation.adapter_spec import AdapterSpec
  from helm.benchmark.window_services.tokenizer_service import TokenizerService
  from helm.common.authentication import Authentication
  from helm.proxy.services.server_service import ServerService
  from .scenario import Scenario, Instance, Reference, TRAIN_SPLIT, TEST_SPLIT, CORRECT_TAG, Input, Output
label_desc: Use image node_id 6 for calling a global function with example usage: sympy_poly_to_poly(poly, degree, num_variables) and returns: Polynomial