code: def validate_coerce_output_type(output_type):
      if output_type == "Figure" or output_type == go.Figure:
          cls = go.Figure
      elif output_type == "FigureWidget" or (
          hasattr(go, "FigureWidget") and output_type == go.FigureWidget
      ):
          cls = go.FigureWidget
      else:
          raise ValueError(
              """
  Invalid output type: {output_type}
      Must be one of: 'Figure', 'FigureWidget'"""
          )
      return cls
  
imports: from __future__ import absolute_import
  import plotly
  import plotly.graph_objs
label_desc: Use image node_id 2 for calling a global function with example usage: validate_coerce_output_type(output_type) and returns: cls