def apply_modifications(model, custom_objects=None):
<EOL>model_path = os.path.join(tempfile.gettempdir(), next(tempfile._get_candidate_names()) + '<STR_LIT>')<EOL>try:<EOL><INDENT>model.save(model_path)<EOL>return load_model(model_path, custom_objects=custom_objects)<EOL><DEDENT>finally:<EOL><INDENT>os.remove(model_path)<EOL><DEDENT>
Applies modifications to the model layers to create a new Graph. For example, simply changing
    `model.layers[idx].activation = new activation` does not change the graph. The entire graph needs to be updated
    with modified inbound and outbound tensors because of change in layer building function.

    Args:
        model: The `keras.models.Model` instance.

    Returns:
        The modified model with changes applied. Does not mutate the original `model`.