code: def ssl_wrap_socket(
      socket, ssl_options, server_hostname=None, **kwargs
  ):
      """Returns an ``ssl.SSLSocket`` wrapping the given socket.
  
      ``ssl_options`` may be either an `ssl.SSLContext` object or a
      dictionary (as accepted by `ssl_options_to_context`).  Additional
      keyword arguments are passed to ``wrap_socket`` (either the
      `~ssl.SSLContext` method or the `ssl` module function as
      appropriate).
      """
      context = ssl_options_to_context(ssl_options)
      if hasattr(ssl, "SSLContext") and isinstance(
          context, ssl.SSLContext
      ):
          if server_hostname is not None and getattr(ssl, "HAS_SNI"):
              # Python doesn't have server-side SNI support so we can't
              # really unittest this, but it can be manually tested with
              # python3.2 -m tornado.httpclient https://sni.velox.ch
              return context.wrap_socket(
                  socket, server_hostname=server_hostname, **kwargs
              )
          else:
              return context.wrap_socket(socket, **kwargs)
      else:
          return ssl.wrap_socket(socket, **dict(context, **kwargs))
  
imports: from __future__ import absolute_import, division, print_function
  import errno
  import os
  import sys
  import socket
  import stat
  from tornado.concurrent import dummy_executor, run_on_executor
  from tornado.ioloop import IOLoop
  from tornado.platform.auto import set_close_exec
  from tornado.util import PY3, Configurable, errno_from_exception
label_desc: Use image node_id 5 for calling a global function with example usage: ssl_wrap_socket(socket, ssl_options, server_hostname) and returns: ssl, context, context