<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def __imap_fetch_content_type(self, msg_nums, content_type):
 """ Given a message number that we found with imap_search, fetch the whole source, dump that into an email object, and pick out the part that matches the content type specified. Return that, if we got multiple emails, return dict of all the parts. @Params msg_nums - message number to search for content_type - content type of email message to return @Returns Specified content type string or dict of all content types of matched email. """


        if not msg_nums:
            raise Exception("Invalid Message Number!")
        if not content_type:
            raise Exception("Need a content type!")

        contents = {}
        self.imap_connect()
        for num in msg_nums:
            status, data = self.mailbox.fetch(num, "(RFC822)")
            for response_part in data:
                if isinstance(response_part, tuple):
                    msg = email.message_from_string(response_part[1])
                    for part in msg.walk():
                        if str(part.get_content_type()) == content_type:
                            content = str(part.get_payload(decode=True))
                            contents[int(num)] = content
        self.imap_disconnect()
        return contents