input: Write a Python function to fit a polynomial curve to given x and y data using `scipy.optimize.curve_fit`.
  assert np.allclose(fit_polynomial(np.arange(-5, 5, 0.1), 3*np.arange(-5, 5, 0.1)**2 + 2*np.arange(-5, 5, 0.1) + 3), [3.0, 2.0, 3.0])
  assert np.allclose(fit_polynomial(np.array([1, 2, 3, 4, 5]), np.array([6, 11, 18, 27, 38])), [1.0, 1.0, 4.0])
  assert np.allclose(fit_polynomial(np.array([-2, -1, 0, 1, 2]), np.array([10, 3, 2, 3, 10])), [1.0, 0.0, 2.0])
output: import numpy as np
  from scipy.optimize import curve_fit
  
  def fit_polynomial(x, y, degree=2):
      def poly_func(x, *coeffs):
          return sum(c * x**i for i, c in enumerate(coeffs))
      
      initial_guess = [1] * (degree + 1)
      coeffs, _ = curve_fit(poly_func, x, y, p0=initial_guess)
      return coeffs