code: def _flatten_dict(x: Dict) -> Tuple[Dict, bool]:
      """Flatten dict of dicts into single dict and checking for duplicates in keys along the way."""
      new_dict = {}
      duplicates = False
      for key, value in x.items():
          if isinstance(value, dict):
              for k, v in value.items():
                  if k in new_dict:
                      duplicates = True
                  new_dict[k] = v
          else:
              if key in new_dict:
                  duplicates = True
              new_dict[key] = value
      return new_dict, duplicates
  
imports: import sys
  from typing import Any, Dict, List, Optional, Sequence, Tuple, Union
  import torch
  from lightning_utilities import apply_to_collection
  from torch import Tensor
  from torchmetrics.utilities.exceptions import TorchMetricsUserWarning
  from torchmetrics.utilities.imports import _TORCH_GREATER_EQUAL_1_12, _TORCH_GREATER_EQUAL_1_13, _XLA_AVAILABLE
  from torchmetrics.utilities.prints import rank_zero_warn
label_desc: Use image node_id 7 for calling a global function with example usage: _flatten_dict(x) and returns: new_dict,  duplicates