code: def make_agent(
      agent_type,
      env,
      policy_hparams,
      policy_dir,
      sampling_temp,
      sim_env_kwargs_fn=None,
      frame_stack_size=None,
      rollout_agent_type=None,
      batch_size=None,
      inner_batch_size=None,
      env_type=None,
      **planner_kwargs,
  ):
      """Factory function for Agents."""
      if batch_size is None:
          batch_size = env.batch_size
      return {
          "random": lambda: rl_utils.RandomAgent(  # pylint: disable=g-long-lambda
              batch_size, env.observation_space, env.action_space
          ),
          "policy": lambda: rl_utils.PolicyAgent(  # pylint: disable=g-long-lambda
              batch_size,
              env.observation_space,
              env.action_space,
              policy_hparams,
              policy_dir,
              sampling_temp,
          ),
          "planner": lambda: rl_utils.PlannerAgent(  # pylint: disable=g-long-lambda
              batch_size,
              make_agent(
                  rollout_agent_type,
                  env,
                  policy_hparams,
                  policy_dir,
                  sampling_temp,
                  batch_size=inner_batch_size,
              ),
              make_env(env_type, env.env, sim_env_kwargs_fn()),
              lambda env: rl_utils.BatchStackWrapper(
                  env, frame_stack_size
              ),
              discount_factor=policy_hparams.gae_gamma,
              **planner_kwargs,
          ),
      }[agent_type]()
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import datetime
  import os
  from tensor2tensor.data_generators import gym_env
  from tensor2tensor.layers import common_video
  from tensor2tensor.models.research import rl
  from tensor2tensor.rl import rl_utils
  from tensor2tensor.rl import trainer_model_based_params
  from tensor2tensor.utils import flags
  from tensor2tensor.utils import hparam
  from tensor2tensor.utils import registry
  from tensor2tensor.utils import trainer_lib
  import tensorflow.compat.v1
label_desc: Use image node_id 15 for calling a global function with example usage: make_agent(agent_type, env, policy_hparams, policy_dir, sampling_temp, sim_env_kwargs_fn, frame_stack_size, rollout_agent_type, batch_size, inner_batch_size, env_type) and returns: dict