def create_lazy_clause(self, reverse_direction=False):
        binds = util.column_dict()
        lookup = collections.defaultdict(list)
        equated_columns = util.column_dict()

        if reverse_direction and self.secondaryjoin is None:
            for l, r in self.local_remote_pairs:
                lookup[r].append((r, l))
                equated_columns[l] = r
        else:
            # replace all "local side" columns, which is
            # anything that isn't marked "remote"
            for l, r in self.local_remote_pairs:
                lookup[l].append((l, r))
                equated_columns[r] = l

        def col_to_bind(col):
            if (reverse_direction and col in lookup) or \
                    (not reverse_direction and "local" in col._annotations):
                if col in lookup:
                    for tobind, equated in lookup[col]:
                        if equated in binds:
                            return None
                if col not in binds:
                    binds[col] = sql.bindparam(
                        None, None, type_=col.type, unique=True)
                return binds[col]
            return None

        lazywhere = self.primaryjoin
        if self.secondaryjoin is None or not reverse_direction:
            lazywhere = visitors.replacement_traverse(
                lazywhere, {}, col_to_bind)

        if self.secondaryjoin is not None:
            secondaryjoin = self.secondaryjoin
            if reverse_direction:
                secondaryjoin = visitors.replacement_traverse(
                    secondaryjoin, {}, col_to_bind)
            lazywhere = sql.and_(lazywhere, secondaryjoin)

        bind_to_col = dict((binds[col].key, col) for col in binds)

        # this is probably not necessary
        lazywhere = _deep_deannotate(lazywhere)

        return lazywhere, bind_to_col, equated_columns
dataset/ETHPy150Open goFrendiAsgard/kokoropy/kokoropy/packages/sqlalchemy/orm/relationships.py/JoinCondition.create_lazy_clause/original