code: def compute(self, config_id, config, budget, working_directory):
      budget = math.log(budget, self.base)
      assert abs(budget - round(budget)) < util.epsilon
      budget = round(budget)
      assert budget < len(self.runs_per_round)
      num_runs = self.runs_per_round[budget]
  
      update = dict(
          unit="episodes", batch_size=config["batch_size"], frequency=1
      )
      policy = dict(
          network=dict(type="auto", size=64, depth=2, rnn=False)
      )
      optimizer = dict(
          optimizer="adam",
          learning_rate=config["learning_rate"],
          multi_step=config["multi_step"],
          linesearch_iterations=5,  # , subsampling_fraction=256
      )
  
      if config["clipping_value"] > 1.0:
          objective = dict(
              type="policy_gradient",
              importance_sampling=(
                  config["importance_sampling"] == "yes"
              ),
          )
      else:
          objective = dict(
              type="policy_gradient",
              importance_sampling=(
                  config["importance_sampling"] == "yes"
              ),
              clipping_value=config["clipping_value"],
          )
  
      if config["baseline"] == "no":
          predict_horizon_values = False
          estimate_advantage = False
          predict_action_values = False
          baseline = None
          baseline_optimizer = None
          baseline_objective = None
  
      elif config["baseline"] == "same":
          predict_horizon_values = "early"
          estimate_advantage = config["estimate_advantage"] == "yes"
          predict_action_values = False
          baseline = None
          baseline_optimizer = config["baseline_weight"]
          baseline_objective = dict(type="value", value="state")
  
      elif config["baseline"] == "yes":
          predict_horizon_values = "early"
          estimate_advantage = config["estimate_advantage"] == "yes"
          predict_action_values = False
          baseline = dict(
              network=dict(type="auto", size=64, depth=2, rnn=False)
          )
          baseline_optimizer = config["baseline_weight"]
          baseline_objective = dict(type="value", value="state")
  
      else:
          assert False
  
      reward_estimation = dict(
          horizon=config["horizon"],
          discount=config["discount"],
          predict_horizon_values=predict_horizon_values,
          estimate_advantage=estimate_advantage,
          predict_action_values=predict_action_values,
      )
  
      if config["entropy_regularization"] < 1e-5:
          entropy_regularization = 0.0
      else:
          entropy_regularization = config["entropy_regularization"]
  
      agent = dict(
          policy=policy,
          memory="recent",
          update=update,
          optimizer=optimizer,
          objective=objective,
          reward_estimation=reward_estimation,
          baseline=baseline,
          baseline_optimizer=baseline_optimizer,
          baseline_objective=baseline_objective,
          entropy_regularization=entropy_regularization,
      )
  
      average_reward = list()
      final_reward = list()
      rewards = list()
  
      for n in range(num_runs):
          if self.num_parallel is None:
              runner = Runner(
                  agent=agent,
                  environment=self.environment,
                  max_episode_timesteps=self.max_episode_timesteps,
              )
              runner.run(num_episodes=self.num_episodes, use_tqdm=False)
          else:
              runner = Runner(
                  agent=agent,
                  environment=self.environment,
                  max_episode_timesteps=self.max_episode_timesteps,
                  num_parallel=min(
                      self.num_parallel, config["batch_size"]
                  ),
                  remote="multiprocessing",
              )
              runner.run(
                  num_episodes=self.num_episodes,
                  batch_agent_calls=True,
                  sync_episodes=True,
                  use_tqdm=False,
              )
          runner.close()
  
          average_reward.append(
              float(np.mean(runner.episode_returns, axis=0))
          )
          final_reward.append(
              float(np.mean(runner.episode_returns[-20:], axis=0))
          )
          rewards.append(list(runner.episode_returns))
  
      mean_average_reward = float(np.mean(average_reward, axis=0))
      mean_final_reward = float(np.mean(final_reward, axis=0))
      loss = -(mean_average_reward + mean_final_reward)
  
      return dict(loss=loss, info=dict(rewards=rewards))
  
file_path: tensorforce/tune.py
imports: import argparse
  import importlib
  import math
  import os
  import pickle
  import ConfigSpace
  from hpbandster.core.nameserver import NameServer, nic_name_to_host
  from hpbandster.core.result import json_result_logger, logged_results_to_HBS_result
  from hpbandster.core.worker import Worker
  from hpbandster.optimizers import BOHB
  import numpy
  from tensorforce import Runner, util
label_desc: Use image node_id 2 for calling the TensorforceWorker obj's underlying member method code with example usage: obj.compute(config_id, config, budget, working_directory) and returns: dict