code: def get_player(train=False, dumpdir=None):
      use_gym = not ENV_NAME.endswith(".bin")
      if use_gym:
          env = gym.make(ENV_NAME)
      else:
          from atari import AtariPlayer
  
          env = AtariPlayer(
              ENV_NAME,
              frame_skip=4,
              viz=False,
              live_lost_as_eoe=train,
              max_num_frames=60000,
              grayscale=False,
          )
      if dumpdir:
          env = gym.wrappers.Monitor(
              env, dumpdir, video_callable=lambda _: True
          )
      env = FireResetEnv(env)
      env = MapState(env, lambda im: cv2.resize(im, IMAGE_SIZE))
      env = FrameStack(env, 4)
      if train and use_gym:
          env = LimitLength(env, 60000)
      return env
  
imports: import argparse
  import cv2
  import gym
  import multiprocessing
  import numpy
  import os
  import sys
  import uuid
  import tensorflow
  from six.moves import queue
  from concurrent import futures
  from tensorpack import *
  from tensorpack.tfutils.gradproc import MapGradient, SummaryGradient
  from tensorpack.utils.concurrency import ensure_proc_terminate, start_proc_mask_signal
  from tensorpack.utils.gpu import get_num_gpu
  from tensorpack.utils.serialize import dumps
  from atari_wrapper import FireResetEnv, FrameStack, LimitLength, MapState
  from common import Evaluator, eval_model_multithread, play_n_episodes
  from simulator import SimulatorMaster, SimulatorProcess, TransitionExperience
label_desc: Use image node_id 1 for calling a global function with example usage: get_player(train, dumpdir) and returns: env