code: def test_dump_and_load():
      res = gp_minimize(
          bench3,
          [(-2.0, 2.0)],
          x0=[0.0],
          acq_func="LCB",
          n_calls=2,
          n_random_starts=1,
          random_state=1,
      )
  
      # Test normal dumping and loading
      with tempfile.TemporaryFile() as f:
          dump(res, f)
          f.seek(0)
          res_loaded = load(f)
      check_optimization_results_equality(res, res_loaded)
      assert "func" in res_loaded.specs["args"]
  
      # Test dumping without objective function
      with tempfile.TemporaryFile() as f:
          dump(res, f, store_objective=False)
          f.seek(0)
          res_loaded = load(f)
      check_optimization_results_equality(res, res_loaded)
      assert not ("func" in res_loaded.specs["args"])
  
      # Delete the objective function and dump the modified object
      del res.specs["args"]["func"]
      with tempfile.TemporaryFile() as f:
          dump(res, f, store_objective=False)
          f.seek(0)
          res_loaded = load(f)
      check_optimization_results_equality(res, res_loaded)
      assert not ("func" in res_loaded.specs["args"])
  
imports: import pytest
  import tempfile
  from numpy.testing import assert_array_equal
  from numpy.testing import assert_equal
  from numpy.testing import assert_raises
  import numpy
  from skopt import gp_minimize, forest_minimize
  from skopt import load
  from skopt import dump
  from skopt import expected_minimum, expected_minimum_random_sampling
  from skopt.benchmarks import bench1
  from skopt.benchmarks import bench3
  from skopt.learning import ExtraTreesRegressor
  from skopt import Optimizer
  from skopt import Space
  from skopt.space import Dimension
  from skopt.utils import point_asdict
  from skopt.utils import point_aslist
  from skopt.utils import dimensions_aslist
  from skopt.utils import has_gradients
  from skopt.utils import cook_estimator
  from skopt.utils import normalize_dimensions
  from skopt.utils import use_named_args
  from skopt.utils import check_list_types
  from skopt.utils import check_dimension_names
  from skopt.space import Real, Integer, Categorical
label_desc: Use image node_id 2 for calling a global function with example usage: test_dump_and_load() without return types