As previously said, if these face attributes can be independently active (1) or inactive (0), then you are dealing with a multi-label approach and could use a single output layer with out_features=40 and nn.BCEWithLogitsLoss as the loss function.