<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def attach(self, id, attributes=None, touch=True):
 """ Attach a model to the parent. """

        if isinstance(id, orator.orm.Model):
            id = id.get_key()

        query = self.new_pivot_statement()

        if not isinstance(id, list):
            id = [id]

        query.insert(self._create_attach_records(id, attributes))

        if touch:
            self.touch_if_touching()