code: def test_component_ctor():
      random.seed(5_432_671_244)
  
      A = 100
      B = 200
      C = 300
  
      x_list = [
          Foo(
              str(random.randint(0, A)),
              Complex(
                  x=random.uniform(0, C), y=str(random.uniform(0, C))
              ),
              b=random.uniform(0, B),
          )
          for i in range(4)
      ]
      fields = [
          Foo(
              a=str(random.randint(0, A)),
              b=random.uniform(0, B),
              c=Complex(
                  x=str(random.uniform(0, C)), y=random.uniform(0, C)
              ),
          )
          for i in range(5)
      ]
      x_dict = {
          i: Foo(
              b=random.uniform(0, B),
              a=str(random.randint(0, A)),
              c=Complex(
                  x=str(random.uniform(0, C)),
                  y=str(random.uniform(0, C)),
              ),
          )
          for i in range(6)
      }
  
      bar01 = Bar(x_list, input_fields=fields, x_dict=x_dict)
      bar02 = load_json(dump_json(bar01))
  
      assert all(isinstance(bar.x_list, list) for bar in [bar01, bar02])
      assert all(isinstance(bar.x_dict, dict) for bar in [bar01, bar02])
      assert all(
          isinstance(bar.input_fields, list) for bar in [bar01, bar02]
      )
  
      assert bar01.x_list == bar02.x_list
      assert bar01.x_dict == bar02.x_dict
      assert bar01.input_fields == bar02.input_fields
  
      baz01 = Baz(a="0", b="9", c=Complex(x="1", y="2"), d="42")
      baz02 = load_json(dump_json(baz01))
  
      assert type(baz01) == type(baz02)
      assert baz01 == baz02
  
file_path: gluonts/test/core/test_component.py
imports: import random
  from typing import Dict, List
  from gluonts.core.component import validated
  from gluonts.core.serde import dump_json, load_json
label_desc: Use image node_id 1 for calling a global function with example usage: test_component_ctor() without return types