<commit_before># -*- coding: utf-8 -*-
#
# Copyright 2018-2020 Data61, CSIRO
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import tensorflow as tf
from tensorflow.keras.layers import Layer
from ..core.experimental import experimental


@experimental(reason="Missing unit tests and generally untested.", issues=[1044])
class SortPooling(Layer):

    """
    Sort Pooling Keras layer.

    Note that sorting is performed using only the last column of the input tensor as stated in [1], "For convenience,
    we set the last graph convolution to have one channel and only used this single channel for sorting."
    
    [1] An End-to-End Deep Learning Atchitecture for Graph Classification, <NAME>, <NAME>, <NAME>, and
    <NAME>, AAAI-18, https://www.aaai.org/ocs/index.php/AAAI/AAAI18/paper/viewPaper/17146


    Args:
        k (int): The number of rows of output tensor.
        flatten_output (bool): If True then the output tensor is reshaped to vector for each element in the batch.

    """

    def __init__(self, k, flatten_output=False):
        super().__init__()

        self.trainable = False
        self.k = k
        self.flatten_output = flatten_output

    def get_config(self):
        """
        Gets class configuration for Keras serialization. Used by keras model serialization.

        Returns:
            A dictionary that contains the config of the layer
        """
        return {"k": self.k, "flatten_output": self.flatten_output}

    def compute_output_shape(self, input_shapes):<commit_msg>Remove whitespace.<commit_after># -*- coding: utf-8 -*-
#
# Copyright 2018-2020 Data61, CSIRO
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import tensorflow as tf
from tensorflow.keras.layers import Layer
from ..core.experimental import experimental


@experimental(reason="Missing unit tests and generally untested.", issues=[1044])
class SortPooling(Layer):

    """
    Sort Pooling Keras layer.

    Note that sorting is performed using only the last column of the input tensor as stated in [1], "For convenience,
    we set the last graph convolution to have one channel and only used this single channel for sorting."

    [1] An End-to-End Deep Learning Atchitecture for Graph Classification, <NAME>, <NAME>, <NAME>, and
    <NAME>, AAAI-18, https://www.aaai.org/ocs/index.php/AAAI/AAAI18/paper/viewPaper/17146

    Args:
        k (int): The number of rows of output tensor.
        flatten_output (bool): If True then the output tensor is reshaped to vector for each element in the batch.
    """
    def __init__(self, k, flatten_output=False):
        super().__init__()

        self.trainable = False
        self.k = k
        self.flatten_output = flatten_output

    def get_config(self):
        """
        Gets class configuration for Keras serialization. Used by keras model serialization.

        Returns:
            A dictionary that contains the config of the layer
        """
        return {"k": self.k, "flatten_output": self.flatten_output}

    def compute_output_shape(self, input_shapes):
{'fraction_non_alphanumeric': 0.08440594059405941, 'fraction_numerical': 0.01485148514851485, 'mean_word_length': 3.3265524625267666, 'pattern_counts': {'":': 4, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 2, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3933565', 'n_tokens_mistral': 1143, 'n_tokens_neox': 1068, 'n_words': 468}