input: Write a function to optimize stock portfolio allocation using numpy and scipy.optimize.
  assert np.allclose(optimize_allocation([0.1, 0.2, 0.3], [1, 1, 1]), [0.33333333, 0.33333333, 0.33333333])
  assert np.allclose(optimize_allocation([0.2, 0.3, 0.5], [1, 2, 1]), [0.33333333, 0.66666667, 0.33333333])
  assert np.allclose(optimize_allocation([0.05, 0.05, 0.9], [2, 1, 2]), [0.5, 0.25, 0.25])
output: import numpy as np
  from scipy.optimize import minimize
  
  def optimize_allocation(expected_returns, risks):
      def objective(weights):
          return -np.dot(weights, expected_returns) + np.dot(weights, risks) # Minimize negative return + risk
      
      constraints = ({'type': 'eq', 'fun': lambda weights: np.sum(weights) - 1})
      bounds = [(0, 1) for _ in expected_returns]
      initial_guess = np.array([1 / len(expected_returns)] * len(expected_returns))
      
      result = minimize(objective, initial_guess, bounds=bounds, constraints=constraints)
      
      return result.x