code: def get_player(viz=False, train=False):
      if USE_GYM:
          env = gym.make(ENV_NAME, render_mode="human" if viz else None)
      else:
          from atari import AtariPlayer
  
          env = AtariPlayer(
              ENV_NAME,
              frame_skip=4,
              viz=viz,
              live_lost_as_eoe=train,
              max_num_frames=60000,
          )
      env = FireResetEnv(env)
      env = MapState(env, lambda im: resize_keepdims(im, IMAGE_SIZE))
      if not train:
          # in training, history is taken care of in expreplay buffer
          env = FrameStack(env, FRAME_HISTORY)
      if train and USE_GYM:
          env = LimitLength(env, 60000)
      return env
  
file_path: tensorpack/examples/DeepQNetwork/DQN.py
imports: import argparse
  import numpy
  import os
  import cv2
  import gym
  import tensorflow
  from tensorpack import *
  from atari_wrapper import FireResetEnv, FrameStack, LimitLength, MapState
  from common import Evaluator, eval_model_multithread, play_n_episodes
  from DQNModel import Model
  from expreplay import ExpReplay
label_desc: Use image node_id 2 for calling a global function with example usage: get_player(viz, train) and returns: env