You’ll need to get an actual bmw code scanner not a generic obd scanner to pull the bmw specific codes.
With that you’ll be able to tell if it’s bank 1 or 2. Then narrow it down to if it’s misfires, bad 02 sensor, bad injector, and etc. without that Info you’ll just be guessing. If it’s the maf, cleaning generally doesn’t work, you’ll have to replace it.
If it’s a 50i which it looks to be, here is the location part#3
https://www.realoem.com/bmw/enUS/sho...diagId=13_1272
It’s a module on your intake air filter housing. I see it in your picture It’s on the air filter housing.