## 3 Materials and Methods
### Neural Network Architecture
In the subsequent stages, specifically stages S2 and S3, we employed various combinations of MBConv blocks (denoted as \"M\") with squeeze-excitation (SE) and Transformer blocks (denoted as \"T\") with solution-based relative attention, where the relative position between patches is used instead of absolute positions to allow for computational efficiency. Additionally, in the second stage, a dense block may be included as part of the configuration. This design enables a flexible arrangement that leverages DenseNet's feature extraction in the early stages, while later stages benefit from MBConv and Transformer blocks to enhance representational capacity and efficiency [14; 40]. Such architectures were trained in two phases, starting with a base of histopathological images of the colon and lung and then being trained and tested on a base of images related to penile cancer, applying the transfer learning technique since the latter has few images. Finally, six different architectural configurations were implemented and tested. We aim to provide a detailed understanding of the impact of these integrations. These architectures are described below:  
* I + D + D + M: The second dense block and the transition layer from DenseNet-201 are used in stage S2. The process is completed with two MBConv blocks, operating with 768 channels in stage S3. This network has 8,959,874 learnable parameters. * I + D + D + T: The second dense block and the transition layer from DenseNet-201 are used in stage S2. Stage S3 of the chain utilizes two Transformer blocks with 768 channels. This network has 9,309,714 learnable parameters. * I + D + T + T: Stage S2 includes five Transformer blocks with 384 channels. The process concludes with an additional two Transformer blocks with 768 channels for greater depth in stage S3. This network has 16,219,002 learnable parameters. * I + D + M + T: It includes five MBConv blocks with 384 channels in stage S2. The design is completed with two Transformer blocks with 768 channels in stage S3. This network has 15,577,746 learnable parameters. * I + D + T + M: It includes five Transformer blocks with 384 channels in stage S2. The sequence ends with two MBConv blocks with 768 channels in stage S3. This network has 15,875,306 learnable parameters. Figure 7: An example of a Transformer block. * I + D + M + M: It includes five MBConv blocks with 384 channels in stage S2 and concludes with two additional MBConv blocks with 768 channels in stage S3. This network has 15,234,050 learnable parameters. After the feature extractor stages, all architectures have an average pooling layer, a dense layer of 256 neurons with Relu activation, drop-out, and a Softmax layer for this binary classification task (presence or not of cancer). For the experiments, we compared the performance of the models using accuracy metrics, precision, recall, and F1-Score based on the class that represents the presence of cancer. The F1-Score was selected as the primary criterion for model evaluation because it combines precision and recall, which are both essential indicators for accurately identifying positive samples (with cancer). This metric is particularly well-suited for assessing performance in medical image classification, where accurately detecting positive cases is essential.