If you see the documentation 1 for the implementation it has 2 modes in reduction ‘mean’ and ‘sum’ which just specifies the mean and sums of all the (10, 1, 2, 2) values default is mean .
a = torch.ones(10, 1, 2, 2)
b = torch.randn(10, 1, 2, 2)

torch.binary_cross_entropy_with_logits(a, b)
# shape (10, 1, 2, 2)

to demonstrate consider this demo code
F.binary_cross_entropy_with_logits(a, b, reduction='mean')
#> tensor(1.2240)
F.binary_cross_entropy_with_logits(a, b, reduction='sum')
#> tensor(48.9613)

which is equivalent to
torch.mean(torch.binary_cross_entropy_with_logits(a, b))
#> tensor(1.2240)
torch.sum(torch.binary_cross_entropy_with_logits(a, b))
#> tensor(48.9613)

and why we use one single return value is because of gradient calculation and we can backpropagate using loss.backward() only on a single value without explicitly writing gradient tensor for a tensor loss.