code: def configure_job():
    
    # See documentation:
    # https://cloud.google.com/ml-engine/reference/rest/v1/projects.jobs#traininginput
    training_input = {
        "pythonModule": "tensor2tensor.bin.t2t_trainer",
        "args": flags_as_args(),
        "region": text_encoder.native_to_unicode(default_region()),
        "runtimeVersion": RUNTIME_VERSION,
        "pythonVersion": "3.5" if sys.version_info.major == 3 else "2.7",
        "jobDir": FLAGS.output_dir,
        "scaleTier": "CUSTOM",
        "masterType": FLAGS.cloud_mlengine_master_type or get_default_master_type(
            num_gpus=FLAGS.worker_gpu)
    }
    if FLAGS.use_tpu:
      training_input["masterType"] = (FLAGS.cloud_mlengine_master_type or
                                      "standard")
      training_input["workerType"] = "cloud_tpu"
      training_input["workerCount"] = 1
    if FLAGS.hparams_range:
      tf.logging.info("Configuring hyperparameter tuning.")
      training_input["hyperparameters"] = configure_autotune(
          FLAGS.hparams_range,
          FLAGS.autotune_objective,
          FLAGS.autotune_maximize,
          FLAGS.autotune_max_trials,
          FLAGS.autotune_parallel_trials,
      )
  
    timestamp = datetime.datetime.now().strftime("%Y%m%d_%H%M%S")
    job_spec = {
        "jobId": "%s_%s_t2t_%s" % (FLAGS.model, FLAGS.problem, timestamp),
        "labels": {
            "model": FLAGS.model,
            "problem": FLAGS.problem,
            "hparams": FLAGS.hparams_set
        },
        "trainingInput": training_input,
    }
    return job_spec
docs: Construct jobSpec for ML Engine job.