code: def test_flatten_with_path():
      """Test that the flatten function works as expected."""
      assert _flatten_with_path([{"foo": 42}]) == [((0, "foo"), 42)]
  
      assert _flatten_with_path("value") == [((), "value")]
      assert _flatten_with_path({"key": "value"}) == [
          (("key",), "value")
      ]
      # Order doesn't matter
      ordered_dict1 = collections.OrderedDict(
          [("key1", "value1"), ("key2", "value2")]
      )
      ordered_dict2 = collections.OrderedDict(
          [("key2", "value2"), ("key1", "value1")]
      )
      expected_result = [(("key1",), "value1"), (("key2",), "value2")]
      assert _flatten_with_path(ordered_dict1) == expected_result
      assert _flatten_with_path(ordered_dict2) == expected_result
  
      complex_dict = {
          "key": "value",
          "nested": {
              "subkey": ["subvalue0", "subvalue1"],
              "subnested": {
                  "subsubkey1": "subsubvalue1",
                  "subsubkey2": "subsubvalue2",
              },
          },
          "key2": "value2",
      }
      assert _flatten_with_path(complex_dict) == [
          (("key",), "value"),
          (("key2",), "value2"),
          (("nested", "subkey", 0), "subvalue0"),
          (("nested", "subkey", 1), "subvalue1"),
          (
              (
                  "nested",
                  "subnested",
                  "subsubkey1",
              ),
              "subsubvalue1",
          ),
          (
              (
                  "nested",
                  "subnested",
                  "subsubkey2",
              ),
              "subsubvalue2",
          ),
      ]
      # Order is consistent with tf.nest.flatten
      assert [
          v for _, v in _flatten_with_path(complex_dict)
      ] == tf.nest.flatten(complex_dict)
  
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 3 for calling a global function with example usage: test_flatten_with_path() without return types