code: def test_composite():
      # Inspired by OpenAI gym:
      # https://github.com/openai/gym/blob/master/tests/spaces/utils.py
      COMPOSITE_SPACES = [
          MutableList([Categorical(range(5)), Categorical(range(4))]),
          MutableList([Categorical(range(5)), Numerical(0, 5)]),
          MutableList(
              [
                  Categorical(range(5)),
                  MutableList(
                      [
                          Numerical(low=0.0, high=1.0),
                          Categorical(range(2)),
                      ]
                  ),
              ]
          ),
          MutableList(
              [
                  Categorical(range(3)),
                  MutableDict(
                      position=Numerical(low=0.0, high=1.0),
                      velocity=Categorical(range(2)),
                  ),
              ]
          ),
          MutableDict(
              {
                  "position": Categorical(range(5)),
                  "velocity": Numerical(
                      low=1, high=5, log_distributed=True
                  ),
              }
          ),
          MutableDict(
              position=Categorical(range(6)),
              velocity=Numerical(low=1, high=5, log_distributed=True),
          ),
          # TODO: Graph not supported yet.
          # MutableList((Graph(node_space=Box(-1, 1, shape=(2, 1)), edge_space=None), Categorical(2))),
          # MutableDict(
          #     a=MutableDict(
          #         a=Graph(node_space=Numerical(-100, 100), edge_space=None),
          #         b=Numerical(-100, 100),
          #     ),
          #     b=MutableList(Numerical(-100, 100), Numerical(-100, 100))
          # ),
          # Graph(node_space=Numerical(low=-100, high=100), edge_space=Categorical(range(5))),
          # Graph(node_space=Categorical(range(5)), edge_space=Numerical(low=-100, high=100)),
          # Graph(node_space=Categorical(3), edge_space=Categorical(range(4))),
      ]
  
      for space in COMPOSITE_SPACES:
          # Sanity check
          space.default()
          space.random()
          for _ in space.grid():
              pass
  
      space = MutableDict(
          {
              "a": Numerical(low=0, high=1, label="x"),
              "b": MutableDict(
                  {
                      "b_1": Numerical(low=-100, high=100),
                      "b_2": Numerical(low=-1, high=1),
                      "b_3": Numerical(low=0, high=1, label="x"),
                  }
              ),
              "c": Categorical(range(4)),
          }
      )
  
      for _ in range(10):
          sample = space.random()
          assert sample["a"] == sample["b"]["b_3"]
  
imports: import math
  from collections import Counter
  import numpy
  import pytest
  from nni.mutable import *
  from nni.mutable.mutable import _dedup_labeled_mutables, _mutable_equal
label_desc: Use image node_id 8 for calling a global function with example usage: test_composite() without return types