code: def test_write_to_shared_memory(space):
      def assert_nested_equal(lhs, rhs):
          assert isinstance(rhs, list)
          if isinstance(lhs, (list, tuple)):
              for i in range(len(lhs)):
                  assert_nested_equal(lhs[i], [rhs_[i] for rhs_ in rhs])
  
          elif isinstance(lhs, (dict, OrderedDict)):
              for key in lhs.keys():
                  assert_nested_equal(
                      lhs[key], [rhs_[key] for rhs_ in rhs]
                  )
  
          elif isinstance(lhs, SynchronizedArray):
              assert np.all(
                  np.array(lhs[:]) == np.stack(rhs, axis=0).flatten()
              )
  
          else:
              raise TypeError(f"Got unknown type `{type(lhs)}`.")
  
      shared_memory_n8 = create_shared_memory(space, n=8)
      samples = [space.sample() for _ in range(8)]
  
      processes = [
          Process(
              target=_write_shared_memory,
              args=(space, i, shared_memory_n8, samples[i]),
          )
          for i in range(8)
      ]
  
      for process in processes:
          process.start()
      for process in processes:
          process.join()
  
      assert_nested_equal(shared_memory_n8, samples)
  
file_path: gym/tests/vector/test_shared_memory.py
imports: import multiprocessing
  from collections import OrderedDict
  from multiprocessing import Array, Process
  from multiprocessing.sharedctypes import SynchronizedArray
  import numpy
  import pytest
  from gym.error import CustomSpaceError
  from gym.spaces import Dict, Tuple
  from gym.vector.utils.shared_memory import create_shared_memory, read_from_shared_memory, write_to_shared_memory
  from gym.vector.utils.spaces import BaseGymSpaces
  from tests.vector.utils import custom_spaces, spaces
label_desc: Use image node_id 4 for calling a global function with example usage: test_write_to_shared_memory(space) without return types