code: def _scale_to_sampwidth(data, sampwidth, vmin, vmax):
      # Scale and translate the values to fit the range of the data type
      # associated with the given sampwidth.
  
      data = data.clip(vmin, vmax)
  
      dt = _sampwidth_dtypes[sampwidth]
      if vmax == vmin:
          data = _np.zeros(data.shape, dtype=dt)
      else:
          outmin, outmax = _sampwidth_ranges[sampwidth]
          if outmin != vmin or outmax != vmax:
              vmin = float(vmin)
              vmax = float(vmax)
              data = (
                  float(outmax - outmin) * (data - vmin) / (vmax - vmin)
              ).astype(_np.int64) + outmin
              data[data == outmax] = outmax - 1
          data = data.astype(dt)
  
      return data
  
file_path: dejavu/dejavu/third_party/wavio.py
imports: import wave
  import numpy
label_desc: Use image node_id 4 for calling a global function with example usage: _scale_to_sampwidth(data, sampwidth, vmin, vmax) and returns: data