code: def test_crashed_actor_restores_depth(shutdown_only):
      @ray.remote
      class TestActor:
          def __init__(self, expected_depth=1):
              task_depth = ray._private.worker.global_worker.task_depth
              assert task_depth == expected_depth
  
          def crash(self):
              assert False
  
          def create_restartable_actor(self):
              task_depth = ray._private.worker.global_worker.task_depth
              actor = TestActor.options(
                  max_restarts=1, max_task_retries=0
              ).remote(expected_depth=task_depth + 1)
              return actor
  
          def run(self):
              pass
  
      actor = TestActor.options(
          max_restarts=1, max_task_retries=0
      ).remote()
  
      with pytest.raises(ray.exceptions.RayTaskError) as _:
          ray.get(actor.crash.remote())
  
      nested_actor = ray.get(actor.create_restartable_actor.remote())
  
      ray.get(nested_actor.run.remote())
  
file_path: ray/python/ray/tests/test_nested_task.py
imports: import sys
  import threading
  import pytest
  import ray
label_desc: Use image node_id 8 for calling a global function with example usage: test_crashed_actor_restores_depth(shutdown_only) and returns: actor