code: def config_dict_to_text(config):
      # if already string return as is
      if isinstance(config, six.string_types):
          return config
      if not isinstance(config, (dict, list)):
          raise ValueError(
              "Configuration only supports dictionary/list objects"
          )
      try:
          # noinspection PyBroadException
          try:
  
              def raise_on_special_key(config_):
                  if not isinstance(config_, dict):
                      return
                  special_chars = "$}[]:=+#`^?!@*&."
                  for key in config_.keys():
                      if not isinstance(key, str):
                          continue
                      if any(
                          key_char in special_chars for key_char in key
                      ):
                          raise ValueError(
                              "Configuration dictionary keys cannot contain any of the following characters: {}".format(
                                  special_chars
                              )
                          )
                  for val in config_.values():
                      raise_on_special_key(val)
  
              # will fall back to json+pyhocon
              raise_on_special_key(config)
              text = HOCONConverter.to_hocon(
                  ConfigFactory.from_dict(hocon_quote_key(config))
              )
          except Exception:
              # fallback json+pyhocon
              # hack, pyhocon is not very good with dict conversion so we pass through json
              import json
  
              text = json.dumps(config)
              text = HOCONConverter.to_hocon(
                  ConfigFactory.parse_string(text)
              )
  
      except Exception:
          raise ValueError(
              "Could not serialize configuration dictionary:\n", config
          )
      return text
  
file_path: clearml/clearml/utilities/config.py
imports: from __future__ import division
  import json
  import six
  import pyparsing
  from .dicts import hocon_quote_key, hocon_unquote_key
  from .pyhocon import ConfigFactory, HOCONConverter
  from ..storage.util import parse_size
label_desc: Use image node_id 4 for calling a global function with example usage: config_dict_to_text(config) and returns: text, config