code: def test_init_hail_context_twice():
      hl_init_for_test(idempotent=True)  # Should be no error
      hl_stop_for_test()
  
      hl_init_for_test(idempotent=True)
      hl.experimental.define_function(lambda x: x + 2, hl.tint32)
      # ensure functions are cleaned up without error
      hl_stop_for_test()
  
      hl_init_for_test(idempotent=True)  # Should be no error
  
      if isinstance(Env.backend(), SparkBackend):
          hl_init_for_test(hl.spark_context(), idempotent=True)
  
file_path: hail/hail/python/test/hail/test_context.py
imports: from typing import Tuple, Dict, Optional
  import hail
  from hail.utils.java import Env
  from hail.backend.backend import Backend
  from hail.backend.spark_backend import SparkBackend
  from test.hail.helpers import skip_unless_spark_backend, hl_init_for_test, hl_stop_for_test, qobtest, with_flags
label_desc: Use image node_id 2 for calling a global function with example usage: test_init_hail_context_twice() without return types