code: def make_agent_from_hparams(
      agent_type,
      base_env,
      stacked_env,
      loop_hparams,
      policy_hparams,
      planner_hparams,
      model_dir,
      policy_dir,
      sampling_temp,
      video_writers=(),
  ):
      """Creates an Agent from hparams."""
  
      def sim_env_kwargs_fn():
          return rl.make_simulated_env_kwargs(
              base_env,
              loop_hparams,
              batch_size=planner_hparams.batch_size,
              model_dir=model_dir,
          )
  
      planner_kwargs = planner_hparams.values()
      planner_kwargs.pop("batch_size")
      planner_kwargs.pop("rollout_agent_type")
      planner_kwargs.pop("env_type")
      return make_agent(
          agent_type,
          stacked_env,
          policy_hparams,
          policy_dir,
          sampling_temp,
          sim_env_kwargs_fn,
          loop_hparams.frame_stack_size,
          planner_hparams.rollout_agent_type,
          inner_batch_size=planner_hparams.batch_size,
          env_type=planner_hparams.env_type,
          video_writers=video_writers,
          **planner_kwargs,
      )
  
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 17 for calling a global function with example usage: make_agent_from_hparams(agent_type, base_env, stacked_env, loop_hparams, policy_hparams, planner_hparams, model_dir, policy_dir, sampling_temp, video_writers) and returns: make_agent, rl