code: def test_pytree_serialize_namedtuple(self):
      Point = namedtuple("Point", ["x", "y"])
      spec = py_pytree.TreeSpec(
          namedtuple,
          Point,
          [py_pytree.LeafSpec(), py_pytree.LeafSpec()],
      )
  
      roundtrip_spec = py_pytree.treespec_loads(
          py_pytree.treespec_dumps(spec)
      )
      # The context in the namedtuple is different now because we recreated
      # the namedtuple type.
      self.assertEqual(
          spec.context._fields, roundtrip_spec.context._fields
      )
  
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 6 for calling the TestPythonPytree obj's underlying member method code with example usage: obj.test_pytree_serialize_namedtuple() without return types