code: def _remove_unlistened_nets(block):
      
  
      listened_nets = set()
      listened_wires = set()
      prev_listened_net_count = 0
  
      def add_to_listened(net):
          listened_nets.add(net)
          listened_wires.update(net.args)
  
      for a_net in block.logic:
          if a_net.op == '@':
              add_to_listened(a_net)
          elif any(isinstance(destW, Output) for destW in a_net.dests):
              add_to_listened(a_net)
  
      while len(listened_nets) > prev_listened_net_count:
          prev_listened_net_count = len(listened_nets)
  
          for net in block.logic - listened_nets:
              if any((destWire in listened_wires) for destWire in net.dests):
                  add_to_listened(net)
  
      block.logic = listened_nets
      _remove_unused_wires(block)
docs: Removes all nets that are not connected to an output wirevector