code: def sampling_task(
      num_samples: int,
      task_id: int,
      progress_actor: ray.actor.ActorHandle,
  ) -> int:
      num_inside = 0
      for i in range(num_samples):
          x, y = random.uniform(-1, 1), random.uniform(-1, 1)
          if math.hypot(x, y) <= 1:
              num_inside += 1
  
          # Report progress every 1 million samples.
          if (i + 1) % 1_000_000 == 0:
              # This is async.
              progress_actor.report_progress.remote(task_id, i + 1)
  
      # Report the final progress.
      progress_actor.report_progress.remote(task_id, num_samples)
      return num_inside
  
file_path: ray/doc/source/ray-core/doc_code/monte_carlo_pi.py
imports: import ray
  import math
  import time
  import random
label_desc: Use image node_id 1 for calling a global function with example usage: sampling_task(num_samples, task_id, progress_actor) and returns: num_inside