IDF Function with a list of list
Use of global variable
In your function, you use test from the global scope in the comprehension which can lead to nasty side effects.
Type hints and formatting
Type hints and proper formatting help future readers understand the code easier. Modern code editors and static code analysis tools can also use them.
Docstring
A function docstring also helps future users to understand the code.
Raise ValueError if no match
Printing Error is not a good way to notify users of this function that something went wrong. What is the problem? Also if you dont return anything in this case, the function returns None with no errors, which can lead to other, harder to find errors later.
Use generator in counting sum
You dont need to create a list to count the occurences, you can just use a generator expression inside the sum.
No need for list of lists
Maybe you have a reason for this, but you dont need the list of lists data structure for your example.
Use python builtins
You dont need numpy for this task, using python builtins is enough. This way, you dont have to install numpy if you only want to use this function.

Putting it all together, my reviewed version looks like this.
import math
from typing import List

def inverse_document_frequency(corpora: List[str], term: str) -&gt; float:
   &quot;&quot;&quot;
   Calculates Inverse Document Frequency.

   Arguments:
       corpora (List[str]): List of strings to check for term 'term'
       term (str): Term to count in 'corpora'

   Returns:
       float: Inverse document frequency, defined as
           1 + log(length of corpora / occurrences of term)
           Rounded to 3 decimal places.
   &quot;&quot;&quot;

   occurences = sum(1 for string in corpora if term in string)
   if occurences == 0:
       raise ValueError(f&quot;No occurrences of term '{term}' in 'corpora'.&quot;)
   else:
       return round(1 + math.log(len(corpora) / occurences), 3)

test = [
   &quot;I like beer&quot;,
   &quot;I like craft beers&quot;,
   &quot;I like ALE craft beers&quot;,
   &quot;If I have to choose a craft beer, I will take the IPA craft beer&quot;,
]

beer = inverse_document_frequency(corpora=test, term=&quot;beer&quot;)
craft_beer = inverse_document_frequency(corpora=test, term=&quot;craft&quot;)
ipa = inverse_document_frequency(corpora=test, term=&quot;IPA&quot;)
print(beer)
print(craft_beer)
print(ipa)
```