'Return a model instance or entity from an input_dict.
Args:
input_dict: Neutral input dictionary describing a single input record.
bulkload_state: bulkload_state object describing the global state.
Returns:
Entity or model instance, or collection of entity or model instances,
to be uploaded.'

def __create_instance(self, input_dict, bulkload_state):

    key = None
    if self._create_key:
        key = self.__dict_to_prop(self._create_key, input_dict, bulkload_state)
        if isinstance(key, (int, long)):
            key = datastore.Key.from_path(self._transformer_spec.kind, key)
        if self._transformer_spec.model:
            if isinstance(key, datastore.Key):
                return self._transformer_spec.model(key=key)
            else:
                return self._transformer_spec.model(key_name=key)
        elif isinstance(key, datastore.Key):
            parent = key.parent()
            if (key.name() is None):
                return datastore.Entity(self._transformer_spec.kind, parent=parent, id=key.id())
            else:
                return datastore.Entity(self._transformer_spec.kind, parent=parent, name=key.name())
    elif self._transformer_spec.model:
        return self._transformer_spec.model()
    return datastore.Entity(self._transformer_spec.kind, name=key)
