code: def write_custom_recording_file(directory):
      # Start recording traces after 80 episodes -- by then, the environment is solved
      environment = Environment.create(
          environment="benchmarks/configs/cartpole.json"
      )
      agent = Agent.create(
          agent="benchmarks/configs/ppo.json", environment=environment
      )
      runner = Runner(agent=agent, environment=environment)
      runner.run(num_episodes=80)
      runner.close()
  
      # Record 20 episodes
      for episode in range(20):
          # Record episode experience
          episode_states = list()
          episode_actions = list()
          episode_terminal = list()
          episode_reward = list()
  
          # Evaluation episode
          states = environment.reset()
          terminal = False
          while not terminal:
              episode_states.append(states)
              actions = agent.act(
                  states=states, independent=True, deterministic=True
              )
              episode_actions.append(actions)
              states, terminal, reward = environment.execute(
                  actions=actions
              )
              episode_terminal.append(terminal)
              episode_reward.append(reward)
  
          # Write recorded episode trace to npz file
          np.savez_compressed(
              file=os.path.join(
                  directory, "trace-{:09d}.npz".format(episode)
              ),
              states=np.stack(episode_states, axis=0),
              actions=np.stack(episode_actions, axis=0),
              terminal=np.stack(episode_terminal, axis=0),
              reward=np.stack(episode_reward, axis=0),
          )
  
imports: import os
  import numpy
  from tensorforce import Agent, Environment, Runner
label_desc: Use image node_id 4 for calling a global function with example usage: write_custom_recording_file(directory) without return types