If I try that I get the following error when using:
def weight_init(m):
    if isinstance(m, torch.nn.Conv2d) or isinstance(m, torch.nn.Linear):
        torch.nn.init.xavier_uniform_(m.weight)
        if m.bias: 
            torch.nn.init.xavier_uniform_(m.bias)

RuntimeError: bool value of Tensor with more than one value is ambiguous