code: def test_actor_parent_task_correct(shutdown_only, actor_type):
      """Verify the parent task id is correct for all actors."""
  
      @ray.remote
      def child():
          pass
  
      @ray.remote
      class ChildActor:
          def child(self):
              pass
  
      def parent_func(child_actor):
          core_worker = ray._private.worker.global_worker.core_worker
          refs = [child_actor.child.remote(), child.remote()]
          expected = {ref.task_id().hex() for ref in refs}
          task_id = ray.get_runtime_context().task_id
          children_task_ids = core_worker.get_pending_children_task_ids(
              task_id
          )
          actual = {task_id.hex() for task_id in children_task_ids}
          ray.get(refs)
          return expected, actual
  
      if actor_type == "actor":
  
          @ray.remote
          class Actor:
              def parent(self, child_actor):
                  return parent_func(child_actor)
  
          @ray.remote
          class GeneratorActor:
              def parent(self, child_actor):
                  yield parent_func(child_actor)
  
      if actor_type == "threaded_actor":
  
          @ray.remote(max_concurrency=5)
          class Actor:  # noqa
              def parent(self, child_actor):
                  return parent_func(child_actor)
  
          @ray.remote(max_concurrency=5)
          class GeneratorActor:  # noqa
              def parent(self, child_actor):
                  yield parent_func(child_actor)
  
      if actor_type == "async_actor":
  
          @ray.remote
          class Actor:  # noqa
              async def parent(self, child_actor):
                  return parent_func(child_actor)
  
          @ray.remote
          class GeneratorActor:  # noqa
              async def parent(self, child_actor):
                  yield parent_func(child_actor)
  
      # Verify a regular actor.
      actor = Actor.remote()
      child_actor = ChildActor.remote()
      actual, expected = ray.get(actor.parent.remote(child_actor))
      assert actual == expected
      # return True
  
      # Verify a generator actor
      actor = GeneratorActor.remote()
      child_actor = ChildActor.remote()
      gen = actor.parent.remote(child_actor)
      for ref in gen:
          result = ray.get(ref)
      actual, expected = result
      assert actual == expected
  
imports: import datetime
  import os
  import random
  import sys
  import tempfile
  import numpy
  import pytest
  import ray
  from ray import cloudpickle
  from ray._private import ray_constants
  from ray._private.test_utils import client_test_enabled, wait_for_condition, wait_for_pid_to_exit
  from ray.actor import ActorClassInheritanceException
  from ray.tests.client_test_utils import create_remote_signal_actor
  from ray._private.test_utils import SignalActor
  import setproctitle
label_desc: Use image node_id 47 for calling a global function with example usage: test_actor_parent_task_correct(shutdown_only, actor_type) and returns: expected,  actual, parent_func, parent_func, parent_func