code: def get_graphviz_format(graphviz, to_file):
      if to_file:
          # Explicitly cast to str in case a Path object was passed in
          to_file = str(to_file)
  
          split_path = to_file.split(".")
          if len(split_path) < 2:
              raise ValueError(
                  "Please use a file extension like '.pdf'"
                  + " so that the format can be inferred",
              )
  
          format_ = split_path[-1]
          valid_formats = graphviz.FORMATS
          if format_ not in valid_formats:
              raise ValueError(
                  "Unknown format. Make sure your format is"
                  + " amongst the following: %s" % valid_formats,
              )
      else:
          format_ = None
      return format_
  
imports: from featuretools.utils.gen_utils import import_or_raise
label_desc: Use image node_id 2 for calling a global function with example usage: get_graphviz_format(graphviz, to_file) and returns: format_