code: def validate_flags():
    
    assert not job_dir()
    assert FLAGS.output_dir.startswith("gs://")
    assert FLAGS.data_dir.startswith("gs://")
    assert FLAGS.worker_replicas <= 1
    assert FLAGS.ps_replicas <= 0
    if FLAGS.hparams_range:
      assert FLAGS.autotune_objective
    if FLAGS.worker_gpu:
      assert FLAGS.worker_gpu in [1, 4, 8]
    if FLAGS.cloud_mlengine_master_type:
      if FLAGS.worker_gpu:
        if FLAGS.worker_gpu == 1:
          assert FLAGS.cloud_mlengine_master_type in ["standard_gpu",
                                                      "standard_p100"]
        elif FLAGS.worker_gpu == 4:
          assert FLAGS.cloud_mlengine_master_type in ["complex_model_m_gpu",
                                                      "complex_model_m_p100"]
        else:
          assert FLAGS.cloud_mlengine_master_type == "complex_model_l_gpu"
      else:
        assert FLAGS.cloud_mlengine_master_type in ["standard", "large_model",
                                                    "complex_model_s",
                                                    "complex_model_m",
                                                    "complex_model_l"]
docs: Validates flags are set to acceptable values for CloudML Engine runs.