code: def run(gpuid, num, dim, max_iter, tol, output):
      """CuPy Gaussian Mixture Model example
  
      Compute GMM parameters, weights, means and covariance matrix, depending on
      sampled data. There are two main components, e_step and m_step.
      In e_step, compute burden rate, which is expressed `resp`, by latest
      weights, means and covariance matrix.
      In m_step, compute weights, means and covariance matrix by latest `resp`.
  
      """
      scale = np.ones(dim)
      train1 = np.random.normal(1, scale, size=(num, dim)).astype(
          np.float32
      )
      train2 = np.random.normal(-1, scale, size=(num, dim)).astype(
          np.float32
      )
      X_train = np.r_[train1, train2]
      test1 = np.random.normal(1, scale, size=(100, dim)).astype(
          np.float32
      )
      test2 = np.random.normal(-1, scale, size=(100, dim)).astype(
          np.float32
      )
      X_test = np.r_[test1, test2]
      y_train = np.r_[np.zeros(num), np.ones(num)].astype(np.int32)
      y_test = np.r_[np.zeros(100), np.ones(100)].astype(np.int32)
  
      mean1 = np.random.normal(1, scale, size=dim)
      mean2 = np.random.normal(-1, scale, size=dim)
      means = np.stack([mean1, mean2])
      covariances = np.random.rand(2, dim)
      print("Running CPU...")
      with timer(" CPU "):
          y_test_pred, means, cov = calc_acc(
              X_train,
              y_train,
              X_test,
              y_test,
              max_iter,
              tol,
              means,
              covariances,
          )
  
      with cupy.cuda.Device(gpuid):
          X_train_gpu = cupy.array(X_train)
          y_train_gpu = cupy.array(y_train)
          y_test_gpu = cupy.array(y_test)
          X_test_gpu = cupy.array(X_test)
          means = cupy.array(means)
          covariances = cupy.array(covariances)
          print("Running GPU...")
          with timer(" GPU "):
              y_test_pred, means, cov = calc_acc(
                  X_train_gpu,
                  y_train_gpu,
                  X_test_gpu,
                  y_test_gpu,
                  max_iter,
                  tol,
                  means,
                  covariances,
              )
          if output is not None:
              draw(X_test_gpu, y_test_pred, means, cov, output)
  
file_path: cupy/examples/gmm/gmm.py
imports: import argparse
  import contextlib
  import time
  import matplotlib.pyplot
  import numpy
  from scipy import stats
  import cupy
label_desc: Use image node_id 9 for calling a global function with example usage: run(gpuid, num, dim, max_iter, tol, output) without return types