<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def rename_fields(layer, fields_to_copy):
 """Rename fields inside an attribute table. Only since QGIS 2.16. :param layer: The vector layer. :type layer: QgsVectorLayer :param fields_to_copy: Dictionary of fields to copy. :type fields_to_copy: dict """

    for field in fields_to_copy:
        index = layer.fields().lookupField(field)
        if index != -1:
            layer.startEditing()
            layer.renameAttribute(index, fields_to_copy[field])
            layer.commitChanges()
            LOGGER.info(
                'Renaming field %s to %s' % (field, fields_to_copy[field]))
        else:
            LOGGER.info(
                'Field %s not present in the layer while trying to renaming '
                'it to %s' % (field, fields_to_copy[field]))