def _decode16(self, offset):
        """
        Decode an UTF-16 String at the given offset

        :param offset: offset of the string inside the data
        :return: str
        """
        str_len, skip = self._decode_length(offset, 2)
        offset += skip

        # The len is the string len in utf-16 units
        encoded_bytes = str_len * 2

        data = self.m_charbuff[offset: offset + encoded_bytes]

        if self.m_charbuff[offset + encoded_bytes:offset + encoded_bytes + 2] != b"\x00\x00":
            raise ResParserError("UTF-16 String is not null terminated! At offset={}".format(offset))

        return self._decode_bytes(data, 'utf-16', str_len)

_decode16(self=<StringPool #strings=85, #styles=0, UTF8=False>, offset=494, self._cache={}, self.flags=0, self.header=<ARSCHeader idx='0x00000008' type='1' header_size='28' size='4252'>, self.m_charbuff=b'\x0f\x00i\x00n\x00s\x00t\x00a\x00l\x00l\x00L\x00o\x00c\x00a\x00t\x00i\x00o\x00n\x00\x00\x00\x0b\x00v\x00e\x00r\x00s\x00i\x00o\x00n\x00C\x00o\x00d\x00e\x00\x00\x00\x0b\x00v\x00e\x00r\x00s\x00i\x00o\x00n\x00N\x00a\x00m\x00e\x00\x00\x00\r\x00m\x00i\x00n\x00S\x00d\x00k\x00V\x00e\x00r\x00s\x00i\x00o\x00n\x00\x00\x00\x10\x00t\x00a\x00r\x00g\x00e\x00t\x00S\x00d\x00k\x00V\x00e\x00r\x00s\x00i\x00o\x00n\x00\x00\x00\x04\x00n\x00a\x00m\x00e\x00\x00\x00\x08\x00r\x00e\x00q\x00u\x00i\x00r\x00e\x00d\x00\x00\x00\x0b\x00a\x00l\x00l\x00o\x00w\x00B\x00a\x00c\x00k\x00u\x00p\x00\x00\x00\x0b\x00d\x00e\x00s\x00c\x00r\x00i\x00p\x00t\x00i\x00o\x00n\x00\x00\x00\x04\x00i\x00c\x00o\x00n\x00\x00\x00\x05\x00l\x00a\x00b\x00e\x00l\x00\x00\x00\n\x00p\x00e\x00r\x00s\x00i\x00s\x00t\x00e\x00n\x00t\x00\x00\x00\n\x00l\x00a\x00u\x00n\x00c\x00h\x00M\x00o\x00d\x00e\x00\x00\x00\x0c\x00m\x00u\x00l\x00t\x00i\x00p\x00r\x00o\x00c\x00e\x00s\x00s\x00\x00\x00\x07\x00e\x00n\x00a\x00b\x00l\x00e\x00d\x00\x00\x00\x12\x00f\x00i\x00n\x00i\x00s\x00h\x00O\x00n\x00T\x00a\x00s\x00k\x00L\x00a\x00u\x00n\x00c\x00h\x00\x00\x00\x08\x00r\x00e\x00s\x00o\x00u\x00r\x00c\x00e\x00\x00\x00\x12\x00p\x00a\x00r\x00e\x00n\x00t\x00A\x00c\x00t\x00i\x00v\x00i\x00t\x00y\x00N\x00a\x00m\x00e\x00\x00\x00\x05\x00v\x00a\x00l\x00u\x00e\x00\x00\x00\n\x00p\x00e\x00r\x00m\x00i\x00s\x00s\x00i\x00o\x00n\x00\x00\x00\x07\x00a\x00n\x00d\x00r\x00o\x00i\x00d\x00\x00\x00*\x00h\x00t\x00t\x00p\x00:\x00/\x00/\x00s\x00c\x00h\x00e\x00m\x00a\x00s\x00.\x00a\x00n\x00d\x00r\x00o\x00i\x00d\x00.\x00c\x00o\x00m\x00/\x00a\x00p\x00k\x00/\x00r\x00e\x00s\x00/\x00a\x00n\x00d\x00r\x00o\x00i\x00d\x00\x00\x00\x00\x00\x00\x00\x07\x00p\x00a\x00c\x00k\x00a\x00g\x00e\x00\x00\x00\x18\x00p\x00l\x00a\x00t\x00f\x00o\x00r\x00m\x00B\x00u\x00i\x00l\x00d\x00V\x00e\x00r\x00s\x00i\x00o\x00n\x00C\x00o\x00d\x00e\x00\x00\x00\x18\x00p\x00l\x00a\x00t\x00f\x00o\x00r\x00m\x00B\x00u\x00i\x00l\x00d\x00V\x00e\x00r\x00s\x00i\x00o\x00n\x00N\x00a\x00m\x00e\x00\x00\x00\x08\x00m\x00a\x00n\x00i\x00f\x00e\x00s\x00t\x00\x00\x00\x08\x00a\x002\x00d\x00p\x00.\x00V\x00o\x00l\x00\x00\x00\x08\x002\x00.\x001\x002\x00.\x009\x00.\x002\x00\x00\x00\x02\x002\x004\x00\x00\x00\x03\x007\x00.\x000\x00\x00\x00\x08\x00u\x00s\x00e\x00s\x00-\x00s\x00d\x00k\x00\x00\x00\x0f\x00u\x00s\x00e\x00s\x00-\x00p\x00e\x00r\x00m\x00i\x00s\x00s\x00i\x00o\x00n\x00\x00\x00)\x00a\x00n\x00d\x00r\x00o\x00i\x00d\x00.\x00p\x00e\x00r\x00m\x00i\x00s\x00s\x00i\x00o\x00n\x00.\x00R\x00E\x00C\x00E\x00I\x00V\x00E\x00_\x00B\x00O\x00O\x00T\x00_\x00C\x00O\x00M\x00P\x00L\x00E\x00T\x00E\x00D\x00\x00\x00$\x00a\x00n\x00d\x00r\x00o\x00i\x00d\x00.\x00p\x00e\x00r\x00m\x00i\x00s\x00s\x00i\x00o\x00n\x00.\x00C\x00H\x00A\x00N\x00G\x00E\x00_\x00W\x00I\x00F\x00I\x00_\x00S\x00T\x00A\x00T\x00E\x00\x00\x00$\x00a\x00n\x00d\x00r\x00o\x00i\x00d\x00.\x00p\x00e\x00r\x00m\x00i\x00s\x00s\x00i\x00o\x00n\x00.\x00A\x00C\x00C\x00E\x00S\x00S\x00_\x00W\x00I\x00F\x00I\x00_\x00S\x00T\x00A\x00T\x00E\x00\x00\x00,\x00a\x00n\x00d\x00r\x00o\x00i\x00d\x00.\x00p\x00e\x00r\x00m\x00i\x00s\x00s\x00i\x00o\x00n\x00.\x00K\x00I\x00L\x00L\x00_\x00B\x00A\x00C\x00K\x00G\x00R\x00O\x00U\x00N\x00D\x00_\x00P\x00R\x00O\x00C\x00E\x00S\x00S\x00E\x00S\x00\x00\x00\x1c\x00a\x00n\x00d\x00r\x00o\x00i\x00d\x00.\x00p\x00e\x00r\x00m\x00i\x00s\x00s\x00i\x00o\x00n\x00.\x00B\x00L\x00U\x00E\x00T\x00O\x00O\x00T\x00H\x00\x00\x00"\x00a\x00n\x00d\x00r\x00o\x00i\x00d\x00.\x00p\x00e\x00r\x00m\x00i\x00s\x00s\x00i\x00o\x00n\x00.\x00B\x00L\x00U\x00E\x00T\x00O\x00O\x00T\x00H\x00_\x00A\x00D\x00M\x00I\x00N\x00\x00\x00-\x00c\x00o\x00m\x00.\x00a\x00n\x00d\x00r\x00o\x00i\x00d\x00.\x00l\x00a\x00u\x00n\x00c\x00h\x00e\x00r\x00.\x00p\x00e\x00r\x00m\x00i\x00s\x00s\x00i\x00o\x00n\x00.\x00R\x00E\x00A\x00D\x00_\x00S\x00E\x00T\x00T\x00I\x00N\x00G\x00S\x00\x00\x00\x0c\x00u\x00s\x00e\x00s\x00-\x00f\x00e\x00a\x00t\x00u\x00r\x00e\x00\x00\x00\x1a\x00a\x00n\x00d\x00r\x00o\x00i\x00d\x00.\x00h\x00a\x00r\x00d\x00w\x00a\x00r\x00e\x00.\x00t\x00e\x00l\x00e\x00p\x00h\x00o\x00n\x00y\x00\x00\x00\x1e\x00a\x00n\x00d\x00r\x00o\x00i\x00d\x00.\x00p\x00e\x00r\x00m\x00i\x00s\x00s\x00i\x00o\x00n\x00.\x00R\x00E\x00C\x00E\x00I\x00V\x00E\x00_\x00S\x00M\x00S\x00\x00\x00(\x00a\x00n\x00d\x00r\x00o\x00i\x00d\x00.\x00p\x00e\x00r\x00m\x00i\x00s\x00s\x00i\x00o\x00n\x00.\x00M\x00O\x00D\x00I\x00F\x00Y\x00_\x00A\x00U\x00D\x00I\x00O\x00_\x00S\x00E\x00T\x00T\x00I\x00N\x00G\x00S\x00\x00\x00 \x00a\x00n\x00d\x00r\x00o\x00i\x00d\x00.\x00p\x00e\x00r\x00m\x00i\x00s\x00s\x00i\x00o\x00n\x00.\x00R\x00E\x00A\x00D\x00_\x00C\x00O\x00N\x00T\x00A\x00C\x00T\x00S\x00\x00\x00)\x00a\x00n\x00d\x00r\x00o\x00i\x00d\x00.\x00p\x00e\x00r\x00m\x00i\x00s\x00s\x00i\x00o\x00n\x00.\x00A\x00C\x00C\x00E\x00S\x00S\x00_\x00C\x00O\x00A\x00R\x00S\x00E\x00_\x00L\x00O\x00C\x00A\x00T\x00I\x00O\x00N\x00\x00\x00\'\x00a\x00n\x00d\x00r\x00o\x00i\x00d\x00.\x00p\x00e\x00r\x00m\x00i\x00s\x00s\x00i\x00o\x00n\x00.\x00A\x00C\x00C\x00E\x00S\x00S\x00_\x00F\x00I\x00N\x00E\x00_\x00L\x00O\x00C\x00A\x00T\x00I\x00O\x00N\x00\x00\x001\x00a\x00n\x00d\x00r\x00o\x00i\x00d\x00.\x00p\x00e\x00r\x00m\x00i\x00s\x00s\x00i\x00o\x00n\x00.\x00A\x00C\x00C\x00E\x00S\x00S\x00_\x00L\x00O\x00C\x00A\x00T\x00I\x00O\x00N\x00_\x00E\x00X\x00T\x00R\x00A\x00_\x00C\x00O\x00M\x00M\x00A\x00N\x00D\x00S\x00\x00\x00)\x00a\x00n\x00d\x00r\x00o\x00i\x00d\x00.\x00p\x00e\x00r\x00m\x00i\x00s\x00s\x00i\x00o\x00n\x00.\x00W\x00R\x00I\x00T\x00E\x00_\x00E\x00X\x00T\x00E\x00R\x00N\x00A\x00L\x00_\x00S\x00T\x00O\x00R\x00A\x00G\x00E\x00\x00\x00#\x00a\x00n\x00d\x00r\x00o\x00i\x00d\x00.\x00p\x00e\x00r\x00m\x00i\x00s\x00s\x00i\x00o\x00n\x00.\x00R\x00E\x00A\x00D\x00_\x00P\x00H\x00O\x00N\x00E\x00_\x00S\x00T\x00A\x00T\x00E\x00\x00\x00#\x00a\x00n\x00d\x00r\x00o\x00i\x00d\x00.\x00p\x00e\x00r\x00m\x00i\x00s\x00s\x00i\x00o\x00n\x00.\x00B\x00R\x00O\x00A\x00D\x00C\x00A\x00S\x00T\x00_\x00S\x00T\x00I\x00C\x00K\x00Y\x00\x00\x00\x1f\x00a\x00n\x00d\x00r\x00o\x00i\x00d\x00.\x00p\x00e\x00r\x00m\x00i\x00s\x00s\x00i\x00o\x00n\x00.\x00G\x00E\x00T\x00_\x00A\x00C\x00C\x00O\x00U\x00N\x00T\x00S\x00\x00\x00\x0b\x00a\x00p\x00p\x00l\x00i\x00c\x00a\x00t\x00i\x00o\x00n\x00\x00\x00\x16\x00a\x002\x00d\x00p\x00.\x00V\x00o\x00l\x00.\x00M\x00y\x00A\x00p\x00p\x00l\x00i\x00c\x00a\x00t\x00i\x00o\x00n\x00\x00\x00\x08\x00a\x00c\x00t\x00i\x00v\x00i\x00t\x00y\x00\x00\x00\r\x00a\x002\x00d\x00p\x00.\x00V\x00o\x00l\x00.\x00m\x00a\x00i\x00n\x00\x00\x00\r\x00i\x00n\x00t\x00e\x00n\x00t\x00-\x00f\x00i\x00l\x00t\x00e\x00r\x00\x00\x00\x06\x00a\x00c\x00t\x00i\x00o\x00n\x00\x00\x00\x1a\x00a\x00n\x00d\x00r\x00o\x00i\x00d\x00.\x00i\x00n\x00t\x00e\x00n\x00t\x00.\x00a\x00c\x00t\x00i\x00o\x00n\x00.\x00M\x00A\x00I\x00N\x00\x00\x00\x08\x00c\x00a\x00t\x00e\x00g\x00o\x00r\x00y\x00\x00\x00 \x00a\x00n\x00d\x00r\x00o\x00i\x00d\x00.\x00i\x00n\x00t\x00e\x00n\x00t\x00.\x00c\x00a\x00t\x00e\x00g\x00o\x00r\x00y\x00.\x00L\x00A\x00U\x00N\x00C\x00H\x00E\x00R\x00\x00\x00\x07\x00s\x00e\x00r\x00v\x00i\x00c\x00e\x00\x00\x00\x10\x00a\x002\x00d\x00p\x00.\x00V\x00o\x00l\x00.\x00s\x00e\x00r\x00v\x00i\x00c\x00e\x00\x00\x00\x13\x00a\x002\x00d\x00p\x00.\x00V\x00o\x00l\x00.\x00M\x00a\x00n\x00a\x00g\x00e\x00D\x00a\x00t\x00a\x00\x00\x00\x14\x00a\x002\x00d\x00p\x00.\x00V\x00o\x00l\x00.\x00P\x00r\x00e\x00f\x00e\x00r\x00e\x00n\x00c\x00e\x00s\x00\x00\x00\x08\x00r\x00e\x00c\x00e\x00i\x00v\x00e\x00r\x00\x00\x00\x10\x00a\x002\x00d\x00p\x00.\x00V\x00o\x00l\x00.\x00S\x00t\x00a\x00r\x00t\x00e\x00r\x00\x00\x00\x1c\x00a\x00n\x00d\x00r\x00o\x00i\x00d\x00.\x00i\x00n\x00t\x00e\x00n\x00t\x00.\x00c\x00a\x00t\x00e\x00g\x00o\x00r\x00y\x00.\x00H\x00O\x00M\x00E\x00\x00\x00$\x00a\x00n\x00d\x00r\x00o\x00i\x00d\x00.\x00i\x00n\x00t\x00e\x00n\x00t\x00.\x00a\x00c\x00t\x00i\x00o\x00n\x00.\x00B\x00O\x00O\x00T\x00_\x00C\x00O\x00M\x00P\x00L\x00E\x00T\x00E\x00D\x00\x00\x00)\x00a\x00n\x00d\x00r\x00o\x00i\x00d\x00.\x00i\x00n\x00t\x00e\x00n\x00t\x00.\x00a\x00c\x00t\x00i\x00o\x00n\x00.\x00M\x00Y\x00_\x00P\x00A\x00C\x00K\x00A\x00G\x00E\x00_\x00R\x00E\x00P\x00L\x00A\x00C\x00E\x00D\x00\x00\x00\x0f\x00a\x002\x00d\x00p\x00.\x00V\x00o\x00l\x00.\x00W\x00i\x00d\x00g\x00e\x00t\x00\x00\x00\t\x00m\x00e\x00t\x00a\x00-\x00d\x00a\x00t\x00a\x00\x00\x00\x1a\x00a\x00n\x00d\x00r\x00o\x00i\x00d\x00.\x00a\x00p\x00p\x00w\x00i\x00d\x00g\x00e\x00t\x00.\x00p\x00r\x00o\x00v\x00i\x00d\x00e\x00r\x00\x00\x00)\x00a\x00n\x00d\x00r\x00o\x00i\x00d\x00.\x00a\x00p\x00p\x00w\x00i\x00d\x00g\x00e\x00t\x00.\x00a\x00c\x00t\x00i\x00o\x00n\x00.\x00A\x00P\x00P\x00W\x00I\x00D\x00G\x00E\x00T\x00_\x00U\x00P\x00D\x00A\x00T\x00E\x00\x00\x00\x12\x00a\x002\x00d\x00p\x00.\x00V\x00o\x00l\x00.\x00A\x00L\x00a\x00u\x00n\x00c\x00h\x00e\x00r\x00\x00\x00\x13\x00a\x002\x00d\x00p\x00.\x00V\x00o\x00l\x00.\x00E\x00d\x00i\x00t\x00D\x00e\x00v\x00i\x00c\x00e\x00\x00\x00\x13\x00a\x002\x00d\x00p\x00.\x00V\x00o\x00l\x00.\x00A\x00p\x00p\x00C\x00h\x00o\x00o\x00s\x00e\x00r\x00\x00\x00\x1a\x00a\x002\x00d\x00p\x00.\x00V\x00o\x00l\x00.\x00C\x00u\x00s\x00t\x00o\x00m\x00I\x00n\x00t\x00e\x00n\x00t\x00M\x00a\x00k\x00e\x00r\x00\x00\x00\x15\x00a\x002\x00d\x00p\x00.\x00V\x00o\x00l\x00.\x00P\x00r\x00o\x00v\x00i\x00d\x00e\x00r\x00L\x00i\x00s\x00t\x00\x00\x00\x11\x00a\x002\x00d\x00p\x00.\x00V\x00o\x00l\x00.\x00S\x00t\x00o\x00r\x00e\x00L\x00o\x00c\x00\x00\x00\x18\x00a\x002\x00d\x00p\x00.\x00V\x00o\x00l\x00.\x00P\x00a\x00c\x00k\x00a\x00g\x00e\x00s\x00C\x00h\x00o\x00o\x00s\x00e\x00r\x00\x00\x00\x1f\x00a\x00n\x00d\x00r\x00o\x00i\x00d\x00.\x00s\x00u\x00p\x00p\x00o\x00r\x00t\x00.\x00P\x00A\x00R\x00E\x00N\x00T\x00_\x00A\x00C\x00T\x00I\x00V\x00I\x00T\x00Y\x00\x00\x00\x1c\x00a\x002\x00d\x00p\x00.\x00V\x00o\x00l\x00.\x00N\x00o\x00t\x00i\x00f\x00i\x00c\x00a\x00t\x00i\x00o\x00n\x00C\x00a\x00t\x00c\x00h\x00e\x00r\x00\x00\x005\x00a\x00n\x00d\x00r\x00o\x00i\x00d\x00.\x00p\x00e\x00r\x00m\x00i\x00s\x00s\x00i\x00o\x00n\x00.\x00B\x00I\x00N\x00D\x00_\x00N\x00O\x00T\x00I\x00F\x00I\x00C\x00A\x00T\x00I\x00O\x00N\x00_\x00L\x00I\x00S\x00T\x00E\x00N\x00E\x00R\x00_\x00S\x00E\x00R\x00V\x00I\x00C\x00E\x00\x00\x008\x00a\x00n\x00d\x00r\x00o\x00i\x00d\x00.\x00s\x00e\x00r\x00v\x00i\x00c\x00e\x00.\x00n\x00o\x00t\x00i\x00f\x00i\x00c\x00a\x00t\x00i\x00o\x00n\x00.\x00N\x00o\x00t\x00i\x00f\x00i\x00c\x00a\x00t\x00i\x00o\x00n\x00L\x00i\x00s\x00t\x00e\x00n\x00e\x00r\x00S\x00e\x00r\x00v\x00i\x00c\x00e\x00\x00\x00\x00\x00', self.m_isUTF8=False, self.m_stringOffsets=[0, 34, 60, 86, 116, 152, 164, 184, 210, 236, 248, 262, 286, 310, 338, 356, 396, 416, 456, 470, 494, 512, 600, 604, 622, 674, 726, 746, 766, 786, 794, 804, 824, 858, 944, 1020, 1096, 1188, 1248, 1320, 1414, 1442, 1498, 1562, 1646, 1714, 1800, 1882, 1984, 2070, 2144, 2218, 2284, 2310, 2358, 2378, 2408, 2438, 2454, 2510, 2530, 2598, 2616, 2652, 2694, 2738, 2758, 2794, 2854, 2930, 3016, 3050, 3072, 3128, 3214, 3254, 3296, 3338, 3394, 3440, 3478, 3530, 3596, 3656, 3766], self.m_styleOffsets=[], self.m_styles=[], self.stringCount=85, self.stringsOffset=368, self.styleCount=0, self.stylesOffset=0)


def format_uptime(uptime_in_seconds):
    """Format number of seconds into human-readable string.

    :param uptime_in_seconds: The server uptime in seconds.
    :returns: A human-readable string representing the uptime.

    >>> uptime = format_uptime('56892')
    >>> print(uptime)
    15 hours 48 min 12 sec
    """

    m, s = divmod(int(uptime_in_seconds), 60)
    h, m = divmod(m, 60)
    d, h = divmod(h, 24)

    uptime_values = []

    for value, unit in ((d, 'days'), (h, 'hours'), (m, 'min'), (s, 'sec')):
        if value == 0 and not uptime_values:
            # Don't include a value/unit if the unit isn't applicable to
            # the uptime. E.g. don't do 0 days 0 hours 1 min 30 sec.
            continue
        elif value == 1 and unit.endswith('s'):
            # Remove the "s" if the unit is singular.
            unit = unit[:-1]
        uptime_values.append('{0} {1}'.format(value, unit))

    uptime = ' '.join(uptime_values)
    return uptime

format_uptime(uptime_in_seconds=59)


def _pntcoord(sol, i, n, m, distances, prec):
    """
    Generate coordinates for point i in constellation to points m and n.

    Check if these coordinates are valid with all other points in the solution.
    """
    tmppnt = []

    state = 1

    pntscount = len(sol)

    # if no distances known, return empty result and the unknown-state
    if distances[i, n] < -0.5 or distances[i, m] < -0.5:
        return tmppnt, state

    # if the Triangle inequality is not fullfilled give a contradiction
    if distances[i, n] + distances[i, m] < _dist(sol[n], sol[m]):
        state = 2
        return tmppnt, state

    # generate the affine rotation to bring the points in the right place
    g = _affinef(*_invtranmat(*_tranmat(sol[n], sol[m])))

    # generate the coordinates
    x = _xvalue(distances[i, n], distances[i, m], _dist(sol[n], sol[m]))
    y1, y2 = _yvalue(distances[i, n], distances[i, m], _dist(sol[n], sol[m]))

    # generate the possible positons
    pos1 = g(np.array([x, y1]))
    pos2 = g(np.array([x, y2]))

    valid1 = True
    valid2 = True

    # check if the possible positions are valid
    for k in range(pntscount):
        if np.ndim(sol[k]) != 0 and distances[i, k] > -0.5:
            valid1 &= abs(_dist(sol[k], pos1) - distances[i, k]) < prec
            valid2 &= abs(_dist(sol[k], pos2) - distances[i, k]) < prec

    # if any position is valid, add it to the result
    if valid1 or valid2:
        state = 0
        same = abs(y1 - y2) < prec / 4.0
        if valid1:
            tmppnt.append(dcopy(pos1))
        if valid2 and not same:
            tmppnt.append(dcopy(pos2))
    # if the positions are not valid, give a contradiction
    else:
        state = 2

    return tmppnt, state

_pntcoord(sol=[array([0., 0.]), array([3., 0.]), 0, 0], i=2, n=0, m=1, distances=array([[ 0.,  3.,  4.,  1.],       [ 3.,  0.,  2.,  3.],       [ 4.,  2.,  0., -1.],       [ 1.,  3., -1.,  0.]]), prec=0.1)

<function _affinef.<locals>.func at 0x7f9d2f5dc9d0>


def encode_z1(self, input: Tensor, z2: Tensor) -> List[Tensor]:
        x = self.embed_data(input)
        z2 = self.embed_z2_code(z2)
        z2 = z2.view(-1, self.img_size, self.img_size).unsqueeze(1)
        result = torch.cat([x, z2], dim=1)

        result = self.encoder_z1_layers(result)
        result = torch.flatten(result, start_dim=1)
        z1_mu = self.fc_z1_mu(result)
        z1_log_var = self.fc_z1_var(result)

        return [z1_mu, z1_log_var]

encode_z1(self=HVAE(  (encoder_z2_layers): Sequential(    (0): Sequential(      (0): Conv2d(3, 32, kernel_size=(3, 3), stride=(2, 2), padding=(1, 1))      (1): BatchNorm2d(32, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)      (2): LeakyReLU(negative_slope=0.01)    )    (1): Sequential(      (0): Conv2d(32, 64, kernel_size=(3, 3), stride=(2, 2), padding=(1, 1))      (1): BatchNorm2d(64, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)      (2): LeakyReLU(negative_slope=0.01)    )    (2): Sequential(      (0): Conv2d(64, 128, kernel_size=(3, 3), stride=(2, 2), padding=(1, 1))      (1): BatchNorm2d(128, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)      (2): LeakyReLU(negative_slope=0.01)    )    (3): Sequential(      (0): Conv2d(128, 256, kernel_size=(3, 3), stride=(2, 2), padding=(1, 1))      (1): BatchNorm2d(256, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)      (2): LeakyReLU(negative_slope=0.01)    )    (4): Sequential(      (0): Conv2d(256, 512, kernel_size=(3, 3), stride=(2, 2), padding=(1, 1))      (1): BatchNorm2d(512, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)      (2): LeakyReLU(negative_slope=0.01)    )  )  (fc_z2_mu): Linear(in_features=2048, out_features=20, bias=True)  (fc_z2_var): Linear(in_features=2048, out_features=20, bias=True)  (embed_z2_code): Linear(in_features=20, out_features=4096, bias=True)  (embed_data): Conv2d(3, 3, kernel_size=(1, 1), stride=(1, 1))  (encoder_z1_layers): Sequential(    (0): Sequential(      (0): Conv2d(4, 32, kernel_size=(3, 3), stride=(2, 2), padding=(1, 1))      (1): BatchNorm2d(32, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)      (2): LeakyReLU(negative_slope=0.01)    )    (1): Sequential(      (0): Conv2d(32, 64, kernel_size=(3, 3), stride=(2, 2), padding=(1, 1))      (1): BatchNorm2d(64, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)      (2): LeakyReLU(negative_slope=0.01)    )    (2): Sequential(      (0): Conv2d(64, 128, kernel_size=(3, 3), stride=(2, 2), padding=(1, 1))      (1): BatchNorm2d(128, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)      (2): LeakyReLU(negative_slope=0.01)    )    (3): Sequential(      (0): Conv2d(128, 256, kernel_size=(3, 3), stride=(2, 2), padding=(1, 1))      (1): BatchNorm2d(256, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)      (2): LeakyReLU(negative_slope=0.01)    )    (4): Sequential(      (0): Conv2d(256, 512, kernel_size=(3, 3), stride=(2, 2), padding=(1, 1))      (1): BatchNorm2d(512, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)      (2): LeakyReLU(negative_slope=0.01)    )  )  (fc_z1_mu): Linear(in_features=2048, out_features=10, bias=True)  (fc_z1_var): Linear(in_features=2048, out_features=10, bias=True)  (recons_z1_mu): Linear(in_features=20, out_features=10, bias=True)  (recons_z1_log_var): Linear(in_features=20, out_features=10, bias=True)  (debed_z1_code): Linear(in_features=10, out_features=1024, bias=True)  (debed_z2_code): Linear(in_features=20, out_features=1024, bias=True)  (decoder): Sequential(    (0): Sequential(      (0): ConvTranspose2d(512, 256, kernel_size=(3, 3), stride=(2, 2), padding=(1, 1), output_padding=(1, 1))      (1): BatchNorm2d(256, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)      (2): LeakyReLU(negative_slope=0.01)    )    (1): Sequential(      (0): ConvTranspose2d(256, 128, kernel_size=(3, 3), stride=(2, 2), padding=(1, 1), output_padding=(1, 1))      (1): BatchNorm2d(128, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)      (2): LeakyReLU(negative_slope=0.01)    )    (2): Sequential(      (0): ConvTranspose2d(128, 64, kernel_size=(3, 3), stride=(2, 2), padding=(1, 1), output_padding=(1, 1))      (1): BatchNorm2d(64, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)      (2): LeakyReLU(negative_slope=0.01)    )    (3): Sequential(      (0): ConvTranspose2d(64, 32, kernel_size=(3, 3), stride=(2, 2), padding=(1, 1), output_padding=(1, 1))      (1): BatchNorm2d(32, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)      (2): LeakyReLU(negative_slope=0.01)    )  )  (final_layer): Sequential(    (0): ConvTranspose2d(32, 32, kernel_size=(3, 3), stride=(2, 2), padding=(1, 1), output_padding=(1, 1))    (1): BatchNorm2d(32, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)    (2): LeakyReLU(negative_slope=0.01)    (3): Conv2d(32, 3, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))    (4): Tanh()  )), input=tensor([[[[-1.8936,  0.4196,  1.2842,  ...,  1.2066,  0.7782,  1.3469],          [-0.8224,  0.4527, -0.0577,  ...,  1.4756,  1.1761, -0.7108],          [-1.6315,  0.8043,  2.6413,  ..., -1.3240,  0.9065, -0.8693],          ...,          [ 0.0383,  1.3328, -0.1353,  ..., -1.1770, -0.1116, -0.3206],          [-1.0151,  0.2528, -0.3343,  ..., -0.0416, -0.9868,  1.1128],          [-1.0028, -1.1892,  0.7485,  ...,  0.7481,  0.0498, -0.0744]],         [[-0.2884, -0.2759,  1.1363,  ...,  1.1605,  0.0775, -1.4702],          [-1.6069, -0.0638, -0.8533,  ...,  0.2473,  1.4863,  0.0158],          [ 2.5342,  0.6854,  1.1528,  ...,  0.6568, -0.5946,  0.1834],          ...,          [ 0.3353,  0.0865, -0.9538,  ..., -1.2018, -1.4665, -0.3575],          [-0.3430, -1.4583, -0.7826,  ...,  2.1256, -0.3949,  0.1570],          [ 0.9678, -1.7589,  0.9122,  ...,  0.4558,  1.4173,  1.6013]],         [[-0.7772,  0.4630,  0.6564,  ..., -1.8964, -2.1647, -0.5534],          [ 0.4105,  0.5011,  1.2573,  ...,  0.3236,  0.9842,  1.0977],          [-0.7429,  1.0571,  0.6543,  ...,  0.3400, -0.2293, -0.5091],          ...,          [ 0.1505, -0.3082,  0.3324,  ...,  0.6619, -0.0814,  0.6934],          [-1.7772, -1.9982,  0.5367,  ...,  0.1102, -0.7138,  0.8455],          [ 0.0332, -0.3734, -1.5362,  ..., -1.2318, -0.4791, -1.6185]]],        [[[ 0.0160,  0.7455,  0.3158,  ..., -0.0860,  0.2626,  1.1479],          [-0.4146,  1.8953,  0.0897,  ..., -0.3885,  1.2116, -1.0973],          [-0.6872, -1.8162,  0.1554,  ..., -1.7179,  1.0908,  0.8081],          ...,          [ 0.1696, -1.8558,  0.1469,  ...,  0.3142,  2.3475,  0.4731],          [ 0.1529, -1.0062,  0.7995,  ...,  0.2377,  0.8177,  0.9386],          [ 0.0217, -0.4921, -0.8103,  ...,  2.6341, -0.5868, -0.0105]],         [[ 1.4296,  0.8156, -0.1442,  ..., -1.5969,  0.2655,  1.3892],          [ 0.0990, -0.1513, -0.2613,  ..., -0.5251, -0.1855, -0.1718],          [ 1.4328,  0.2132, -1.6794,  ...,  0.8488,  1.4868, -1.7160],          ...,          [-0.0693,  0.1337,  1.1090,  ..., -1.3724, -2.5672,  1.0906],          [ 0.2655,  0.3716, -0.1245,  ...,  0.7961, -0.3946,  1.0061],          [-0.8810,  0.1413, -0.6222,  ..., -0.4905, -0.3606, -1.0626]],         [[-0.0948, -0.0486,  0.0157,  ...,  2.1004, -1.5879, -0.2739],          [-0.2656,  1.1246,  1.0048,  ...,  0.4671, -0.1705, -0.7745],          [-0.3759,  0.2029, -1.7732,  ..., -0.2653, -2.3626, -1.0251],          ...,          [ 1.4900, -1.3544,  1.5717,  ..., -1.9406,  0.7142, -0.6601],          [ 0.0120,  0.9058,  0.0421,  ...,  1.5632,  1.1624,  0.1822],          [-0.9256,  0.8344, -0.9597,  ..., -0.4188,  0.2051,  0.6043]]],        [[[-0.6292,  1.5933,  1.1558,  ..., -1.0939,  0.3556, -1.9305],          [ 2.2168,  0.9184, -0.6098,  ...,  0.1250,  0.2496,  0.5268],          [ 0.6035, -0.7713,  0.4179,  ...,  0.1061,  0.2763, -1.1580],          ...,          [ 0.6361, -0.9818,  0.2838,  ..., -0.1032, -0.1063,  0.2971],          [-0.9087, -0.8842,  1.3305,  ...,  0.7932,  1.0652, -0.1426],          [-2.2427, -0.6605,  0.9667,  ..., -0.4021, -1.1495, -0.0572]],         [[-0.1344,  0.6562,  0.4687,  ...,  0.1312,  0.5327,  0.3450],          [ 0.4334,  1.3153,  1.9282,  ...,  0.5667,  1.4108,  0.4699],          [ 0.5254, -0.2920,  1.7819,  ..., -0.5157, -0.3931, -0.8093],          ...,          [-0.5848,  0.6157,  1.1588,  ...,  0.5449, -1.0721,  0.5217],          [ 0.3995,  0.2235,  0.2506,  ..., -0.3272,  0.8440,  0.4930],          [-0.8263, -0.0577, -0.9538,  ..., -1.2877,  1.6349,  1.3202]],         [[ 0.6381, -1.4398, -0.7744,  ...,  1.2140,  0.9096, -0.6753],          [ 0.4048, -2.5466,  1.1450,  ...,  0.5030,  0.4698,  0.5673],          [-0.0358,  0.2170, -0.6245,  ..., -0.4325,  0.5767, -0.2755],          ...,          [ 0.3158, -1.6521,  0.9919,  ...,  2.0221, -1.2303,  0.4039],          [ 0.2354, -0.9477, -0.6534,  ..., -0.5600, -1.3333,  0.5403],          [ 1.1120, -2.0893, -1.3755,  ...,  1.9954,  0.8662, -1.6815]]],        ...,        [[[ 1.2590,  0.1363, -0.6754,  ..., -0.8791,  1.2095, -0.1012],          [ 2.3050, -0.1425, -0.9242,  ..., -0.7649, -0.7488,  0.6949],          [ 0.4214,  0.3215, -2.3866,  ..., -0.5338,  0.4479, -0.8477],          ...,          [ 0.1499, -0.5690,  0.0180,  ...,  1.6823,  0.3056, -0.6216],          [-0.3886,  0.6260, -0.6109,  ...,  0.0346,  0.2253, -0.5103],          [-0.1228,  0.1755,  0.1834,  ..., -2.4334, -0.4735,  0.3909]],         [[-0.5463,  0.1758,  0.3594,  ..., -1.5349, -0.1570,  0.0686],          [-0.1374,  1.0209, -0.5383,  ..., -0.9182, -0.2435, -0.2757],          [ 0.6611, -0.2038, -1.1446,  ..., -1.4481,  0.6467, -0.6618],          ...,          [-0.2686,  0.0405, -0.1467,  ...,  1.0902,  0.5896, -0.7653],          [-1.9040,  0.0179,  1.1207,  ..., -0.2288, -1.6366,  1.1901],          [ 0.1832,  0.3417,  0.9626,  ...,  0.3803,  0.7350, -0.3099]],         [[-0.9969, -0.5508, -0.4998,  ...,  0.6936,  1.6136,  0.3220],          [-0.0770,  1.3169,  0.1651,  ...,  1.7485,  0.7226, -0.2574],          [ 0.0803, -0.9462,  1.2021,  ..., -0.0972,  0.0682,  0.1344],          ...,          [-1.7403,  1.7113,  3.0679,  ...,  1.0908,  1.0581, -0.5222],          [ 0.4028, -1.0059, -2.1630,  ..., -0.0682,  0.5164,  1.6635],          [ 2.7208, -0.5648, -0.1862,  ..., -1.5719, -0.3802,  0.2935]]],        [[[ 0.8409, -0.7438, -1.0032,  ...,  0.1318, -0.4320,  0.4415],          [ 1.5099, -1.1524,  1.1499,  ..., -1.6440, -0.0798,  0.6606],          [ 1.0045, -0.9537,  1.1316,  ..., -1.3674, -0.9758, -0.0078],          ...,          [ 0.3468,  0.5475, -0.7472,  ...,  1.5581,  0.2254,  0.8593],          [-0.0717,  0.4480,  1.3726,  ...,  0.6523, -1.1766, -0.3996],          [-1.6755, -0.8156,  0.5543,  ..., -1.4320,  0.4414, -0.1122]],         [[ 1.3380, -1.1875,  0.5178,  ...,  0.3197, -0.7422,  0.5158],          [-1.1908,  1.4007,  0.8123,  ..., -1.4919, -1.7273, -0.0800],          [-1.3901, -0.3755,  0.0897,  ...,  1.6764, -1.3049, -0.0079],          ...,          [-0.1568, -1.4188, -0.7429,  ..., -1.6218,  0.6604,  1.6529],          [ 0.6247,  0.6867, -1.0114,  ..., -0.0381,  0.1275, -0.8645],          [-0.0610,  0.5389,  0.3990,  ..., -1.0361, -2.4215, -0.6971]],         [[ 0.7516, -1.9676,  1.4015,  ...,  0.5336,  1.0704,  1.7422],          [-1.6988, -1.2900, -0.6327,  ..., -0.9592,  1.5238,  0.2264],          [ 1.0729,  0.8629, -0.5775,  ..., -0.7702, -0.0271,  0.7063],          ...,          [ 0.4322,  1.7422,  0.5302,  ...,  1.7000,  1.1956,  0.4742],          [ 0.4945,  0.2216, -1.3425,  ..., -0.9851,  0.1730,  1.0625],          [-0.6886, -0.1384, -0.4764,  ...,  0.3615,  0.5811,  0.4600]]],        [[[-0.8843,  0.8162, -0.5182,  ...,  0.3598, -0.5506, -0.5101],          [-0.4878, -1.6419, -0.5060,  ...,  1.8825, -0.1327,  0.3133],          [ 0.4729,  0.4339,  1.0820,  ..., -1.3299, -0.7871, -0.6630],          ...,          [-1.1407,  0.0937,  1.0086,  ...,  0.2854,  0.4308,  1.1841],          [ 0.3772, -0.8250,  1.1873,  ...,  0.1146, -0.7267,  0.4953],          [-0.3229, -1.0868, -0.0125,  ..., -0.6451,  1.2862, -1.9553]],         [[-0.4689, -0.3666, -0.3470,  ..., -0.0699, -1.9161, -0.4589],          [-0.4437,  0.9324, -2.2532,  ...,  0.1354,  1.1196, -0.0070],          [ 1.1838,  0.3169,  1.2460,  ..., -0.9694,  0.3669,  0.7385],          ...,          [-1.7229,  0.6705,  0.0683,  ...,  1.0143,  0.6204, -1.1060],          [ 0.2528, -2.3181, -0.0774,  ..., -0.3610,  0.4452, -0.3837],          [-1.2532, -0.3006,  0.6067,  ..., -0.8430, -0.5149,  0.8442]],         [[-1.8861, -0.4756,  0.9849,  ...,  0.7845, -0.8080, -0.6442],          [-0.7163,  0.8101, -0.1905,  ...,  0.3361,  0.6133, -0.1919],          [-0.7476, -0.5810, -0.1615,  ..., -0.5631,  0.0637, -0.1969],          ...,          [-0.9449, -0.9001,  1.0701,  ...,  0.4150,  0.1768, -0.4086],          [ 0.5126,  1.4135,  1.6389,  ..., -0.6361, -0.3524, -0.2547],          [ 0.0541, -1.5909, -1.5796,  ..., -0.1662, -0.7188, -0.6655]]]]), z2=tensor([[-1.2900e+00, -1.9974e+00, -1.2873e+00,  6.8312e-01,  1.1999e+00,          5.2038e-01, -1.1960e+00,  5.8112e-01,  1.0388e-01, -1.2854e-01,          4.6986e-01,  4.9946e-01,  7.0090e-01,  3.2990e-01,  6.1682e-01,          4.5016e-01,  6.5489e-01, -3.5582e-01, -5.0099e-01,  8.5103e-01],        [-6.6771e-01, -1.3980e+00, -4.8212e-01, -2.3246e-01,  5.8675e-01,         -4.5213e-01, -5.7778e-02, -9.8022e-02, -2.0276e+00, -2.1314e+00,         -6.2125e-01,  1.7824e+00, -9.2441e-02, -5.5198e-01,  3.9835e-01,         -8.2421e-02,  4.7706e-01, -7.4640e-02, -9.8138e-01,  1.1754e+00],        [-1.9242e-01,  4.4564e-01, -1.7303e-01,  1.7473e+00, -1.4152e+00,          8.4109e-01, -1.9819e+00,  2.4425e+00,  7.1755e-01, -9.0582e-01,         -5.1756e-01,  1.8689e+00, -6.7044e-01, -1.3858e+00, -1.6933e-01,         -6.0295e-01, -3.1655e-01, -9.6165e-01,  1.0204e+00, -6.7928e-01],        [-9.2453e-01,  9.0098e-01,  4.8510e-01,  9.0699e-01, -7.1865e-01,          3.9064e-01, -1.9083e+00, -1.1505e+00,  7.4294e-01, -3.6578e-02,         -5.0377e-02, -1.4724e+00,  1.4315e+00, -1.1902e-01, -2.1044e-01,         -9.7274e-02,  1.4786e+00,  5.8825e-01,  2.4738e-01,  4.7886e-01],        [-5.2584e-01, -5.9981e-02,  9.6410e-02,  1.4674e-01, -2.5624e+00,         -1.2189e+00,  3.6519e-01,  1.9240e+00,  2.7167e+00, -8.9335e-01,         -8.4352e-01,  3.2160e-01,  2.1540e+00,  1.9824e+00,  9.2087e-01,          1.2441e-01, -3.8424e-01,  1.0510e+00, -1.6387e+00, -6.6610e-01],        [ 1.9033e-02, -8.3761e-01, -1.7144e+00, -2.1722e-01,  5.7782e-01,         -8.5884e-01,  1.5352e-01, -3.2194e-02,  1.7006e+00,  2.2611e-01,         -6.6798e-01,  4.2757e-01,  1.1844e+00, -8.2032e-01,  8.5881e-01,         -1.6389e+00, -1.1470e-01,  4.3548e-01, -4.9292e-01, -1.4239e+00],        [-1.8718e-03,  5.0300e-01,  9.4769e-01,  1.3772e-01,  1.2630e+00,          4.9913e-01, -1.8855e+00, -3.6696e-01, -2.0715e-01, -1.8160e-01,          2.6803e-01, -1.7591e-01, -1.1231e+00,  2.9996e-01,  3.0419e-01,          3.2485e-01, -7.8852e-01, -1.3825e+00,  1.5446e+00, -1.5957e+00],        [ 1.2224e+00,  5.4267e-02, -2.8773e-01, -7.6571e-01,  1.3390e-01,          6.8962e-01,  1.7844e-01, -3.5639e-01, -4.0127e-02, -9.6210e-01,         -5.4299e-01,  5.6972e-01,  1.4236e+00, -4.4062e-01,  1.2558e+00,          9.4424e-01,  7.9834e-01, -1.9353e+00,  2.2831e-02,  1.1698e+00],        [ 3.0282e-01,  4.6073e-01, -1.0822e+00, -3.9287e-01, -5.2540e-01,         -6.2057e-01, -1.0958e+00, -1.3846e-01,  9.9414e-01,  1.3613e+00,         -1.3443e+00,  4.5995e-01,  7.6624e-01, -1.8855e+00,  4.2138e-01,          8.1800e-02,  1.0457e+00, -1.3314e+00, -1.4370e+00, -2.2902e-02],        [-1.2029e+00, -4.5437e-01,  2.1817e-01,  5.0700e-01,  2.3848e-01,         -1.5998e+00,  3.1236e+00,  3.2451e-01,  1.0552e+00, -1.3499e-01,         -2.4435e+00,  6.1070e-01,  1.7400e+00, -8.0414e-01, -9.5173e-01,         -3.1292e-01,  2.3043e+00, -1.5358e+00, -1.0775e-01, -1.1630e+00],        [-1.1019e+00,  1.6819e+00, -4.5248e-01,  8.8460e-01, -1.1410e-01,         -1.0526e+00, -8.9691e-01,  4.4700e-01,  3.9597e-01, -8.3095e-01,         -2.4551e+00,  1.1435e-01, -2.9407e-01, -1.2293e+00, -2.8295e+00,         -3.0189e-01,  1.6674e-02, -1.5991e+00,  1.5892e-01, -4.5429e-01],        [ 1.5585e+00, -1.6472e-02, -1.7998e-01, -7.0806e-01, -1.9840e+00,         -5.5717e-01,  7.8396e-01,  4.3221e-01,  1.9304e-02, -8.3582e-01,          3.1031e-01, -4.0005e-01,  2.2043e-01,  4.4766e-01,  1.3857e-01,         -1.0083e+00,  5.1706e-02, -1.2183e+00, -1.8305e-01, -8.0962e-01],        [ 1.1933e+00, -1.9682e-01,  3.0758e-01, -9.4026e-01, -1.5966e-01,          1.2627e+00,  9.4436e-01,  2.0236e-01, -1.1885e+00,  6.8988e-01,         -1.0912e+00, -6.8157e-02,  1.9551e+00, -1.6896e+00, -2.6537e-01,         -1.5902e+00,  1.8715e-02, -1.7566e+00, -4.4485e-01, -2.9117e-01],        [-2.2808e+00, -1.3932e+00, -2.1048e-01, -2.3856e+00,  3.1914e-01,         -6.4313e-01, -8.6689e-01, -1.2414e+00, -9.7393e-01, -1.1433e+00,          1.5302e-01,  6.6312e-01, -1.9848e-01, -1.2353e+00,  2.5797e-01,         -6.6730e-01,  2.6706e-01, -2.6511e+00, -1.1872e+00, -1.0793e+00],        [-9.9676e-01,  4.2526e-01,  1.8178e+00, -9.1751e-03,  8.7009e-01,         -3.2026e-01, -1.0095e+00,  3.5825e-01,  8.4667e-01, -2.8318e-02,          4.1016e-01, -1.4537e+00,  3.3764e+00, -1.7832e+00, -1.0972e+00,          3.9235e-01,  4.3836e-01,  1.4538e-01, -1.1909e+00,  9.7822e-01],        [ 1.2616e+00, -1.4657e-01, -2.5914e+00, -7.2625e-01,  1.2653e+00,         -2.3051e+00,  1.6718e-01, -5.7320e-01, -2.1863e-01, -1.9877e+00,         -1.3305e+00, -1.1724e-01,  1.8090e+00, -5.3239e-01,  2.1936e-01,         -2.3490e+00, -1.7993e+00, -2.7736e+00, -2.0880e-01,  1.0949e+00]],       grad_fn=<AddBackward0>), self._backward_hooks=OrderedDict(), self._backward_pre_hooks=OrderedDict(), self._buffers=OrderedDict(), self._forward_hooks=OrderedDict(), self._forward_hooks_always_called=OrderedDict(), self._forward_hooks_with_kwargs=OrderedDict(), self._forward_pre_hooks=OrderedDict(), self._forward_pre_hooks_with_kwargs=OrderedDict(), self._is_full_backward_hook=None, self._load_state_dict_post_hooks=OrderedDict(), self._load_state_dict_pre_hooks=OrderedDict(), self._modules=OrderedDict([('encoder_z2_layers', Sequential(  (0): Sequential(    (0): Conv2d(3, 32, kernel_size=(3, 3), stride=(2, 2), padding=(1, 1))    (1): BatchNorm2d(32, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)    (2): LeakyReLU(negative_slope=0.01)  )  (1): Sequential(    (0): Conv2d(32, 64, kernel_size=(3, 3), stride=(2, 2), padding=(1, 1))    (1): BatchNorm2d(64, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)    (2): LeakyReLU(negative_slope=0.01)  )  (2): Sequential(    (0): Conv2d(64, 128, kernel_size=(3, 3), stride=(2, 2), padding=(1, 1))    (1): BatchNorm2d(128, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)    (2): LeakyReLU(negative_slope=0.01)  )  (3): Sequential(    (0): Conv2d(128, 256, kernel_size=(3, 3), stride=(2, 2), padding=(1, 1))    (1): BatchNorm2d(256, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)    (2): LeakyReLU(negative_slope=0.01)  )  (4): Sequential(    (0): Conv2d(256, 512, kernel_size=(3, 3), stride=(2, 2), padding=(1, 1))    (1): BatchNorm2d(512, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)    (2): LeakyReLU(negative_slope=0.01)  ))), ('fc_z2_mu', Linear(in_features=2048, out_features=20, bias=True)), ('fc_z2_var', Linear(in_features=2048, out_features=20, bias=True)), ('embed_z2_code', Linear(in_features=20, out_features=4096, bias=True)), ('embed_data', Conv2d(3, 3, kernel_size=(1, 1), stride=(1, 1))), ('encoder_z1_layers', Sequential(  (0): Sequential(    (0): Conv2d(4, 32, kernel_size=(3, 3), stride=(2, 2), padding=(1, 1))    (1): BatchNorm2d(32, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)    (2): LeakyReLU(negative_slope=0.01)  )  (1): Sequential(    (0): Conv2d(32, 64, kernel_size=(3, 3), stride=(2, 2), padding=(1, 1))    (1): BatchNorm2d(64, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)    (2): LeakyReLU(negative_slope=0.01)  )  (2): Sequential(    (0): Conv2d(64, 128, kernel_size=(3, 3), stride=(2, 2), padding=(1, 1))    (1): BatchNorm2d(128, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)    (2): LeakyReLU(negative_slope=0.01)  )  (3): Sequential(    (0): Conv2d(128, 256, kernel_size=(3, 3), stride=(2, 2), padding=(1, 1))    (1): BatchNorm2d(256, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)    (2): LeakyReLU(negative_slope=0.01)  )  (4): Sequential(    (0): Conv2d(256, 512, kernel_size=(3, 3), stride=(2, 2), padding=(1, 1))    (1): BatchNorm2d(512, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)    (2): LeakyReLU(negative_slope=0.01)  ))), ('fc_z1_mu', Linear(in_features=2048, out_features=10, bias=True)), ('fc_z1_var', Linear(in_features=2048, out_features=10, bias=True)), ('recons_z1_mu', Linear(in_features=20, out_features=10, bias=True)), ('recons_z1_log_var', Linear(in_features=20, out_features=10, bias=True)), ('debed_z1_code', Linear(in_features=10, out_features=1024, bias=True)), ('debed_z2_code', Linear(in_features=20, out_features=1024, bias=True)), ('decoder', Sequential(  (0): Sequential(    (0): ConvTranspose2d(512, 256, kernel_size=(3, 3), stride=(2, 2), padding=(1, 1), output_padding=(1, 1))    (1): BatchNorm2d(256, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)    (2): LeakyReLU(negative_slope=0.01)  )  (1): Sequential(    (0): ConvTranspose2d(256, 128, kernel_size=(3, 3), stride=(2, 2), padding=(1, 1), output_padding=(1, 1))    (1): BatchNorm2d(128, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)    (2): LeakyReLU(negative_slope=0.01)  )  (2): Sequential(    (0): ConvTranspose2d(128, 64, kernel_size=(3, 3), stride=(2, 2), padding=(1, 1), output_padding=(1, 1))    (1): BatchNorm2d(64, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)    (2): LeakyReLU(negative_slope=0.01)  )  (3): Sequential(    (0): ConvTranspose2d(64, 32, kernel_size=(3, 3), stride=(2, 2), padding=(1, 1), output_padding=(1, 1))    (1): BatchNorm2d(32, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)    (2): LeakyReLU(negative_slope=0.01)  ))), ('final_layer', Sequential(  (0): ConvTranspose2d(32, 32, kernel_size=(3, 3), stride=(2, 2), padding=(1, 1), output_padding=(1, 1))  (1): BatchNorm2d(32, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)  (2): LeakyReLU(negative_slope=0.01)  (3): Conv2d(32, 3, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))  (4): Tanh()))]), self._non_persistent_buffers_set=set(), self._parameters=OrderedDict(), self._state_dict_hooks=OrderedDict(), self._state_dict_pre_hooks=OrderedDict(), self.img_size=64, self.latent1_dim=10, self.latent2_dim=20, self.training=True)

Input: tensor([[[[-1.8936,  0.4196,  1.2842,  ...,  1.2066,  0.7782,  1.3469],          [-0.8224,  0.4527, -0.0577,  ...,  1.4756,  1.1761, -0.7108],          [-1.6315,  0.8043,  2.6413,  ..., -1.3240,  0.9065, -0.8693],          ...,          [ 0.0383,  1.3328, -0.1353,  ..., -1.1770, -0.1116, -0.3206],          [-1.0151,  0.2528, -0.3343,  ..., -0.0416, -0.9868,  1.1128],          [-1.0028, -1.1892,  0.7485,  ...,  0.7481,  0.0498, -0.0744]],         [[-0.2884, -0.2759,  1.1363,  ...,  1.1605,  0.0775, -1.4702],          [-1.6069, -0.0638, -0.8533,  ...,  0.2473,  1.4863,  0.0158],          [ 2.5342,  0.6854,  1.1528,  ...,  0.6568, -0.5946,  0.1834],          ...,          [ 0.3353,  0.0865, -0.9538,  ..., -1.2018, -1.4665, -0.3575],          [-0.3430, -1.4583, -0.7826,  ...,  2.1256, -0.3949,  0.1570],          [ 0.9678, -1.7589,  0.9122,  ...,  0.4558,  1.4173,  1.6013]],         [[-0.7772,  0.4630,  0.6564,  ..., -1.8964, -2.1647, -0.5534],          [ 0.4105,  0.5011,  1.2573,  ...,  0.3236,  0.9842,  1.0977],          [-0.7429,  1.0571,  0.6543,  ...,  0.3400, -0.2293, -0.5091],          ...,          [ 0.1505, -0.3082,  0.3324,  ...,  0.6619, -0.0814,  0.6934],          [-1.7772, -1.9982,  0.5367,  ...,  0.1102, -0.7138,  0.8455],          [ 0.0332, -0.3734, -1.5362,  ..., -1.2318, -0.4791, -1.6185]]],        [[[ 0.0160,  0.7455,  0.3158,  ..., -0.0860,  0.2626,  1.1479],          [-0.4146,  1.8953,  0.0897,  ..., -0.3885,  1.2116, -1.0973],          [-0.6872, -1.8162,  0.1554,  ..., -1.7179,  1.0908,  0.8081],          ...,          [ 0.1696, -1.8558,  0.1469,  ...,  0.3142,  2.3475,  0.4731],          [ 0.1529, -1.0062,  0.7995,  ...,  0.2377,  0.8177,  0.9386],          [ 0.0217, -0.4921, -0.8103,  ...,  2.6341, -0.5868, -0.0105]],         [[ 1.4296,  0.8156, -0.1442,  ..., -1.5969,  0.2655,  1.3892],          [ 0.0990, -0.1513, -0.2613,  ..., -0.5251, -0.1855, -0.1718],          [ 1.4328,  0.2132, -1.6794,  ...,  0.8488,  1.4868, -1.7160],          ...,          [-0.0693,  0.1337,  1.1090,  ..., -1.3724, -2.5672,  1.0906],          [ 0.2655,  0.3716, -0.1245,  ...,  0.7961, -0.3946,  1.0061],          [-0.8810,  0.1413, -0.6222,  ..., -0.4905, -0.3606, -1.0626]],         [[-0.0948, -0.0486,  0.0157,  ...,  2.1004, -1.5879, -0.2739],          [-0.2656,  1.1246,  1.0048,  ...,  0.4671, -0.1705, -0.7745],          [-0.3759,  0.2029, -1.7732,  ..., -0.2653, -2.3626, -1.0251],          ...,          [ 1.4900, -1.3544,  1.5717,  ..., -1.9406,  0.7142, -0.6601],          [ 0.0120,  0.9058,  0.0421,  ...,  1.5632,  1.1624,  0.1822],          [-0.9256,  0.8344, -0.9597,  ..., -0.4188,  0.2051,  0.6043]]],        [[[-0.6292,  1.5933,  1.1558,  ..., -1.0939,  0.3556, -1.9305],          [ 2.2168,  0.9184, -0.6098,  ...,  0.1250,  0.2496,  0.5268],          [ 0.6035, -0.7713,  0.4179,  ...,  0.1061,  0.2763, -1.1580],          ...,          [ 0.6361, -0.9818,  0.2838,  ..., -0.1032, -0.1063,  0.2971],          [-0.9087, -0.8842,  1.3305,  ...,  0.7932,  1.0652, -0.1426],          [-2.2427, -0.6605,  0.9667,  ..., -0.4021, -1.1495, -0.0572]],         [[-0.1344,  0.6562,  0.4687,  ...,  0.1312,  0.5327,  0.3450],          [ 0.4334,  1.3153,  1.9282,  ...,  0.5667,  1.4108,  0.4699],          [ 0.5254, -0.2920,  1.7819,  ..., -0.5157, -0.3931, -0.8093],          ...,          [-0.5848,  0.6157,  1.1588,  ...,  0.5449, -1.0721,  0.5217],          [ 0.3995,  0.2235,  0.2506,  ..., -0.3272,  0.8440,  0.4930],          [-0.8263, -0.0577, -0.9538,  ..., -1.2877,  1.6349,  1.3202]],         [[ 0.6381, -1.4398, -0.7744,  ...,  1.2140,  0.9096, -0.6753],          [ 0.4048, -2.5466,  1.1450,  ...,  0.5030,  0.4698,  0.5673],          [-0.0358,  0.2170, -0.6245,  ..., -0.4325,  0.5767, -0.2755],          ...,          [ 0.3158, -1.6521,  0.9919,  ...,  2.0221, -1.2303,  0.4039],          [ 0.2354, -0.9477, -0.6534,  ..., -0.5600, -1.3333,  0.5403],          [ 1.1120, -2.0893, -1.3755,  ...,  1.9954,  0.8662, -1.6815]]],        ...,        [[[ 1.2590,  0.1363, -0.6754,  ..., -0.8791,  1.2095, -0.1012],          [ 2.3050, -0.1425, -0.9242,  ..., -0.7649, -0.7488,  0.6949],          [ 0.4214,  0.3215, -2.3866,  ..., -0.5338,  0.4479, -0.8477],          ...,          [ 0.1499, -0.5690,  0.0180,  ...,  1.6823,  0.3056, -0.6216],          [-0.3886,  0.6260, -0.6109,  ...,  0.0346,  0.2253, -0.5103],          [-0.1228,  0.1755,  0.1834,  ..., -2.4334, -0.4735,  0.3909]],         [[-0.5463,  0.1758,  0.3594,  ..., -1.5349, -0.1570,  0.0686],          [-0.1374,  1.0209, -0.5383,  ..., -0.9182, -0.2435, -0.2757],          [ 0.6611, -0.2038, -1.1446,  ..., -1.4481,  0.6467, -0.6618],          ...,          [-0.2686,  0.0405, -0.1467,  ...,  1.0902,  0.5896, -0.7653],          [-1.9040,  0.0179,  1.1207,  ..., -0.2288, -1.6366,  1.1901],          [ 0.1832,  0.3417,  0.9626,  ...,  0.3803,  0.7350, -0.3099]],         [[-0.9969, -0.5508, -0.4998,  ...,  0.6936,  1.6136,  0.3220],          [-0.0770,  1.3169,  0.1651,  ...,  1.7485,  0.7226, -0.2574],          [ 0.0803, -0.9462,  1.2021,  ..., -0.0972,  0.0682,  0.1344],          ...,          [-1.7403,  1.7113,  3.0679,  ...,  1.0908,  1.0581, -0.5222],          [ 0.4028, -1.0059, -2.1630,  ..., -0.0682,  0.5164,  1.6635],          [ 2.7208, -0.5648, -0.1862,  ..., -1.5719, -0.3802,  0.2935]]],        [[[ 0.8409, -0.7438, -1.0032,  ...,  0.1318, -0.4320,  0.4415],          [ 1.5099, -1.1524,  1.1499,  ..., -1.6440, -0.0798,  0.6606],          [ 1.0045, -0.9537,  1.1316,  ..., -1.3674, -0.9758, -0.0078],          ...,          [ 0.3468,  0.5475, -0.7472,  ...,  1.5581,  0.2254,  0.8593],          [-0.0717,  0.4480,  1.3726,  ...,  0.6523, -1.1766, -0.3996],          [-1.6755, -0.8156,  0.5543,  ..., -1.4320,  0.4414, -0.1122]],         [[ 1.3380, -1.1875,  0.5178,  ...,  0.3197, -0.7422,  0.5158],          [-1.1908,  1.4007,  0.8123,  ..., -1.4919, -1.7273, -0.0800],          [-1.3901, -0.3755,  0.0897,  ...,  1.6764, -1.3049, -0.0079],          ...,          [-0.1568, -1.4188, -0.7429,  ..., -1.6218,  0.6604,  1.6529],          [ 0.6247,  0.6867, -1.0114,  ..., -0.0381,  0.1275, -0.8645],          [-0.0610,  0.5389,  0.3990,  ..., -1.0361, -2.4215, -0.6971]],         [[ 0.7516, -1.9676,  1.4015,  ...,  0.5336,  1.0704,  1.7422],          [-1.6988, -1.2900, -0.6327,  ..., -0.9592,  1.5238,  0.2264],          [ 1.0729,  0.8629, -0.5775,  ..., -0.7702, -0.0271,  0.7063],          ...,          [ 0.4322,  1.7422,  0.5302,  ...,  1.7000,  1.1956,  0.4742],          [ 0.4945,  0.2216, -1.3425,  ..., -0.9851,  0.1730,  1.0625],          [-0.6886, -0.1384, -0.4764,  ...,  0.3615,  0.5811,  0.4600]]],        [[[-0.8843,  0.8162, -0.5182,  ...,  0.3598, -0.5506, -0.5101],          [-0.4878, -1.6419, -0.5060,  ...,  1.8825, -0.1327,  0.3133],          [ 0.4729,  0.4339,  1.0820,  ..., -1.3299, -0.7871, -0.6630],          ...,          [-1.1407,  0.0937,  1.0086,  ...,  0.2854,  0.4308,  1.1841],          [ 0.3772, -0.8250,  1.1873,  ...,  0.1146, -0.7267,  0.4953],          [-0.3229, -1.0868, -0.0125,  ..., -0.6451,  1.2862, -1.9553]],         [[-0.4689, -0.3666, -0.3470,  ..., -0.0699, -1.9161, -0.4589],          [-0.4437,  0.9324, -2.2532,  ...,  0.1354,  1.1196, -0.0070],          [ 1.1838,  0.3169,  1.2460,  ..., -0.9694,  0.3669,  0.7385],          ...,          [-1.7229,  0.6705,  0.0683,  ...,  1.0143,  0.6204, -1.1060],          [ 0.2528, -2.3181, -0.0774,  ..., -0.3610,  0.4452, -0.3837],          [-1.2532, -0.3006,  0.6067,  ..., -0.8430, -0.5149,  0.8442]],         [[-1.8861, -0.4756,  0.9849,  ...,  0.7845, -0.8080, -0.6442],          [-0.7163,  0.8101, -0.1905,  ...,  0.3361,  0.6133, -0.1919],          [-0.7476, -0.5810, -0.1615,  ..., -0.5631,  0.0637, -0.1969],          ...,          [-0.9449, -0.9001,  1.0701,  ...,  0.4150,  0.1768, -0.4086],          [ 0.5126,  1.4135,  1.6389,  ..., -0.6361, -0.3524, -0.2547],          [ 0.0541, -1.5909, -1.5796,  ..., -0.1662, -0.7188, -0.6655]]]])

Input: tensor([[[[-1.8936,  0.4196,  1.2842,  ...,  1.2066,  0.7782,  1.3469],          [-0.8224,  0.4527, -0.0577,  ...,  1.4756,  1.1761, -0.7108],          [-1.6315,  0.8043,  2.6413,  ..., -1.3240,  0.9065, -0.8693],          ...,          [ 0.0383,  1.3328, -0.1353,  ..., -1.1770, -0.1116, -0.3206],          [-1.0151,  0.2528, -0.3343,  ..., -0.0416, -0.9868,  1.1128],          [-1.0028, -1.1892,  0.7485,  ...,  0.7481,  0.0498, -0.0744]],         [[-0.2884, -0.2759,  1.1363,  ...,  1.1605,  0.0775, -1.4702],          [-1.6069, -0.0638, -0.8533,  ...,  0.2473,  1.4863,  0.0158],          [ 2.5342,  0.6854,  1.1528,  ...,  0.6568, -0.5946,  0.1834],          ...,          [ 0.3353,  0.0865, -0.9538,  ..., -1.2018, -1.4665, -0.3575],          [-0.3430, -1.4583, -0.7826,  ...,  2.1256, -0.3949,  0.1570],          [ 0.9678, -1.7589,  0.9122,  ...,  0.4558,  1.4173,  1.6013]],         [[-0.7772,  0.4630,  0.6564,  ..., -1.8964, -2.1647, -0.5534],          [ 0.4105,  0.5011,  1.2573,  ...,  0.3236,  0.9842,  1.0977],          [-0.7429,  1.0571,  0.6543,  ...,  0.3400, -0.2293, -0.5091],          ...,          [ 0.1505, -0.3082,  0.3324,  ...,  0.6619, -0.0814,  0.6934],          [-1.7772, -1.9982,  0.5367,  ...,  0.1102, -0.7138,  0.8455],          [ 0.0332, -0.3734, -1.5362,  ..., -1.2318, -0.4791, -1.6185]]],        [[[ 0.0160,  0.7455,  0.3158,  ..., -0.0860,  0.2626,  1.1479],          [-0.4146,  1.8953,  0.0897,  ..., -0.3885,  1.2116, -1.0973],          [-0.6872, -1.8162,  0.1554,  ..., -1.7179,  1.0908,  0.8081],          ...,          [ 0.1696, -1.8558,  0.1469,  ...,  0.3142,  2.3475,  0.4731],          [ 0.1529, -1.0062,  0.7995,  ...,  0.2377,  0.8177,  0.9386],          [ 0.0217, -0.4921, -0.8103,  ...,  2.6341, -0.5868, -0.0105]],         [[ 1.4296,  0.8156, -0.1442,  ..., -1.5969,  0.2655,  1.3892],          [ 0.0990, -0.1513, -0.2613,  ..., -0.5251, -0.1855, -0.1718],          [ 1.4328,  0.2132, -1.6794,  ...,  0.8488,  1.4868, -1.7160],          ...,          [-0.0693,  0.1337,  1.1090,  ..., -1.3724, -2.5672,  1.0906],          [ 0.2655,  0.3716, -0.1245,  ...,  0.7961, -0.3946,  1.0061],          [-0.8810,  0.1413, -0.6222,  ..., -0.4905, -0.3606, -1.0626]],         [[-0.0948, -0.0486,  0.0157,  ...,  2.1004, -1.5879, -0.2739],          [-0.2656,  1.1246,  1.0048,  ...,  0.4671, -0.1705, -0.7745],          [-0.3759,  0.2029, -1.7732,  ..., -0.2653, -2.3626, -1.0251],          ...,          [ 1.4900, -1.3544,  1.5717,  ..., -1.9406,  0.7142, -0.6601],          [ 0.0120,  0.9058,  0.0421,  ...,  1.5632,  1.1624,  0.1822],          [-0.9256,  0.8344, -0.9597,  ..., -0.4188,  0.2051,  0.6043]]],        [[[-0.6292,  1.5933,  1.1558,  ..., -1.0939,  0.3556, -1.9305],          [ 2.2168,  0.9184, -0.6098,  ...,  0.1250,  0.2496,  0.5268],          [ 0.6035, -0.7713,  0.4179,  ...,  0.1061,  0.2763, -1.1580],          ...,          [ 0.6361, -0.9818,  0.2838,  ..., -0.1032, -0.1063,  0.2971],          [-0.9087, -0.8842,  1.3305,  ...,  0.7932,  1.0652, -0.1426],          [-2.2427, -0.6605,  0.9667,  ..., -0.4021, -1.1495, -0.0572]],         [[-0.1344,  0.6562,  0.4687,  ...,  0.1312,  0.5327,  0.3450],          [ 0.4334,  1.3153,  1.9282,  ...,  0.5667,  1.4108,  0.4699],          [ 0.5254, -0.2920,  1.7819,  ..., -0.5157, -0.3931, -0.8093],          ...,          [-0.5848,  0.6157,  1.1588,  ...,  0.5449, -1.0721,  0.5217],          [ 0.3995,  0.2235,  0.2506,  ..., -0.3272,  0.8440,  0.4930],          [-0.8263, -0.0577, -0.9538,  ..., -1.2877,  1.6349,  1.3202]],         [[ 0.6381, -1.4398, -0.7744,  ...,  1.2140,  0.9096, -0.6753],          [ 0.4048, -2.5466,  1.1450,  ...,  0.5030,  0.4698,  0.5673],          [-0.0358,  0.2170, -0.6245,  ..., -0.4325,  0.5767, -0.2755],          ...,          [ 0.3158, -1.6521,  0.9919,  ...,  2.0221, -1.2303,  0.4039],          [ 0.2354, -0.9477, -0.6534,  ..., -0.5600, -1.3333,  0.5403],          [ 1.1120, -2.0893, -1.3755,  ...,  1.9954,  0.8662, -1.6815]]],        ...,        [[[ 1.2590,  0.1363, -0.6754,  ..., -0.8791,  1.2095, -0.1012],          [ 2.3050, -0.1425, -0.9242,  ..., -0.7649, -0.7488,  0.6949],          [ 0.4214,  0.3215, -2.3866,  ..., -0.5338,  0.4479, -0.8477],          ...,          [ 0.1499, -0.5690,  0.0180,  ...,  1.6823,  0.3056, -0.6216],          [-0.3886,  0.6260, -0.6109,  ...,  0.0346,  0.2253, -0.5103],          [-0.1228,  0.1755,  0.1834,  ..., -2.4334, -0.4735,  0.3909]],         [[-0.5463,  0.1758,  0.3594,  ..., -1.5349, -0.1570,  0.0686],          [-0.1374,  1.0209, -0.5383,  ..., -0.9182, -0.2435, -0.2757],          [ 0.6611, -0.2038, -1.1446,  ..., -1.4481,  0.6467, -0.6618],          ...,          [-0.2686,  0.0405, -0.1467,  ...,  1.0902,  0.5896, -0.7653],          [-1.9040,  0.0179,  1.1207,  ..., -0.2288, -1.6366,  1.1901],          [ 0.1832,  0.3417,  0.9626,  ...,  0.3803,  0.7350, -0.3099]],         [[-0.9969, -0.5508, -0.4998,  ...,  0.6936,  1.6136,  0.3220],          [-0.0770,  1.3169,  0.1651,  ...,  1.7485,  0.7226, -0.2574],          [ 0.0803, -0.9462,  1.2021,  ..., -0.0972,  0.0682,  0.1344],          ...,          [-1.7403,  1.7113,  3.0679,  ...,  1.0908,  1.0581, -0.5222],          [ 0.4028, -1.0059, -2.1630,  ..., -0.0682,  0.5164,  1.6635],          [ 2.7208, -0.5648, -0.1862,  ..., -1.5719, -0.3802,  0.2935]]],        [[[ 0.8409, -0.7438, -1.0032,  ...,  0.1318, -0.4320,  0.4415],          [ 1.5099, -1.1524,  1.1499,  ..., -1.6440, -0.0798,  0.6606],          [ 1.0045, -0.9537,  1.1316,  ..., -1.3674, -0.9758, -0.0078],          ...,          [ 0.3468,  0.5475, -0.7472,  ...,  1.5581,  0.2254,  0.8593],          [-0.0717,  0.4480,  1.3726,  ...,  0.6523, -1.1766, -0.3996],          [-1.6755, -0.8156,  0.5543,  ..., -1.4320,  0.4414, -0.1122]],         [[ 1.3380, -1.1875,  0.5178,  ...,  0.3197, -0.7422,  0.5158],          [-1.1908,  1.4007,  0.8123,  ..., -1.4919, -1.7273, -0.0800],          [-1.3901, -0.3755,  0.0897,  ...,  1.6764, -1.3049, -0.0079],          ...,          [-0.1568, -1.4188, -0.7429,  ..., -1.6218,  0.6604,  1.6529],          [ 0.6247,  0.6867, -1.0114,  ..., -0.0381,  0.1275, -0.8645],          [-0.0610,  0.5389,  0.3990,  ..., -1.0361, -2.4215, -0.6971]],         [[ 0.7516, -1.9676,  1.4015,  ...,  0.5336,  1.0704,  1.7422],          [-1.6988, -1.2900, -0.6327,  ..., -0.9592,  1.5238,  0.2264],          [ 1.0729,  0.8629, -0.5775,  ..., -0.7702, -0.0271,  0.7063],          ...,          [ 0.4322,  1.7422,  0.5302,  ...,  1.7000,  1.1956,  0.4742],          [ 0.4945,  0.2216, -1.3425,  ..., -0.9851,  0.1730,  1.0625],          [-0.6886, -0.1384, -0.4764,  ...,  0.3615,  0.5811,  0.4600]]],        [[[-0.8843,  0.8162, -0.5182,  ...,  0.3598, -0.5506, -0.5101],          [-0.4878, -1.6419, -0.5060,  ...,  1.8825, -0.1327,  0.3133],          [ 0.4729,  0.4339,  1.0820,  ..., -1.3299, -0.7871, -0.6630],          ...,          [-1.1407,  0.0937,  1.0086,  ...,  0.2854,  0.4308,  1.1841],          [ 0.3772, -0.8250,  1.1873,  ...,  0.1146, -0.7267,  0.4953],          [-0.3229, -1.0868, -0.0125,  ..., -0.6451,  1.2862, -1.9553]],         [[-0.4689, -0.3666, -0.3470,  ..., -0.0699, -1.9161, -0.4589],          [-0.4437,  0.9324, -2.2532,  ...,  0.1354,  1.1196, -0.0070],          [ 1.1838,  0.3169,  1.2460,  ..., -0.9694,  0.3669,  0.7385],          ...,          [-1.7229,  0.6705,  0.0683,  ...,  1.0143,  0.6204, -1.1060],          [ 0.2528, -2.3181, -0.0774,  ..., -0.3610,  0.4452, -0.3837],          [-1.2532, -0.3006,  0.6067,  ..., -0.8430, -0.5149,  0.8442]],         [[-1.8861, -0.4756,  0.9849,  ...,  0.7845, -0.8080, -0.6442],          [-0.7163,  0.8101, -0.1905,  ...,  0.3361,  0.6133, -0.1919],          [-0.7476, -0.5810, -0.1615,  ..., -0.5631,  0.0637, -0.1969],          ...,          [-0.9449, -0.9001,  1.0701,  ...,  0.4150,  0.1768, -0.4086],          [ 0.5126,  1.4135,  1.6389,  ..., -0.6361, -0.3524, -0.2547],          [ 0.0541, -1.5909, -1.5796,  ..., -0.1662, -0.7188, -0.6655]]]])


def generate(resource_types=()):
    resource_defs = {}
    definitions = {
        'resources': resource_defs,
        'string_dict': {
            "type": "object",
            "patternProperties": {
                "": {"type": "string"},
            },
        },
        'basic_dict': {
            "type": "object",
            "patternProperties": {
                "": {
                    'oneOf': [
                        {"type": "string"},
                        {"type": "boolean"},
                        {"type": "number"},
                    ],
                }
            },
        },
        'iam-statement': {
            'additionalProperties': False,
            'type': 'object',
            'properties': {
                'Sid': {'type': 'string'},
                'Effect': {'type': 'string', 'enum': ['Allow', 'Deny']},
                'Principal': {'anyOf': [
                    {'type': 'string'},
                    {'type': 'object'}, {'type': 'array'}]},
                'NotPrincipal': {'anyOf': [{'type': 'object'}, {'type': 'array'}]},
                'Action': {'anyOf': [{'type': 'string'}, {'type': 'array'}]},
                'NotAction': {'anyOf': [{'type': 'string'}, {'type': 'array'}]},
                'Resource': {'anyOf': [{'type': 'string'}, {'type': 'array'}]},
                'NotResource': {'anyOf': [{'type': 'string'}, {'type': 'array'}]},
                'Condition': {'type': 'object'}
            },
            'required': ['Sid', 'Effect'],
            'oneOf': [
                {'required': ['Principal', 'Action', 'Resource']},
                {'required': ['NotPrincipal', 'Action', 'Resource']},
                {'required': ['Principal', 'NotAction', 'Resource']},
                {'required': ['NotPrincipal', 'NotAction', 'Resource']},
                {'required': ['Principal', 'Action', 'NotResource']},
                {'required': ['NotPrincipal', 'Action', 'NotResource']},
                {'required': ['Principal', 'NotAction', 'NotResource']},
                {'required': ['NotPrincipal', 'NotAction', 'NotResource']}
            ]
        },
        'actions': {},
        'filters': {
            'value': ValueFilter.schema,
            'event': EventFilter.schema,
            'age': AgeFilter.schema,
            'reduce': ReduceFilter.schema,
            # Shortcut form of value filter as k=v
            'valuekv': {
                'type': 'object',
                'additionalProperties': {'oneOf': [{'type': 'number'}, {'type': 'null'},
                    {'type': 'array', 'maxItems': 0}, {'type': 'string'}, {'type': 'boolean'}]},
                'minProperties': 1,
                'maxProperties': 1},
        },
        'filters_common': {
            'list_item_attrs': _get_attr_schema(),
            'comparison_operators': {
                'enum': list(OPERATORS.keys())},
            'value_types': {'enum': VALUE_TYPES},
            'value_from': ValuesFrom.schema,
            'value': {'oneOf': [
                {'type': 'array'},
                {'type': 'string'},
                {'type': 'boolean'},
                {'type': 'number'},
                {'type': 'null'}]},
        },
        'policy': {
            'type': 'object',
            'required': ['name', 'resource'],
            'additionalProperties': False,
            'properties': {
                'name': {
                    'type': 'string',
                    'pattern': "^[A-z][A-z0-9]*(-[A-z0-9]+)*$"},
                'conditions': {
                    'type': 'array',
                    'items': {'anyOf': [
                        {'type': 'object', 'additionalProperties': False,
                         'properties': {'or': {
                             '$ref': '#/definitions/policy/properties/conditions'}}},
                        {'type': 'object', 'additionalProperties': False,
                         'properties': {'not': {
                             '$ref': '#/definitions/policy/properties/conditions'}}},
                        {'type': 'object', 'additionalProperties': False,
                         'properties': {'and': {
                             '$ref': '#/definitions/policy/properties/conditions'}}},
                        {'$ref': '#/definitions/filters/value'},
                        {'$ref': '#/definitions/filters/event'},
                        {'$ref': '#/definitions/filters/valuekv'}]}},
                # these should be deprecated for conditions
                'region': {'type': 'string'},
                'tz': {'type': 'string'},
                'start': {'format': 'date-time'},
                'end': {'format': 'date-time'},
                'resource': {'oneOf': [
                    {'type': 'string'},
                    {'type': 'array', 'items': {'type': 'string'}}]},
                'max-resources': {'anyOf': [
                    {'type': 'integer', 'minimum': 1},
                    {'$ref': '#/definitions/max-resources-properties'}
                ]},
                'max-resources-percent': {'type': 'number', 'minimum': 0, 'maximum': 100},
                'comment': {'type': 'string'},
                'comments': {'type': 'string'},
                'description': {'type': 'string'},
                'tags': {'type': 'array', 'items': {'type': 'string'}},
                'metadata': {'type': 'object'},
                'mode': {'$ref': '#/definitions/policy-mode'},
                'source': {'enum': list(sources.keys())},
                'actions': {
                    'type': 'array',
                },
                'filters': {
                    'type': 'array'
                },
                #
                # TODO: source queries should really move under
                # source. This was initially used for describe sources
                # to expose server side query mechanisms, however its
                # important to note it also prevents resource cache
                # utilization between policies that have different
                # queries.
                'query': {
                    'type': 'array', 'items': {'type': 'object'}}

            },
        },
        'policy-mode': {
            'anyOf': [e.schema for _, e in execution.items()],
        },
        'max-resources-properties': {
            'type': 'object',
            'additionalProperties': False,
            'properties': {
                'amount': {"type": 'integer', 'minimum': 1},
                'op': {'enum': ['or', 'and']},
                'percent': {'type': 'number', 'minimum': 0, 'maximum': 100}
            }
        }
    }

    resource_refs = []
    for cloud_name, cloud_type in sorted(clouds.items()):
        for type_name, resource_type in sorted(cloud_type.resources.items()):
            r_type_name = "%s.%s" % (cloud_name, type_name)
            if resource_types and r_type_name not in resource_types:
                if not resource_type.type_aliases:
                    continue
                elif not {"%s.%s" % (cloud_name, ralias) for ralias
                        in resource_type.type_aliases}.intersection(
                        resource_types):
                    continue

            aliases = []
            if resource_type.type_aliases:
                aliases.extend(["%s.%s" % (cloud_name, a) for a in resource_type.type_aliases])
                # aws gets legacy aliases with no cloud prefix
                if cloud_name == 'aws':
                    aliases.extend(resource_type.type_aliases)

            # aws gets additional alias for default name
            if cloud_name == 'aws':
                aliases.append(type_name)

            resource_refs.append(
                process_resource(
                    r_type_name,
                    resource_type,
                    resource_defs,
                    aliases,
                    definitions,
                    cloud_name
                ))

    schema = {
        "$schema": "http://json-schema.org/draft-07/schema#",
        'id': 'http://schema.cloudcustodian.io/v0/custodian.json',
        'definitions': definitions,
        'type': 'object',
        'required': ['policies'],
        'additionalProperties': False,
        'properties': {
            'vars': {'type': 'object'},
            'policies': {
                'type': 'array',
                'additionalItems': False,
                'items': {'anyOf': resource_refs}
            }
        }
    }

    # allow empty policies with lazy load
    if not resource_refs:
        schema['properties']['policies']['items'] = {'type': 'object'}
    return schema

generate(resource_types=())

{'resources': {}, 'string_dict': {'type': 'object', 'patternProperties': {'': {'type': 'string'}}}, 'basic_dict': {'type': 'object', 'patternProperties': {'': {'oneOf': [{'type': 'string'}, {'type': 'boolean'}, {'type': 'number'}]}}}, 'iam-statement': {'additionalProperties': False, 'type': 'object', 'properties': {'Sid': {'type': 'string'}, 'Effect': {'type': 'string', 'enum': ['Allow', 'Deny']}, 'Principal': {'anyOf': [{'type': 'string'}, {'type': 'object'}, {'type': 'array'}]}, 'NotPrincipal': {'anyOf': [{'type': 'object'}, {'type': 'array'}]}, 'Action': {'anyOf': [{'type': 'string'}, {'type': 'array'}]}, 'NotAction': {'anyOf': [{'type': 'string'}, {'type': 'array'}]}, 'Resource': {'anyOf': [{'type': 'string'}, {'type': 'array'}]}, 'NotResource': {'anyOf': [{'type': 'string'}, {'type': 'array'}]}, 'Condition': {'type': 'object'}}, 'required': ['Sid', 'Effect'], 'oneOf': [{'required': ['Principal', 'Action', 'Resource']}, {'required': ['NotPrincipal', 'Action', 'Resource']}, {'required': ['Principal', 'NotAction', 'Resource']}, {'required': ['NotPrincipal', 'NotAction', 'Resource']}, {'required': ['Principal', 'Action', 'NotResource']}, {'required': ['NotPrincipal', 'Action', 'NotResource']}, {'required': ['Principal', 'NotAction', 'NotResource']}, {'required': ['NotPrincipal', 'NotAction', 'NotResource']}]}, 'actions': {}, 'filters': {'value': {'type': 'object', 'additionalProperties': False, 'required': ['type'], 'properties': {'type': {'enum': ['value']}, 'key': {'type': 'string'}, 'value_type': {'$ref': '#/definitions/filters_common/value_types'}, 'default': {'type': 'object'}, 'value_regex': {'type': 'string'}, 'value_from': {'$ref': '#/definitions/filters_common/value_from'}, 'value': {'$ref': '#/definitions/filters_common/value'}, 'op': {'$ref': '#/definitions/filters_common/comparison_operators'}, 'value_path': {'type': 'string'}}}, 'event': {'type': 'object', 'additionalProperties': False, 'required': ['type'], 'properties': {'type': {'enum': ['event']}, 'key': {'type': 'string'}, 'value_type': {'$ref': '#/definitions/filters_common/value_types'}, 'default': {'type': 'object'}, 'value_regex': {'type': 'string'}, 'value_from': {'$ref': '#/definitions/filters_common/value_from'}, 'value': {'$ref': '#/definitions/filters_common/value'}, 'op': {'$ref': '#/definitions/filters_common/comparison_operators'}, 'value_path': {'type': 'string'}}}, 'age': None, 'reduce': {'type': 'object', 'additionalProperties': False, 'required': ['type'], 'properties': {'type': {'enum': ['reduce']}, 'group-by': {'oneOf': [{'type': 'string'}, {'type': 'object', 'key': {'type': 'string'}, 'value_type': {'enum': ['string', 'number', 'date']}, 'value_regex': 'string'}]}, 'sort-by': {'oneOf': [{'type': 'string'}, {'type': 'object', 'key': {'type': 'string'}, 'value_type': {'enum': ['string', 'number', 'date']}, 'value_regex': 'string'}]}, 'order': {'enum': ['asc', 'desc', 'reverse', 'randomize']}, 'null-order': {'enum': ['first', 'last']}, 'limit': {'type': 'number', 'minimum': 0}, 'limit-percent': {'type': 'number', 'minimum': 0, 'maximum': 100}, 'discard': {'type': 'number', 'minimum': 0}, 'discard-percent': {'type': 'number', 'minimum': 0, 'maximum': 100}}}, 'valuekv': {'type': 'object', 'additionalProperties': {'oneOf': [{'type': 'number'}, {'type': 'null'}, {'type': 'array', 'maxItems': 0}, {'type': 'string'}, {'type': 'boolean'}]}, 'minProperties': 1, 'maxProperties': 1}}, 'filters_common': {'list_item_attrs': {'items': {'anyOf': [{'$ref': '#/definitions/filters/value'}, {'$ref': '#/definitions/filters/valuekv'}, {'additional_properties': False, 'properties': {'and': {'type': 'array', 'items': {'anyOf': [{'$ref': '#/definitions/filters/value'}, {'$ref': '#/definitions/filters/valuekv'}]}}}, 'type': 'object'}, {'additional_properties': False, 'properties': {'or': {'type': 'array', 'items': {'anyOf': [{'$ref': '#/definitions/filters/value'}, {'$ref': '#/definitions/filters/valuekv'}]}}}, 'type': 'object'}, {'additional_properties': False, 'properties': {'not': {'type': 'array', 'items': {'anyOf': [{'$ref': '#/definitions/filters/value...onalProperties': False, 'properties': {'execution-options': {'type': 'object'}, 'function-prefix': {'type': 'string'}, 'member-role': {'type': 'string'}, 'packages': {'type': 'array', 'items': {'type': 'string'}}, 'layers': {'type': 'array', 'items': {'type': 'string'}}, 'concurrency': {'type': 'integer'}, 'runtime': {'enum': ['python3.8', 'python3.9', 'python3.10', 'python3.11', 'python3.12']}, 'role': {'type': 'string'}, 'handler': {'type': 'string'}, 'pattern': {'type': 'object', 'minProperties': 1}, 'timeout': {'type': 'number'}, 'memory': {'type': 'number'}, 'environment': {'type': 'object'}, 'tags': {'type': 'object'}, 'dead_letter_config': {'type': 'object'}, 'kms_key_arn': {'type': 'string'}, 'tracing_config': {'type': 'object'}, 'security_groups': {'type': 'array'}, 'subnets': {'type': 'array'}, 'type': {'enum': ['asg-instance-state']}, 'events': {'type': 'array', 'items': {'enum': ['launch-success', 'launch-failure', 'terminate-success', 'terminate-failure']}}}, 'required': ['type']}, {'type': 'object', 'additionalProperties': False, 'properties': {'execution-options': {'type': 'object'}, 'function-prefix': {'type': 'string'}, 'member-role': {'type': 'string'}, 'packages': {'type': 'array', 'items': {'type': 'string'}}, 'layers': {'type': 'array', 'items': {'type': 'string'}}, 'concurrency': {'type': 'integer'}, 'runtime': {'enum': ['python3.8', 'python3.9', 'python3.10', 'python3.11', 'python3.12']}, 'role': {'type': 'string'}, 'handler': {'type': 'string'}, 'pattern': {'type': 'object', 'minProperties': 1}, 'timeout': {'type': 'number'}, 'memory': {'type': 'number'}, 'environment': {'type': 'object'}, 'tags': {'type': 'object'}, 'dead_letter_config': {'type': 'object'}, 'kms_key_arn': {'type': 'string'}, 'tracing_config': {'type': 'object'}, 'security_groups': {'type': 'array'}, 'subnets': {'type': 'array'}, 'type': {'enum': ['guard-duty']}}, 'required': ['type']}, {'type': 'object', 'additionalProperties': False, 'properties': {'execution-options': {'type': 'object'}, 'function-prefix': {'type': 'string'}, 'member-role': {'type': 'string'}, 'packages': {'type': 'array', 'items': {'type': 'string'}}, 'layers': {'type': 'array', 'items': {'type': 'string'}}, 'concurrency': {'type': 'integer'}, 'runtime': {'enum': ['python3.8', 'python3.9', 'python3.10', 'python3.11', 'python3.12']}, 'role': {'type': 'string'}, 'handler': {'type': 'string'}, 'pattern': {'type': 'object', 'minProperties': 1}, 'timeout': {'type': 'number'}, 'memory': {'type': 'number'}, 'environment': {'type': 'object'}, 'tags': {'type': 'object'}, 'dead_letter_config': {'type': 'object'}, 'kms_key_arn': {'type': 'string'}, 'tracing_config': {'type': 'object'}, 'security_groups': {'type': 'array'}, 'subnets': {'type': 'array'}, 'type': {'enum': ['config-poll-rule']}, 'schedule': {'enum': ['One_Hour', 'Three_Hours', 'Six_Hours', 'Twelve_Hours', 'TwentyFour_Hours']}, 'ignore-support-check': {'type': 'boolean'}}, 'required': ['type']}, {'type': 'object', 'additionalProperties': False, 'properties': {'execution-options': {'type': 'object'}, 'function-prefix': {'type': 'string'}, 'member-role': {'type': 'string'}, 'packages': {'type': 'array', 'items': {'type': 'string'}}, 'layers': {'type': 'array', 'items': {'type': 'string'}}, 'concurrency': {'type': 'integer'}, 'runtime': {'enum': ['python3.8', 'python3.9', 'python3.10', 'python3.11', 'python3.12']}, 'role': {'type': 'string'}, 'handler': {'type': 'string'}, 'pattern': {'type': 'object', 'minProperties': 1}, 'timeout': {'type': 'number'}, 'memory': {'type': 'number'}, 'environment': {'type': 'object'}, 'tags': {'type': 'object'}, 'dead_letter_config': {'type': 'object'}, 'kms_key_arn': {'type': 'string'}, 'tracing_config': {'type': 'object'}, 'security_groups': {'type': 'array'}, 'subnets': {'type': 'array'}, 'type': {'enum': ['config-rule']}}, 'required': ['type']}]}, 'max-resources-properties': {'type': 'object', 'additionalProperties': False, 'properties': {'amount': {'type': 'integer', 'minimum': 1}, 'op': {'enum': ['or', 'and']}, 'percent': {'type': 'number', 'minimum': 0, 'maximum': 100}}}}

{'resources': {'gcp.region': {'actions': {}, 'filters': {}, 'policy': {'allOf': [{'$ref': '#/definitions/policy'}, {'properties': {'resource': {'enum': ['gcp.region']}, 'filters': {'type': 'array', 'items': {'anyOf': [{'enum': []}, {'type': 'object', 'additionalProperties': False, 'properties': {'or': {'$ref': '#/definitions/resources/gcp.region/policy/allOf/1/properties/filters'}}}, {'type': 'object', 'additionalProperties': False, 'properties': {'and': {'$ref': '#/definitions/resources/gcp.region/policy/allOf/1/properties/filters'}}}, {'type': 'object', 'additionalProperties': False, 'properties': {'not': {'$ref': '#/definitions/resources/gcp.region/policy/allOf/1/properties/filters'}}}]}}, 'actions': {'type': 'array', 'items': {'anyOf': [{'enum': []}]}}}}]}}}, 'string_dict': {'type': 'object', 'patternProperties': {'': {'type': 'string'}}}, 'basic_dict': {'type': 'object', 'patternProperties': {'': {'oneOf': [{'type': 'string'}, {'type': 'boolean'}, {'type': 'number'}]}}}, 'iam-statement': {'additionalProperties': False, 'type': 'object', 'properties': {'Sid': {'type': 'string'}, 'Effect': {'type': 'string', 'enum': ['Allow', 'Deny']}, 'Principal': {'anyOf': [{'type': 'string'}, {'type': 'object'}, {'type': 'array'}]}, 'NotPrincipal': {'anyOf': [{'type': 'object'}, {'type': 'array'}]}, 'Action': {'anyOf': [{'type': 'string'}, {'type': 'array'}]}, 'NotAction': {'anyOf': [{'type': 'string'}, {'type': 'array'}]}, 'Resource': {'anyOf': [{'type': 'string'}, {'type': 'array'}]}, 'NotResource': {'anyOf': [{'type': 'string'}, {'type': 'array'}]}, 'Condition': {'type': 'object'}}, 'required': ['Sid', 'Effect'], 'oneOf': [{'required': ['Principal', 'Action', 'Resource']}, {'required': ['NotPrincipal', 'Action', 'Resource']}, {'required': ['Principal', 'NotAction', 'Resource']}, {'required': ['NotPrincipal', 'NotAction', 'Resource']}, {'required': ['Principal', 'Action', 'NotResource']}, {'required': ['NotPrincipal', 'Action', 'NotResource']}, {'required': ['Principal', 'NotAction', 'NotResource']}, {'required': ['NotPrincipal', 'NotAction', 'NotResource']}]}, 'actions': {}, 'filters': {'value': {'type': 'object', 'additionalProperties': False, 'required': ['type'], 'properties': {'type': {'enum': ['value']}, 'key': {'type': 'string'}, 'value_type': {'$ref': '#/definitions/filters_common/value_types'}, 'default': {'type': 'object'}, 'value_regex': {'type': 'string'}, 'value_from': {'$ref': '#/definitions/filters_common/value_from'}, 'value': {'$ref': '#/definitions/filters_common/value'}, 'op': {'$ref': '#/definitions/filters_common/comparison_operators'}, 'value_path': {'type': 'string'}}}, 'event': {'type': 'object', 'additionalProperties': False, 'required': ['type'], 'properties': {'type': {'enum': ['event']}, 'key': {'type': 'string'}, 'value_type': {'$ref': '#/definitions/filters_common/value_types'}, 'default': {'type': 'object'}, 'value_regex': {'type': 'string'}, 'value_from': {'$ref': '#/definitions/filters_common/value_from'}, 'value': {'$ref': '#/definitions/filters_common/value'}, 'op': {'$ref': '#/definitions/filters_common/comparison_operators'}, 'value_path': {'type': 'string'}}}, 'age': None, 'reduce': {'type': 'object', 'additionalProperties': False, 'required': ['type'], 'properties': {'type': {'enum': ['reduce']}, 'group-by': {'oneOf': [{'type': 'string'}, {'type': 'object', 'key': {'type': 'string'}, 'value_type': {'enum': ['string', 'number', 'date']}, 'value_regex': 'string'}]}, 'sort-by': {'oneOf': [{'type': 'string'}, {'type': 'object', 'key': {'type': 'string'}, 'value_type': {'enum': ['string', 'number', 'date']}, 'value_regex': 'string'}]}, 'order': {'enum': ['asc', 'desc', 'reverse', 'randomize']}, 'null-order': {'enum': ['first', 'last']}, 'limit': {'type': 'number', 'minimum': 0}, 'limit-percent': {'type': 'number', 'minimum': 0, 'maximum': 100}, 'discard': {'type': 'number', 'minimum': 0}, 'discard-percent': {'type': 'number', 'minimum': 0, 'maximum': 100}}}, 'valuekv': {'type': 'object', 'additionalProperties': {'oneOf': [{'type': 'number'}, {'type': 'null'}, {'type': 'array', 'maxItems': 0}, {...onalProperties': False, 'properties': {'execution-options': {'type': 'object'}, 'function-prefix': {'type': 'string'}, 'member-role': {'type': 'string'}, 'packages': {'type': 'array', 'items': {'type': 'string'}}, 'layers': {'type': 'array', 'items': {'type': 'string'}}, 'concurrency': {'type': 'integer'}, 'runtime': {'enum': ['python3.8', 'python3.9', 'python3.10', 'python3.11', 'python3.12']}, 'role': {'type': 'string'}, 'handler': {'type': 'string'}, 'pattern': {'type': 'object', 'minProperties': 1}, 'timeout': {'type': 'number'}, 'memory': {'type': 'number'}, 'environment': {'type': 'object'}, 'tags': {'type': 'object'}, 'dead_letter_config': {'type': 'object'}, 'kms_key_arn': {'type': 'string'}, 'tracing_config': {'type': 'object'}, 'security_groups': {'type': 'array'}, 'subnets': {'type': 'array'}, 'type': {'enum': ['asg-instance-state']}, 'events': {'type': 'array', 'items': {'enum': ['launch-success', 'launch-failure', 'terminate-success', 'terminate-failure']}}}, 'required': ['type']}, {'type': 'object', 'additionalProperties': False, 'properties': {'execution-options': {'type': 'object'}, 'function-prefix': {'type': 'string'}, 'member-role': {'type': 'string'}, 'packages': {'type': 'array', 'items': {'type': 'string'}}, 'layers': {'type': 'array', 'items': {'type': 'string'}}, 'concurrency': {'type': 'integer'}, 'runtime': {'enum': ['python3.8', 'python3.9', 'python3.10', 'python3.11', 'python3.12']}, 'role': {'type': 'string'}, 'handler': {'type': 'string'}, 'pattern': {'type': 'object', 'minProperties': 1}, 'timeout': {'type': 'number'}, 'memory': {'type': 'number'}, 'environment': {'type': 'object'}, 'tags': {'type': 'object'}, 'dead_letter_config': {'type': 'object'}, 'kms_key_arn': {'type': 'string'}, 'tracing_config': {'type': 'object'}, 'security_groups': {'type': 'array'}, 'subnets': {'type': 'array'}, 'type': {'enum': ['guard-duty']}}, 'required': ['type']}, {'type': 'object', 'additionalProperties': False, 'properties': {'execution-options': {'type': 'object'}, 'function-prefix': {'type': 'string'}, 'member-role': {'type': 'string'}, 'packages': {'type': 'array', 'items': {'type': 'string'}}, 'layers': {'type': 'array', 'items': {'type': 'string'}}, 'concurrency': {'type': 'integer'}, 'runtime': {'enum': ['python3.8', 'python3.9', 'python3.10', 'python3.11', 'python3.12']}, 'role': {'type': 'string'}, 'handler': {'type': 'string'}, 'pattern': {'type': 'object', 'minProperties': 1}, 'timeout': {'type': 'number'}, 'memory': {'type': 'number'}, 'environment': {'type': 'object'}, 'tags': {'type': 'object'}, 'dead_letter_config': {'type': 'object'}, 'kms_key_arn': {'type': 'string'}, 'tracing_config': {'type': 'object'}, 'security_groups': {'type': 'array'}, 'subnets': {'type': 'array'}, 'type': {'enum': ['config-poll-rule']}, 'schedule': {'enum': ['One_Hour', 'Three_Hours', 'Six_Hours', 'Twelve_Hours', 'TwentyFour_Hours']}, 'ignore-support-check': {'type': 'boolean'}}, 'required': ['type']}, {'type': 'object', 'additionalProperties': False, 'properties': {'execution-options': {'type': 'object'}, 'function-prefix': {'type': 'string'}, 'member-role': {'type': 'string'}, 'packages': {'type': 'array', 'items': {'type': 'string'}}, 'layers': {'type': 'array', 'items': {'type': 'string'}}, 'concurrency': {'type': 'integer'}, 'runtime': {'enum': ['python3.8', 'python3.9', 'python3.10', 'python3.11', 'python3.12']}, 'role': {'type': 'string'}, 'handler': {'type': 'string'}, 'pattern': {'type': 'object', 'minProperties': 1}, 'timeout': {'type': 'number'}, 'memory': {'type': 'number'}, 'environment': {'type': 'object'}, 'tags': {'type': 'object'}, 'dead_letter_config': {'type': 'object'}, 'kms_key_arn': {'type': 'string'}, 'tracing_config': {'type': 'object'}, 'security_groups': {'type': 'array'}, 'subnets': {'type': 'array'}, 'type': {'enum': ['config-rule']}}, 'required': ['type']}]}, 'max-resources-properties': {'type': 'object', 'additionalProperties': False, 'properties': {'amount': {'type': 'integer', 'minimum': 1}, 'op': {'enum': ['or', 'and']}, 'percent': {'type': 'number', 'minimum': 0, 'maximum': 100}}}}

{'$schema': 'http://json-schema.org/draft-07/schema#', 'id': 'http://schema.cloudcustodian.io/v0/custodian.json', 'definitions': {'resources': {'gcp.region': {'actions': {}, 'filters': {}, 'policy': {'allOf': [{'$ref': '#/definitions/policy'}, {'properties': {'resource': {'enum': ['gcp.region']}, 'filters': {'type': 'array', 'items': {'anyOf': [{'enum': []}, {'type': 'object', 'additionalProperties': False, 'properties': {'or': {'$ref': '#/definitions/resources/gcp.region/policy/allOf/1/properties/filters'}}}, {'type': 'object', 'additionalProperties': False, 'properties': {'and': {'$ref': '#/definitions/resources/gcp.region/policy/allOf/1/properties/filters'}}}, {'type': 'object', 'additionalProperties': False, 'properties': {'not': {'$ref': '#/definitions/resources/gcp.region/policy/allOf/1/properties/filters'}}}]}}, 'actions': {'type': 'array', 'items': {'anyOf': [{'enum': []}]}}}}]}}}, 'string_dict': {'type': 'object', 'patternProperties': {'': {'type': 'string'}}}, 'basic_dict': {'type': 'object', 'patternProperties': {'': {'oneOf': [{'type': 'string'}, {'type': 'boolean'}, {'type': 'number'}]}}}, 'iam-statement': {'additionalProperties': False, 'type': 'object', 'properties': {'Sid': {'type': 'string'}, 'Effect': {'type': 'string', 'enum': ['Allow', 'Deny']}, 'Principal': {'anyOf': [{'type': 'string'}, {'type': 'object'}, {'type': 'array'}]}, 'NotPrincipal': {'anyOf': [{'type': 'object'}, {'type': 'array'}]}, 'Action': {'anyOf': [{'type': 'string'}, {'type': 'array'}]}, 'NotAction': {'anyOf': [{'type': 'string'}, {'type': 'array'}]}, 'Resource': {'anyOf': [{'type': 'string'}, {'type': 'array'}]}, 'NotResource': {'anyOf': [{'type': 'string'}, {'type': 'array'}]}, 'Condition': {'type': 'object'}}, 'required': ['Sid', 'Effect'], 'oneOf': [{'required': ['Principal', 'Action', 'Resource']}, {'required': ['NotPrincipal', 'Action', 'Resource']}, {'required': ['Principal', 'NotAction', 'Resource']}, {'required': ['NotPrincipal', 'NotAction', 'Resource']}, {'required': ['Principal', 'Action', 'NotResource']}, {'required': ['NotPrincipal', 'Action', 'NotResource']}, {'required': ['Principal', 'NotAction', 'NotResource']}, {'required': ['NotPrincipal', 'NotAction', 'NotResource']}]}, 'actions': {}, 'filters': {'value': {'type': 'object', 'additionalProperties': False, 'required': ['type'], 'properties': {'type': {'enum': ['value']}, 'key': {'type': 'string'}, 'value_type': {'$ref': '#/definitions/filters_common/value_types'}, 'default': {'type': 'object'}, 'value_regex': {'type': 'string'}, 'value_from': {'$ref': '#/definitions/filters_common/value_from'}, 'value': {'$ref': '#/definitions/filters_common/value'}, 'op': {'$ref': '#/definitions/filters_common/comparison_operators'}, 'value_path': {'type': 'string'}}}, 'event': {'type': 'object', 'additionalProperties': False, 'required': ['type'], 'properties': {'type': {'enum': ['event']}, 'key': {'type': 'string'}, 'value_type': {'$ref': '#/definitions/filters_common/value_types'}, 'default': {'type': 'object'}, 'value_regex': {'type': 'string'}, 'value_from': {'$ref': '#/definitions/filters_common/value_from'}, 'value': {'$ref': '#/definitions/filters_common/value'}, 'op': {'$ref': '#/definitions/filters_common/comparison_operators'}, 'value_path': {'type': 'string'}}}, 'age': None, 'reduce': {'type': 'object', 'additionalProperties': False, 'required': ['type'], 'properties': {'type': {'enum': ['reduce']}, 'group-by': {'oneOf': [{'type': 'string'}, {'type': 'object', 'key': {'type': 'string'}, 'value_type': {'enum': ['string', 'number', 'date']}, 'value_regex': 'string'}]}, 'sort-by': {'oneOf': [{'type': 'string'}, {'type': 'object', 'key': {'type': 'string'}, 'value_type': {'enum': ['string', 'number', 'date']}, 'value_regex': 'string'}]}, 'order': {'enum': ['asc', 'desc', 'reverse', 'randomize']}, 'null-order': {'enum': ['first', 'last']}, 'limit': {'type': 'number', 'minimum': 0}, 'limit-percent': {'type': 'number', 'minimum': 0, 'maximum': 100}, 'discard': {'type': 'number', 'minimum': 0}, 'discard-percent': {'type': 'number', 'minimum': 0, 'maximum': 100}}}, 'valuekv'...ype': 'string'}}, 'concurrency': {'type': 'integer'}, 'runtime': {'enum': ['python3.8', 'python3.9', 'python3.10', 'python3.11', 'python3.12']}, 'role': {'type': 'string'}, 'handler': {'type': 'string'}, 'pattern': {'type': 'object', 'minProperties': 1}, 'timeout': {'type': 'number'}, 'memory': {'type': 'number'}, 'environment': {'type': 'object'}, 'tags': {'type': 'object'}, 'dead_letter_config': {'type': 'object'}, 'kms_key_arn': {'type': 'string'}, 'tracing_config': {'type': 'object'}, 'security_groups': {'type': 'array'}, 'subnets': {'type': 'array'}, 'type': {'enum': ['asg-instance-state']}, 'events': {'type': 'array', 'items': {'enum': ['launch-success', 'launch-failure', 'terminate-success', 'terminate-failure']}}}, 'required': ['type']}, {'type': 'object', 'additionalProperties': False, 'properties': {'execution-options': {'type': 'object'}, 'function-prefix': {'type': 'string'}, 'member-role': {'type': 'string'}, 'packages': {'type': 'array', 'items': {'type': 'string'}}, 'layers': {'type': 'array', 'items': {'type': 'string'}}, 'concurrency': {'type': 'integer'}, 'runtime': {'enum': ['python3.8', 'python3.9', 'python3.10', 'python3.11', 'python3.12']}, 'role': {'type': 'string'}, 'handler': {'type': 'string'}, 'pattern': {'type': 'object', 'minProperties': 1}, 'timeout': {'type': 'number'}, 'memory': {'type': 'number'}, 'environment': {'type': 'object'}, 'tags': {'type': 'object'}, 'dead_letter_config': {'type': 'object'}, 'kms_key_arn': {'type': 'string'}, 'tracing_config': {'type': 'object'}, 'security_groups': {'type': 'array'}, 'subnets': {'type': 'array'}, 'type': {'enum': ['guard-duty']}}, 'required': ['type']}, {'type': 'object', 'additionalProperties': False, 'properties': {'execution-options': {'type': 'object'}, 'function-prefix': {'type': 'string'}, 'member-role': {'type': 'string'}, 'packages': {'type': 'array', 'items': {'type': 'string'}}, 'layers': {'type': 'array', 'items': {'type': 'string'}}, 'concurrency': {'type': 'integer'}, 'runtime': {'enum': ['python3.8', 'python3.9', 'python3.10', 'python3.11', 'python3.12']}, 'role': {'type': 'string'}, 'handler': {'type': 'string'}, 'pattern': {'type': 'object', 'minProperties': 1}, 'timeout': {'type': 'number'}, 'memory': {'type': 'number'}, 'environment': {'type': 'object'}, 'tags': {'type': 'object'}, 'dead_letter_config': {'type': 'object'}, 'kms_key_arn': {'type': 'string'}, 'tracing_config': {'type': 'object'}, 'security_groups': {'type': 'array'}, 'subnets': {'type': 'array'}, 'type': {'enum': ['config-poll-rule']}, 'schedule': {'enum': ['One_Hour', 'Three_Hours', 'Six_Hours', 'Twelve_Hours', 'TwentyFour_Hours']}, 'ignore-support-check': {'type': 'boolean'}}, 'required': ['type']}, {'type': 'object', 'additionalProperties': False, 'properties': {'execution-options': {'type': 'object'}, 'function-prefix': {'type': 'string'}, 'member-role': {'type': 'string'}, 'packages': {'type': 'array', 'items': {'type': 'string'}}, 'layers': {'type': 'array', 'items': {'type': 'string'}}, 'concurrency': {'type': 'integer'}, 'runtime': {'enum': ['python3.8', 'python3.9', 'python3.10', 'python3.11', 'python3.12']}, 'role': {'type': 'string'}, 'handler': {'type': 'string'}, 'pattern': {'type': 'object', 'minProperties': 1}, 'timeout': {'type': 'number'}, 'memory': {'type': 'number'}, 'environment': {'type': 'object'}, 'tags': {'type': 'object'}, 'dead_letter_config': {'type': 'object'}, 'kms_key_arn': {'type': 'string'}, 'tracing_config': {'type': 'object'}, 'security_groups': {'type': 'array'}, 'subnets': {'type': 'array'}, 'type': {'enum': ['config-rule']}}, 'required': ['type']}]}, 'max-resources-properties': {'type': 'object', 'additionalProperties': False, 'properties': {'amount': {'type': 'integer', 'minimum': 1}, 'op': {'enum': ['or', 'and']}, 'percent': {'type': 'number', 'minimum': 0, 'maximum': 100}}}}, 'type': 'object', 'required': ['policies'], 'additionalProperties': False, 'properties': {'vars': {'type': 'object'}, 'policies': {'type': 'array', 'additionalItems': False, 'items': {'anyOf': [{'$ref': '#/definitions/resources/gcp.region/policy'}]}}}}


def _readCharVec(fp: BinaryIO, itemsize:int=None, dtype=None, size:tuple=None, use_unicode=is_unicode):
        """

        :param fp:
        :param itemsize:
        :param dtype:
        :param size:
        :param is_unicode:
        :return:
        """

        array = np.chararray(size, itemsize=itemsize, unicode=use_unicode)
        Clen = array.itemsize

        if "<U" in str(dtype):
            Clen = Clen // 4

        MaxEntry = size[0]
        NRec = 100
        ndata = 0
        dataFormStart = '=4siii'

        while NRec > 1:
            nbyte = HarFileIO._getEntrySize(fp)

            V = HarFileIO._unpack_data(fp, dataFormStart)

            if fb(V[0]) != '    ':
                raise IOError("Encountered characters at first four positions")

            NRec = V[1]
            if V[2] != MaxEntry:
                raise ValueError("Different Size than specified")

            if ndata + V[3] > MaxEntry:
                raise RuntimeError("More data on Header than declared")

            AllStr = fb(fp.read(V[3] * Clen))

            if nbyte != HarFileIO._getEntrySize(fp):
                raise IOError("I/O Error: sizes on 1C header do not match record length")

            for j, i in enumerate(range(0, V[3] * Clen, Clen)):
                array[ndata + j] = AllStr[i:i + Clen]
            ndata += V[3]

        return np.ascontiguousarray(array)

_readCharVec(fp=<_io.BufferedReader name='/local/rcs/XXX/code/pytrace-collector/logs/pypibugs/tried/GEMPACKsoftware+HARPY/GEMPACKsoftware+HARPY/test_remove_header_array.har'>, itemsize=70, dtype='<U12', size=(1,), use_unicode=True)


def _write7DFullArray(fp, array, dtype):
        StEndList = []
        for i, j in HarFileIO._slice_inds(array, 7996):
            StEndList.append([i[:], j[:]])
        nrec = len(StEndList) * 2 + 1
        dataForm = '=i4sii7ii'
        nbyte = struct.calcsize(dataForm) - 8
        writeList = [nbyte, tb('    '), nrec, 7]
        writeList.extend([array.shape[i] if i < array.ndim else 1 for i in range(0, 7)])
        writeList.append(nbyte)

        fp.write(struct.pack(dataForm, *writeList))

        array1=array.flatten('F')
        nWritten=0
        for StEnd in StEndList:
            nrec = nrec - 1
            st = StEnd[0]
            end = StEnd[1]

            PosList = [[st[i] + 1, end[i]][ind] if i < array.ndim else [1, 1][ind] for i in range(0, 7) for ind in
                       range(0, 2)]
            dataForm = '=i4s16i'
            nbyte = struct.calcsize(dataForm) - 8
            writeList = [nbyte, tb('    '), nrec]
            writeList.extend(PosList)
            writeList.append(nbyte)
            fp.write(struct.pack(dataForm, *writeList))

            nrec = nrec - 1
            ndata = 1
            for i, j in zip(st, end): ndata *= (j - i)
            if dtype == 'f' or dtype == 'i': nbyte = ndata * 4 + 8

            dataForm = '=i4si'
            fp.write(struct.pack(dataForm, nbyte, tb('    '), nrec))
            dataForm = '=' + str(ndata) + dtype
            fp.write(struct.pack(dataForm, *array1[nWritten:nWritten+ndata].flatten('F')))
            nWritten+=ndata
            dataForm = '=i'
            fp.write(struct.pack(dataForm, nbyte))

_write7DFullArray(fp=<_io.BufferedWriter name='test_overwrite_header.har'>, array=array([[1.  , 3.14],       [3.14, 5.  ]], dtype=float32), dtype='f')


def _add_committer_to_committers(all_committers: List[str], initials: str, name: str, email: str):
    committer_formatted = f'{initials},{name},{email}\n'
    committer_position = _position_of_committer_with_initials(all_committers, initials)
    if committer_position is _COMMITTER_NOT_PRESENT:
        all_committers.append(committer_formatted)
    else:
        all_committers[committer_position] = committer_formatted

_add_committer_to_committers(all_committers=[], initials='initials3', name='name3', email='email3')


def return_logger(name: str) -> logging.Logger:
    # Set log message format

    logger = logging.getLogger(name)

    if not len(logger.handlers):
        log_formatter = logging.Formatter('%(asctime)-s: %(levelname)-s %(message)s')
        # set logging level
        logger.setLevel(logging.DEBUG)

        # Direct logs to stderr
        console_handler = logging.StreamHandler()
        console_handler.setFormatter(log_formatter)
        logger.addHandler(console_handler)

    return logger

return_logger(name='imagededup.handlers.metrics.classification')

{_style=<logging.PercentStyle object at 0x7fcf18561f10>, _fmt='%(asctime)-s: %(levelname)-s %(message)s', datefmt=None}


def get_mylogin_cnf_path():
    """Return the path to the login path file or None if it doesn't exist."""
    mylogin_cnf_path = os.getenv('MYSQL_TEST_LOGIN_FILE')

    if mylogin_cnf_path is None:
        app_data = os.getenv('APPDATA')
        default_dir = os.path.join(app_data, 'MySQL') if app_data else '~'
        mylogin_cnf_path = os.path.join(default_dir, '.mylogin.cnf')

    mylogin_cnf_path = os.path.expanduser(mylogin_cnf_path)

    if exists(mylogin_cnf_path):
        logger.debug("Found login path file at '{0}'".format(mylogin_cnf_path))
        return mylogin_cnf_path
    return None

get_mylogin_cnf_path()


def hmac_digest(secret, message, encoding="utf-8"):
    """Return hex digest of a message HMAC using secret"""
    if isinstance(secret, str):
        secret = secret.encode(encoding)
    return hmac.new(secret, message.encode(encoding), hashlib.sha256).hexdigest()

hmac_digest(secret='secret_hmac_for_userids', message='mat:secret', encoding='utf-8')

'mat:secret'

'mat:secret'


def replace_part_with_missing_leading_whitespace(whole_lines, part_lines, replace_lines):
    # GPT often messes up leading whitespace.
    # It usually does it uniformly across the ORIG and UPD blocks.
    # Either omitting all leading whitespace, or including only some of it.

    # Outdent everything in part_lines and replace_lines by the max fixed amount possible
    leading = [len(p) - len(p.lstrip()) for p in part_lines if p.strip()] + [
        len(p) - len(p.lstrip()) for p in replace_lines if p.strip()
    ]

    if leading and min(leading):
        num_leading = min(leading)
        part_lines = [p[num_leading:] if p.strip() else p for p in part_lines]
        replace_lines = [p[num_leading:] if p.strip() else p for p in replace_lines]

    # can we find an exact match not including the leading whitespace
    num_part_lines = len(part_lines)

    for i in range(len(whole_lines) - num_part_lines + 1):
        add_leading = match_but_for_leading_whitespace(
            whole_lines[i : i + num_part_lines], part_lines
        )

        if add_leading is None:
            continue

        replace_lines = [add_leading + rline if rline.strip() else rline for rline in replace_lines]
        whole_lines = whole_lines[:i] + replace_lines + whole_lines[i + num_part_lines :]
        return "".join(whole_lines)

    return None

replace_part_with_missing_leading_whitespace(whole_lines=['    line1\n', '    line2\n', '    line3\n'], part_lines=[' line1\n', ' line2\n'], replace_lines=[' new_line1\n', '     new_line2\n'])

['    new_line1\n', '        new_line2\n', '    line3\n']

['    new_line1\n', '        new_line2\n']


def register_mesh(mesh_info: MeshInfo, base_path: Optional[str]) -> None:
    geodists, symmetry, texcoords = mesh_info.geodists, mesh_info.symmetry, mesh_info.texcoords
    if geodists:
        geodists = maybe_prepend_base_path(base_path, geodists)
    if symmetry:
        symmetry = maybe_prepend_base_path(base_path, symmetry)
    if texcoords:
        texcoords = maybe_prepend_base_path(base_path, texcoords)
    MeshCatalog[mesh_info.name] = MeshInfo(
        name=mesh_info.name,
        data=maybe_prepend_base_path(base_path, mesh_info.data),
        geodists=geodists,
        symmetry=symmetry,
        texcoords=texcoords,
    )

register_mesh(mesh_info=MeshInfo(name='smpl_27554', data='smpl_27554.pkl', geodists='geodists/geodists_smpl_27554.pkl', symmetry='symmetry/symmetry_smpl_27554.pkl', texcoords='texcoords/texcoords_smpl_27554.pkl'), base_path='https://dl.fbaipublicfiles.com/densepose/meshes/')


def byteatoms(characterstring):
            binary = characterstring.encode()
            atoms.extend(binary[i:i + 1] for i in range(len(binary)))

byteatoms(characterstring='xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', atoms=[])


def mknode(id=None, ip=None, port=None, intid=None):
    """
    Make a node.  Created a random id if not specified.
    """
    if intid is not None:
        id = pack('>l', intid)
    id = id or hashlib.sha1(str(random.getrandbits(255))).digest()
    return Node(id, ip, port)

mknode(id=None, ip=None, port=None, intid=0)


def read_config_file(f, list_values=True):
    """Read a config file.

    *list_values* set to `True` is the default behavior of ConfigObj.
    Disabling it causes values to not be parsed for lists,
    (e.g. 'a,b,c' -> ['a', 'b', 'c']. Additionally, the config values are
    not unquoted. We are disabling list_values when reading MySQL config files
    so we can correctly interpret commas in passwords.

    """

    if isinstance(f, basestring):
        f = os.path.expanduser(f)

    try:
        config = ConfigObj(f, interpolation=False, encoding='utf8',
                           list_values=list_values)
    except ConfigObjError as e:
        log(logger, logging.WARNING, "Unable to parse line {0} of config file "
            "'{1}'.".format(e.line_number, f))
        log(logger, logging.WARNING, "Using successfully parsed config values.")
        return e.config
    except (IOError, OSError) as e:
        log(logger, logging.WARNING, "You don't have permission to read "
            "config file '{0}'.".format(e.filename))
        return None

    return config

read_config_file(f={}, list_values=True)

ConfigObj({'main': {'weather': 'cloudy with a chance of meatballs'}})


def _identify_environment(environment=None):
    """
    Returns the environment identifier.

    There are multiple ways to define the default environment (in order
    of priority):

    1. The --environment command line option;
    2. The content of the file .python_secrets_environment in the current
       working directory;
    3. The value specified by environment variable D2_ENVIRONMENT; or
    4. The basename of the current working directory.
    """
    cwd = os.getcwd()
    if environment is None:
        env_file = os.path.join(cwd, '.python_secrets_environment')
        if os.path.exists(env_file):
            with open(env_file, 'r') as f:
                environment = f.read().replace('\n', '')
        else:
            environment = os.getenv('D2_ENVIRONMENT',
                                    os.path.basename(cwd))
    return environment

_identify_environment(environment=None)


def type_correct_with(cdict, cfg_tuple):
    """Use type hints of the cfg tuple to cast parameters i.e. attributes into their intended types"""
    # TODO: This would be cleaner, if the config would use Schema or derivative in the
    # first place and use its validation process
    res = {}
    for k, v in cdict.items():
        typename = getattr(cfg_tuple, k)
        res.update({k: type(typename)(v)})
    return res

type_correct_with(cdict={'bar': '42'}, cfg_tuple={})


def _parse_time(t):
    t = " ".join(token.strip() for token in t.lower().split(" "))
    try:
        try:
            _t = time.strptime(t, "%b %d %Y")
        except ValueError:
            _t = time.strptime(t, "%b %d %H:%M")
    except ValueError:
        # Unknown time format
        return None

    year = _t.tm_year if _t.tm_year != 1900 else time.localtime().tm_year
    month = _t.tm_mon
    day = _t.tm_mday
    hour = _t.tm_hour
    minutes = _t.tm_min
    dt = datetime.datetime(year, month, day, hour, minutes, tzinfo=UTC)

    epoch_time = (dt - epoch_dt).total_seconds()
    return epoch_time

_parse_time(t='Jan 18  2006')

datetime.datetime(2006, 1, 18, 0, 0, tzinfo=<UTC>)

time.struct_time(tm_year=2006, tm_mon=1, tm_mday=18, tm_hour=0, tm_min=0, tm_sec=0, tm_wday=2, tm_yday=18, tm_isdst=-1)


def _load_global_committers(path: str) -> List[Committer]:
    lines = read_lines(path)
    committers = []
    for line in lines:
        initials, name, email = line.rstrip().split(',')
        committers.append(GlobalCommitter(initials=initials, name=name, email=email))
    return committers

_load_global_committers(path='/home/XXX/.guet/committers')

[<guet.committers.global_committer.GlobalCommitter object at 0x7fc0ad6a46a0>]