code: def validate_plugin(plugin):
      if isinstance(plugin, Plugin):
          return plugin.value
      elif isinstance(plugin, str):
          if plugin not in Plugin.options():
              raise PerspectiveError(
                  "Unrecognized `plugin`: {0}".format(plugin)
              )
          return plugin
      else:
          raise PerspectiveError(
              "Cannot parse `plugin` of type: {0}".format(
                  str(type(plugin))
              )
          )
  
file_path: perspective/python/perspective/perspective/viewer/validate.py
imports: from datetime import datetime
  from ..core import ALL_FILTERS, Aggregate, Plugin, Sort
  from ..core.exception import PerspectiveError
label_desc: Use image node_id 1 for calling a global function with example usage: validate_plugin(plugin) and returns: plugin, plugin