code: def test_parallelization(self):
      self.start_tests(name="parallelization")
  
      # ====================
  
      agent = "benchmarks/configs/ppo.json"
      environment = "benchmarks/configs/cartpole.json"
      runner = Runner(
          agent=agent, environment=environment, num_parallel=4
      )
      # Batch act/observe calls to agent, unless environment.is_vectorizable()
      # (otherwise essentially equivalent to single environment)
      runner.run(num_episodes=10, batch_agent_calls=True)
      runner.close()
  
      # ====================
  
      agent = "benchmarks/configs/ppo.json"
      environment = "custom_cartpole"
      runner = Runner(
          agent=agent,
          environment=environment,
          max_episode_timesteps=500,
          num_parallel=4,
      )
      runner.run(num_episodes=10)
      runner.close()
  
      # ====================
  
      agent = "benchmarks/configs/ppo.json"
      environment = "benchmarks/configs/cartpole.json"
      runner = Runner(
          agent=agent,
          environment=environment,
          num_parallel=4,
          remote="multiprocessing",
      )
      runner.run(
          num_episodes=10, batch_agent_calls=True
      )  # optional: batch_agent_calls=True
      runner.close()
  
      # ====================
  
      agent = "benchmarks/configs/ppo.json"
      environment = "benchmarks/configs/cartpole.json"
  
      def server(port):
          Environment.create(
              environment=environment, remote="socket-server", port=port
          )
  
      server1 = Thread(target=server, kwargs=dict(port=65432))
      server2 = Thread(target=server, kwargs=dict(port=65433))
      server1.start()
      server2.start()
  
      runner = Runner(
          agent=agent,
          num_parallel=2,
          remote="socket-client",
          host="127.0.0.1",
          port=65432,
      )
      runner.run(num_episodes=10)  # optional: batch_agent_calls=True
      runner.close()
  
      server1.join()
      server2.join()
  
      # ====================
  
      self.finished_test()
  
imports: import os
  from tempfile import TemporaryDirectory
  from threading import Thread
  import unittest
  import numpy
  import tensorflow
  from tensorforce import Agent, Environment, Runner
  from test.unittest_base import UnittestBase
label_desc: Use image node_id 8 for calling the TestExamples obj's underlying member method code with example usage: obj.test_parallelization() without return types