code: def _create_context_manager(self, mode):
          " Create a context manager that sends 'mode' commands to the client. "
          class mode_context_manager(object):
              def __enter__(*a):
                  self.send_packet({'cmd': 'mode', 'data': mode})
  
              def __exit__(*a):
                  self.send_packet({'cmd': 'mode', 'data': 'restore'})
  
          return mode_context_manager(f _create_context_manager(self, mode):
          " Create a context manager that sends 'mode' commands to the client. "
          class mode_context_manager(object):
              def __enter__(*a):
                  self.send_packet({'cmd': 'mode', 'data': mode})
  
              def __exit__(*a):
                  self.send_packet({'cmd': 'mode', 'data': 'restore'})
  
          return mode_context_manager()
docs: Create a context manager that sends 'mode' commands to the client.