def get_device_id(self):
        """
        Obtain the id of the device to use.

        :return: an int, describing the device to use. -1 for CPU.
        """
        if self.is_distributed:
            device_id = self.rank
        else:
            device_id = 0

        if self.use_cuda:
            return device_id

        return -1

        Obtain the id of the device to use.

        :return: an int, describing the device to use. -1 for CPU.
        
avalanche/distributed/distributed_helper.py