docstr: Tests whether correct dict order is restored based on the original order.
docstr_tok: ["Tests","whether","correct","dict","order","is","restored","based","on","the","original","order","."]
code: def test_dict_space_with_ordered_dict(self):
      """Tests whether correct dict order is restored based on the original order."""
      # User provides an OrderedDict -> gymnasium should take it and not further
      # sort the keys. The same (user-provided) order must be restored.
      input_space = gym.spaces.Dict(
          OrderedDict(
              {
                  "b_key": gym.spaces.Box(
                      low=np.array([-1.0]), high=np.array([1.0])
                  ),
                  "a_key": gym.spaces.Discrete(n=3),
              }
          )
      )
      serialized_dict = space_to_dict(input_space)
      deserialized_space = space_from_dict(serialized_dict)
      self.assertTrue(input_space == deserialized_space)
  
      # User provides a simple dict -> gymnasium automatically sorts all keys
      # alphabetically. The same (alphabetical) order must be restored.
      input_space = gym.spaces.Dict(
          {
              "b_key": gym.spaces.Box(
                  low=np.array([-1.0]), high=np.array([1.0])
              ),
              "a_key": gym.spaces.Discrete(n=3),
          }
      )
      serialized_dict = space_to_dict(input_space)
      deserialized_space = space_from_dict(serialized_dict)
      self.assertTrue(input_space == deserialized_space)
  
imports: import unittest
  from collections import OrderedDict
  import gymnasium
  import numpy
  from ray.rllib.utils.serialization import convert_numpy_to_python_primitives, gym_space_from_dict, gym_space_to_dict, space_from_dict, space_to_dict
  from ray.rllib.utils.spaces.flexdict import FlexDict
  from ray.rllib.utils.spaces.repeated import Repeated
  from ray.rllib.utils.spaces.simplex import Simplex
label_desc: Use image node_id 7 for calling the TestGymCheckEnv obj's underlying member method code with example usage: obj.test_dict_space_with_ordered_dict() without return types