code: def test_encode_into_top_categories_plus_drop_binary(df_enc_binary):
      # top_categories = 1
      encoder = OneHotEncoder(
          top_categories=1,
          variables=None,
          drop_last=False,
          drop_last_binary=True,
      )
      X = encoder.fit_transform(df_enc_binary)
      X = X.astype("int32")
  
      # test fit attr
      transf = {
          "var_num": [
              1,
              1,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              1,
              1,
              0,
              0,
              0,
              0,
              1,
              1,
              0,
              0,
          ],
          "var_A_B": [
              0,
              0,
              0,
              0,
              0,
              0,
              1,
              1,
              1,
              1,
              1,
              1,
              1,
              1,
              1,
              1,
              0,
              0,
              0,
              0,
          ],
          "var_B_A": [
              1,
              1,
              1,
              1,
              1,
              1,
              1,
              1,
              1,
              1,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
          ],
          "var_C_AHA": [
              1,
              1,
              1,
              1,
              1,
              1,
              1,
              1,
              1,
              1,
              1,
              1,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
          ],
          "var_D_OHO": [
              1,
              1,
              1,
              1,
              1,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
          ],
      }
      transf = pd.DataFrame(transf).astype("int32")
  
      assert encoder.variables_ == ["var_A", "var_B", "var_C", "var_D"]
      assert encoder.variables_binary_ == ["var_C", "var_D"]
      assert encoder.n_features_in_ == 5
      assert encoder.encoder_dict_ == {
          "var_A": ["B"],
          "var_B": ["A"],
          "var_C": ["AHA"],
          "var_D": ["OHO"],
      }
      # test transform output
      pd.testing.assert_frame_equal(X, transf)
      assert "var_C_B" not in X.columns
  
      # top_categories = 2
      encoder = OneHotEncoder(
          top_categories=2,
          variables=None,
          drop_last=False,
          drop_last_binary=True,
      )
      X = encoder.fit_transform(df_enc_binary)
      X = X.astype("int32")
  
      # test fit attr
      transf = {
          "var_num": [
              1,
              1,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              1,
              1,
              0,
              0,
              0,
              0,
              1,
              1,
              0,
              0,
          ],
          "var_A_B": [
              0,
              0,
              0,
              0,
              0,
              0,
              1,
              1,
              1,
              1,
              1,
              1,
              1,
              1,
              1,
              1,
              0,
              0,
              0,
              0,
          ],
          "var_A_A": [
              1,
              1,
              1,
              1,
              1,
              1,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
          ],
          "var_B_A": [
              1,
              1,
              1,
              1,
              1,
              1,
              1,
              1,
              1,
              1,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
          ],
          "var_B_B": [
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              1,
              1,
              1,
              1,
              1,
              1,
              0,
              0,
              0,
              0,
          ],
          "var_C_AHA": [
              1,
              1,
              1,
              1,
              1,
              1,
              1,
              1,
              1,
              1,
              1,
              1,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
          ],
          "var_D_OHO": [
              1,
              1,
              1,
              1,
              1,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
          ],
      }
      transf = pd.DataFrame(transf).astype("int32")
  
      assert encoder.variables_ == ["var_A", "var_B", "var_C", "var_D"]
      assert encoder.variables_binary_ == ["var_C", "var_D"]
      assert encoder.n_features_in_ == 5
      assert encoder.encoder_dict_ == {
          "var_A": ["B", "A"],
          "var_B": ["A", "B"],
          "var_C": ["AHA"],
          "var_D": ["OHO"],
      }
      # test transform output
      pd.testing.assert_frame_equal(X, transf)
      assert "var_C_B" not in X.columns
  
file_path: feature_engine/tests/test_encoding/test_onehot_encoder.py
imports: import pandas
  import pytest
  from sklearn.pipeline import Pipeline
  from feature_engine.encoding import OneHotEncoder
label_desc: Use image node_id 12 for calling a global function with example usage: test_encode_into_top_categories_plus_drop_binary(df_enc_binary) without return types