code: def _keys_and_values(  # pylint: disable=invalid-name
      key_maybe_dict: Union[str, Dict[str, str]],
      features: Dict[str, np.ndarray],
  ) -> Tuple[
      Optional[List[str]],
      Optional[Union[np.ndarray, Dict[str, np.ndarray]]],
  ]:
      """Returns keys and values in dict given key (or dict of keys)."""
      if isinstance(key_maybe_dict, dict):
          values = {}
          keys = set()
          for output_name, key in key_maybe_dict.items():
              if key in features:
                  values[output_name] = features[key]
                  if key not in keys:
                      keys.add(key)
          return (list(keys), values)
      elif key_maybe_dict in features:
          return ([key_maybe_dict], features[key_maybe_dict])
      else:
          return ([], None)
  
file_path: model-analysis/tensorflow_model_analysis/extractors/legacy_input_extractor.py
imports: import copy
  from typing import Any, Dict, List, Optional, Tuple, Union
  import apache_beam
  import numpy
  from tensorflow_model_analysis import constants
  from tensorflow_model_analysis.api import types
  from tensorflow_model_analysis.extractors import extractor
  from tensorflow_model_analysis.proto import config_pb2
  from tfx_bsl.coders import example_coder
label_desc: Use image node_id 2 for calling a global function with example usage: _keys_and_values(key_maybe_dict, features) and returns: list,  values, list,  features, list,  None