docstr: Tests the time taken by `validate_workers_after_construction=True`.
docstr_tok: ["Tests","the","time","taken","by","`","validate_workers_after_construction=True","`","."]
code: def test_worker_validation_time(self):
      """Tests the time taken by `validate_workers_after_construction=True`."""
      config = ppo.PPOConfig().environment(env="CartPole-v1")
      config.validate_workers_after_construction = True
  
      # Test, whether validating one worker takes just as long as validating
      # >> 1 workers.
      config.num_rollout_workers = 1
      t0 = time.time()
      algo = config.build()
      total_time_1 = time.time() - t0
      print(f"Validating w/ 1 worker: {total_time_1}sec")
      algo.stop()
  
      config.num_rollout_workers = 5
      t0 = time.time()
      algo = config.build()
      total_time_5 = time.time() - t0
      print(f"Validating w/ 5 workers: {total_time_5}sec")
      algo.stop()
  
      check(total_time_5 / total_time_1, 1.0, atol=1.0)
  
imports: import gymnasium
  import numpy
  import os
  from pathlib import Path
  from random import choice
  import time
  import unittest
  import ray
  import ray.rllib.algorithms.dqn
  from ray.rllib.algorithms.bc import BCConfig
  import ray.rllib.algorithms.ppo
  from ray.rllib.examples.env.multi_agent import MultiAgentCartPole
  from ray.rllib.examples.parallel_evaluation_and_training import AssertEvalCallback
  from ray.rllib.utils.metrics.learner_info import LEARNER_INFO
  from ray.rllib.utils.test_utils import check, framework_iterator
label_desc: Use image node_id 8 for calling the TestAlgorithm obj's underlying member method code with example usage: obj.test_worker_validation_time() without return types