class_docstr: The InferenceDevice class provides zmq.device to connect with frontend and
  backend.
class_docstr_tok: ["The","InferenceDevice","class","provides","zmq.device","to","connect","with","frontend","and","backend","."]
docstr: Start zmq.device to listen from frontend address to backend address.
docstr_tok: ["Start","zmq.device","to","listen","from","frontend","address","to","backend","address","."]
code: def listen(self, frontend_addr: str, backend_addr: str):
      """
      Start zmq.device to listen from frontend address to backend address.
      """
      try:
          context = zmq.Context(1)
  
          self.frontend = context.socket(zmq.ROUTER)
          self.frontend.bind(frontend_addr)
  
          self.backend = context.socket(zmq.DEALER)
          self.backend.bind(backend_addr)
  
          zmq.device(zmq.QUEUE, self.frontend, self.backend)
      except Exception as e:
          self.logger.error(traceback.format_exc())
      finally:
          self.frontend.close()
          self.backend.close()
          context.term()
  
file_path: PaddleHub/paddlehub/serving/device.py
imports: import zmq
  import time
  import os
  import json
  import platform
  import traceback
  import subprocess
  from paddlehub.utils import log
  from paddlehub.utils.utils import is_port_occupied
label_desc: Use image node_id 2 for calling the InferenceDevice obj's underlying member method code with example usage: obj.listen(frontend_addr, backend_addr) without return types