code: def test_masking_text_sampler_ratios():
      sampler = MaskingTextSampler(min_replace=2)
      samples, sims = sampler.sample_near("foo bar baz", n_samples=100)
      assert {s.strip() for s in samples} == {"foo", "bar", "baz", ""}
  
      sampler = MaskingTextSampler(max_replace=1)
      samples, sims = sampler.sample_near("foo bar baz", n_samples=100)
      assert {s.strip() for s in samples} == {
          "foo bar",
          "foo  baz",
          "bar baz",
      }
  
      sampler = MaskingTextSampler(max_replace=0.3)  # should be 1
      samples, sims = sampler.sample_near("foo bar baz", n_samples=100)
      assert {s.strip() for s in samples} == {
          "foo bar",
          "foo  baz",
          "bar baz",
      }
  
      sampler = MaskingTextSampler(min_replace=0.9)  # should be 2
      samples, sims = sampler.sample_near("foo bar baz", n_samples=100)
      assert {s.strip() for s in samples} == {"foo", "bar", "baz", ""}
  
file_path: eli5/tests/test_samplers.py
imports: from functools import partial
  import numpy
  import pytest
  from hypothesis import given
  from hypothesis.strategies import integers, text
  from eli5.lime.samplers import MaskingTextSampler, MaskingTextSamplers, UnivariateKernelDensitySampler, MultivariateKernelDensitySampler
  from sklearn.neighbors import KernelDensity
label_desc: Use image node_id 5 for calling a global function with example usage: test_masking_text_sampler_ratios() without return types