## 1 Introduction  
In the incoming era of 5G communication, there is a huge amount of data to be transmitted from IoT (Internet of Things) devices to computational data centers in order to make analytics on it. In this regard, Cisco has recently argued that, at the end of the next year (2021), more than 50 billion IoT devices will be connected to the Internet, which are estimated to consume about 850 Zettabytes of data per year [1]. This aspect will be further stressed and taken to extremes by the future 6G communication technology [2]. However, the global intra-data center traffic will remain limited up to 21 Zettabytes. This implies, in turn, that producers/consumers of big data will progressively move from large-scale centralized cloud-hosted data centers to a wide range of spatially distributed ones [3], also induced by the limited bandwidth still offered by multi-hop cellular Wide Area Networks (WANs) [4]. In order to efficiently mine the huge Big Data streams generated by IoT devices, the technological platforms supporting these analytics and the related algorithms should be: (i) _powerful enough_ to take into account the heterogeneous and possibly noisy sensing data generated by resource-limited IoT devices; (ii) _fast enough_, in order to cope with the stream nature of the IoT data; and (iii) suitable for a _distributed execution_, in order to be compliant with the spatially distributed nature of the IoT devices. The emerging Deep Learning (DL) paradigm of the so-called Conditional Deep Neural Networks (CDNNs) with early exits [5; 6; 7], also known as BranchyNets [8; 9], meets the first two requirements and provides an effective means of performing real-time analytics on structured/unstructured IoT data. As sketched in Figure 1a, a CDNN with early exits is obtained by augmenting the stack topology of a baseline feedforward Deep Neural Network (DNN) [10] with a number of local classifiers connected to associated intermediate output branches, called the early exits. The introduction of these auxiliary classifiers allows a fast prediction if there is enough confidence, i.e., the input data is sufficiently simple to be classified in the first layers, while more complicated data will use more or even all the CDNN layers, in order to provide reliable decisions. Both the reliability and associated delay of the local classifiers' decisions increase, while moving from the bottom to the top of the CDNN stack. Hence, CDNNs with early exits may be capable of _self-tuning_ the right reliability-vs.-delay tradeoff, so as to _reduce_ both computing effort and inference delay, providing _distributed_ local exit points to the running application. In order to guarantee such a distributed implementation, the technological platform supporting the execution of a CDNN with early exits cannot rely only on a standing-alone remote and centralized cloud data center. It should be composed, indeed, of the networked interconnection of a number of hierarchically-organized computing nodes, which are spatially scattered and operate nearby the IoT devices. This is the native layout of the emerging paradigm of Fog Computing (FC) [11]. An FC technological platform (sketched in Figure 1b) enables pervasive local access to a set of \((M-1)\) clusters of virtualized small-size pools of computing resources, hierarchically-organized into tiers, which can be quickly provisioned, dynamically scaled up/down and released on an on-demand basis. Nearby resource-limited mobile devices may access these resources by establishing single-hop WiFi-supported communication links. The Fog paradigm exploits resource virtualization for supporting a set of virtualized services by distributing computing-plus-communication virtualized resources along the full path from the IoT realm to the remote Cloud data center [11] and offers a powerful paradigm for developing DL applications [12; 13; 14].