code: def test_sample_penalty(profiler):
      penalty = SampleProfilerPenalty(profiler, 20000, 2.0)
      loss, details = penalty(42.0, {"conv": 1})
      assert details["loss_original"] == 42.0
      assert details["penalty"] == 25000
      assert details["normalized_penalty"] == 0.25
      assert loss == 42.0 + 0.25 * 2.0
  
file_path: nni/test/algo/nas/oneshot/test_profiler.py
imports: import pytest
  import torch
  from torch.nn import Conv2d
  from nni.nas.nn import ModelSpace, LayerChoice
  from nni.nas.oneshot.pytorch.profiler import RangeProfilerFilter, ExpectationProfilerPenalty, SampleProfilerPenalty
  from nni.nas.profiler.pytorch.flops import FlopsProfiler
label_desc: Use image node_id 4 for calling a global function with example usage: test_sample_penalty(profiler) without return types