docs: def preprocess_input(features, target, train_config, preprocess_output_dir,
                       model_type):
    """Perform some transformations after reading in the input tensors.
  
    Args:
      features: dict of feature_name to tensor
      target: tensor
      train_config: our training config object
      preprocess_output_dir: folder should contain the vocab files.
      model_type: the tf model type.
  
    Raises:
      ValueError: if wrong transforms are used
  
    Returns:
      New features dict and new target tensor.
    """
  
    target_name = train_config['target_column']
    key_name = train_config['key_column']
  
    # Do the numerical transforms.
    # Numerical transforms supported for regression/classification
    # 1) num -> do nothing (identity, default)
    # 2) num -> scale to -1, 1 (scale)
    # 3) num -> scale to -a, a (scale with value parameter)
    with tf.name_scope('numerical_feature_preprocess'):
      if train_config['numerical_columns']:
        numerical_analysis_file = os.path.join(preprocess_output_dir,
                                               NUMERICAL_ANALYSIS)
        if not file_io.file_exists(numerical_analysis_file):
          raise ValueError('File %s not found in %s' %
                           (NUMERICAL_ANALYSIS, preprocess_output_dir))
  
        numerical_anlysis = json.loads(
            python_portable_string(
                file_io.read_file_to_string(numerical_analysis_file)))
  
        for name in train_config['numerical_columns']:
          if name == target_name or name == key_name:
            continue
  
          transform_config = train_config['transforms'].get(name, {})
          transform_name = transform_config.get('transform', None)
          if transform_name == 'scale':
            value = float(transform_config.get('value', 1.0))
            features[name] = _scale_tensor(
                features[name],
                range_min=numerical_anlysis[name]['min'],
                range_max=numerical_anlysis[name]['max'],
                scale_min=-value,
                scale_max=value)
          elif transform_name == 'identity' or transform_name is None:
            pass
          else:
            raise ValueError(('For numerical variables, only scale '
                              'and identity are supported: '
                              'Error for %s') % name)
  
    # Do target transform if it exists.
    if target is not None:
      with tf.name_scope('target_feature_preprocess'):
        if target_name in train_config['categorical_columns']:
          labels = train_config['vocab_stats'][target_name]['labels']
          table = tf.contrib.lookup.string_to_index_table_from_tensor(labels)
          target = table.lookup(target)
          # target = tf.contrib.lookup.string_to_index(target, labels)
  
    # Do categorical transforms. Only apply vocab mapping. The real
    # transforms are done with tf learn column features.
    with tf.name_scope('categorical_feature_preprocess'):
      for name in train_config['categorical_columns']:
        if name == key_name or name == target_name:
          continue
        transform_config = train_config['transforms'].get(name, {})
        transform_name = transform_config.get('transform', None)
  
        if is_dnn_model(model_type):
          if transform_name == 'embedding' or transform_name == 'one_hot' or transform_name is None:
            map_vocab = True
          else:
            raise ValueError('Unknown transform %s' % transform_name)
        elif is_linear_model(model_type):
          if (transform_name == 'one_hot' or transform_name is None):
            map_vocab = True
          elif transform_name == 'embedding':
            map_vocab = False
          else:
            raise ValueError('Unknown transform %s' % transform_name)
        if map_vocab:
          labels = train_config['vocab_stats'][name]['labels']
          table = tf.contrib.lookup.string_to_index_table_from_tensor(labels)
          features[name] = table.lookup(features[name])
  
    return features, target