code: def _create_executor_spec_instance(
      func: types.FunctionType,
      base_executor_class: Type[base_executor.BaseExecutor],
      executor_spec_class: Type[executor_spec.ExecutorClassSpec],
      arg_formats: Dict[str, ArgFormats],
      arg_defaults: Dict[str, Any],
      return_values_optionality: Optional[Dict[str, bool]] = None,
      json_compatible_outputs: Optional[Dict[str, Any]] = None,
  ) -> executor_spec.ExecutorClassSpec:
      """Creates the executor spec instance for the func-generated component.
  
      Args:
        func: The function which executor spec instance will be generated based on.
        base_executor_class: base class of the generated executor class.
        executor_spec_class: class of the generated executor spec instance.
        arg_formats: An updated dict from arg name to its format. The format is the
          value of `ArgFormats` enum). Note that the parameter arg will be added to
          the dict if it's in the valid format and existing entries won't be
          changed.
        arg_defaults: A dict from func arg name to its default value.
        return_values_optionality: A dict from output names that are primitive type
          values returned from the user function to whether they are `Optional`.
        json_compatible_outputs: A dict from output names that have json compatible
          types to their typehints. Json compatibility is determined by
          `tfx.dsl.component.experimental.json_compat.is_json_compatible`.
  
      Returns:
        an instance of `executor_spec_class` whose executor_class is a subclass of
        `base_executor_class`.
      """
      executor_class = type(
          "%s_Executor" % func.__name__,
          (base_executor_class,),
          {
              "_ARG_FORMATS": arg_formats,
              "_ARG_DEFAULTS": arg_defaults,
              # The function needs to be marked with `staticmethod` so that later
              # references of `self._FUNCTION` do not result in a bound method (i.e.
              # one with `self` as its first parameter).
              "_FUNCTION": staticmethod(
                  func
              ),  # pytype: disable=not-callable
              "_RETURNED_VALUES": return_values_optionality,
              "_RETURN_JSON_COMPAT_TYPEHINT": json_compatible_outputs,
              "__module__": func.__module__,
          },
      )
      # Expose the generated executor class in the same module as the decorated
      # function. This is needed so that the executor class can be accessed at the
      # proper module path. One place this is needed is in the Dill pickler used by
      # Apache Beam serialization.
      module = sys.modules[func.__module__]
      setattr(module, "%s_Executor" % func.__name__, executor_class)
  
      executor_spec_instance = executor_spec_class(
          executor_class=executor_class
      )
      return executor_spec_instance
  
imports: import enum
  import inspect
  import sys
  import types
  from typing import Any, Dict, Optional, Type
  from tfx import types
  from tfx.dsl.components.base import base_component
  from tfx.dsl.components.base import base_executor
  from tfx.dsl.components.base import executor_spec
  from tfx.types import artifact
  from tfx.types import component_spec
  from tfx.types import system_executions
label_desc: Use image node_id 7 for calling a global function with example usage: _create_executor_spec_instance(func, base_executor_class, executor_spec_class, arg_formats, arg_defaults, return_values_optionality, json_compatible_outputs) and returns: executor_spec_instance