def _commnet_block(self, n, hidden, skip, name, hidden_size):
        """a block of CommNet

        Parameters
        ----------
        n: int
            number of agent
        hidden: tf.tensor
            hidden layer input
        skip: tf.tensor
            skip connection
        name: str
        hidden_size: int
        """
        mask = (tf.ones((n, n)) - tf.eye(n))
        mask *= tf.where(n > 1, 1.0 / (tf.cast(n, tf.float32) - 1.0), 0)

        C = tf.get_variable(name + "_C", shape=(hidden_size, hidden_size))
        H = tf.get_variable(name + "_H", shape=(hidden_size, hidden_size))

        message = tf.matmul(mask, hidden)

        return tf.tanh(tf.matmul(message, C) + tf.matmul(hidden, H) + skip)
a block of CommNet

        Parameters
        ----------
        n: int
            number of agent
        hidden: tf.tensor
            hidden layer input
        skip: tf.tensor
            skip connection
        name: str
        hidden_size: int
        
python/magent/builtin/tf_model/a2c.py