code: def test_hpopt_context():
      import json
      from speechbrain.utils import hpopt as hp
      from io import StringIO
  
      output = StringIO()
      reporter = hp.GenericHyperparameterOptimizationReporter(
          objective_key="per", output=output
      )
  
      with hp.hyperparameter_optimization() as hp_ctx:
          hp_ctx.reporter = reporter
          result = {"per": 10, "loss": 1.2}
          hp.report_result(result)
  
          result = {"per": 3, "loss": 1.3}
          hp.report_result(result)
  
      output.seek(0)
      output_result = json.load(output)
      assert output_result["per"] == 3
  
imports: import pytest
label_desc: Use image node_id 3 for calling a global function with example usage: test_hpopt_context() without return types