code: def test_hpopt_generic():
      from io import StringIO
      from speechbrain.utils import hpopt as hp
      import json
  
      output = StringIO()
  
      reporter = hp.GenericHyperparameterOptimizationReporter(
          objective_key="per", output=output
      )
      result = {"train_loss": 0.9, "valid_loss": 1.2, "per": 0.10}
      reporter.report_objective(result)
      output.seek(0)
      output_result = json.load(output)
      assert output_result["train_loss"] == pytest.approx(0.9)
      assert output_result["valid_loss"] == pytest.approx(1.2)
      assert output_result["per"] == pytest.approx(0.10)
      assert output_result["objective"] == pytest.approx(0.10)
  
imports: import pytest
label_desc: Use image node_id 1 for calling a global function with example usage: test_hpopt_generic() without return types