code: def test_flatten_nested(self):
      f = features_lib.FeaturesDict(
          {
              "a": np.int32,
              "b": {
                  "c": {
                      "d": np.int32,
                      "e": np.int32,
                  },
              },
              "f": features_lib.Sequence(
                  {
                      "g": features_lib.Sequence(np.int32),
                      "h": np.int32,
                  }
              ),
          }
      )
  
      flat1 = f._flatten(
          {
              "a": "a",
              "b": {
                  "c": {
                      "d": {"d": 123},
                  },
              },
              "f": {
                  "g": "g",
              },
          }
      )
      self.assertEqual(
          flat1,
          [
              "a",
              {"d": 123},
              None,  # 'e'
              "g",
              None,  # h
          ],
      )
      self.assertEqual(
          f._nest(flat1),
          {
              "a": "a",
              "b": {
                  "c": {
                      "d": {"d": 123},
                      "e": None,
                  },
              },
              "f": {
                  "g": "g",
                  "h": None,
              },
          },
      )
  
      f = features_lib.FeaturesDict(
          {
              "a": np.int32,
              "b": {
                  "c": np.int32,
              },
          }
      )
      with self.assertRaisesWithPredicateMatch(
          ValueError, "received a non dict"
      ):
          f._flatten({"b": 123})
  
      with self.assertRaisesWithPredicateMatch(
          ValueError, "Unrecognized keys: ['d']"
      ):
          f._flatten({"b": {"c": 123, "d": 123}})
  
      with self.assertRaisesWithPredicateMatch(
          ValueError, "Expected length 2 does not match input length 3"
      ):
          f._nest([None, None, None])
  
file_path: datasets/tensorflow_datasets/core/features/top_level_feature_test.py
imports: import time
  import numpy
  from tensorflow_datasets import testing
  from tensorflow_datasets.core import features
  from tensorflow_datasets.core.features import top_level_feature
label_desc: Use image node_id 2 for calling the FeaturesManagerTest obj's underlying member method code with example usage: obj.test_flatten_nested() without return types