How should I use template to write a class while using TORCH_MODULE

Original declaration goes as follows:

class UNetImpl : public torch::nn::Module
{
public:
    UNetImpl(int num_classes, std::string encoder_name = "resnet18", std::string pretrained_path = "", int encoder_depth = 5,
             std::vector<int> decoder_channels={256, 128, 64, 32, 16}, bool use_attention = false);
    torch::Tensor forward(torch::Tensor x);
private:
    ResNet encoder{nullptr};
    UNetDecoder decoder{nullptr};
    SegmentationHead segmentation_head{nullptr};
    int num_classes = 1;
    std::vector<int> BasicChannels = {3, 64, 64, 128, 256, 512};
    std::vector<int> BottleChannels = {3, 64, 256, 512, 1024, 2048};
    std::map<std::string, std::vector<int>> name2layers = getParams();
};TORCH_MODULE(UNet);

But when I tried to replace ResNet with a template class “Backbone”, there was an error “XML comment contains invalid XML”.

Could you post the complete error message here, please?

|Error|C3203|‘UNetImpl’: unspecialized class template can’t be used as a template argument for template parameter ‘Contained’, expected a real type|VSLibtorch|d:\allentfiles\code\personal\c++\vslibtorch\vslibtorch\unet.h|35||

Thanks for the update. I don’t know why this C++ error is raised and don’t know what class implementations are supported.
Based on the tutorial structs are used, but I don’t know if this is causing an error. Is this a custom code snippet or are you using any tutorial as the base?

Thanks for your kindly reply.
Well, it is indeed a code snippet from my project here. I want to replace ResNet with different backbones like SeNet. To improve code quality, I don’t want to add a new class member or “if else”. So I tried to use template. The class implementations can be find here.