class_docstr: Transform features using quantiles information.
  
  Stripped down version of sklearn.preprocessing.QuantileTransformer.
  https://github.com/scikit-learn/scikit-learn/blob/
  863e58fcd5ce960b4af60362b44d4f33f08c0f97/sklearn/preprocessing/_data.py
  
  Putting directly in ddsp library to avoid dependency on sklearn that breaks
  when pickling and unpickling from different versions of sklearn.
class_docstr_tok: ["Transform","features","using","quantiles","information",".","Stripped","down","version","of","sklearn.preprocessing.QuantileTransformer",".","https",":","\/\/github.com\/scikit-learn\/scikit-learn\/blob\/","863e58fcd5ce960b4af60362b44d4f33f08c0f97\/sklearn\/preprocessing\/_data.py","Putting","directly","in","ddsp","library","to","avoid","dependency","on","sklearn","that","breaks","when","pickling","and","unpickling","from","different","versions","of","sklearn","."]
docstr: Private function to transform a single feature.
docstr_tok: ["Private","function","to","transform","a","single","feature","."]
code: def _transform_col(self, x_col, quantiles, inverse):
      """Private function to transform a single feature."""
      output_distribution = self.output_distribution
      bounds_threshold = 1e-7
  
      if not inverse:
          lower_bound_x = quantiles[0]
          upper_bound_x = quantiles[-1]
          lower_bound_y = 0
          upper_bound_y = 1
      else:
          lower_bound_x = 0
          upper_bound_x = 1
          lower_bound_y = quantiles[0]
          upper_bound_y = quantiles[-1]
          # for inverse transform, match a uniform distribution
          with np.errstate(
              invalid="ignore"
          ):  # hide NaN comparison warnings
              if output_distribution == "normal":
                  x_col = stats.norm.cdf(x_col)
              # else output distribution is already a uniform distribution
  
      # find index for lower and higher bounds
      with np.errstate(
          invalid="ignore"
      ):  # hide NaN comparison warnings
          if output_distribution == "normal":
              lower_bounds_idx = (
                  x_col - bounds_threshold < lower_bound_x
              )
              upper_bounds_idx = (
                  x_col + bounds_threshold > upper_bound_x
              )
          if output_distribution == "uniform":
              lower_bounds_idx = x_col == lower_bound_x
              upper_bounds_idx = x_col == upper_bound_x
  
      isfinite_mask = ~np.isnan(x_col)
      x_col_finite = x_col[isfinite_mask]
      if not inverse:
          # Interpolate in one direction and in the other and take the
          # mean. This is in case of repeated values in the features
          # and hence repeated quantiles
          #
          # If we don't do this, only one extreme of the duplicated is
          # used (the upper when we do ascending, and the
          # lower for descending). We take the mean of these two
          x_col[isfinite_mask] = 0.5 * (
              np.interp(x_col_finite, quantiles, self.references_)
              - np.interp(
                  -x_col_finite,
                  -quantiles[::-1],
                  -self.references_[::-1],
              )
          )
      else:
          x_col[isfinite_mask] = np.interp(
              x_col_finite, self.references_, quantiles
          )
  
      x_col[upper_bounds_idx] = upper_bound_y
      x_col[lower_bounds_idx] = lower_bound_y
      # for forward transform, match the output distribution
      if not inverse:
          with np.errstate(
              invalid="ignore"
          ):  # hide NaN comparison warnings
              if output_distribution == "normal":
                  x_col = stats.norm.ppf(x_col)
                  # find the value to clip the data to avoid mapping to
                  # infinity. Clip such that the inverse transform will be
                  # consistent
                  clip_min = stats.norm.ppf(
                      bounds_threshold - np.spacing(1)
                  )
                  clip_max = stats.norm.ppf(
                      1 - (bounds_threshold - np.spacing(1))
                  )
                  x_col = np.clip(x_col, clip_min, clip_max)
              # else output distribution is uniform and the ppf is the
              # identity function so we let x_col unchanged
  
      return x_col
  
file_path: ddsp/ddsp/training/postprocessing.py
imports: from ddsp import spectral_ops
  from ddsp.core import hz_to_midi
  import numpy
  from scipy import stats
  import tensorflow.compat.v2
label_desc: Use image node_id 4 for calling the QuantileTransformer obj's underlying member method code with example usage: obj._transform_col(x_col, quantiles, inverse) and returns: x_col