code: def flatten_dict(
      data: Dict[str, Any], sep: str = ".", drop_empty: bool = False
  ) -> Dict[str, Any]:
      """
      Flatten a data dictionary
  
      Parameters
      ----------
      data:
          The data dictionary
      sep:
          The generated key separator. Default="."
      drop_empty:
          If true, keys with empty lists or None values will be omitted
  
      Returns
      -------
  
          A flattened key dictionary
      """
  
      def _is_empty_value(value: Any) -> bool:
          if value is None:
              return True
          if isinstance(value, list) and len(value) == 0:
              return True
          return False
  
      def _flatten_internal_(
          _data: Dict[str, Any], _parent_key="", _sep="."
      ):
          items = []
          for key, value in _data.items():
              if drop_empty and _is_empty_value(value):
                  continue
  
              new_key = _parent_key + _sep + key if _parent_key else key
              try:
                  items.extend(
                      _flatten_internal_(
                          value, new_key, _sep=_sep
                      ).items()
                  )
              except Exception:
                  items.append((new_key, value))
          return dict(items)
  
      return _flatten_internal_(data, _sep=sep)
  
file_path: argilla/src/argilla/server/helpers.py
imports: import logging
  from typing import Any, Dict, List, Optional
label_desc: Use image node_id 2 for calling a global function with example usage: flatten_dict(data, sep, drop_empty) and returns: _flatten_internal_, False, dict, True, True