code: def _type_inferred(writepath=None, format=None):
      """guess ('logfile', 'support', or archive type) from format and writepath
  
      writepath: the string path at which to write the trajectories
      format: type ('logfile', 'support', or klepto.archive type) for writepath
      """
      if writepath is None:
          if format is None:
              msg = "either a format or writepath must be provided"
              raise ValueError(msg)
      if format is None:
          import os
  
          guess = not os.path.exists(writepath)
          if _issupport(writepath, guess=guess):
              file_out = "support"
          elif _islogfile(writepath, guess=guess):
              file_out = "logfile"
          else:
              file_out = _archive_inferred(
                  writepath
              )  # FIXME: is always guess
      else:
          import klepto.archives as kl
  
          archives = kl.__all__[:]
          [
              archives.remove(i)
              for i in ("cache", "dict_archive", "null_archive")
          ]
          if format in ["support", "logfile"] + [
              kl.__dict__[a] for a in archives
          ]:
              file_out = format
          elif format in archives:
              file_out = kl.__dict__[format]
          else:
              msg = "unknown archive format: {0}".format(format)
              raise ValueError(msg)
      return file_out
  
imports: from collections.abc import Callable
label_desc: Use image node_id 3 for calling a global function with example usage: _type_inferred(writepath, format) and returns: file_out