code: def typed_subpart_iterator(msg, maintype="text", subtype=None):
      """Iterate over the subparts with a given MIME type.
  
      Use `maintype' as the main MIME type to match against; this defaults to
      "text".  Optional `subtype' is the MIME subtype to match against; if
      omitted, only the main type is matched.
      """
      for subpart in msg.walk():
          if subpart.get_content_maintype() == maintype:
              if (
                  subtype is None
                  or subpart.get_content_subtype() == subtype
              ):
                  yield subpart
  
imports: import sys
  from cStringIO import StringIO
label_desc: Use image node_id 3 for calling a global function with example usage: typed_subpart_iterator(msg, maintype, subtype) without return types