Attach to an existing hyperparameter tuning job.

        Create a HyperparameterTuner bound to an existing hyperparameter tuning job. After attaching, if there exists a
        best training job (or any other completed training job), that can be deployed to create
        an Amazon SageMaker Endpoint and return a ``Predictor``.

        Args:
            tuning_job_name (str): The name of the hyperparameter tuning job to attach to.
            sagemaker_session (sagemaker.session.Session): Session object which manages interactions with
                Amazon SageMaker APIs and any other AWS services needed. If not specified, one is created
                using the default AWS configuration chain.
            job_details (dict): The response to a ``DescribeHyperParameterTuningJob`` call. If not specified,
                the ``HyperparameterTuner`` will perform one such call with the provided hyperparameter tuning job name.
            estimator_cls (str): The estimator class name associated with the training jobs,
                e.g. 'sagemaker.estimator.Estimator'. If not specified, the ``HyperparameterTuner`` will try to derive
                the correct estimator class from training job metadata, defaulting to
                :class:~`sagemaker.estimator.Estimator` if it is unable to determine a more specific class.

        Examples:
            >>> my_tuner.fit()
            >>> job_name = my_tuner.latest_tuning_job.name
            Later on:
            >>> attached_tuner = HyperparameterTuner.attach(job_name)
            >>> attached_tuner.deploy()

        Returns:
            sagemaker.tuner.HyperparameterTuner: A ``HyperparameterTuner`` instance with the attached hyperparameter
                tuning job.

def attach(cls, tuning_job_name, sagemaker_session=None, job_details=None, estimator_cls=None):
        """Attach to an existing hyperparameter tuning job.

        Create a HyperparameterTuner bound to an existing hyperparameter tuning job. After attaching, if there exists a
        best training job (or any other completed training job), that can be deployed to create
        an Amazon SageMaker Endpoint and return a ``Predictor``.

        Args:
            tuning_job_name (str): The name of the hyperparameter tuning job to attach to.
            sagemaker_session (sagemaker.session.Session): Session object which manages interactions with
                Amazon SageMaker APIs and any other AWS services needed. If not specified, one is created
                using the default AWS configuration chain.
            job_details (dict): The response to a ``DescribeHyperParameterTuningJob`` call. If not specified,
                the ``HyperparameterTuner`` will perform one such call with the provided hyperparameter tuning job name.
            estimator_cls (str): The estimator class name associated with the training jobs,
                e.g. 'sagemaker.estimator.Estimator'. If not specified, the ``HyperparameterTuner`` will try to derive
                the correct estimator class from training job metadata, defaulting to
                :class:~`sagemaker.estimator.Estimator` if it is unable to determine a more specific class.

        Examples:
            >>> my_tuner.fit()
            >>> job_name = my_tuner.latest_tuning_job.name
            Later on:
            >>> attached_tuner = HyperparameterTuner.attach(job_name)
            >>> attached_tuner.deploy()

        Returns:
            sagemaker.tuner.HyperparameterTuner: A ``HyperparameterTuner`` instance with the attached hyperparameter
                tuning job.
        """
        sagemaker_session = sagemaker_session or Session()

        if job_details is None:
            job_details = sagemaker_session.sagemaker_client \
                .describe_hyper_parameter_tuning_job(HyperParameterTuningJobName=tuning_job_name)

        estimator_cls = cls._prepare_estimator_cls(estimator_cls, job_details['TrainingJobDefinition'])
        estimator = cls._prepare_estimator_from_job_description(estimator_cls, job_details['TrainingJobDefinition'],
                                                                sagemaker_session)
        init_params = cls._prepare_init_params_from_job_description(job_details)

        tuner = cls(estimator=estimator, **init_params)
        tuner.latest_tuning_job = _TuningJob(sagemaker_session=sagemaker_session, job_name=tuning_job_name)

        return tuner