<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def from_qtype_and_id(qtype, queue_id, qname=None):
 """ Return a new istance of the appropriate subclass. Args: qtype: String specifying the Resource manager type. queue_id: Job identifier. qname: Name of the queue (optional). """

        for cls in all_subclasses(QueueJob):
            if cls.QTYPE == qtype: break
        else:
            logger.critical("Cannot find QueueJob subclass registered for qtype %s" % qtype)
            cls = QueueJob

        return cls(queue_id, qname=qname)