code: def test_init_entrypoint():
      # FIXME: Python 2 workaround because nonlocal doesn't exist
      counters = {"init": 0}
  
      def init_function():
          counters["init"] += 1
  
      mod = types.ModuleType("_test_mars_extension")
      mod.init_func = init_function
  
      try:
          # will remove this module at the end of the test
          sys.modules[mod.__name__] = mod
  
          # We are registering an entry point using the "mars" package
          # ("distribution" in pkg_resources-speak) itself, though these are
          # normally registered by other packages.
          dist = "pymars"
          entrypoints = pkg_resources.get_entry_map(dist)
          my_entrypoint = pkg_resources.EntryPoint(
              "init",  # name of entry point
              mod.__name__,  # module with entry point object
              attrs=["init_func"],  # name of entry point object
              dist=pkg_resources.get_distribution(dist),
          )
          entrypoints.setdefault("mars_extensions", {})[
              "init"
          ] = my_entrypoint
  
          from .. import entrypoints
  
          # Allow reinitialization
          entrypoints.init_extension_entrypoints.cache_clear()
  
          entrypoints.init_extension_entrypoints()
  
          # was our init function called?
          assert counters["init"] == 1
  
          # ensure we do not initialize twice
          entrypoints.init_extension_entrypoints()
          assert counters["init"] == 1
      finally:
          # remove fake module
          if mod.__name__ in sys.modules:
              del sys.modules[mod.__name__]
  
file_path: mars/mars/core/tests/test_entrypoints.py
imports: import sys
  import types
  import warnings
  import pkg_resources
label_desc: Use image node_id 1 for calling a global function with example usage: test_init_entrypoint() without return types