Thanks for great idea. It is working. 
class UpOrTrans(nn.Module):
    def __init__(self,in_channels, out_channels, mode='up', kernel_size=1, stride=1, scale_factor=2,  padding=0, batch_norm=True, **kwargs):
        super(UpOrTrans, self).__init__()
        self.mode = mode
        upmode = kwargs.get('upmode', 'nearest')
        align_corners = kwargs.get('align_corners', None)
        self.batch_norm = batch_norm
        
        if self.mode == 'up':
            self.up = nn.Upsample(scale_factor=scale_factor, mode=upmode, align_corners=align_corners)
            self.conv = nn.Conv2d(in_channels, out_channels,  kernel_size, stride, padding)
        
        if self.mode == 'trans':
            self.trans = nn.ConvTranspose2d(in_channels, out_channels, kernel_size, stride, padding)
        
        if self.batch_norm:
            self.bn = nn.BatchNorm2d(out_channels)
        
    def forward(self, x, output_size=None):
        if self.mode == 'up':
            x = self.up(x)
            x = self.conv(x)
        if self.mode == 'trans':
            x = self.trans(x, output_size=output_size)
        
        if self.batch_norm:
            x = self.bn(x) 
        return x