code: def dict(self) -> Dict[int, int]:
      d = {}
      for remote_port, local_port in self.restrictions.items():
          if local_port:
              d[remote_port] = local_port
          else:
              d[remote_port] = self.sockets[remote_port].getsockname()[
                  1
              ]
      return d
  
file_path: dstack/src/dstack/_internal/core/services/ssh/ports.py
imports: import errno
  import socket
  from typing import Dict, List, Optional
  from dstack._internal.core.errors import DstackError
  from dstack._internal.core.models.configurations import PortMapping
label_desc: Use image node_id 4 for calling the PortsLock obj's underlying member method code with example usage: obj.dict() and returns: d