The reasoning is as follows:

For 9999, there are 4 closed regions (consider the top part of the digit 9) and no other digits, so 9999=4

For 8888, there are 8 closed regions (consider the top part and the bottom part of the digit 8) and no other digits, so 8888=8

For 1816, there are 3 closed regions (2 of the digit 8 and 1 of the digit 6) and 2 other digits, so 1816=3*2=6

For 1212, there are 0 closed regions (digits 1 and 2 do not have closed regions) and 4 other digits, so 1212=0*4=0

Use same calculation for 1919, there are 2 closed regions (digit 9) and 2 other digits, so 1919=2*2=4

Given a number N, f(N) is defined as follows:

Count the number of closed regions for each digit of N, and get total T.

If every digit has closed regions, then f(N)=T

Else if R digits do not have closed regions, then f(N)=T*R

So f(9999)=4 and f(8888)=8 and f(1816)=6 and f(1212)=0 and f(1919)=4.