code: def random_sample(input_param, obj_func, n_generations=100):
      """Return the best result from random sampling"""
      rs_optimizer = RandomSearchOptimizer(
          input_param,
          obj_func,
          batch_size=512,
      )
      min_reward_rs_optimizer = torch.tensor(9999.0)
      print("Random Sampling")
      for i in range(n_generations):
          (
              sampled_solutions,
              reward,
          ) = rs_optimizer.optimize_step()
          min_reward_rs_optimizer = torch.min(
              min_reward_rs_optimizer, torch.min(reward.data)
          )
          print(f"Generation={i}, min_reward={min_reward_rs_optimizer}")
      print()
  
      return min_reward_rs_optimizer
  
imports: import random
  import unittest
  from collections import defaultdict
  from typing import Dict
  import nevergrad
  import numpy
  import torch
  import torch.nn
  from reagent.lite.optimizer import BayesianByBackpropOptimizer, BayesianMLPEnsemblerOptimizer, BayesianOptimizerBase, GREEDY_TEMP, GumbelSoftmaxOptimizer, NeverGradOptimizer, PolicyGradientOptimizer, QLearningOptimizer, RandomSearchOptimizer, sol_to_tensors
label_desc: Use image node_id 1 for calling a global function with example usage: random_sample(input_param, obj_func, n_generations) and returns: min_reward_rs_optimizer