code: def test_flatten_nest_dict(self):
      nest_d = {
          "a": 1,
          "b/c": 2,
          "b": {
              "e": 3,
              "f": {"g": 4},
          },
      }
      flat_d = {
          "a": 1,
          "b/c": 2,
          "b/e": 3,
          "b/f/g": 4,
      }
  
      self.assertEqual(py_utils.flatten_nest_dict(nest_d), flat_d)
      self.assertEqual(
          py_utils.pack_as_nest_dict(flat_d, nest_d), nest_d
      )
  
      with self.assertRaisesWithPredicateMatch(
          ValueError, "Extra keys"
      ):
          py_utils.pack_as_nest_dict(
              {
                  "a": 1,
                  "b/c": 2,
                  "b/e": 3,
                  "b/f/g": 4,
                  "b/h": 5,  # Extra key
              },
              nest_d,
          )
  
      with self.assertRaisesWithPredicateMatch(KeyError, "b/e"):
          py_utils.pack_as_nest_dict(
              {
                  "a": 1,
                  "b/c": 2,
                  "b/d": 3,
              },
              {
                  "a": 1,
                  "b": {
                      "c": 2,
                      "d": 3,
                      "e": 4,  # Extra key
                  },
              },
          )
  
      with self.assertRaisesWithPredicateMatch(
          ValueError, "overwrite existing key:"
      ):
          py_utils.flatten_nest_dict(
              {
                  "a": {
                      "b": 1,
                  },
                  "a/b": 2,  # Collision
              }
          )
  
imports: import collections
  import pathlib
  from etils import epath
  import pytest
  import tensorflow
  from tensorflow_datasets import testing
  from tensorflow_datasets.core import constants
  from tensorflow_datasets.core import utils
  from tensorflow_datasets.core.utils import py_utils
label_desc: Use image node_id 5 for calling the PyUtilsTest obj's underlying member method code with example usage: obj.test_flatten_nest_dict() without return types