def METHOD_NAME(params):
    """Returns a tf.ConfigProto instance with appropriate device_filters set."""
    tf.compat.v1.disable_v2_behavior()
    tf_config = json.loads(os.environ.get("TF_CONFIG", "{}"))
    if tf_config and "task" in tf_config and "type" in tf_config["task"] and "index" in tf_config["task"]:
        # Master should only communicate with itself and ps.
        if tf_config["task"]["type"] == "master":
            return tf.compat.v1.ConfigProto(
                device_filters=["/job:ps", "/job:master"],
                intra_op_parallelism_threads=params["resource"]["num_thread"],
                inter_op_parallelism_threads=params["resource"]["num_thread"],
            )
        # Worker should only communicate with itself and ps.
        elif tf_config["task"]["type"] == "worker":
            return tf.compat.v1.ConfigProto(  # gpu_options=gpu_options,
                device_filters=["/job:ps", "/job:worker/task:%d" % tf_config["task"]["index"]],
                intra_op_parallelism_threads=params["resource"]["num_thread"],
                inter_op_parallelism_threads=params["resource"]["num_thread"],
            )
    return None