Well that depends on when and how you'd like it to be called, but as an example you have the options to specify when a node is initialized, entering the tree, readied, or exiting the tree.
Init happens as soon as you make a new class, enter tree is when you add it to the scene tree, and ready happens when it is made ready in the scene tree, and exit when it is removed.
func _init():
func _enter_tree():
func _ready():
func _exit_tree():
So if you want it to happen on ready when it enters the scene tree in the level.gd base class, just move the ready code there.
func _ready():
print(count_nodes("Sprite"))
If you want something more particular, you will have to decide and design the conditions you want.