<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def bnode_id(self):
 """ calculates the bnode id for the class """

        if self.subject.type != 'bnode':
            return self.subject
        rtn_list = []
        for prop in sorted(self):
            for value in sorted(self[prop]):
                rtn_list.append("%s%s" % (prop, value))
        return sha1("".join(rtn_list).encode()).hexdigest()