It depends a bit on your use case, but I think the most flexible and general use case would be to derive a custom class from resnet50 and to override the forward method with the mask layer applied to the appropriate layer.
Let me know, if this workflow would work for you or if you plan to apply the mask in another way.