code: def test_non_reuse_generator():
      def eval_fn(v):
          return -(v**4 - 5 * v**2 - 3 * v)
  
      search_space = Categorical(range(-3, 4), label="x")
      best = max(map(eval_fn, search_space.grid()))
  
      replay_buffer = ReplayBuffer(20)
      generator = TuningTrajectoryGenerator(
          search_space,
          partial(default_policy_fn, hidden_dim=16, lr=1e-3),
      )
      policy = generator.policy
  
      reward_curve = []
      for __ in range(50):
          rewards = []
          generators = []
          for _ in range(20):
              generator = TuningTrajectoryGenerator(
                  search_space, policy=policy
              )
              sample = generator.next_sample()
              generators.append(generator)
              reward = eval_fn(search_space.freeze(sample))
              rewards.append(reward)
  
          for generator, reward in zip(generators, rewards):
              trajectory = generator.send_reward(reward)
              replay_buffer.update(trajectory)
  
          policy.update(0, replay_buffer, batch_size=10, repeat=10)
          reward_curve.append(np.mean(rewards))
  
      assert _has_upward_trend(reward_curve)
  
      rewards = []
      for _ in range(3):
          sample = generator.next_sample()
          sample_logits = generator.sample_logits
          assert np.max(sample_logits["x"]) > 0.9
          reward = eval_fn(search_space.freeze(sample))
          rewards.append(reward)
          if reward == best:
              break
      else:
          assert False, f"Cannot find the best sample, found: {rewards}"
  
file_path: nni/test/algo/nas/strategy/test_rl_impl.py
imports: from functools import partial
  import numpy
  import pytest
  from tianshou.data import ReplayBuffer, Batch
  from tianshou.policy import BasePolicy
  from nni.mutable import Categorical, Numerical, CategoricalMultiple, MutableDict, MutableList, ExpressionConstraint
  from nni.nas.strategy._rl_impl import TuningTrajectoryGenerator, default_policy_fn
label_desc: Use image node_id 3 for calling a global function with example usage: test_non_reuse_generator() and returns: unknown