code: def parse_multi_part(request):
      """Parse a multi-part request
  
      :param request:flask.Request multipart request.
      :return: a tuple with the resource, media_headers and the media_body.
      :rtype: (dict, dict, str)
      """
      content_type = request.headers.get("content-type")
      if content_type is None or not content_type.startswith(
          "multipart/related"
      ):
          raise error_response.ErrorResponse(
              "Missing or invalid content-type header in multipart upload"
          )
      _, _, boundary = content_type.partition("boundary=")
      boundary = boundary.strip('"')
      if boundary is None:
          raise error_response.ErrorResponse(
              "Missing or invalid boundary in content-type header in multipart upload"
          )
  
      def parse_metadata(part):
          result = part.split(b"\r\n")
          if result[0] != b"" and result[-1] != b"":
              raise error_response.ErrorResponse(
                  "Missing or invalid multipart %s" % str(part)
              )
          result = list(filter(None, result))
          headers = {}
          if len(result) < 2:
              result.append(b"")
          for header in result[:-1]:
              key, value = header.split(b": ")
              headers[key.decode("utf-8").lower()] = value.decode(
                  "utf-8"
              )
          return result[-1]
  
      def parse_body(part):
          if part[0:2] != b"\r\n" or part[-2:] != b"\r\n":
              raise error_response.ErrorResponse(
                  "Missing or invalid multipart %s" % str(part)
              )
          part = part[2:-2]
          part.lstrip(b"\r\n")
          content_type_index = part.find(b"\r\n")
          if content_type_index == -1:
              raise error_response.ErrorResponse(
                  "Missing or invalid multipart %s" % str(part)
              )
          content_type = part[:content_type_index]
          _, value = content_type.decode("utf-8").split(": ")
          media = part[content_type_index + 2 :]
          if media[:2] == b"\r\n":
              # It is either `\r\n` or `\r\n\r\n`, we should remove at most 4 characters.
              media = media[2:]
          return {"content-type": value}, media
  
      boundary = boundary.encode("utf-8")
      body = extract_media(request)
      parts = body.split(b"--" + boundary)
      if parts[-1] != b"--\r\n" and parts[-1] != b"--":
          raise error_response.ErrorResponse(
              "Missing end marker (--%s--) in media body" % boundary
          )
      resource = parse_metadata(parts[1])
      metadata = json.loads(resource)
      content_type, media = parse_body(parts[2])
      return metadata, content_type, media
  
imports: import base64
  import error_response
  import hashlib
  import json
  import random
  import re
label_desc: Use image node_id 17 for calling a global function with example usage: parse_multi_part(request) and returns: metadata,  content_type,  media, result, dict,  media