<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def remove_nio(self, port_number):
 """ Removes the specified NIO as member of this Frame Relay switch. :param port_number: allocated port number :returns: the NIO that was bound to the allocated port """


        if port_number not in self._nios:
            raise DynamipsError("Port {} is not allocated".format(port_number))

        # remove VCs mapped with the port
        for source, destination in self._active_mappings.copy().items():
            source_port, source_dlci = source
            destination_port, destination_dlci = destination
            if port_number == source_port:
                log.info('Frame Relay switch "{name}" [{id}]: unmapping VC between port {source_port} DLCI {source_dlci} and port {destination_port} DLCI {destination_dlci}'.format(name=self._name,
                                                                                                                                                                                     id=self._id,
                                                                                                                                                                                     source_port=source_port,
                                                                                                                                                                                     source_dlci=source_dlci,
                                                                                                                                                                                     destination_port=destination_port,
                                                                                                                                                                                     destination_dlci=destination_dlci))
                yield from self.unmap_vc(source_port, source_dlci, destination_port, destination_dlci)
                yield from self.unmap_vc(destination_port, destination_dlci, source_port, source_dlci)

        nio = self._nios[port_number]
        if isinstance(nio, NIOUDP):
            self.manager.port_manager.release_udp_port(nio.lport, self._project)

        log.info('Frame Relay switch "{name}" [{id}]: NIO {nio} removed from port {port}'.format(name=self._name,
                                                                                                 id=self._id,
                                                                                                 nio=nio,
                                                                                                 port=port_number))

        del self._nios[port_number]
        return nio