def next_idle_dev(self) -> typing.Optional[int]:
        """Return the next idle (available) device id

        Returns
        -------
        Union[None, int]
            The next idle device id. If all devices are busy, return None
        """
        ret_id = None
        for dev_id, dev_status in self._dev_stats.items():
            if dev_status is False:
                ret_id = dev_id
        self._dev_stats[ret_id] = True
        return ret_id
Return the next idle (available) device id

        Returns
        -------
        Union[None, int]
            The next idle device id. If all devices are busy, return None
        
python/aitemplate/backend/task_runner.py