code: def _create_component_spec_class(
      func: types.FunctionType,
      arg_defaults: Dict[str, Any],
      inputs: Optional[Dict[str, Type[artifact.Artifact]]] = None,
      outputs: Optional[Dict[str, Type[artifact.Artifact]]] = None,
      parameters: Optional[Dict[str, Any]] = None,
      type_annotation: Optional[
          Type[system_executions.SystemExecution]
      ] = None,
      json_compatible_inputs: Optional[Dict[str, Any]] = None,
      json_compatible_outputs: Optional[Dict[str, Any]] = None,
  ) -> Type[tfx_types.ComponentSpec]:
      """Creates the ComponentSpec class for the func-generated component.
  
      Args:
        func: The function which component will be generated based on.
        arg_defaults: A dict from func arg name to its default value.
        inputs: A dict from input name to its Artifact type.
        outputs: A dict from output name to its Artifact type.
        parameters: A dict from parameter name to its primitive type.
        type_annotation: a subclass to SystemExecution used to annotate the
          component on ComponentSpec.
        json_compatible_inputs: A dict from input names that have json compatible
          types to their typehints. Json compatibility is determined by
          `tfx.dsl.component.experimental.json_compat.is_json_compatible`.
        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:
        a subclass of ComponentSpec.
      """
      spec_inputs = {}
      spec_outputs = {}
      spec_parameters = {}
      if inputs:
          for key, artifact_type in inputs.items():
              spec_inputs[key] = component_spec.ChannelParameter(
                  type=artifact_type, optional=(key in arg_defaults)
              )
              if (
                  json_compatible_inputs
                  and key in json_compatible_inputs
              ):
                  setattr(
                      spec_inputs[key],
                      "_JSON_COMPAT_TYPEHINT",
                      json_compatible_inputs[key],
                  )
      if outputs:
          for key, artifact_type in outputs.items():
              assert (
                  key not in arg_defaults
              ), "Optional outputs are not supported."
              spec_outputs[key] = component_spec.ChannelParameter(
                  type=artifact_type
              )
              if (
                  json_compatible_outputs
                  and key in json_compatible_outputs
              ):
                  setattr(
                      spec_outputs[key],
                      "_JSON_COMPAT_TYPEHINT",
                      json_compatible_outputs[key],
                  )
      if parameters:
          for key, primitive_type in parameters.items():
              spec_parameters[key] = component_spec.ExecutionParameter(
                  type=primitive_type, optional=(key in arg_defaults)
              )
      component_spec_class = type(
          "%s_Spec" % func.__name__,
          (tfx_types.ComponentSpec,),
          {
              "INPUTS": spec_inputs,
              "OUTPUTS": spec_outputs,
              "PARAMETERS": spec_parameters,
              "TYPE_ANNOTATION": type_annotation,
          },
      )
      return component_spec_class
  
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 6 for calling a global function with example usage: _create_component_spec_class(func, arg_defaults, inputs, outputs, parameters, type_annotation, json_compatible_inputs, json_compatible_outputs) and returns: component_spec_class