code: def test_cov(bs_setup):
      bs = IIDBootstrap(bs_setup.x)
      num_bootstrap = 10
      cov = bs.cov(
          func=bs_setup.func, reps=num_bootstrap, recenter=False
      )
      bs.reset()
  
      results = np.zeros((num_bootstrap, 2))
      count = 0
      for data, _ in bs.bootstrap(num_bootstrap):
          results[count] = data[0].mean(axis=0)
          count += 1
      errors = results - bs_setup.x.mean(axis=0)
      direct_cov = errors.T.dot(errors) / num_bootstrap
      assert_allclose(cov, direct_cov)
  
      bs.reset()
      cov = bs.cov(
          func=bs_setup.func, recenter=True, reps=num_bootstrap
      )
      errors = results - results.mean(axis=0)
      direct_cov = errors.T.dot(errors) / num_bootstrap
      assert_allclose(cov, direct_cov)
  
      bs = IIDBootstrap(bs_setup.x_df)
      cov = bs.cov(
          func=bs_setup.func, reps=num_bootstrap, recenter=False
      )
      bs.reset()
      var = bs.var(
          func=bs_setup.func, reps=num_bootstrap, recenter=False
      )
      bs.reset()
      results = np.zeros((num_bootstrap, 2))
      count = 0
      for data, _ in bs.bootstrap(num_bootstrap):
          results[count] = data[0].mean(axis=0)
          count += 1
      errors = results - bs_setup.x.mean(axis=0)
      direct_cov = errors.T.dot(errors) / num_bootstrap
      assert_allclose(cov, direct_cov)
      assert_allclose(var, np.diag(direct_cov))
  
      bs.reset()
      cov = bs.cov(
          func=bs_setup.func, recenter=True, reps=num_bootstrap
      )
      errors = results - results.mean(axis=0)
      direct_cov = errors.T.dot(errors) / num_bootstrap
      assert_allclose(cov, direct_cov)
  
imports: from __future__ import annotations
  import copy
  from typing import Callable, NamedTuple
  import warnings
  import numpy
  from numpy.random import RandomState
  from numpy.testing import assert_allclose, assert_equal
  import pandas
  from pandas.testing import assert_frame_equal, assert_series_equal
  import pytest
  import scipy.stats
  from arch.bootstrap import CircularBlockBootstrap, IIDBootstrap, IndependentSamplesBootstrap, MovingBlockBootstrap, StationaryBootstrap
  from arch.bootstrap._samplers_python import stationary_bootstrap_sample
  from arch.bootstrap._samplers_python import stationary_bootstrap_sample_python
  from arch.bootstrap.base import _loo_jackknife
  from arch.utility.exceptions import StudentizationError
label_desc: Use image node_id 7 for calling a global function with example usage: test_cov(bs_setup) without return types