code: def set_ray_cluster_activity_hook(request):
      """
      Fixture that sets RAY_CLUSTER_ACTIVITY_HOOK environment variable
      for test_e2e_component_activities_hook.
      """
      external_hook = getattr(request, "param")
      assert (
          external_hook
      ), "Please pass value of RAY_CLUSTER_ACTIVITY_HOOK env var to this fixture"
      old_hook = os.environ.get(RAY_CLUSTER_ACTIVITY_HOOK)
      os.environ[RAY_CLUSTER_ACTIVITY_HOOK] = external_hook
  
      yield external_hook
  
      if old_hook is not None:
          os.environ[RAY_CLUSTER_ACTIVITY_HOOK] = old_hook
      else:
          del os.environ[RAY_CLUSTER_ACTIVITY_HOOK]
  
file_path: ray/python/ray/dashboard/modules/snapshot/tests/test_component_activities.py
imports: import os
  import sys
  import json
  import jsonschema
  import pprint
  import pytest
  import requests
  from ray._private.test_utils import format_web_url, run_string_as_driver, run_string_as_driver_nonblocking, wait_for_condition
  from ray.dashboard import dashboard
  from ray.dashboard.consts import RAY_CLUSTER_ACTIVITY_HOOK
  from ray.dashboard.modules.snapshot.snapshot_head import RayActivityResponse
  from ray.dashboard.tests.conftest import *
label_desc: Use image node_id 1 for calling a global function with example usage: set_ray_cluster_activity_hook(request) without return types