How do fuel trim and air bubbles prevention work in inverted flight?
A typical GA airplane will draw fuel from at or near the bottom of the tank.

An aerobatic airplane will have a hose from the engine to the middle of the tank, then on the inside of the tank there will be another flexible hose with a weight on the end.  This inside hose is called a "flop tube".

When the plane is in upright flight, the "clunk weight" on the bottom of the "flop tube" (these are the real terms for them, I'm not making this up!) will rest on the bottom of the tank and draw fuel from there.

When the plane is inverted, the weight will move (along with the fuel) to what was formerly the top of the tank.

This ensures that as long as the tank has a reasonable amount of fuel in it, the clunk weight will be submerged most of the time.  There are occasions (usually rolls while going straight up or down) where the weight (and end of the flop tube) is momentarily exposed to air in the tank.  The engine will "hiccup", but there's usually enough inertia in the propeller and engine parts to restart the engine by itself when fuel flow is restored a fraction of a second later.

There's an additional component - a special header tank - that helps by confining the flop tube to a very small tank that's 100% full of fuel 99% of the time.