def _run_training_job(cfg: DictConfig) -> None:
    """
    Run a training job on Amazon SageMaker.
    The model, the hyperparameters, and all the sagemaker-related parameters
    (image_uri to be used, the model training entry point, the AWS IAM role to use, the instance type/count to use,
    the input/output paths on s3 or local disk) have to be defined in the configuration dictionary.

    Parameters
    ----------
    cfg: DictConfig
        Configuration dictionary.
    """
    if hasattr(cfg.sagemaker, "metrics"):
        metrics = [dict(d) for d in cfg.sagemaker.metrics]
    else:
        metrics = []

    # define the dependency path
    source_dir = pathlib.Path(fortuna.__file__).parents[1]
    # get proper datasets
    channels = create_input_channels(cfg)
    # get entrypoint args
    hparams = get_hparams(cfg=cfg)
    # update channels
    if "model_path" in cfg.model:
        channels.update({"loadmodel": cfg.model.model_path})

    logger.info(f"Training job with parameters: {hparams}")
    logger.info(f"\nEstimating with channels: {channels}")

    base_job_name = get_base_job_name(cfg)

    logger.info(f"Source dir: {source_dir}")

    rules = [
        ProfilerRule.sagemaker(rule_configs.LowGPUUtilization()),
        ProfilerRule.sagemaker(rule_configs.ProfilerReport()),
    ]
    profiler_config = ProfilerConfig(
        system_monitor_interval_millis=500,
        framework_profile_params=FrameworkProfile(
            local_path="/opt/ml/output/profiler/", start_step=5, num_steps=2
        ),
    )

    sm_role = f"arn:aws:iam::{cfg.sagemaker.account_id}:role/{cfg.sagemaker.iam_role}"
    boto_sess = boto3.Session(
        profile_name=cfg.sagemaker.profile, region_name=cfg.sagemaker.region
    )
    sm_sess = sagemaker.Session(boto_session=boto_sess)
    sm = boto_sess.client(service_name="sagemaker")

    estimator = TensorFlow(
        image_uri=f"{cfg.sagemaker.account_id}.dkr.ecr.{cfg.sagemaker.region}.amazonaws.com/fortuna:dev",
        entry_point=f"./{cfg.sagemaker.entrypoint}",
        source_dir=str(source_dir),
        role=sm_role,
        instance_type=cfg.sagemaker.instance_type,
        instance_count=1,
        hyperparameters=hparams,
        output_path=cfg.output_data_path,
        base_job_name=base_job_name,
        metric_definitions=metrics,
        py_version="py38",
        sagemaker_session=sm_sess,
        profiler_config=profiler_config,
        rules=rules,
    )

    if "tuner" in cfg.hyperparams:
        logger.info(f"Starting hyperparams optimization: {cfg.hyperparams.tuner}")
        estimator = HyperparameterTuner(
            estimator=estimator,
            base_tuning_job_name=base_job_name,
            metric_definitions=metrics,
            **instantiate(cfg.hyperparams.tuner, _convert_="partial"),
        )

    estimator.fit(inputs=channels, wait=False)

    Run a training job on Amazon SageMaker.
    The model, the hyperparameters, and all the sagemaker-related parameters
    (image_uri to be used, the model training entry point, the AWS IAM role to use, the instance type/count to use,
    the input/output paths on s3 or local disk) have to be defined in the configuration dictionary.

    Parameters
    ----------
    cfg: DictConfig
        Configuration dictionary.
    
fortuna/sagemaker/base.py