class_docstr: Base (abstract) environment for interactive human play with gym.utils.play.
  
  Additionally to normal actions passed to underlying environment(s) it
  allows to pass special actions by `step` method.
  
  Special actions:
    RETURN_DONE_ACTION: Returns done from `step` to force gym.utils.play to
      call reset.
    TOGGLE_WAIT_ACTION: Change between real-time-play and wait-for-pressed-key
      modes.
    WAIT_MODE_NOOP_ACTION: perform noop action (when wait-for-pressed-key mode
    is on)
  
  For keyboard keys related to actions above see `get_keys_to_action` method.
  
  Naming conventions:
    envs_step_tuples: Dictionary of tuples similar to these returned by
      gym.Env.step().
      {
        "env_name": (observation, reward, done, info),
        ...
      }
      Keys depend on subclass.
class_docstr_tok: ["Base","(","abstract",")","environment","for","interactive","human","play","with","gym.utils.play",".","Additionally","to","normal","actions","passed","to","underlying","environment","(","s",")","it","allows","to","pass","special","actions","by","`","step","`","method",".","Special","actions",":","RETURN_DONE_ACTION",":","Returns","done","from","`","step","`","to","force","gym.utils.play","to","call","reset",".","TOGGLE_WAIT_ACTION",":","Change","between","real-time-play","and","wait-for-pressed-key","modes",".","WAIT_MODE_NOOP_ACTION",":","perform","noop","action","(","when","wait-for-pressed-key","mode","is","on",")","For","keyboard","keys","related","to","actions","above","see","`","get_keys_to_action","`","method",".","Naming","conventions",":","envs_step_tuples",":","Dictionary","of","tuples","similar","to","these","returned","by","gym.Env.step","(",")",".","{","``","env_name","''",":","(","observation",",","reward",",","done",",","info",")",",","...","}","Keys","depend","on","subclass","."]
docstr: Get mapping from keyboard keys to actions.
  
  Required by gym.utils.play in environment or top level wrapper.
  
  Returns:
    {
      Unicode code point for keyboard key: action (formatted for step()),
      ...
    }
docstr_tok: ["Get","mapping","from","keyboard","keys","to","actions",".","Required","by","gym.utils.play","in","environment","or","top","level","wrapper",".","Returns",":","{","Unicode","code","point","for","keyboard","key",":","action","(","formatted","for","step","(",")",")",",","...","}"]
code: def get_keys_to_action(self):
      """Get mapping from keyboard keys to actions.
  
      Required by gym.utils.play in environment or top level wrapper.
  
      Returns:
        {
          Unicode code point for keyboard key: action (formatted for step()),
          ...
        }
      """
      # Based on gym AtariEnv.get_keys_to_action()
      keyword_to_key = {
          "UP": ord("w"),
          "DOWN": ord("s"),
          "LEFT": ord("a"),
          "RIGHT": ord("d"),
          "FIRE": ord(" "),
      }
  
      keys_to_action = {}
  
      for action_id, action_meaning in enumerate(self.action_meanings):
          keys_tuple = tuple(
              sorted(
                  [
                      key
                      for keyword, key in keyword_to_key.items()
                      if keyword in action_meaning
                  ]
              )
          )
          assert keys_tuple not in keys_to_action
          keys_to_action[keys_tuple] = action_id
  
      # Special actions:
      keys_to_action[(ord("r"),)] = self.RETURN_DONE_ACTION
      keys_to_action[(ord("c"),)] = self.TOGGLE_WAIT_ACTION
      keys_to_action[(ord("n"),)] = self.WAIT_MODE_NOOP_ACTION
  
      return keys_to_action
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import gym
  from gym.utils import play
  import numpy
  from tensor2tensor.bin import t2t_trainer
  from tensor2tensor.rl import player_utils
  from tensor2tensor.rl.envs.simulated_batch_env import PIL_Image
  from tensor2tensor.rl.envs.simulated_batch_env import PIL_ImageDraw
  from tensor2tensor.rl.envs.simulated_batch_gym_env import FlatBatchEnv
  from tensor2tensor.rl.rl_utils import absolute_hinge_difference
  from tensor2tensor.rl.rl_utils import full_game_name
  import tensor2tensor.rl.trainer_model_based_params
  from tensor2tensor.utils import registry
  import tensorflow.compat.v1
label_desc: Use image node_id 2 for calling the PlayerEnv obj's underlying member method code with example usage: obj.get_keys_to_action() and returns: keys_to_action