class_docstr: A TFX component for model hyperparameter tuning.
  
  Component `outputs` contains:
   - `best_hyperparameters`: Channel of type
                             `standard_artifacts.HyperParameters` for result of
                             the best hparams.
   - `tuner_results`: Channel of type `standard_artifacts.TunerResults` for
   results of all trials. Experimental: subject to change and no backwards
   compatibility guarantees.
  
  See [the Tuner guide](https://www.tensorflow.org/tfx/guide/tuner)
  for more details.
docstr: Construct a Tuner component.
  
  Args:
    examples: A BaseChannel of type `standard_artifacts.Examples`, serving as
      the source of examples that are used in tuning (required).
    schema:  An optional BaseChannel of type `standard_artifacts.Schema`,
      serving as the schema of training and eval data. This is used when raw
      examples are provided.
    transform_graph: An optional BaseChannel of type
      `standard_artifacts.TransformGraph`, serving as the input transform
      graph if present. This is used when transformed examples are provided.
    base_model: A BaseChannel of type `Model`, containing model that will be
      used for training. This can be used for warmstart, transfer learning or
      model ensembling.
    module_file: A path to python module file containing UDF tuner definition.
      The module_file must implement a function named `tuner_fn` at its top
      level. The function must have the following signature.
          def tuner_fn(fn_args: FnArgs) -> TunerFnResult: Exactly one of
            'module_file' or 'tuner_fn' must be supplied.
    tuner_fn:  A python path to UDF model definition function. See
      'module_file' for the required signature of the UDF. Exactly one of
      'module_file' or 'tuner_fn' must be supplied.
    train_args: A trainer_pb2.TrainArgs instance, containing args used for
      training. Currently only splits and num_steps are available. Default
      behavior (when splits is empty) is train on `train` split.
    eval_args: A trainer_pb2.EvalArgs instance, containing args used for eval.
      Currently only splits and num_steps are available. Default behavior
      (when splits is empty) is evaluate on `eval` split.
    tune_args: A tuner_pb2.TuneArgs instance, containing args used for tuning.
      Currently only num_parallel_trials is available.
    custom_config: A dict which contains addtional training job parameters
      that will be passed into user module.
docstr_tok: ["Construct","a","Tuner","component",".","Args",":","examples",":","A","BaseChannel","of","type","`","standard_artifacts.Examples","`",",","serving","as","the","source","of","examples","that","are","used","in","tuning","(","required",")",".","schema",":","An","optional","BaseChannel","of","type","`","standard_artifacts.Schema","`",",","serving","as","the","schema","of","training","and","eval","data",".","This","is","used","when","raw","examples","are","provided",".","transform_graph",":","An","optional","BaseChannel","of","type","`","standard_artifacts.TransformGraph","`",",","serving","as","the","input","transform","graph","if","present",".","This","is","used","when","transformed","examples","are","provided",".","base_model",":","A","BaseChannel","of","type","`","Model","`",",","containing","model","that","will","be","used","for","training",".","This","can","be","used","for","warmstart",",","transfer","learning","or","model","ensembling",".","module_file",":","A","path","to","python","module","file","containing","UDF","tuner","definition",".","The","module_file","must","implement","a","function","named","`","tuner_fn","`","at","its","top","level",".","The","function","must","have","the","following","signature",".","def","tuner_fn","(","fn_args",":","FnArgs",")","-",">","TunerFnResult",":","Exactly","one","of","'module_file","'","or","'tuner_fn","'","must","be","supplied",".","tuner_fn",":","A","python","path","to","UDF","model","definition","function",".","See","'module_file","'","for","the","required","signature","of","the","UDF",".","Exactly","one","of","'module_file","'","or","'tuner_fn","'","must","be","supplied",".","train_args",":","A","trainer_pb2.TrainArgs","instance",",","containing","args","used","for","training",".","Currently","only","splits","and","num_steps","are","available",".","Default","behavior","(","when","splits","is","empty",")","is","train","on","`","train","`","split",".","eval_args",":","A","trainer_pb2.EvalArgs","instance",",","containing","args","used","for","eval",".","Currently","only","splits","and","num_steps","are","available",".","Default","behavior","(","when","splits","is","empty",")","is","evaluate","on","`","eval","`","split",".","tune_args",":","A","tuner_pb2.TuneArgs","instance",",","containing","args","used","for","tuning",".","Currently","only","num_parallel_trials","is","available",".","custom_config",":","A","dict","which","contains","addtional","training","job","parameters","that","will","be","passed","into","user","module","."]
code: def __init__(
      self,
      examples: types.BaseChannel,
      schema: Optional[types.BaseChannel] = None,
      transform_graph: Optional[types.BaseChannel] = None,
      base_model: Optional[types.BaseChannel] = None,
      module_file: Optional[str] = None,
      tuner_fn: Optional[str] = None,
      train_args: Optional[trainer_pb2.TrainArgs] = None,
      eval_args: Optional[trainer_pb2.EvalArgs] = None,
      tune_args: Optional[tuner_pb2.TuneArgs] = None,
      custom_config: Optional[Dict[str, Any]] = None,
  ):
      """Construct a Tuner component.
  
      Args:
        examples: A BaseChannel of type `standard_artifacts.Examples`, serving as
          the source of examples that are used in tuning (required).
        schema:  An optional BaseChannel of type `standard_artifacts.Schema`,
          serving as the schema of training and eval data. This is used when raw
          examples are provided.
        transform_graph: An optional BaseChannel of type
          `standard_artifacts.TransformGraph`, serving as the input transform
          graph if present. This is used when transformed examples are provided.
        base_model: A BaseChannel of type `Model`, containing model that will be
          used for training. This can be used for warmstart, transfer learning or
          model ensembling.
        module_file: A path to python module file containing UDF tuner definition.
          The module_file must implement a function named `tuner_fn` at its top
          level. The function must have the following signature.
              def tuner_fn(fn_args: FnArgs) -> TunerFnResult: Exactly one of
                'module_file' or 'tuner_fn' must be supplied.
        tuner_fn:  A python path to UDF model definition function. See
          'module_file' for the required signature of the UDF. Exactly one of
          'module_file' or 'tuner_fn' must be supplied.
        train_args: A trainer_pb2.TrainArgs instance, containing args used for
          training. Currently only splits and num_steps are available. Default
          behavior (when splits is empty) is train on `train` split.
        eval_args: A trainer_pb2.EvalArgs instance, containing args used for eval.
          Currently only splits and num_steps are available. Default behavior
          (when splits is empty) is evaluate on `eval` split.
        tune_args: A tuner_pb2.TuneArgs instance, containing args used for tuning.
          Currently only num_parallel_trials is available.
        custom_config: A dict which contains addtional training job parameters
          that will be passed into user module.
      """
      if bool(module_file) == bool(tuner_fn):
          raise ValueError(
              "Exactly one of 'module_file' or 'tuner_fn' must be supplied"
          )
  
      best_hyperparameters = types.Channel(
          type=standard_artifacts.HyperParameters
      )
      tuner_results = types.Channel(
          type=standard_artifacts.TunerResults
      )
      spec = standard_component_specs.TunerSpec(
          examples=examples,
          schema=schema,
          transform_graph=transform_graph,
          base_model=base_model,
          module_file=module_file,
          tuner_fn=tuner_fn,
          train_args=train_args or trainer_pb2.TrainArgs(),
          eval_args=eval_args or trainer_pb2.EvalArgs(),
          tune_args=tune_args,
          best_hyperparameters=best_hyperparameters,
          tuner_results=tuner_results,
          custom_config=json_utils.dumps(custom_config),
      )
      super().__init__(spec=spec)
  
      if udf_utils.should_package_user_modules():
          # In this case, the `MODULE_PATH_KEY` execution property will be injected
          # as a reference to the given user module file after packaging, at which
          # point the `MODULE_FILE_KEY` execution property will be removed.
          udf_utils.add_user_module_dependency(
              self,
              standard_component_specs.MODULE_FILE_KEY,
              standard_component_specs.MODULE_PATH_KEY,
          )
  
file_path: tfx/tfx/components/tuner/component.py
imports: from typing import Any, Dict, NamedTuple, Optional
  from keras_tuner.engine import base_tuner
  from tfx import types
  from tfx.components.tuner import executor
  from tfx.components.util import udf_utils
  from tfx.dsl.components.base import base_component
  from tfx.dsl.components.base import executor_spec
  from tfx.proto import trainer_pb2
  from tfx.proto import tuner_pb2
  from tfx.types import standard_artifacts
  from tfx.types import standard_component_specs
  from tfx.utils import json_utils
label_desc: Use image node_id 1 to create a new Tuner object from inherited base classes: base_component with example: obj = Tuner(examples, schema, transform_graph, base_model, module_file, tuner_fn, train_args, eval_args, tune_args, custom_config)