code: def test_idempotent_order_with_balanced_dataset(
      requests_mock: Mocker,
  ):
      pd.set_option("display.max_columns", 1000)
      url = "http://fake_url2"
  
      mock_default_requests(requests_mock, url)
  
      path = os.path.join(
          os.path.dirname(os.path.realpath(__file__)),
          "test_data/binary/data.csv",
      )
      df = pd.read_csv(path, sep=",")
      df.drop(columns="SystemRecordId_473310000", inplace=True)
      df = df[df["phone_num"] >= 10_000_000]
  
      search_keys = {
          "phone_num": SearchKey.PHONE,
          "rep_date": SearchKey.DATE,
      }
      enricher = FeaturesEnricher(
          search_keys=search_keys,
          endpoint=url,
          api_key="fake_api_key",
          date_format="%Y-%m-%d",
          logs_enabled=False,
      )
  
      result_wrapper = DataFrameWrapper()
  
      def mocked_initial_search(
          self,
          trace_id,
          file_path,
          metadata,
          metrics,
          search_customization,
      ):
          result_wrapper.df = pd.read_parquet(file_path)
          raise TestException()
  
      original_initial_search = _RestClient.initial_search_v2
      _RestClient.initial_search_v2 = mocked_initial_search
  
      expected_result_path = os.path.join(
          os.path.dirname(os.path.realpath(__file__)),
          "test_data/binary/expected_prepared.parquet",
      )
  
      expected_result_df = (
          pd.read_parquet(expected_result_path)
          .sort_values(by="system_record_id")
          .reset_index(drop=True)
      )
  
      def test(n_shuffles: int):
          train_df = df.head(10000)
          for _ in range(n_shuffles):
              train_df = train_df.sample(frac=1).reset_index(drop=True)
          train_features = train_df.drop(columns="target")
          train_target = train_df["target"]
          eval1_df = df[10000:11000]
          for _ in range(n_shuffles):
              eval1_df = eval1_df.sample(frac=1).reset_index(drop=True)
          eval1_features = eval1_df.drop(columns="target")
          eval1_target = eval1_df["target"]
          eval2_df = df[11000:12000]
          for _ in range(n_shuffles):
              eval2_df = eval2_df.sample(frac=1).reset_index(drop=True)
          eval2_features = eval2_df.drop(columns="target")
          eval2_target = eval2_df["target"]
          eval_set = [
              (eval1_features, eval1_target),
              (eval2_features, eval2_target),
          ]
  
          try:
              enricher.fit(
                  train_features,
                  train_target,
                  eval_set,
                  calculate_metrics=False,
              )
          except TestException:
              pass
  
          actual_result_df = result_wrapper.df.sort_values(
              by="system_record_id"
          ).reset_index(drop=True)
          assert_frame_equal(actual_result_df, expected_result_df)
  
      try:
          for i in range(5):
              test(i)
      finally:
          _RestClient.initial_search_v2 = original_initial_search
  
imports: import os
  from datetime import date
  from typing import List, Optional
  import numpy
  import pandas
  import pytest
  from pandas.testing import assert_frame_equal
  from requests_mock.mocker import Mocker
  from upgini import FeaturesEnricher, SearchKey
  from upgini.dataset import Dataset
  from upgini.errors import ValidationError
  from upgini.http import _RestClient
  from upgini.metadata import CVType, FeaturesMetadataV2, HitRateMetrics, ModelEvalSet, ModelTaskType, ProviderTaskMetadataV2, RuntimeParameters
  from upgini.resource_bundle import bundle
  from upgini.search_task import SearchTask
  from upgini.utils.datetime_utils import DateTimeSearchKeyConverter
  from .utils import mock_default_requests, mock_get_metadata, mock_get_task_metadata_v2, mock_initial_and_validation_summary, mock_initial_progress, mock_initial_search, mock_initial_summary, mock_raw_features, mock_validation_progress, mock_validation_raw_features, mock_validation_search, mock_validation_summary
label_desc: Use image node_id 23 for calling a global function with example usage: test_idempotent_order_with_balanced_dataset(requests_mock) without return types