def map_layer_output_name_with_index(model_layers):
    """
    Each layer has a unique output name. This function maps this unique name with
    the layer index so that we can easily access each layer with index instead of name.

    :param model_layers: List of layers of the model
    :return: a dictionary that contains mapping of all layer names to their index
    """
    output_name_to_index = {}
    total_layer_count = len(model_layers)
    for i in range(total_layer_count):
        output_name_to_index[model_layers[i].output.name] = i
    return output_name_to_index