code: def main():
      parser = argparse.ArgumentParser()
      parser.add_argument(
          "--gpu-id", "-g", default=0, type=int, help="GPU ID"
      )
      parser.add_argument("--n-options", default=1000, type=int)
      parser.add_argument(
          "--n-samples-per-thread", default=1000, type=int
      )
      parser.add_argument(
          "--n-threads-per-option", default=100000, type=int
      )
      args = parser.parse_args()
  
      cupy.cuda.Device(args.gpu_id).use()
  
      def rand_range(m, M):
          samples = cupy.random.rand(args.n_options)
          return (m + (M - m) * samples).astype(numpy.float64)
  
      print("initializing...")
      stock_price = rand_range(5, 30)
      option_strike = rand_range(1, 100)
      option_years = rand_range(0.25, 10)
      risk_free = 0.02
      volatility = 0.3
  
      @contextlib.contextmanager
      def timer(message):
          cupy.cuda.Stream.null.synchronize()
          start = time.time()
          yield
          cupy.cuda.Stream.null.synchronize()
          end = time.time()
          print("%s:\t%f sec" % (message, end - start))
  
      print("start computation")
      print("    # of options: {}".format(args.n_options))
      print(
          "    # of samples per option: {}".format(
              args.n_samples_per_thread * args.n_threads_per_option
          )
      )
      with timer("GPU (CuPy, Monte Carlo method)"):
          call_mc = compute_option_prices(
              stock_price,
              option_strike,
              option_years,
              risk_free,
              volatility,
              args.n_threads_per_option,
              args.n_samples_per_thread,
          )
  
      # Compute the error between the value of the exact solution
      # and that of the Monte-Carlo simulation
      call_bs, _ = black_scholes_kernel(
          stock_price,
          option_strike,
          option_years,
          risk_free,
          volatility,
      )
      error = cupy.std(call_mc - call_bs)
      print("Error: %f" % error)
      return 0
  
file_path: cupy/examples/finance/monte_carlo.py
imports: import argparse
  import contextlib
  import sys
  import time
  import cupy
  import numpy
  from black_scholes import black_scholes_kernel
label_desc: Use image node_id 2 for calling a global function with example usage: main() and returns: int, unknown