code: def test_vecenv_custom_calls(vec_env_class, vec_env_wrapper):
      """Test access to methods/attributes of vectorized environments"""
  
      def make_env():
          return CustomGymEnv(
              gym.spaces.Box(low=np.zeros(2), high=np.ones(2))
          )
  
      vec_env = vec_env_class([make_env for _ in range(N_ENVS)])
  
      if vec_env_wrapper is not None:
          if vec_env_wrapper == VecFrameStack:
              vec_env = vec_env_wrapper(vec_env, n_stack=2)
          else:
              vec_env = vec_env_wrapper(vec_env)
  
      # Test seed method
      vec_env.seed(0)
      # Test render method call
      # vec_env.render()  # we need a X server  to test the "human" mode
      vec_env.render(mode="rgb_array")
  
      env_method_results = vec_env.env_method(
          "custom_method", 1, indices=None, dim_1=2
      )
      setattr_results = []
      # Set current_step to an arbitrary value
      for env_idx in range(N_ENVS):
          setattr_results.append(
              vec_env.set_attr("current_step", env_idx, indices=env_idx)
          )
      # Retrieve the value for each environment
      getattr_results = vec_env.get_attr("current_step")
  
      assert len(env_method_results) == N_ENVS
      assert len(setattr_results) == N_ENVS
      assert len(getattr_results) == N_ENVS
  
      for env_idx in range(N_ENVS):
          assert (env_method_results[env_idx] == np.ones((1, 2))).all()
          assert setattr_results[env_idx] is None
          assert getattr_results[env_idx] == env_idx
  
      # Call env_method on a subset of the VecEnv
      env_method_subset = vec_env.env_method(
          "custom_method", 1, indices=[0, 2], dim_1=3
      )
      assert (env_method_subset[0] == np.ones((1, 3))).all()
      assert (env_method_subset[1] == np.ones((1, 3))).all()
      assert len(env_method_subset) == 2
  
      # Test to change value for all the environments
      setattr_result = vec_env.set_attr(
          "current_step", 42, indices=None
      )
      getattr_result = vec_env.get_attr("current_step")
      assert setattr_result is None
      assert getattr_result == [42 for _ in range(N_ENVS)]
  
      # Additional tests for setattr that does not affect all the environments
      vec_env.reset()
      setattr_result = vec_env.set_attr(
          "current_step", 12, indices=[0, 1]
      )
      getattr_result = vec_env.get_attr("current_step")
      getattr_result_subset = vec_env.get_attr(
          "current_step", indices=[0, 1]
      )
      assert setattr_result is None
      assert getattr_result == [12 for _ in range(2)] + [
          0 for _ in range(N_ENVS - 2)
      ]
      assert getattr_result_subset == [12, 12]
      assert vec_env.get_attr("current_step", indices=[0, 2]) == [12, 0]
  
      vec_env.reset()
      # Change value only for first and last environment
      setattr_result = vec_env.set_attr(
          "current_step", 12, indices=[0, -1]
      )
      getattr_result = vec_env.get_attr("current_step")
      assert setattr_result is None
      assert getattr_result == [12] + [0 for _ in range(N_ENVS - 2)] + [
          12
      ]
      assert vec_env.get_attr("current_step", indices=[-1]) == [12]
  
      vec_env.close()
  
imports: import collections
  import functools
  import itertools
  import multiprocessing
  import pytest
  import gym
  import numpy
  from stable_baselines.common.vec_env import DummyVecEnv, SubprocVecEnv, VecNormalize, VecFrameStack
label_desc: Use image node_id 1 for calling a global function with example usage: test_vecenv_custom_calls(vec_env_class, vec_env_wrapper) and returns: CustomGymEnv