code: def scale(
      sample: npt.ArrayLike,
      l_bounds: npt.ArrayLike,
      u_bounds: npt.ArrayLike,
      *,
      reverse: bool = False,
  ) -> np.ndarray:
      r"""Sample scaling from unit hypercube to different bounds.
  
      To convert a sample from :math:`[0, 1)` to :math:`[a, b), b>a`,
      with :math:`a` the lower bounds and :math:`b` the upper bounds.
      The following transformation is used:
  
      .. math::
  
          (b - a) \cdot \text{sample} + a
  
      Parameters
      ----------
      sample : array_like (n, d)
          Sample to scale.
      l_bounds, u_bounds : array_like (d,)
          Lower and upper bounds (resp. :math:`a`, :math:`b`) of transformed
          data. If `reverse` is True, range of the original data to transform
          to the unit hypercube.
      reverse : bool, optional
          Reverse the transformation from different bounds to the unit hypercube.
          Default is False.
  
      Returns
      -------
      sample : array_like (n, d)
          Scaled sample.
  
      Examples
      --------
      Transform 3 samples in the unit hypercube to bounds:
  
      >>> from scipy.stats import qmc
      >>> l_bounds = [-2, 0]
      >>> u_bounds = [6, 5]
      >>> sample = [[0.5 , 0.75],
      ...           [0.5 , 0.5],
      ...           [0.75, 0.25]]
      >>> sample_scaled = qmc.scale(sample, l_bounds, u_bounds)
      >>> sample_scaled
      array([[2.  , 3.75],
             [2.  , 2.5 ],
             [4.  , 1.25]])
  
      And convert back to the unit hypercube:
  
      >>> sample_ = qmc.scale(sample_scaled, l_bounds, u_bounds, reverse=True)
      >>> sample_
      array([[0.5 , 0.75],
             [0.5 , 0.5 ],
             [0.75, 0.25]])
  
      """
      sample = np.asarray(sample)
      lower = np.atleast_1d(l_bounds)
      upper = np.atleast_1d(u_bounds)
  
      # Checking bounds and sample
      if not sample.ndim == 2:
          raise ValueError("Sample is not a 2D array")
  
      lower, upper = np.broadcast_arrays(lower, upper)
  
      if not np.all(lower < upper):
          raise ValueError("Bounds are not consistent a < b")
  
      if len(lower) != sample.shape[1]:
          raise ValueError(
              "Sample dimension is different than bounds dimension"
          )
  
      if not reverse:
          # Checking that sample is within the hypercube
          if not (np.all(sample >= 0) and np.all(sample <= 1)):
              raise ValueError("Sample is not in unit hypercube")
  
          return sample * (upper - lower) + lower
      else:
          # Checking that sample is within the bounds
          if not (np.all(sample >= lower) and np.all(sample <= upper)):
              raise ValueError("Sample is out of bounds")
  
          return (sample - lower) / (upper - lower)
  
imports: from __future__ import annotations
  import os
  import copy
  import numbers
  from abc import ABC, abstractmethod
  import math
  from typing import ClassVar, List, Optional, overload, TYPE_CHECKING
  import warnings
  import numpy
  import scipy.stats
  from scipy._lib._util import rng_integers
  from scipy.stats._sobol import initialize_v, _cscramble, _fill_p_cumulative, _draw, _fast_forward, _categorize, initialize_direction_numbers, _MAXDIM, _MAXBIT
  from scipy.stats._qmc_cy import _cy_wrapper_centered_discrepancy, _cy_wrapper_wrap_around_discrepancy, _cy_wrapper_mixture_discrepancy, _cy_wrapper_l2_star_discrepancy, _cy_wrapper_update_discrepancy
label_desc: Use image node_id 4 for calling a global function with example usage: scale(sample, l_bounds, u_bounds) and returns: unknown, unknown