code: def test_iterative_imputer(dtypes_to_select, imputer):
      """Test iterative imputer"""
      data = pycaret.datasets.get_data("juice")
      categories = {}
      for i, col in enumerate(data.columns):
          # leave two columns and target filled
          if col in ("STORE", "PriceCH", "DiscMM"):
              continue
          if col in ("Purchase", "Store7"):
              categories[col] = set(data[col].unique())
          data.loc[
              data.sample(frac=0.1, random_state=i).index, col
          ] = np.nan
  
      if dtypes_to_select == "num_only":
          data_subset = data.select_dtypes(include="float")
          categories = {}
      elif dtypes_to_select == "cat_only":
          data_subset = data.select_dtypes(exclude="float")
      else:
          data_subset = data
      data_subset["STORE"] = data["STORE"]
  
      data_subset = data_subset.copy()
      pc = pycaret.classification.setup(
          data=data_subset,
          target="STORE",
          imputation_type="iterative",
          numeric_iterative_imputer=imputer,
          categorical_iterative_imputer=imputer,
      )
      transformer = pc.pipeline.named_steps["iterative_imputer"]
      df = transformer.transform(data_subset, data_subset["STORE"])[0]
      assert not df.isnull().values.any()
      assert all(
          categories[col] == set(df[col].unique()) for col in categories
      )
      df = transformer.transform(data_subset, data_subset["STORE"])[0]
      assert not df.isnull().values.any()
      assert all(
          categories[col] == set(df[col].unique()) for col in categories
      )
  
imports: import io
  import numpy
  import pandas
  import pytest
  from imblearn.over_sampling import ADASYN
  from scipy.sparse import csr_matrix
  from sklearn.decomposition import PCA
  from sklearn.ensemble import RandomForestClassifier
  from sklearn.pipeline import Pipeline
  from sklearn.preprocessing import StandardScaler
  import pycaret.classification
  import pycaret.datasets
  import pycaret.regression
label_desc: Use image node_id 21 for calling a global function with example usage: test_iterative_imputer(dtypes_to_select, imputer) without return types