code: def testEncodeDecodeNamedTuple(self):
      named_tuple_type = collections.namedtuple(
          "NamedTuple", ["x", "y"]
      )
      named_tuple = named_tuple_type(x=[1, 2], y="hello")
      self.assertTrue(nested_structure_coder.can_encode(named_tuple))
      encoded = nested_structure_coder.encode_structure(named_tuple)
      expected = struct_pb2.StructuredValue()
      expected_named_tuple = expected.named_tuple_value
      expected_named_tuple.name = "NamedTuple"
      key_value_pair = expected_named_tuple.values.add()
      key_value_pair.key = "x"
      list_value = key_value_pair.value.list_value
      list_value.values.add().int64_value = 1
      list_value.values.add().int64_value = 2
      key_value_pair = expected_named_tuple.values.add()
      key_value_pair.key = "y"
      key_value_pair.value.string_value = "hello"
      self.assertEqual(expected, encoded)
      decoded = nested_structure_coder.decode_proto(encoded)
      self.assertEqual(named_tuple._asdict(), decoded._asdict())
      self.assertEqual(
          named_tuple.__class__.__name__, decoded.__class__.__name__
      )
  
imports: import collections
  import typing
  import warnings
  import numpy
  from google.protobuf import text_format
  from tensorflow.core.protobuf import struct_pb2
  from tensorflow.python.data.ops import dataset_ops
  from tensorflow.python.framework import constant_op
  from tensorflow.python.framework import dtypes
  from tensorflow.python.framework import extension_type
  from tensorflow.python.framework import sparse_tensor
  from tensorflow.python.framework import tensor
  from tensorflow.python.framework import tensor_shape
  from tensorflow.python.framework import tensor_util
  from tensorflow.python.framework import test_util
  from tensorflow.python.framework import type_spec
  from tensorflow.python.framework import type_spec_registry
  from tensorflow.python.ops.ragged import ragged_tensor
  from tensorflow.python.platform import test
  from tensorflow.python.saved_model import nested_structure_coder
  from tensorflow.python.types import internal
label_desc: Use image node_id 5 for calling the NestedStructureCoderTest obj's underlying member method code with example usage: obj.testEncodeDecodeNamedTuple() without return types