def extract_features(features, feature_columns, use_core_columns):
    'Extracts columns from a dictionary of features.\n\n  Args:\n    features: `dict` of `Tensor` objects.\n    feature_columns: A list of feature_columns.\n\n  Returns:\n    Seven values:\n      - A list of all feature column names.\n      - A list of dense floats.\n      - A list of sparse float feature indices.\n      - A list of sparse float feature values.\n      - A list of sparse float feature shapes.\n      - A list of sparse int feature indices.\n      - A list of sparse int feature values.\n      - A list of sparse int feature shapes.\n  Raises:\n    ValueError: if features is not valid.\n  '
    if (not features):
        raise ValueError('Features dictionary must be specified.')
    features = copy.copy(features)
    if feature_columns:
        scope = 'gbdt'
        with variable_scope.variable_scope(scope):
            feature_columns = list(feature_columns)
            transformed_features = collections.OrderedDict()
            for fc in feature_columns:
                if use_core_columns:
                    tensor = fc_core._transform_features(features, [fc])[fc]
                    transformed_features[fc.name] = tensor
                elif isinstance(fc, feature_column_lib._EmbeddingColumn):
                    transformed_features[fc.name] = fc_core.input_layer(features, [fc], weight_collections=[scope])
                else:
                    result = feature_column_ops.transform_features(features, [fc])
                    if (len(result) > 1):
                        raise ValueError('Unexpected number of output features')
                    transformed_features[fc.name] = result[list(result.keys())[0]]
        features = transformed_features
    dense_float_names = []
    dense_floats = []
    sparse_float_names = []
    sparse_float_indices = []
    sparse_float_values = []
    sparse_float_shapes = []
    sparse_int_names = []
    sparse_int_indices = []
    sparse_int_values = []
    sparse_int_shapes = []
    for key in sorted(features.keys()):
        tensor = features[key]
        if isinstance(tensor, tuple):
            categorical_tensor = tensor[0]
            weight_tensor = tensor[1]
            shape = categorical_tensor.dense_shape
            indices = array_ops.concat([array_ops.slice(categorical_tensor.indices, [0, 0], [(- 1), 1]), array_ops.expand_dims(math_ops.to_int64(categorical_tensor.values), (- 1))], 1)
            tensor = sparse_tensor.SparseTensor(indices=indices, values=weight_tensor.values, dense_shape=shape)
        if isinstance(tensor, sparse_tensor.SparseTensor):
            if (tensor.values.dtype == dtypes.float32):
                sparse_float_names.append(key)
                sparse_float_indices.append(tensor.indices)
                sparse_float_values.append(tensor.values)
                sparse_float_shapes.append(tensor.dense_shape)
            elif (tensor.values.dtype == dtypes.int64):
                sparse_int_names.append(key)
                sparse_int_indices.append(tensor.indices)
                sparse_int_values.append(tensor.values)
                sparse_int_shapes.append(tensor.dense_shape)
            else:
                raise ValueError(('Unsupported sparse feature %s with dtype %s.' % (tensor.indices.name, tensor.dtype)))
        elif (tensor.dtype == dtypes.float32):
            if ((len(tensor.shape) > 1) and (tensor.shape[1] > 1)):
                unstacked = array_ops.unstack(tensor, axis=1)
                for i in range(len(unstacked)):
                    dense_float_names.append((_FEATURE_NAME_TEMPLATE % (key, i)))
                    dense_floats.append(array_ops.reshape(unstacked[i], [(- 1), 1]))
            else:
                dense_float_names.append(key)
                dense_floats.append(tensor)
        else:
            raise ValueError(('Unsupported dense feature %s with dtype %s.' % (tensor.name, tensor.dtype)))
    fc_names = ((dense_float_names + sparse_float_names) + sparse_int_names)
    return (fc_names, dense_floats, sparse_float_indices, sparse_float_values, sparse_float_shapes, sparse_int_indices, sparse_int_values, sparse_int_shapes)
Extracts columns from a dictionary of features.

Args:
  features: `dict` of `Tensor` objects.
  feature_columns: A list of feature_columns.

Returns:
  Seven values:
    - A list of all feature column names.
    - A list of dense floats.
    - A list of sparse float feature indices.
    - A list of sparse float feature values.
    - A list of sparse float feature shapes.
    - A list of sparse int feature indices.
    - A list of sparse int feature values.
    - A list of sparse int feature shapes.
Raises:
  ValueError: if features is not valid.
def extract_features(features, feature_columns, use_core_columns):
    'Extracts columns from a dictionary of features.\n\n  Args:\n    features: `dict` of `Tensor` objects.\n    feature_columns: A list of feature_columns.\n\n  Returns:\n    Seven values:\n      - A list of all feature column names.\n      - A list of dense floats.\n      - A list of sparse float feature indices.\n      - A list of sparse float feature values.\n      - A list of sparse float feature shapes.\n      - A list of sparse int feature indices.\n      - A list of sparse int feature values.\n      - A list of sparse int feature shapes.\n  Raises:\n    ValueError: if features is not valid.\n  '
    if (not features):
        raise ValueError('Features dictionary must be specified.')
    features = copy.copy(features)
    if feature_columns:
        scope = 'gbdt'
        with variable_scope.variable_scope(scope):
            feature_columns = list(feature_columns)
            transformed_features = collections.OrderedDict()
            for fc in feature_columns:
                if use_core_columns:
                    tensor = fc_core._transform_features(features, [fc])[fc]
                    transformed_features[fc.name] = tensor
                elif isinstance(fc, feature_column_lib._EmbeddingColumn):
                    transformed_features[fc.name] = fc_core.input_layer(features, [fc], weight_collections=[scope])
                else:
                    result = feature_column_ops.transform_features(features, [fc])
                    if (len(result) > 1):
                        raise ValueError('Unexpected number of output features')
                    transformed_features[fc.name] = result[list(result.keys())[0]]
        features = transformed_features
    dense_float_names = []
    dense_floats = []
    sparse_float_names = []
    sparse_float_indices = []
    sparse_float_values = []
    sparse_float_shapes = []
    sparse_int_names = []
    sparse_int_indices = []
    sparse_int_values = []
    sparse_int_shapes = []
    for key in sorted(features.keys()):
        tensor = features[key]
        if isinstance(tensor, tuple):
            categorical_tensor = tensor[0]
            weight_tensor = tensor[1]
            shape = categorical_tensor.dense_shape
            indices = array_ops.concat([array_ops.slice(categorical_tensor.indices, [0, 0], [(- 1), 1]), array_ops.expand_dims(math_ops.to_int64(categorical_tensor.values), (- 1))], 1)
            tensor = sparse_tensor.SparseTensor(indices=indices, values=weight_tensor.values, dense_shape=shape)
        if isinstance(tensor, sparse_tensor.SparseTensor):
            if (tensor.values.dtype == dtypes.float32):
                sparse_float_names.append(key)
                sparse_float_indices.append(tensor.indices)
                sparse_float_values.append(tensor.values)
                sparse_float_shapes.append(tensor.dense_shape)
            elif (tensor.values.dtype == dtypes.int64):
                sparse_int_names.append(key)
                sparse_int_indices.append(tensor.indices)
                sparse_int_values.append(tensor.values)
                sparse_int_shapes.append(tensor.dense_shape)
            else:
                raise ValueError(('Unsupported sparse feature %s with dtype %s.' % (tensor.indices.name, tensor.dtype)))
        elif (tensor.dtype == dtypes.float32):
            if ((len(tensor.shape) > 1) and (tensor.shape[1] > 1)):
                unstacked = array_ops.unstack(tensor, axis=1)
                for i in range(len(unstacked)):
                    dense_float_names.append((_FEATURE_NAME_TEMPLATE % (key, i)))
                    dense_floats.append(array_ops.reshape(unstacked[i], [(- 1), 1]))
            else:
                dense_float_names.append(key)
                dense_floats.append(tensor)
        else:
            raise ValueError(('Unsupported dense feature %s with dtype %s.' % (tensor.name, tensor.dtype)))
    fc_names = ((dense_float_names + sparse_float_names) + sparse_int_names)
    return (fc_names, dense_floats, sparse_float_indices, sparse_float_values, sparse_float_shapes, sparse_int_indices, sparse_int_values, sparse_int_shapes)