# Codeblock 7a class DeiT(nn.Module): def __init__(self): super().__init__() self.patcher = Patcher() #(1) self.class_token = nn.Parameter(torch.zeros(BATCH_SIZE, 1, EMBED_DIM)) #(2) self.dist_token = nn.Parameter(torch.zeros(BATCH_SIZE, 1, EMBED_DIM)) #(3) trunc_normal_(self.class_token, std=.02) #(4) trunc_normal_(self.dist_token, std=.02) #(5) self.pos_embedding = nn.Parameter(torch.zeros(BATCH_SIZE, NUM_PATCHES+2, EMBED_DIM)) #(6) trunc_normal_(self.pos_embedding, std=.02) #(7) self.encoders = nn.ModuleList([Encoder() for _ in range(NUM_LAYERS)]) #(8) self.norm_out = nn.LayerNorm(EMBED_DIM) #(9) self.class_head = nn.Linear(in_features=EMBED_DIM, out_features=NUM_CLASSES) #(10) self.dist_head = nn.Linear(in_features=EMBED_DIM, out_features=NUM_CLASSES) #(11)