code: def _convert_key_path_to_dict(
      key_path: Union[_KeyPath, Tuple[()]]
  ) -> Dict[str, Any]:
      """Recursively converts _KeyPath to nested dict."""
      return (
          {key_path[0]: _convert_key_path_to_dict(key_path[1:])}
          if key_path
          else {}
      )
  
file_path: model-analysis/tensorflow_model_analysis/metrics/stats.py
imports: import dataclasses
  from typing import Any, Dict, Iterable, Optional, Tuple, Union
  import apache_beam
  from tensorflow_model_analysis.metrics import metric_types
  from tensorflow_model_analysis.utils import util
label_desc: Use image node_id 1 for calling a global function with example usage: _convert_key_path_to_dict(key_path) and returns: unknown