'Transform the entity to a dict, possibly via a model.
Args:
entity: An entity.
bulkload_state: bulkload_state object describing the global state.
Returns:
A neutral output dictionary describing the record to write to the
output.
In the future this may return zero or multiple output dictionaries.'

def entity_to_dict(self, entity, bulkload_state):

    if self._transformer_spec.use_model_on_export:
        instance = self._transformer_spec.model.from_entity(entity)
    else:
        instance = entity
    export_dict = {}
    bulkload_state.current_entity = entity
    bulkload_state.current_instance = instance
    bulkload_state.current_dictionary = export_dict
    self.__run_export_transforms(instance, export_dict, bulkload_state)
    if self._transformer_spec.post_export_function:
        post_export_result = self._transformer_spec.post_export_function(instance, export_dict, bulkload_state)
        return post_export_result
    return export_dict
