code: def test_studentized(bs_setup, seed):
      num_bootstrap = 20
      bs = IIDBootstrap(bs_setup.x, seed=seed)
  
      def std_err_func(mu, y):
          errors = y - mu
          var = (errors**2.0).mean(axis=0)
          return np.sqrt(var / y.shape[0])
  
      ci = bs.conf_int(
          bs_setup.func,
          reps=num_bootstrap,
          method="studentized",
          std_err_func=std_err_func,
      )
      bs.reset()
      base = bs_setup.func(bs_setup.x)
      results = np.zeros((num_bootstrap, 2))
      stud_results = np.zeros((num_bootstrap, 2))
      count = 0
      for pos, _ in bs.bootstrap(reps=num_bootstrap):
          results[count] = bs_setup.func(*pos)
          std_err = std_err_func(results[count], *pos)
          stud_results[count] = (results[count] - base) / std_err
          count += 1
  
      assert_allclose(results, bs._results)
      assert_allclose(stud_results, bs._studentized_results)
      errors = results - results.mean(0)
      std_err = np.sqrt(np.mean(errors**2.0, axis=0))
      ci_direct = np.zeros((2, 2))
      for i in range(2):
          ci_direct[0, i] = base[i] - std_err[i] * np.percentile(
              stud_results[:, i], 97.5
          )
          ci_direct[1, i] = base[i] - std_err[i] * np.percentile(
              stud_results[:, i], 2.5
          )
      assert_allclose(ci, ci_direct)
  
      bs.reset()
      ci = bs.conf_int(
          bs_setup.func,
          reps=num_bootstrap,
          method="studentized",
          studentize_reps=50,
      )
  
      bs.reset()
      base = bs_setup.func(bs_setup.x)
      results = np.zeros((num_bootstrap, 2))
      stud_results = np.zeros((num_bootstrap, 2))
      count = 0
      for pos, _ in bs.bootstrap(reps=num_bootstrap):
          results[count] = bs_setup.func(*pos)
          if isinstance(bs._generator, RandomState):
              seed = bs._generator.randint(2**31 - 1)
          else:
              seed = bs._generator.integers(2**31 - 1)
          inner_bs = IIDBootstrap(*pos, seed=seed)
          cov = inner_bs.cov(bs_setup.func, reps=50)
          std_err = np.sqrt(np.diag(cov))
          stud_results[count] = (results[count] - base) / std_err
          count += 1
  
      assert_allclose(results, bs._results)
      assert_allclose(stud_results, bs._studentized_results)
      errors = results - results.mean(0)
      std_err = np.sqrt(np.mean(errors**2.0, axis=0))
  
      ci_direct = np.zeros((2, 2))
      for i in range(2):
          ci_direct[0, i] = base[i] - std_err[i] * np.percentile(
              stud_results[:, i], 97.5
          )
          ci_direct[1, i] = base[i] - std_err[i] * np.percentile(
              stud_results[:, i], 2.5
          )
      assert_allclose(ci, ci_direct)
  
      with warnings.catch_warnings(record=True) as w:
          warnings.simplefilter("always")
          bs.conf_int(
              bs_setup.func,
              reps=num_bootstrap,
              method="studentized",
              std_err_func=std_err_func,
              reuse=True,
          )
          assert_equal(len(w), 1)
  
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 12 for calling a global function with example usage: test_studentized(bs_setup, seed) and returns: np