code: def test_relative_scaling(self):
      img = self.imt[0]
      lower = 10
      upper = 99
      b_min = 100
      b_max = 300
      scaler = ScaleIntensityRangePercentiles(
          lower=lower,
          upper=upper,
          b_min=b_min,
          b_max=b_max,
          relative=True,
      )
  
      expected_a_min = np.percentile(img, lower)
      expected_a_max = np.percentile(img, upper)
      expected_b_min = ((b_max - b_min) * (lower / 100.0)) + b_min
      expected_b_max = ((b_max - b_min) * (upper / 100.0)) + b_min
      expected_img = (img - expected_a_min) / (
          expected_a_max - expected_a_min
      )
      expected_img = (
          expected_img * (expected_b_max - expected_b_min)
      ) + expected_b_min
  
      for p in TEST_NDARRAYS:
          result = scaler(p(img))
          assert_allclose(
              result, p(expected_img), type_test="tensor", rtol=1e-3
          )
  
      scaler = ScaleIntensityRangePercentiles(
          lower=lower,
          upper=upper,
          b_min=b_min,
          b_max=b_max,
          relative=True,
          clip=True,
      )
      for p in TEST_NDARRAYS:
          result = scaler(p(img))
          assert_allclose(
              result,
              p(np.clip(expected_img, expected_b_min, expected_b_max)),
              type_test="tensor",
              rtol=0.1,
          )
  
file_path: MONAI/tests/test_scale_intensity_range_percentiles.py
imports: from __future__ import annotations
  import unittest
  import numpy
  from monai.transforms.intensity.array import ScaleIntensityRangePercentiles
  from tests.utils import TEST_NDARRAYS, NumpyImageTestCase2D, assert_allclose
label_desc: Use image node_id 2 for calling the TestScaleIntensityRangePercentiles obj's underlying member method code with example usage: obj.test_relative_scaling() without return types