code: def MetropolisCuda(InputCU):
      print("Inside ", InputCU)
  
      iterations = InputCU["Iterations"]
      steps = InputCU["Steps"]
      blocks = InputCU["Blocks"]
      threads = InputCU["Threads"]
      Device = InputCU["Device"]
      RNG = InputCU["RNG"]
      ValueType = InputCU["ValueType"]
      Seeds = InputCU["Seeds"]
  
      Marsaglia, Computing, Test = DictionariesAPI()
  
      try:
          # For PyCUDA import
          import pycuda.driver as cuda
          from pycuda.compiler import SourceModule
  
          cuda.init()
          for Id in range(cuda.Device.count()):
              if Id == Device:
                  XPU = cuda.Device(Id)
                  print("GPU selected %s" % XPU.name())
          print
  
      except ImportError:
          print("Platform does not seem to support CUDA")
  
      circle = numpy.zeros(blocks * threads).astype(numpy.uint64)
      circleCU = cuda.InOut(circle)
      # circleCU = cuda.mem_alloc(circle.size*circle.dtype.itemize)
      # cuda.memcpy_htod(circleCU, circle)
  
      Context = XPU.make_context()
  
      try:
          mod = SourceModule(
              KernelCodeCuda(),
              options=[
                  "--compiler-options",
                  "-DTRNG=%i -DTYPE=%s"
                  % (Marsaglia[RNG], Computing[ValueType]),
              ],
          )
          # mod = SourceModule(KernelCodeCuda(),nvcc='nvcc',keep=True)
          # Needed to set the compiler via ccbin for CUDA9 implementation
          # mod = SourceModule(KernelCodeCuda(),options=['-ccbin','clang-3.9','--compiler-options','-DTRNG=%i' % Marsaglia[RNG],'-DTYPE=%s' % Computing[ValueType],'-DTEST=%s' % Test[TestType]],keep=True)  # noqa: E501
      except Exception:
          print("Compilation seems to break")
  
      MetropolisBlocksCU = mod.get_function(
          "MainLoopBlocks"
      )  # noqa: F841
      MetropolisThreadsCU = mod.get_function(
          "MainLoopThreads"
      )  # noqa: F841
      MetropolisHybridCU = mod.get_function("MainLoopHybrid")
  
      MyDuration = numpy.zeros(steps)
  
      jobs = blocks * threads
  
      iterationsCU = numpy.uint64(iterations / jobs)
      if iterations % jobs != 0:
          iterationsCU += numpy.uint64(1)
  
      for i in range(steps):
          start_time = time.time()
  
          try:
              MetropolisHybridCU(
                  circleCU,
                  numpy.uint64(iterationsCU),
                  numpy.uint32(Seeds[0]),
                  numpy.uint32(Seeds[1]),
                  grid=(blocks, 1),
                  block=(threads, 1, 1),
              )
          except Exception:
              print("Crash during CUDA call")
  
          elapsed = time.time() - start_time
          print(
              "(Blocks/Threads)=(%i,%i) method done in %.2f s..."
              % (blocks, threads, elapsed)
          )
  
          MyDuration[i] = elapsed
  
      OutputCU = {
          "Inside": sum(circle),
          "NewIterations": numpy.uint64(iterationsCU * jobs),
          "Duration": MyDuration,
      }
      print(OutputCU)
      Context.pop()
  
      Context.detach()
  
      return OutputCU
  
imports: import numpy
  import sys
  import getopt
  import time
  import itertools
  from socket import gethostname
label_desc: Use image node_id 10 for calling a global function with example usage: MetropolisCuda(InputCU) and returns: OutputCU