'Interpret the \'backref\' instruction to create a
:func:`.relationship` complementary to this one.'

def _generate_backref(self):

    if (not self.is_primary()):
        return
    if ((self.backref is not None) and (not self.back_populates)):
        if isinstance(self.backref, util.string_types):
            (backref_key, kwargs) = (self.backref, {})
        else:
            (backref_key, kwargs) = self.backref
        mapper = self.mapper.primary_mapper()
        check = set(mapper.iterate_to_root()).union(mapper.self_and_descendants)
        for m in check:
            if m.has_property(backref_key):
                raise sa_exc.ArgumentError(("Error    creating    backref    '%s'    on    relationship    '%s':    property    of    that    name    exists    on    mapper    '%s'" % (backref_key, self, m)))
        if (self.secondary is not None):
            pj = kwargs.pop('primaryjoin', self._join_condition.secondaryjoin_minus_local)
            sj = kwargs.pop('secondaryjoin', self._join_condition.primaryjoin_minus_local)
        else:
            pj = kwargs.pop('primaryjoin', self._join_condition.primaryjoin_reverse_remote)
            sj = kwargs.pop('secondaryjoin', None)
            if sj:
                raise sa_exc.InvalidRequestError("Can't    assign    'secondaryjoin'    on    a    backref    against    a    non-secondary    relationship.")
        foreign_keys = kwargs.pop('foreign_keys', self._user_defined_foreign_keys)
        parent = self.parent.primary_mapper()
        kwargs.setdefault('viewonly', self.viewonly)
        kwargs.setdefault('post_update', self.post_update)
        kwargs.setdefault('passive_updates', self.passive_updates)
        self.back_populates = backref_key
        relationship = RelationshipProperty(parent, self.secondary, pj, sj, foreign_keys=foreign_keys, back_populates=self.key, **kwargs)
        mapper._configure_property(backref_key, relationship)
    if self.back_populates:
        self._add_reverse_property(self.back_populates)
