code: def infer_type(output, out_type):
      """Infer type of plot file based on output filename or provided type.
  
      If output has a valid extension, this extension is used as the type. Otherwise,
      the provided (or default) output type is used.
      """
      if output:
          ext = output.split(".")[-1]
          if ext and ext not in VALID_TYPES:
              log.warning(
                  "Overriding the `type` field with something from `output`, "
                  f"but we got the invalid value : {out_type}. Will revert to png."
                  f"Should be one of {VALID_TYPES}"
              )
          else:
              out_type = ext
  
      return out_type
  
file_path: orion/src/orion/core/cli/plot.py
imports: import logging
  from orion.client.experiment import ExperimentClient
  from orion.core.cli import base
  from orion.core.io import experiment_builder
  from orion.plotting.base import SINGLE_EXPERIMENT_PLOTS
label_desc: Use image node_id 2 for calling a global function with example usage: infer_type(output, out_type) and returns: out_type