How to map buildings in inner yards of buildings?

From a real world perspective, imo it’s possible to have buildings where this inner structure is considered part of the outer building. But it’s also possible to have a separate building in there.

So, is both valid, or are there any rules regarding such cases?

Nested Multipolygons. Please see https://wiki.openstreetmap.org/wiki/Multipolygon_Examples

Unless there’s a clear argument in favour of treating the complex as a single building, I’d probably consider them two separate buildings.

But if it’s a single building, then that could be mapped with one multipolygon relation that has two outer rings (outer edge of the outer building, outer edge of the inner building) and one inner ring (inner edge of the outer building).