code: def test_pytree_custom_type_serialize(self):
      cxx_pytree.register_pytree_node(
          GlobalDummyType,
          lambda dummy: ([dummy.x, dummy.y], None),
          lambda xs, _: GlobalDummyType(*xs),
          serialized_type_name="GlobalDummyType",
      )
      spec = cxx_pytree.tree_structure(GlobalDummyType(0, 1))
      serialized_spec = cxx_pytree.treespec_dumps(spec)
      roundtrip_spec = cxx_pytree.treespec_loads(serialized_spec)
      self.assertEqual(roundtrip_spec, spec)
  
      class LocalDummyType:
          def __init__(self, x, y):
              self.x = x
              self.y = y
  
      cxx_pytree.register_pytree_node(
          LocalDummyType,
          lambda dummy: ([dummy.x, dummy.y], None),
          lambda xs, _: LocalDummyType(*xs),
          serialized_type_name="LocalDummyType",
      )
      spec = cxx_pytree.tree_structure(LocalDummyType(0, 1))
      serialized_spec = cxx_pytree.treespec_dumps(spec)
      roundtrip_spec = cxx_pytree.treespec_loads(serialized_spec)
      self.assertEqual(roundtrip_spec, spec)
  
imports: import inspect
  import re
  import unittest
  from collections import defaultdict, deque, namedtuple, OrderedDict, UserDict
  import torch
  import torch.utils._pytree
  from torch.testing._internal.common_utils import instantiate_parametrized_tests, IS_FBCODE, parametrize, run_tests, subtest, TEST_WITH_TORCHDYNAMO, TestCase
label_desc: Use image node_id 7 for calling the TestCxxPytree obj's underlying member method code with example usage: obj.test_pytree_custom_type_serialize() without return types