nodes: 0, module; 1, function_definition; 2, function_name:flatten_dict; 3, parameters; 4, block; 5, identifier:dict_obj; 6, default_parameter; 7, default_parameter; 8, expression_statement; 9, expression_statement; 10, expression_statement; 11, function_definition; 12, function_definition; 13, expression_statement; 14, return_statement; 15, identifier:separator; 16, string; 17, identifier:flatten_lists; 18, False; 19, comment:"""Flattens the given dict into a single-level dict with flattend keys.
  
      Parameters
      ----------
      dict_obj : dict
          A possibly nested dict.
      separator : str, optional
          The character to use as a separator between keys. Defaults to '.'.
      flatten_lists : bool, optional
          If True, list values are also flattened. False by default.
  
      Returns
      -------
      dict
          A shallow dict, where no value is a dict in itself, and keys are
          concatenations of original key paths separated with the given
          separator.
  
      Example
      -------
      >>> dicti = {'a': 1, 'b': {'g': 4, 'o': 9}, 'x': [4, 'd']}
      >>> flat = flatten_dict(dicti)
      >>> sorted(flat.items())
      [('a', 1), ('b.g', 4), ('b.o', 9), ('x.0', 4), ('x.1', 'd')]
      """; 20, assignment; 21, assignment; 22, function_name:_flatten_key_val; 23, parameters; 24, block; 25, function_name:_flatten; 26, parameters; 27, block; 28, call; 29, identifier:flat; 30, string_content:.; 31, identifier:reducer; 32, call; 33, identifier:flat; 34, dictionary; 35, identifier:key; 36, identifier:val; 37, identifier:parent; 38, expression_statement; 39, try_statement; 40, identifier:d; 41, default_parameter; 42, try_statement; 43, identifier:_flatten; 44, argument_list; 45, identifier:_get_key_reducer; 46, argument_list; 47, assignment; 48, block; 49, except_clause; 50, identifier:parent; 51, None; 52, block; 53, except_clause; 54, identifier:dict_obj; 55, identifier:separator; 56, identifier:flat_key; 57, call; 58, expression_statement; 59, identifier:TypeError; 60, block; 61, for_statement; 62, identifier:AttributeError; 63, block; 64, identifier:reducer; 65, argument_list; 66, call; 67, expression_statement; 68, pattern_list; 69, call; 70, block; 71, if_statement; 72, for_statement; 73, identifier:parent; 74, identifier:key; 75, identifier:_flatten; 76, argument_list; 77, assignment; 78, identifier:key; 79, identifier:val; 80, attribute; 81, argument_list; 82, expression_statement; 83, call; 84, block; 85, pattern_list; 86, call; 87, block; 88, identifier:val; 89, identifier:flat_key; 90, subscript; 91, identifier:val; 92, identifier:d; 93, identifier:items; 94, call; 95, identifier:isinstance; 96, argument_list; 97, raise_statement; 98, identifier:i; 99, identifier:value; 100, identifier:enumerate; 101, argument_list; 102, expression_statement; 103, identifier:flat; 104, identifier:flat_key; 105, identifier:_flatten_key_val; 106, argument_list; 107, identifier:d; 108, tuple; 109, identifier:TypeError; 110, identifier:d; 111, call; 112, identifier:key; 113, identifier:val; 114, identifier:parent; 115, identifier:str; 116, identifier:bytes; 117, identifier:_flatten_key_val; 118, argument_list; 119, call; 120, identifier:value; 121, identifier:parent; 122, identifier:str; 123, argument_list; 124, identifier:i
code: def flatten_dict(dict_obj, separator='.', flatten_lists=False):
      """Flattens the given dict into a single-level dict with flattend keys.
  
      Parameters
      ----------
      dict_obj : dict
          A possibly nested dict.
      separator : str, optional
          The character to use as a separator between keys. Defaults to '.'.
      flatten_lists : bool, optional
          If True, list values are also flattened. False by default.
  
      Returns
      -------
      dict
          A shallow dict, where no value is a dict in itself, and keys are
          concatenations of original key paths separated with the given
          separator.
  
      Example
      -------
      >>> dicti = {'a': 1, 'b': {'g': 4, 'o': 9}, 'x': [4, 'd']}
      >>> flat = flatten_dict(dicti)
      >>> sorted(flat.items())
      [('a', 1), ('b.g', 4), ('b.o', 9), ('x.0', 4), ('x.1', 'd')]
      """
      reducer = _get_key_reducer(separator)
      flat = {}
  
      def _flatten_key_val(key, val, parent):
          flat_key = reducer(parent, key)
          try:
              _flatten(val, flat_key)
          except TypeError:
              flat[flat_key] = val
  
      def _flatten(d, parent=None):
          try:
              for key, val in d.items():
                  _flatten_key_val(key, val, parent)
          except AttributeError:
              if isinstance(d, (str, bytes)):
                  raise TypeError
              for i, value in enumerate(d):
                  _flatten_key_val(str(i), value, parent)
      _flatten(dict_obj)
      return flat