'Constructs a :class:`PreparedRequest <PreparedRequest>` for
transmission and returns it. The :class:`PreparedRequest` has settings
merged from the :class:`Request <Request>` instance and those of the
:class:`Session`.
:param request: :class:`Request` instance to prepare with this
session\'s settings.
:rtype: requests.PreparedRequest'

def prepare_request(self, request):

    cookies = (request.cookies or {})
    if (not isinstance(cookies, cookielib.CookieJar)):
        cookies = cookiejar_from_dict(cookies)
    merged_cookies = merge_cookies(merge_cookies(RequestsCookieJar(), self.cookies), cookies)
    auth = request.auth
    if (self.trust_env and (not auth) and (not self.auth)):
        auth = get_netrc_auth(request.url)
    p = PreparedRequest()
    p.prepare(method=request.method.upper(), url=request.url, files=request.files, data=request.data, json=request.json, headers=merge_setting(request.headers, self.headers, dict_class=CaseInsensitiveDict), params=merge_setting(request.params, self.params), auth=merge_setting(auth, self.auth), cookies=merged_cookies, hooks=merge_hooks(request.hooks, self.hooks))
    return p
