<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def i2m(self, pkt, p):
 """ Update the context with information from the built packet. If no type was given at the record layer, we try to infer it. """

        cur = b""
        if isinstance(p, _GenericTLSSessionInheritance):
            if pkt.type is None:
                if isinstance(p, TLSChangeCipherSpec):
                    pkt.type = 20
                elif isinstance(p, TLSAlert):
                    pkt.type = 21
                elif isinstance(p, _TLSHandshake):
                    pkt.type = 22
                elif isinstance(p, TLSApplicationData):
                    pkt.type = 23
            p.tls_session = pkt.tls_session
            if not pkt.tls_session.frozen:
                cur = p.raw_stateful()
                p.post_build_tls_session_update(cur)
            else:
                cur = raw(p)
        else:
            pkt.type = 23
            cur = raw(p)
        return cur