code: def test_gradient(key, data, dtype):
      """
      Test batched gradient implementation against scipy non-batched
      gradient.
  
      .. note:: it doesn't test that the loglikelihood is correct!
      """
      order, seasonal_order, intercept = extract_order(key)
      p, _, q = order
      P, _, Q, _ = seasonal_order
      h = 1e-8
  
      _, y_train_cudf, _, _, _, exog_past_cudf, *_ = get_dataset(
          data, dtype
      )
  
      # Create cuML model
      cuml_model = arima.ARIMA(
          endog=y_train_cudf,
          exog=exog_past_cudf,
          order=order,
          seasonal_order=seasonal_order,
          fit_intercept=intercept,
      )
  
      N = cuml_model.complexity
  
      # Get an estimate of the parameters and pack them into a vector
      cuml_model._estimate_x0()
      x = cuml_model.pack()
  
      # Compute the batched loglikelihood gradient
      batched_grad = cuml_model._loglike_grad(x, h)
  
      # Iterate over the batch to compute a reference gradient
      scipy_grad = np.zeros(N * data.batch_size)
      for i in range(data.batch_size):
          # Create a model with only the current series
          model_i = arima.ARIMA(
              endog=y_train_cudf[y_train_cudf.columns[i]],
              exog=None
              if exog_past_cudf is None
              else exog_past_cudf[
                  exog_past_cudf.columns[
                      data.n_exog * i : data.n_exog * (i + 1)
                  ]
              ],
              order=order,
              seasonal_order=seasonal_order,
              fit_intercept=intercept,
          )
  
          def f(x):
              return model_i._loglike(x)
  
          scipy_grad[N * i : N * (i + 1)] = approx_fprime(
              x[N * i : N * (i + 1)], f, h
          )
  
      # Compare
      np.testing.assert_allclose(
          batched_grad, scipy_grad, rtol=0.001, atol=0.01
      )
  
imports: from cuml.testing.utils import stress_param
  from cuml.internals.input_utils import input_to_host_array
  import cuml.tsa.arima
  from cuml.internals.safe_imports import gpu_only_import
  import statsmodels.api
  from sklearn.model_selection import train_test_split
  from cuml.internals.safe_imports import cpu_only_import_from
  import warnings
  import os
  import pytest
  from cuml.internals.safe_imports import cpu_only_import
label_desc: Use image node_id 14 for calling a global function with example usage: test_gradient(key, data, dtype) and returns: model_i