code: def test_random_under_sampling_nan_inf():
      # check that we can undersample even with missing or infinite data
      # regression tests for #605
      rng = np.random.RandomState(42)
      n_not_finite = X.shape[0] // 3
      row_indices = rng.choice(np.arange(X.shape[0]), size=n_not_finite)
      col_indices = rng.randint(0, X.shape[1], size=n_not_finite)
      not_finite_values = rng.choice(
          [np.nan, np.inf], size=n_not_finite
      )
  
      X_ = X.copy()
      X_[row_indices, col_indices] = not_finite_values
  
      rus = RandomUnderSampler(random_state=0)
      X_res, y_res = rus.fit_resample(X_, Y)
  
      assert y_res.shape == (6,)
      assert X_res.shape == (6, 2)
      assert np.any(~np.isfinite(X_res))
  
file_path: imbalanced-learn/imblearn/under_sampling/_prototype_selection/tests/test_random_under_sampler.py
imports: from collections import Counter
  from datetime import datetime
  import numpy
  import pytest
  from sklearn.datasets import make_classification
  from sklearn.utils._testing import assert_array_equal
  from imblearn.under_sampling import RandomUnderSampler
label_desc: Use image node_id 5 for calling a global function with example usage: test_random_under_sampling_nan_inf() without return types