A Tic-Tac-Toe AI based on two rules
First of all, this is too big for one function. You have 7 levels of indentation. Split it up, or remove levels.
Second, you say &quot;I think this is inefficient&quot;. Why? Have you timed it? How long does it take? How long do you think it should take? It is a bad idea to try to speed things up before measuring--maybe there is no problem. Maybe some other part of your program is the slow part.
If you are trying to figure out how to make your program efficient, you normally. only need to loop at the for loops:
for pattern in (horizontals + verticals + diagonals):
    for losing_pattern in losing_three:
        for i in range(9):

It should take (8 * 3 * 9)=216 iterations. Actually less, because you have if branches, but that's the maximum. You could make this smaller, yes (both of the two inner loops can be removed). But also, 216 iterations is just not that many--your computer executes a billion operations per second.
You should remove your third for loop, and every use of id, because it is confusing and hard to read, not because it's a loop.