code: def piecewise_linear_stretch(  # noqa: D417
      img: XRImage,
      xp: ArrayLike,
      fp: ArrayLike,
      reference_scale_factor: Optional[Number] = None,
      **kwargs,
  ) -> xr.DataArray:
      """Apply 1D linear interpolation.
  
      This uses :func:`numpy.interp` mapped over the provided dask array chunks.
  
      Args:
          img: Image data to be scaled. It is assumed the data is already
              normalized between 0 and 1.
          xp: Input reference values of the image data points used for
              interpolation. This is passed directly to :func:`numpy.interp`.
          fp: Target reference values of the output image data points used for
              interpolation. This is passed directly to :func:`numpy.interp`.
          reference_scale_factor: Divide ``xp`` and ``fp`` by this value before
              using them for interpolation. This is a convenience to make
              matching normalized image data to interp coordinates or to avoid
              floating point precision errors in YAML configuration files.
              If not provided, ``xp`` and ``fp`` will not be modified.
  
      Examples:
          This example YAML uses a 'crude' stretch to pre-scale the RGB data
          and then uses reference points in a 0-255 range.
  
          .. code-block:: yaml
  
                true_color_linear_interpolation:
                  sensor: abi
                  standard_name: true_color
                  operations:
                  - name: reflectance_range
                    method: !!python/name:satpy.enhancements.stretch
                    kwargs: {stretch: 'crude', min_stretch: 0., max_stretch: 100.}
                  - name: Linear interpolation
                    method: !!python/name:satpy.enhancements.piecewise_linear_stretch
                    kwargs:
                     xp: [0., 25., 55., 100., 255.]
                     fp: [0., 90., 140., 175., 255.]
                     reference_scale_factor: 255
  
          This example YAML does the same as the above on the C02 channel, but
          the interpolation reference points are already adjusted for the input
          reflectance (%) data and the output range (0 to 1).
  
          .. code-block:: yaml
  
                c02_linear_interpolation:
                  sensor: abi
                  standard_name: C02
                  operations:
                  - name: Linear interpolation
                    method: !!python/name:satpy.enhancements.piecewise_linear_stretch
                    kwargs:
                     xp: [0., 9.8039, 21.5686, 39.2157, 100.]
                     fp: [0., 0.3529, 0.5490, 0.6863, 1.0]
  
      """
      LOG.debug("Applying the piecewise_linear_stretch")
      if reference_scale_factor is not None:
          xp = np.asarray(xp) / reference_scale_factor
          fp = np.asarray(fp) / reference_scale_factor
  
      return _piecewise_linear(img.data, xp=xp, fp=fp)
  
imports: import logging
  import os
  from collections import namedtuple
  from functools import wraps
  from numbers import Number
  from typing import Optional
  import dask
  import dask.array
  import numpy
  import xarray
  from trollimage.colormap import Colormap
  from trollimage.xrimage import XRImage
  from satpy._compat import ArrayLike
  from satpy._config import get_config_path
  from satpy.utils import find_in_ancillary
label_desc: Use image node_id 8 for calling a global function with example usage: piecewise_linear_stretch(img, xp, fp, reference_scale_factor) and returns: _piecewise_linear