code: def _topologically_sorted_input_keys(
      input_specs: Mapping[str, pipeline_pb2.InputSpec],
      input_graphs: Mapping[str, pipeline_pb2.InputGraph],
  ) -> List[str]:
      """Get topologically sorted input keys."""
      parents = _get_dependencies(input_specs, input_graphs)
      children = _get_reverse_dependencies(parents)
      _check_cycle(input_specs.keys(), parents)
  
      topsorted_layers = topsort.topsorted_layers(
          list(input_specs.keys()),
          get_node_id_fn=lambda x: x,
          get_parent_nodes=parents.__getitem__,
          get_child_nodes=children.__getitem__,
      )
  
      result = []
      for layer in topsorted_layers:
          result.extend(layer)
      return result
  
imports: import collections
  from typing import Dict, Iterable, List, Mapping, Sequence, Tuple, TypeVar
  from tfx import types
  from tfx.dsl.compiler import placeholder_utils
  from tfx.orchestration import metadata
  from tfx.orchestration import mlmd_connection_manager
  from tfx.orchestration.portable import data_types
  from tfx.orchestration.portable.input_resolution import exceptions
  from tfx.orchestration.portable.input_resolution import input_graph_resolver
  from tfx.orchestration.portable.input_resolution import partition_utils
  from tfx.orchestration.portable.input_resolution import channel_resolver
  from tfx.proto.orchestration import pipeline_pb2
  from tfx.types import artifact_utils
  from tfx.utils import topsort
  from tfx.utils import typing_utils
  from tfx.utils import governance_utils
label_desc: Use image node_id 5 for calling a global function with example usage: _topologically_sorted_input_keys(input_specs, input_graphs) and returns: result