code: def turn_off_internet(verbose=False):
      """
      Disable internet access via python by preventing connections from being
      created using the socket module.  Presumably this could be worked around by
      using some other means of accessing the internet, but all default python
      modules (urllib, requests, etc.) use socket [citation needed].
      """
  
      global INTERNET_OFF
      global _orig_opener
  
      if INTERNET_OFF:
          return
  
      INTERNET_OFF = True
  
      __tracebackhide__ = True
      if verbose:
          print("Internet access disabled")
  
      # Update urllib2 to force it not to use any proxies
      # Must use {} here (the default of None will kick off an automatic search
      # for proxies)
      _orig_opener = urllib.request.build_opener()
      no_proxy_handler = urllib.request.ProxyHandler({})
      opener = urllib.request.build_opener(no_proxy_handler)
      urllib.request.install_opener(opener)
  
      socket.create_connection = check_internet_off(
          socket_create_connection
      )
      socket.socket.bind = check_internet_off(socket_bind)
      socket.socket.connect = check_internet_off(socket_connect)
  
      return socket
  
file_path: catboost/contrib/python/matplotlib/py2/matplotlib/testing/disable_internet.py
imports: from __future__ import absolute_import, division, print_function, unicode_literals
  import contextlib
  import socket
  from six.moves import urllib
label_desc: Use image node_id 2 for calling a global function with example usage: turn_off_internet(verbose) and returns: socket