/* Generated by Cython 0.29.36 */

/* BEGIN: Cython Metadata
{
    "distutils": {
        "name": "apache_beam.transforms.stats",
        "sources": [
            "apache_beam/transforms/stats.py"
        ]
    },
    "module_name": "apache_beam.transforms.stats"
}
END: Cython Metadata */

#ifndef PY_SSIZE_T_CLEAN
#define PY_SSIZE_T_CLEAN
#endif /* PY_SSIZE_T_CLEAN */
#include "Python.h"
#ifndef Py_PYTHON_H
    #error Python headers needed to compile C extensions, please install development version of Python.
#elif PY_VERSION_HEX < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03030000)
    #error Cython requires Python 2.6+ or Python 3.3+.
#else
#define CYTHON_ABI "0_29_36"
#define CYTHON_HEX_VERSION 0x001D24F0
#define CYTHON_FUTURE_DIVISION 1
#include <stddef.h>
#ifndef offsetof
  #define offsetof(type, member) ( (size_t) & ((type*)0) -> member )
#endif
#if !defined(WIN32) && !defined(MS_WINDOWS)
  #ifndef __stdcall
    #define __stdcall
  #endif
  #ifndef __cdecl
    #define __cdecl
  #endif
  #ifndef __fastcall
    #define __fastcall
  #endif
#endif
#ifndef DL_IMPORT
  #define DL_IMPORT(t) t
#endif
#ifndef DL_EXPORT
  #define DL_EXPORT(t) t
#endif
#define __PYX_COMMA ,
#ifndef HAVE_LONG_LONG
  #if PY_VERSION_HEX >= 0x02070000
    #define HAVE_LONG_LONG
  #endif
#endif
#ifndef PY_LONG_LONG
  #define PY_LONG_LONG LONG_LONG
#endif
#ifndef Py_HUGE_VAL
  #define Py_HUGE_VAL HUGE_VAL
#endif
#ifdef PYPY_VERSION
  #define CYTHON_COMPILING_IN_PYPY 1
  #define CYTHON_COMPILING_IN_PYSTON 0
  #define CYTHON_COMPILING_IN_CPYTHON 0
  #define CYTHON_COMPILING_IN_NOGIL 0
  #undef CYTHON_USE_TYPE_SLOTS
  #define CYTHON_USE_TYPE_SLOTS 0
  #undef CYTHON_USE_PYTYPE_LOOKUP
  #define CYTHON_USE_PYTYPE_LOOKUP 0
  #if PY_VERSION_HEX < 0x03050000
    #undef CYTHON_USE_ASYNC_SLOTS
    #define CYTHON_USE_ASYNC_SLOTS 0
  #elif !defined(CYTHON_USE_ASYNC_SLOTS)
    #define CYTHON_USE_ASYNC_SLOTS 1
  #endif
  #undef CYTHON_USE_PYLIST_INTERNALS
  #define CYTHON_USE_PYLIST_INTERNALS 0
  #undef CYTHON_USE_UNICODE_INTERNALS
  #define CYTHON_USE_UNICODE_INTERNALS 0
  #undef CYTHON_USE_UNICODE_WRITER
  #define CYTHON_USE_UNICODE_WRITER 0
  #undef CYTHON_USE_PYLONG_INTERNALS
  #define CYTHON_USE_PYLONG_INTERNALS 0
  #undef CYTHON_AVOID_BORROWED_REFS
  #define CYTHON_AVOID_BORROWED_REFS 1
  #undef CYTHON_ASSUME_SAFE_MACROS
  #define CYTHON_ASSUME_SAFE_MACROS 0
  #undef CYTHON_UNPACK_METHODS
  #define CYTHON_UNPACK_METHODS 0
  #undef CYTHON_FAST_THREAD_STATE
  #define CYTHON_FAST_THREAD_STATE 0
  #undef CYTHON_FAST_PYCALL
  #define CYTHON_FAST_PYCALL 0
  #if PY_VERSION_HEX < 0x03090000
    #undef CYTHON_PEP489_MULTI_PHASE_INIT
    #define CYTHON_PEP489_MULTI_PHASE_INIT 0
  #elif !defined(CYTHON_PEP489_MULTI_PHASE_INIT)
    #define CYTHON_PEP489_MULTI_PHASE_INIT 1
  #endif
  #undef CYTHON_USE_TP_FINALIZE
  #define CYTHON_USE_TP_FINALIZE (PY_VERSION_HEX >= 0x030400a1 && PYPY_VERSION_NUM >= 0x07030C00)
  #undef CYTHON_USE_DICT_VERSIONS
  #define CYTHON_USE_DICT_VERSIONS 0
  #undef CYTHON_USE_EXC_INFO_STACK
  #define CYTHON_USE_EXC_INFO_STACK 0
  #ifndef CYTHON_UPDATE_DESCRIPTOR_DOC
    #define CYTHON_UPDATE_DESCRIPTOR_DOC 0
  #endif
#elif defined(PYSTON_VERSION)
  #define CYTHON_COMPILING_IN_PYPY 0
  #define CYTHON_COMPILING_IN_PYSTON 1
  #define CYTHON_COMPILING_IN_CPYTHON 0
  #define CYTHON_COMPILING_IN_NOGIL 0
  #ifndef CYTHON_USE_TYPE_SLOTS
    #define CYTHON_USE_TYPE_SLOTS 1
  #endif
  #undef CYTHON_USE_PYTYPE_LOOKUP
  #define CYTHON_USE_PYTYPE_LOOKUP 0
  #undef CYTHON_USE_ASYNC_SLOTS
  #define CYTHON_USE_ASYNC_SLOTS 0
  #undef CYTHON_USE_PYLIST_INTERNALS
  #define CYTHON_USE_PYLIST_INTERNALS 0
  #ifndef CYTHON_USE_UNICODE_INTERNALS
    #define CYTHON_USE_UNICODE_INTERNALS 1
  #endif
  #undef CYTHON_USE_UNICODE_WRITER
  #define CYTHON_USE_UNICODE_WRITER 0
  #undef CYTHON_USE_PYLONG_INTERNALS
  #define CYTHON_USE_PYLONG_INTERNALS 0
  #ifndef CYTHON_AVOID_BORROWED_REFS
    #define CYTHON_AVOID_BORROWED_REFS 0
  #endif
  #ifndef CYTHON_ASSUME_SAFE_MACROS
    #define CYTHON_ASSUME_SAFE_MACROS 1
  #endif
  #ifndef CYTHON_UNPACK_METHODS
    #define CYTHON_UNPACK_METHODS 1
  #endif
  #undef CYTHON_FAST_THREAD_STATE
  #define CYTHON_FAST_THREAD_STATE 0
  #undef CYTHON_FAST_PYCALL
  #define CYTHON_FAST_PYCALL 0
  #undef CYTHON_PEP489_MULTI_PHASE_INIT
  #define CYTHON_PEP489_MULTI_PHASE_INIT 0
  #undef CYTHON_USE_TP_FINALIZE
  #define CYTHON_USE_TP_FINALIZE 0
  #undef CYTHON_USE_DICT_VERSIONS
  #define CYTHON_USE_DICT_VERSIONS 0
  #undef CYTHON_USE_EXC_INFO_STACK
  #define CYTHON_USE_EXC_INFO_STACK 0
  #ifndef CYTHON_UPDATE_DESCRIPTOR_DOC
    #define CYTHON_UPDATE_DESCRIPTOR_DOC 0
  #endif
#elif defined(PY_NOGIL)
  #define CYTHON_COMPILING_IN_PYPY 0
  #define CYTHON_COMPILING_IN_PYSTON 0
  #define CYTHON_COMPILING_IN_CPYTHON 0
  #define CYTHON_COMPILING_IN_NOGIL 1
  #ifndef CYTHON_USE_TYPE_SLOTS
    #define CYTHON_USE_TYPE_SLOTS 1
  #endif
  #undef CYTHON_USE_PYTYPE_LOOKUP
  #define CYTHON_USE_PYTYPE_LOOKUP 0
  #ifndef CYTHON_USE_ASYNC_SLOTS
    #define CYTHON_USE_ASYNC_SLOTS 1
  #endif
  #undef CYTHON_USE_PYLIST_INTERNALS
  #define CYTHON_USE_PYLIST_INTERNALS 0
  #ifndef CYTHON_USE_UNICODE_INTERNALS
    #define CYTHON_USE_UNICODE_INTERNALS 1
  #endif
  #undef CYTHON_USE_UNICODE_WRITER
  #define CYTHON_USE_UNICODE_WRITER 0
  #undef CYTHON_USE_PYLONG_INTERNALS
  #define CYTHON_USE_PYLONG_INTERNALS 0
  #ifndef CYTHON_AVOID_BORROWED_REFS
    #define CYTHON_AVOID_BORROWED_REFS 0
  #endif
  #ifndef CYTHON_ASSUME_SAFE_MACROS
    #define CYTHON_ASSUME_SAFE_MACROS 1
  #endif
  #ifndef CYTHON_UNPACK_METHODS
    #define CYTHON_UNPACK_METHODS 1
  #endif
  #undef CYTHON_FAST_THREAD_STATE
  #define CYTHON_FAST_THREAD_STATE 0
  #undef CYTHON_FAST_PYCALL
  #define CYTHON_FAST_PYCALL 0
  #ifndef CYTHON_PEP489_MULTI_PHASE_INIT
    #define CYTHON_PEP489_MULTI_PHASE_INIT 1
  #endif
  #ifndef CYTHON_USE_TP_FINALIZE
    #define CYTHON_USE_TP_FINALIZE 1
  #endif
  #undef CYTHON_USE_DICT_VERSIONS
  #define CYTHON_USE_DICT_VERSIONS 0
  #undef CYTHON_USE_EXC_INFO_STACK
  #define CYTHON_USE_EXC_INFO_STACK 0
#else
  #define CYTHON_COMPILING_IN_PYPY 0
  #define CYTHON_COMPILING_IN_PYSTON 0
  #define CYTHON_COMPILING_IN_CPYTHON 1
  #define CYTHON_COMPILING_IN_NOGIL 0
  #ifndef CYTHON_USE_TYPE_SLOTS
    #define CYTHON_USE_TYPE_SLOTS 1
  #endif
  #if PY_VERSION_HEX < 0x02070000
    #undef CYTHON_USE_PYTYPE_LOOKUP
    #define CYTHON_USE_PYTYPE_LOOKUP 0
  #elif !defined(CYTHON_USE_PYTYPE_LOOKUP)
    #define CYTHON_USE_PYTYPE_LOOKUP 1
  #endif
  #if PY_MAJOR_VERSION < 3
    #undef CYTHON_USE_ASYNC_SLOTS
    #define CYTHON_USE_ASYNC_SLOTS 0
  #elif !defined(CYTHON_USE_ASYNC_SLOTS)
    #define CYTHON_USE_ASYNC_SLOTS 1
  #endif
  #if PY_VERSION_HEX < 0x02070000
    #undef CYTHON_USE_PYLONG_INTERNALS
    #define CYTHON_USE_PYLONG_INTERNALS 0
  #elif !defined(CYTHON_USE_PYLONG_INTERNALS)
    #define CYTHON_USE_PYLONG_INTERNALS (PY_VERSION_HEX < 0x030C00A5)
  #endif
  #ifndef CYTHON_USE_PYLIST_INTERNALS
    #define CYTHON_USE_PYLIST_INTERNALS 1
  #endif
  #ifndef CYTHON_USE_UNICODE_INTERNALS
    #define CYTHON_USE_UNICODE_INTERNALS 1
  #endif
  #if PY_VERSION_HEX < 0x030300F0 || PY_VERSION_HEX >= 0x030B00A2
    #undef CYTHON_USE_UNICODE_WRITER
    #define CYTHON_USE_UNICODE_WRITER 0
  #elif !defined(CYTHON_USE_UNICODE_WRITER)
    #define CYTHON_USE_UNICODE_WRITER 1
  #endif
  #ifndef CYTHON_AVOID_BORROWED_REFS
    #define CYTHON_AVOID_BORROWED_REFS 0
  #endif
  #ifndef CYTHON_ASSUME_SAFE_MACROS
    #define CYTHON_ASSUME_SAFE_MACROS 1
  #endif
  #ifndef CYTHON_UNPACK_METHODS
    #define CYTHON_UNPACK_METHODS 1
  #endif
  #if PY_VERSION_HEX >= 0x030B00A4
    #undef CYTHON_FAST_THREAD_STATE
    #define CYTHON_FAST_THREAD_STATE 0
  #elif !defined(CYTHON_FAST_THREAD_STATE)
    #define CYTHON_FAST_THREAD_STATE 1
  #endif
  #ifndef CYTHON_FAST_PYCALL
    #define CYTHON_FAST_PYCALL (PY_VERSION_HEX < 0x030A0000)
  #endif
  #ifndef CYTHON_PEP489_MULTI_PHASE_INIT
    #define CYTHON_PEP489_MULTI_PHASE_INIT (PY_VERSION_HEX >= 0x03050000)
  #endif
  #ifndef CYTHON_USE_TP_FINALIZE
    #define CYTHON_USE_TP_FINALIZE (PY_VERSION_HEX >= 0x030400a1)
  #endif
  #ifndef CYTHON_USE_DICT_VERSIONS
    #define CYTHON_USE_DICT_VERSIONS ((PY_VERSION_HEX >= 0x030600B1) && (PY_VERSION_HEX < 0x030C00A5))
  #endif
  #if PY_VERSION_HEX >= 0x030B00A4
    #undef CYTHON_USE_EXC_INFO_STACK
    #define CYTHON_USE_EXC_INFO_STACK 0
  #elif !defined(CYTHON_USE_EXC_INFO_STACK)
    #define CYTHON_USE_EXC_INFO_STACK (PY_VERSION_HEX >= 0x030700A3)
  #endif
  #ifndef CYTHON_UPDATE_DESCRIPTOR_DOC
    #define CYTHON_UPDATE_DESCRIPTOR_DOC 1
  #endif
#endif
#if !defined(CYTHON_FAST_PYCCALL)
#define CYTHON_FAST_PYCCALL  (CYTHON_FAST_PYCALL && PY_VERSION_HEX >= 0x030600B1)
#endif
#if CYTHON_USE_PYLONG_INTERNALS
  #if PY_MAJOR_VERSION < 3
    #include "longintrepr.h"
  #endif
  #undef SHIFT
  #undef BASE
  #undef MASK
  #ifdef SIZEOF_VOID_P
    enum { __pyx_check_sizeof_voidp = 1 / (int)(SIZEOF_VOID_P == sizeof(void*)) };
  #endif
#endif
#ifndef __has_attribute
  #define __has_attribute(x) 0
#endif
#ifndef __has_cpp_attribute
  #define __has_cpp_attribute(x) 0
#endif
#ifndef CYTHON_RESTRICT
  #if defined(__GNUC__)
    #define CYTHON_RESTRICT __restrict__
  #elif defined(_MSC_VER) && _MSC_VER >= 1400
    #define CYTHON_RESTRICT __restrict
  #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
    #define CYTHON_RESTRICT restrict
  #else
    #define CYTHON_RESTRICT
  #endif
#endif
#ifndef CYTHON_UNUSED
# if defined(__GNUC__)
#   if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
#     define CYTHON_UNUSED __attribute__ ((__unused__))
#   else
#     define CYTHON_UNUSED
#   endif
# elif defined(__ICC) || (defined(__INTEL_COMPILER) && !defined(_MSC_VER))
#   define CYTHON_UNUSED __attribute__ ((__unused__))
# else
#   define CYTHON_UNUSED
# endif
#endif
#ifndef CYTHON_MAYBE_UNUSED_VAR
#  if defined(__cplusplus)
     template<class T> void CYTHON_MAYBE_UNUSED_VAR( const T& ) { }
#  else
#    define CYTHON_MAYBE_UNUSED_VAR(x) (void)(x)
#  endif
#endif
#ifndef CYTHON_NCP_UNUSED
# if CYTHON_COMPILING_IN_CPYTHON
#  define CYTHON_NCP_UNUSED
# else
#  define CYTHON_NCP_UNUSED CYTHON_UNUSED
# endif
#endif
#define __Pyx_void_to_None(void_result) ((void)(void_result), Py_INCREF(Py_None), Py_None)
#ifdef _MSC_VER
    #ifndef _MSC_STDINT_H_
        #if _MSC_VER < 1300
           typedef unsigned char     uint8_t;
           typedef unsigned int      uint32_t;
        #else
           typedef unsigned __int8   uint8_t;
           typedef unsigned __int32  uint32_t;
        #endif
    #endif
#else
   #include <stdint.h>
#endif
#ifndef CYTHON_FALLTHROUGH
  #if defined(__cplusplus) && __cplusplus >= 201103L
    #if __has_cpp_attribute(fallthrough)
      #define CYTHON_FALLTHROUGH [[fallthrough]]
    #elif __has_cpp_attribute(clang::fallthrough)
      #define CYTHON_FALLTHROUGH [[clang::fallthrough]]
    #elif __has_cpp_attribute(gnu::fallthrough)
      #define CYTHON_FALLTHROUGH [[gnu::fallthrough]]
    #endif
  #endif
  #ifndef CYTHON_FALLTHROUGH
    #if __has_attribute(fallthrough)
      #define CYTHON_FALLTHROUGH __attribute__((fallthrough))
    #else
      #define CYTHON_FALLTHROUGH
    #endif
  #endif
  #if defined(__clang__ ) && defined(__apple_build_version__)
    #if __apple_build_version__ < 7000000
      #undef  CYTHON_FALLTHROUGH
      #define CYTHON_FALLTHROUGH
    #endif
  #endif
#endif

#ifndef CYTHON_INLINE
  #if defined(__clang__)
    #define CYTHON_INLINE __inline__ __attribute__ ((__unused__))
  #elif defined(__GNUC__)
    #define CYTHON_INLINE __inline__
  #elif defined(_MSC_VER)
    #define CYTHON_INLINE __inline
  #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
    #define CYTHON_INLINE inline
  #else
    #define CYTHON_INLINE
  #endif
#endif

#define __PYX_BUILD_PY_SSIZE_T "n"
#define CYTHON_FORMAT_SSIZE_T "z"
#if PY_MAJOR_VERSION < 3
  #define __Pyx_BUILTIN_MODULE_NAME "__builtin__"
  #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
          PyCode_New(a+k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
  #define __Pyx_DefaultClassType PyClass_Type
#else
  #define __Pyx_BUILTIN_MODULE_NAME "builtins"
  #define __Pyx_DefaultClassType PyType_Type
#if PY_VERSION_HEX >= 0x030B00A1
    static CYTHON_INLINE PyCodeObject* __Pyx_PyCode_New(int a, int k, int l, int s, int f,
                                                    PyObject *code, PyObject *c, PyObject* n, PyObject *v,
                                                    PyObject *fv, PyObject *cell, PyObject* fn,
                                                    PyObject *name, int fline, PyObject *lnos) {
        PyObject *kwds=NULL, *argcount=NULL, *posonlyargcount=NULL, *kwonlyargcount=NULL;
        PyObject *nlocals=NULL, *stacksize=NULL, *flags=NULL, *replace=NULL, *call_result=NULL, *empty=NULL;
        const char *fn_cstr=NULL;
        const char *name_cstr=NULL;
        PyCodeObject* co=NULL;
        PyObject *type, *value, *traceback;
        PyErr_Fetch(&type, &value, &traceback);
        if (!(kwds=PyDict_New())) goto end;
        if (!(argcount=PyLong_FromLong(a))) goto end;
        if (PyDict_SetItemString(kwds, "co_argcount", argcount) != 0) goto end;
        if (!(posonlyargcount=PyLong_FromLong(0))) goto end;
        if (PyDict_SetItemString(kwds, "co_posonlyargcount", posonlyargcount) != 0) goto end;
        if (!(kwonlyargcount=PyLong_FromLong(k))) goto end;
        if (PyDict_SetItemString(kwds, "co_kwonlyargcount", kwonlyargcount) != 0) goto end;
        if (!(nlocals=PyLong_FromLong(l))) goto end;
        if (PyDict_SetItemString(kwds, "co_nlocals", nlocals) != 0) goto end;
        if (!(stacksize=PyLong_FromLong(s))) goto end;
        if (PyDict_SetItemString(kwds, "co_stacksize", stacksize) != 0) goto end;
        if (!(flags=PyLong_FromLong(f))) goto end;
        if (PyDict_SetItemString(kwds, "co_flags", flags) != 0) goto end;
        if (PyDict_SetItemString(kwds, "co_code", code) != 0) goto end;
        if (PyDict_SetItemString(kwds, "co_consts", c) != 0) goto end;
        if (PyDict_SetItemString(kwds, "co_names", n) != 0) goto end;
        if (PyDict_SetItemString(kwds, "co_varnames", v) != 0) goto end;
        if (PyDict_SetItemString(kwds, "co_freevars", fv) != 0) goto end;
        if (PyDict_SetItemString(kwds, "co_cellvars", cell) != 0) goto end;
        if (PyDict_SetItemString(kwds, "co_linetable", lnos) != 0) goto end;
        if (!(fn_cstr=PyUnicode_AsUTF8AndSize(fn, NULL))) goto end;
        if (!(name_cstr=PyUnicode_AsUTF8AndSize(name, NULL))) goto end;
        if (!(co = PyCode_NewEmpty(fn_cstr, name_cstr, fline))) goto end;
        if (!(replace = PyObject_GetAttrString((PyObject*)co, "replace"))) goto cleanup_code_too;
        if (!(empty = PyTuple_New(0))) goto cleanup_code_too; // unfortunately __pyx_empty_tuple isn't available here
        if (!(call_result = PyObject_Call(replace, empty, kwds))) goto cleanup_code_too;
        Py_XDECREF((PyObject*)co);
        co = (PyCodeObject*)call_result;
        call_result = NULL;
        if (0) {
            cleanup_code_too:
            Py_XDECREF((PyObject*)co);
            co = NULL;
        }
        end:
        Py_XDECREF(kwds);
        Py_XDECREF(argcount);
        Py_XDECREF(posonlyargcount);
        Py_XDECREF(kwonlyargcount);
        Py_XDECREF(nlocals);
        Py_XDECREF(stacksize);
        Py_XDECREF(replace);
        Py_XDECREF(call_result);
        Py_XDECREF(empty);
        if (type) {
            PyErr_Restore(type, value, traceback);
        }
        return co;
    }
#else
  #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
          PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
#endif
  #define __Pyx_DefaultClassType PyType_Type
#endif
#if PY_VERSION_HEX >= 0x030900F0 && !CYTHON_COMPILING_IN_PYPY
  #define __Pyx_PyObject_GC_IsFinalized(o) PyObject_GC_IsFinalized(o)
#else
  #define __Pyx_PyObject_GC_IsFinalized(o) _PyGC_FINALIZED(o)
#endif
#ifndef Py_TPFLAGS_CHECKTYPES
  #define Py_TPFLAGS_CHECKTYPES 0
#endif
#ifndef Py_TPFLAGS_HAVE_INDEX
  #define Py_TPFLAGS_HAVE_INDEX 0
#endif
#ifndef Py_TPFLAGS_HAVE_NEWBUFFER
  #define Py_TPFLAGS_HAVE_NEWBUFFER 0
#endif
#ifndef Py_TPFLAGS_HAVE_FINALIZE
  #define Py_TPFLAGS_HAVE_FINALIZE 0
#endif
#ifndef METH_STACKLESS
  #define METH_STACKLESS 0
#endif
#if PY_VERSION_HEX <= 0x030700A3 || !defined(METH_FASTCALL)
  #ifndef METH_FASTCALL
     #define METH_FASTCALL 0x80
  #endif
  typedef PyObject *(*__Pyx_PyCFunctionFast) (PyObject *self, PyObject *const *args, Py_ssize_t nargs);
  typedef PyObject *(*__Pyx_PyCFunctionFastWithKeywords) (PyObject *self, PyObject *const *args,
                                                          Py_ssize_t nargs, PyObject *kwnames);
#else
  #define __Pyx_PyCFunctionFast _PyCFunctionFast
  #define __Pyx_PyCFunctionFastWithKeywords _PyCFunctionFastWithKeywords
#endif
#if CYTHON_FAST_PYCCALL
#define __Pyx_PyFastCFunction_Check(func)\
    ((PyCFunction_Check(func) && (METH_FASTCALL == (PyCFunction_GET_FLAGS(func) & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS | METH_STACKLESS)))))
#else
#define __Pyx_PyFastCFunction_Check(func) 0
#endif
#if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Malloc)
  #define PyObject_Malloc(s)   PyMem_Malloc(s)
  #define PyObject_Free(p)     PyMem_Free(p)
  #define PyObject_Realloc(p)  PyMem_Realloc(p)
#endif
#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX < 0x030400A1
  #define PyMem_RawMalloc(n)           PyMem_Malloc(n)
  #define PyMem_RawRealloc(p, n)       PyMem_Realloc(p, n)
  #define PyMem_RawFree(p)             PyMem_Free(p)
#endif
#if CYTHON_COMPILING_IN_PYSTON
  #define __Pyx_PyCode_HasFreeVars(co)  PyCode_HasFreeVars(co)
  #define __Pyx_PyFrame_SetLineNumber(frame, lineno) PyFrame_SetLineNumber(frame, lineno)
#else
  #define __Pyx_PyCode_HasFreeVars(co)  (PyCode_GetNumFree(co) > 0)
  #define __Pyx_PyFrame_SetLineNumber(frame, lineno)  (frame)->f_lineno = (lineno)
#endif
#if !CYTHON_FAST_THREAD_STATE || PY_VERSION_HEX < 0x02070000
  #define __Pyx_PyThreadState_Current PyThreadState_GET()
#elif PY_VERSION_HEX >= 0x03060000
  #define __Pyx_PyThreadState_Current _PyThreadState_UncheckedGet()
#elif PY_VERSION_HEX >= 0x03000000
  #define __Pyx_PyThreadState_Current PyThreadState_GET()
#else
  #define __Pyx_PyThreadState_Current _PyThreadState_Current
#endif
#if PY_VERSION_HEX < 0x030700A2 && !defined(PyThread_tss_create) && !defined(Py_tss_NEEDS_INIT)
#include "pythread.h"
#define Py_tss_NEEDS_INIT 0
typedef int Py_tss_t;
static CYTHON_INLINE int PyThread_tss_create(Py_tss_t *key) {
  *key = PyThread_create_key();
  return 0;
}
static CYTHON_INLINE Py_tss_t * PyThread_tss_alloc(void) {
  Py_tss_t *key = (Py_tss_t *)PyObject_Malloc(sizeof(Py_tss_t));
  *key = Py_tss_NEEDS_INIT;
  return key;
}
static CYTHON_INLINE void PyThread_tss_free(Py_tss_t *key) {
  PyObject_Free(key);
}
static CYTHON_INLINE int PyThread_tss_is_created(Py_tss_t *key) {
  return *key != Py_tss_NEEDS_INIT;
}
static CYTHON_INLINE void PyThread_tss_delete(Py_tss_t *key) {
  PyThread_delete_key(*key);
  *key = Py_tss_NEEDS_INIT;
}
static CYTHON_INLINE int PyThread_tss_set(Py_tss_t *key, void *value) {
  return PyThread_set_key_value(*key, value);
}
static CYTHON_INLINE void * PyThread_tss_get(Py_tss_t *key) {
  return PyThread_get_key_value(*key);
}
#endif
#if CYTHON_COMPILING_IN_CPYTHON || defined(_PyDict_NewPresized)
#define __Pyx_PyDict_NewPresized(n)  ((n <= 8) ? PyDict_New() : _PyDict_NewPresized(n))
#else
#define __Pyx_PyDict_NewPresized(n)  PyDict_New()
#endif
#if PY_MAJOR_VERSION >= 3 || CYTHON_FUTURE_DIVISION
  #define __Pyx_PyNumber_Divide(x,y)         PyNumber_TrueDivide(x,y)
  #define __Pyx_PyNumber_InPlaceDivide(x,y)  PyNumber_InPlaceTrueDivide(x,y)
#else
  #define __Pyx_PyNumber_Divide(x,y)         PyNumber_Divide(x,y)
  #define __Pyx_PyNumber_InPlaceDivide(x,y)  PyNumber_InPlaceDivide(x,y)
#endif
#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1 && CYTHON_USE_UNICODE_INTERNALS
#define __Pyx_PyDict_GetItemStr(dict, name)  _PyDict_GetItem_KnownHash(dict, name, ((PyASCIIObject *) name)->hash)
#else
#define __Pyx_PyDict_GetItemStr(dict, name)  PyDict_GetItem(dict, name)
#endif
#if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND)
  #define CYTHON_PEP393_ENABLED 1
  #if PY_VERSION_HEX >= 0x030C0000
    #define __Pyx_PyUnicode_READY(op)       (0)
  #else
    #define __Pyx_PyUnicode_READY(op)       (likely(PyUnicode_IS_READY(op)) ?\
                                                0 : _PyUnicode_Ready((PyObject *)(op)))
  #endif
  #define __Pyx_PyUnicode_GET_LENGTH(u)   PyUnicode_GET_LENGTH(u)
  #define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_READ_CHAR(u, i)
  #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u)   PyUnicode_MAX_CHAR_VALUE(u)
  #define __Pyx_PyUnicode_KIND(u)         PyUnicode_KIND(u)
  #define __Pyx_PyUnicode_DATA(u)         PyUnicode_DATA(u)
  #define __Pyx_PyUnicode_READ(k, d, i)   PyUnicode_READ(k, d, i)
  #define __Pyx_PyUnicode_WRITE(k, d, i, ch)  PyUnicode_WRITE(k, d, i, ch)
  #if PY_VERSION_HEX >= 0x030C0000
    #define __Pyx_PyUnicode_IS_TRUE(u)      (0 != PyUnicode_GET_LENGTH(u))
  #else
    #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x03090000
    #define __Pyx_PyUnicode_IS_TRUE(u)      (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : ((PyCompactUnicodeObject *)(u))->wstr_length))
    #else
    #define __Pyx_PyUnicode_IS_TRUE(u)      (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : PyUnicode_GET_SIZE(u)))
    #endif
  #endif
#else
  #define CYTHON_PEP393_ENABLED 0
  #define PyUnicode_1BYTE_KIND  1
  #define PyUnicode_2BYTE_KIND  2
  #define PyUnicode_4BYTE_KIND  4
  #define __Pyx_PyUnicode_READY(op)       (0)
  #define __Pyx_PyUnicode_GET_LENGTH(u)   PyUnicode_GET_SIZE(u)
  #define __Pyx_PyUnicode_READ_CHAR(u, i) ((Py_UCS4)(PyUnicode_AS_UNICODE(u)[i]))
  #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u)   ((sizeof(Py_UNICODE) == 2) ? 65535 : 1114111)
  #define __Pyx_PyUnicode_KIND(u)         (sizeof(Py_UNICODE))
  #define __Pyx_PyUnicode_DATA(u)         ((void*)PyUnicode_AS_UNICODE(u))
  #define __Pyx_PyUnicode_READ(k, d, i)   ((void)(k), (Py_UCS4)(((Py_UNICODE*)d)[i]))
  #define __Pyx_PyUnicode_WRITE(k, d, i, ch)  (((void)(k)), ((Py_UNICODE*)d)[i] = ch)
  #define __Pyx_PyUnicode_IS_TRUE(u)      (0 != PyUnicode_GET_SIZE(u))
#endif
#if CYTHON_COMPILING_IN_PYPY
  #define __Pyx_PyUnicode_Concat(a, b)      PyNumber_Add(a, b)
  #define __Pyx_PyUnicode_ConcatSafe(a, b)  PyNumber_Add(a, b)
#else
  #define __Pyx_PyUnicode_Concat(a, b)      PyUnicode_Concat(a, b)
  #define __Pyx_PyUnicode_ConcatSafe(a, b)  ((unlikely((a) == Py_None) || unlikely((b) == Py_None)) ?\
      PyNumber_Add(a, b) : __Pyx_PyUnicode_Concat(a, b))
#endif
#if CYTHON_COMPILING_IN_PYPY && !defined(PyUnicode_Contains)
  #define PyUnicode_Contains(u, s)  PySequence_Contains(u, s)
#endif
#if CYTHON_COMPILING_IN_PYPY && !defined(PyByteArray_Check)
  #define PyByteArray_Check(obj)  PyObject_TypeCheck(obj, &PyByteArray_Type)
#endif
#if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Format)
  #define PyObject_Format(obj, fmt)  PyObject_CallMethod(obj, "__format__", "O", fmt)
#endif
#define __Pyx_PyString_FormatSafe(a, b)   ((unlikely((a) == Py_None || (PyString_Check(b) && !PyString_CheckExact(b)))) ? PyNumber_Remainder(a, b) : __Pyx_PyString_Format(a, b))
#define __Pyx_PyUnicode_FormatSafe(a, b)  ((unlikely((a) == Py_None || (PyUnicode_Check(b) && !PyUnicode_CheckExact(b)))) ? PyNumber_Remainder(a, b) : PyUnicode_Format(a, b))
#if PY_MAJOR_VERSION >= 3
  #define __Pyx_PyString_Format(a, b)  PyUnicode_Format(a, b)
#else
  #define __Pyx_PyString_Format(a, b)  PyString_Format(a, b)
#endif
#if PY_MAJOR_VERSION < 3 && !defined(PyObject_ASCII)
  #define PyObject_ASCII(o)            PyObject_Repr(o)
#endif
#if PY_MAJOR_VERSION >= 3
  #define PyBaseString_Type            PyUnicode_Type
  #define PyStringObject               PyUnicodeObject
  #define PyString_Type                PyUnicode_Type
  #define PyString_Check               PyUnicode_Check
  #define PyString_CheckExact          PyUnicode_CheckExact
#ifndef PyObject_Unicode
  #define PyObject_Unicode             PyObject_Str
#endif
#endif
#if PY_MAJOR_VERSION >= 3
  #define __Pyx_PyBaseString_Check(obj) PyUnicode_Check(obj)
  #define __Pyx_PyBaseString_CheckExact(obj) PyUnicode_CheckExact(obj)
#else
  #define __Pyx_PyBaseString_Check(obj) (PyString_Check(obj) || PyUnicode_Check(obj))
  #define __Pyx_PyBaseString_CheckExact(obj) (PyString_CheckExact(obj) || PyUnicode_CheckExact(obj))
#endif
#ifndef PySet_CheckExact
  #define PySet_CheckExact(obj)        (Py_TYPE(obj) == &PySet_Type)
#endif
#if PY_VERSION_HEX >= 0x030900A4
  #define __Pyx_SET_REFCNT(obj, refcnt) Py_SET_REFCNT(obj, refcnt)
  #define __Pyx_SET_SIZE(obj, size) Py_SET_SIZE(obj, size)
#else
  #define __Pyx_SET_REFCNT(obj, refcnt) Py_REFCNT(obj) = (refcnt)
  #define __Pyx_SET_SIZE(obj, size) Py_SIZE(obj) = (size)
#endif
#if CYTHON_ASSUME_SAFE_MACROS
  #define __Pyx_PySequence_SIZE(seq)  Py_SIZE(seq)
#else
  #define __Pyx_PySequence_SIZE(seq)  PySequence_Size(seq)
#endif
#if PY_MAJOR_VERSION >= 3
  #define PyIntObject                  PyLongObject
  #define PyInt_Type                   PyLong_Type
  #define PyInt_Check(op)              PyLong_Check(op)
  #define PyInt_CheckExact(op)         PyLong_CheckExact(op)
  #define PyInt_FromString             PyLong_FromString
  #define PyInt_FromUnicode            PyLong_FromUnicode
  #define PyInt_FromLong               PyLong_FromLong
  #define PyInt_FromSize_t             PyLong_FromSize_t
  #define PyInt_FromSsize_t            PyLong_FromSsize_t
  #define PyInt_AsLong                 PyLong_AsLong
  #define PyInt_AS_LONG                PyLong_AS_LONG
  #define PyInt_AsSsize_t              PyLong_AsSsize_t
  #define PyInt_AsUnsignedLongMask     PyLong_AsUnsignedLongMask
  #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask
  #define PyNumber_Int                 PyNumber_Long
#endif
#if PY_MAJOR_VERSION >= 3
  #define PyBoolObject                 PyLongObject
#endif
#if PY_MAJOR_VERSION >= 3 && CYTHON_COMPILING_IN_PYPY
  #ifndef PyUnicode_InternFromString
    #define PyUnicode_InternFromString(s) PyUnicode_FromString(s)
  #endif
#endif
#if PY_VERSION_HEX < 0x030200A4
  typedef long Py_hash_t;
  #define __Pyx_PyInt_FromHash_t PyInt_FromLong
  #define __Pyx_PyInt_AsHash_t   __Pyx_PyIndex_AsHash_t
#else
  #define __Pyx_PyInt_FromHash_t PyInt_FromSsize_t
  #define __Pyx_PyInt_AsHash_t   __Pyx_PyIndex_AsSsize_t
#endif
#if PY_MAJOR_VERSION >= 3
  #define __Pyx_PyMethod_New(func, self, klass) ((self) ? ((void)(klass), PyMethod_New(func, self)) : __Pyx_NewRef(func))
#else
  #define __Pyx_PyMethod_New(func, self, klass) PyMethod_New(func, self, klass)
#endif
#if CYTHON_USE_ASYNC_SLOTS
  #if PY_VERSION_HEX >= 0x030500B1
    #define __Pyx_PyAsyncMethodsStruct PyAsyncMethods
    #define __Pyx_PyType_AsAsync(obj) (Py_TYPE(obj)->tp_as_async)
  #else
    #define __Pyx_PyType_AsAsync(obj) ((__Pyx_PyAsyncMethodsStruct*) (Py_TYPE(obj)->tp_reserved))
  #endif
#else
  #define __Pyx_PyType_AsAsync(obj) NULL
#endif
#ifndef __Pyx_PyAsyncMethodsStruct
    typedef struct {
        unaryfunc am_await;
        unaryfunc am_aiter;
        unaryfunc am_anext;
    } __Pyx_PyAsyncMethodsStruct;
#endif

#if defined(_WIN32) || defined(WIN32) || defined(MS_WINDOWS)
  #if !defined(_USE_MATH_DEFINES)
    #define _USE_MATH_DEFINES
  #endif
#endif
#include <math.h>
#ifdef NAN
#define __PYX_NAN() ((float) NAN)
#else
static CYTHON_INLINE float __PYX_NAN() {
  float value;
  memset(&value, 0xFF, sizeof(value));
  return value;
}
#endif
#if defined(__CYGWIN__) && defined(_LDBL_EQ_DBL)
#define __Pyx_truncl trunc
#else
#define __Pyx_truncl truncl
#endif

#define __PYX_MARK_ERR_POS(f_index, lineno) \
    { __pyx_filename = __pyx_f[f_index]; (void)__pyx_filename; __pyx_lineno = lineno; (void)__pyx_lineno; __pyx_clineno = __LINE__; (void)__pyx_clineno; }
#define __PYX_ERR(f_index, lineno, Ln_error) \
    { __PYX_MARK_ERR_POS(f_index, lineno) goto Ln_error; }

#ifndef __PYX_EXTERN_C
  #ifdef __cplusplus
    #define __PYX_EXTERN_C extern "C"
  #else
    #define __PYX_EXTERN_C extern
  #endif
#endif

#define __PYX_HAVE__apache_beam__transforms__stats
#define __PYX_HAVE_API__apache_beam__transforms__stats
/* Early includes */
#include <stdint.h>
#ifdef _OPENMP
#include <omp.h>
#endif /* _OPENMP */

#if defined(PYREX_WITHOUT_ASSERTIONS) && !defined(CYTHON_WITHOUT_ASSERTIONS)
#define CYTHON_WITHOUT_ASSERTIONS
#endif

typedef struct {PyObject **p; const char *s; const Py_ssize_t n; const char* encoding;
                const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry;

#define __PYX_DEFAULT_STRING_ENCODING_IS_ASCII 0
#define __PYX_DEFAULT_STRING_ENCODING_IS_UTF8 0
#define __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT (PY_MAJOR_VERSION >= 3 && __PYX_DEFAULT_STRING_ENCODING_IS_UTF8)
#define __PYX_DEFAULT_STRING_ENCODING ""
#define __Pyx_PyObject_FromString __Pyx_PyBytes_FromString
#define __Pyx_PyObject_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
#define __Pyx_uchar_cast(c) ((unsigned char)c)
#define __Pyx_long_cast(x) ((long)x)
#define __Pyx_fits_Py_ssize_t(v, type, is_signed)  (\
    (sizeof(type) < sizeof(Py_ssize_t))  ||\
    (sizeof(type) > sizeof(Py_ssize_t) &&\
          likely(v < (type)PY_SSIZE_T_MAX ||\
                 v == (type)PY_SSIZE_T_MAX)  &&\
          (!is_signed || likely(v > (type)PY_SSIZE_T_MIN ||\
                                v == (type)PY_SSIZE_T_MIN)))  ||\
    (sizeof(type) == sizeof(Py_ssize_t) &&\
          (is_signed || likely(v < (type)PY_SSIZE_T_MAX ||\
                               v == (type)PY_SSIZE_T_MAX)))  )
static CYTHON_INLINE int __Pyx_is_valid_index(Py_ssize_t i, Py_ssize_t limit) {
    return (size_t) i < (size_t) limit;
}
#if defined (__cplusplus) && __cplusplus >= 201103L
    #include <cstdlib>
    #define __Pyx_sst_abs(value) std::abs(value)
#elif SIZEOF_INT >= SIZEOF_SIZE_T
    #define __Pyx_sst_abs(value) abs(value)
#elif SIZEOF_LONG >= SIZEOF_SIZE_T
    #define __Pyx_sst_abs(value) labs(value)
#elif defined (_MSC_VER)
    #define __Pyx_sst_abs(value) ((Py_ssize_t)_abs64(value))
#elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
    #define __Pyx_sst_abs(value) llabs(value)
#elif defined (__GNUC__)
    #define __Pyx_sst_abs(value) __builtin_llabs(value)
#else
    #define __Pyx_sst_abs(value) ((value<0) ? -value : value)
#endif
static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject*);
static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject*, Py_ssize_t* length);
#define __Pyx_PyByteArray_FromString(s) PyByteArray_FromStringAndSize((const char*)s, strlen((const char*)s))
#define __Pyx_PyByteArray_FromStringAndSize(s, l) PyByteArray_FromStringAndSize((const char*)s, l)
#define __Pyx_PyBytes_FromString        PyBytes_FromString
#define __Pyx_PyBytes_FromStringAndSize PyBytes_FromStringAndSize
static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*);
#if PY_MAJOR_VERSION < 3
    #define __Pyx_PyStr_FromString        __Pyx_PyBytes_FromString
    #define __Pyx_PyStr_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
#else
    #define __Pyx_PyStr_FromString        __Pyx_PyUnicode_FromString
    #define __Pyx_PyStr_FromStringAndSize __Pyx_PyUnicode_FromStringAndSize
#endif
#define __Pyx_PyBytes_AsWritableString(s)     ((char*) PyBytes_AS_STRING(s))
#define __Pyx_PyBytes_AsWritableSString(s)    ((signed char*) PyBytes_AS_STRING(s))
#define __Pyx_PyBytes_AsWritableUString(s)    ((unsigned char*) PyBytes_AS_STRING(s))
#define __Pyx_PyBytes_AsString(s)     ((const char*) PyBytes_AS_STRING(s))
#define __Pyx_PyBytes_AsSString(s)    ((const signed char*) PyBytes_AS_STRING(s))
#define __Pyx_PyBytes_AsUString(s)    ((const unsigned char*) PyBytes_AS_STRING(s))
#define __Pyx_PyObject_AsWritableString(s)    ((char*) __Pyx_PyObject_AsString(s))
#define __Pyx_PyObject_AsWritableSString(s)    ((signed char*) __Pyx_PyObject_AsString(s))
#define __Pyx_PyObject_AsWritableUString(s)    ((unsigned char*) __Pyx_PyObject_AsString(s))
#define __Pyx_PyObject_AsSString(s)    ((const signed char*) __Pyx_PyObject_AsString(s))
#define __Pyx_PyObject_AsUString(s)    ((const unsigned char*) __Pyx_PyObject_AsString(s))
#define __Pyx_PyObject_FromCString(s)  __Pyx_PyObject_FromString((const char*)s)
#define __Pyx_PyBytes_FromCString(s)   __Pyx_PyBytes_FromString((const char*)s)
#define __Pyx_PyByteArray_FromCString(s)   __Pyx_PyByteArray_FromString((const char*)s)
#define __Pyx_PyStr_FromCString(s)     __Pyx_PyStr_FromString((const char*)s)
#define __Pyx_PyUnicode_FromCString(s) __Pyx_PyUnicode_FromString((const char*)s)
static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u) {
    const Py_UNICODE *u_end = u;
    while (*u_end++) ;
    return (size_t)(u_end - u - 1);
}
#define __Pyx_PyUnicode_FromUnicode(u)       PyUnicode_FromUnicode(u, __Pyx_Py_UNICODE_strlen(u))
#define __Pyx_PyUnicode_FromUnicodeAndLength PyUnicode_FromUnicode
#define __Pyx_PyUnicode_AsUnicode            PyUnicode_AsUnicode
#define __Pyx_NewRef(obj) (Py_INCREF(obj), obj)
#define __Pyx_Owned_Py_None(b) __Pyx_NewRef(Py_None)
static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b);
static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*);
static CYTHON_INLINE int __Pyx_PyObject_IsTrueAndDecref(PyObject*);
static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x);
#define __Pyx_PySequence_Tuple(obj)\
    (likely(PyTuple_CheckExact(obj)) ? __Pyx_NewRef(obj) : PySequence_Tuple(obj))
static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*);
static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t);
static CYTHON_INLINE Py_hash_t __Pyx_PyIndex_AsHash_t(PyObject*);
#if CYTHON_ASSUME_SAFE_MACROS
#define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x))
#else
#define __pyx_PyFloat_AsDouble(x) PyFloat_AsDouble(x)
#endif
#define __pyx_PyFloat_AsFloat(x) ((float) __pyx_PyFloat_AsDouble(x))
#if PY_MAJOR_VERSION >= 3
#define __Pyx_PyNumber_Int(x) (PyLong_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Long(x))
#else
#define __Pyx_PyNumber_Int(x) (PyInt_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Int(x))
#endif
#define __Pyx_PyNumber_Float(x) (PyFloat_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Float(x))
#if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
static int __Pyx_sys_getdefaultencoding_not_ascii;
static int __Pyx_init_sys_getdefaultencoding_params(void) {
    PyObject* sys;
    PyObject* default_encoding = NULL;
    PyObject* ascii_chars_u = NULL;
    PyObject* ascii_chars_b = NULL;
    const char* default_encoding_c;
    sys = PyImport_ImportModule("sys");
    if (!sys) goto bad;
    default_encoding = PyObject_CallMethod(sys, (char*) "getdefaultencoding", NULL);
    Py_DECREF(sys);
    if (!default_encoding) goto bad;
    default_encoding_c = PyBytes_AsString(default_encoding);
    if (!default_encoding_c) goto bad;
    if (strcmp(default_encoding_c, "ascii") == 0) {
        __Pyx_sys_getdefaultencoding_not_ascii = 0;
    } else {
        char ascii_chars[128];
        int c;
        for (c = 0; c < 128; c++) {
            ascii_chars[c] = c;
        }
        __Pyx_sys_getdefaultencoding_not_ascii = 1;
        ascii_chars_u = PyUnicode_DecodeASCII(ascii_chars, 128, NULL);
        if (!ascii_chars_u) goto bad;
        ascii_chars_b = PyUnicode_AsEncodedString(ascii_chars_u, default_encoding_c, NULL);
        if (!ascii_chars_b || !PyBytes_Check(ascii_chars_b) || memcmp(ascii_chars, PyBytes_AS_STRING(ascii_chars_b), 128) != 0) {
            PyErr_Format(
                PyExc_ValueError,
                "This module compiled with c_string_encoding=ascii, but default encoding '%.200s' is not a superset of ascii.",
                default_encoding_c);
            goto bad;
        }
        Py_DECREF(ascii_chars_u);
        Py_DECREF(ascii_chars_b);
    }
    Py_DECREF(default_encoding);
    return 0;
bad:
    Py_XDECREF(default_encoding);
    Py_XDECREF(ascii_chars_u);
    Py_XDECREF(ascii_chars_b);
    return -1;
}
#endif
#if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT && PY_MAJOR_VERSION >= 3
#define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_DecodeUTF8(c_str, size, NULL)
#else
#define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_Decode(c_str, size, __PYX_DEFAULT_STRING_ENCODING, NULL)
#if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
static char* __PYX_DEFAULT_STRING_ENCODING;
static int __Pyx_init_sys_getdefaultencoding_params(void) {
    PyObject* sys;
    PyObject* default_encoding = NULL;
    char* default_encoding_c;
    sys = PyImport_ImportModule("sys");
    if (!sys) goto bad;
    default_encoding = PyObject_CallMethod(sys, (char*) (const char*) "getdefaultencoding", NULL);
    Py_DECREF(sys);
    if (!default_encoding) goto bad;
    default_encoding_c = PyBytes_AsString(default_encoding);
    if (!default_encoding_c) goto bad;
    __PYX_DEFAULT_STRING_ENCODING = (char*) malloc(strlen(default_encoding_c) + 1);
    if (!__PYX_DEFAULT_STRING_ENCODING) goto bad;
    strcpy(__PYX_DEFAULT_STRING_ENCODING, default_encoding_c);
    Py_DECREF(default_encoding);
    return 0;
bad:
    Py_XDECREF(default_encoding);
    return -1;
}
#endif
#endif


/* Test for GCC > 2.95 */
#if defined(__GNUC__)     && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95)))
  #define likely(x)   __builtin_expect(!!(x), 1)
  #define unlikely(x) __builtin_expect(!!(x), 0)
#else /* !__GNUC__ or GCC < 2.95 */
  #define likely(x)   (x)
  #define unlikely(x) (x)
#endif /* __GNUC__ */
static CYTHON_INLINE void __Pyx_pretend_to_initialize(void* ptr) { (void)ptr; }

static PyObject *__pyx_m = NULL;
static PyObject *__pyx_d;
static PyObject *__pyx_b;
static PyObject *__pyx_cython_runtime = NULL;
static PyObject *__pyx_empty_tuple;
static PyObject *__pyx_empty_bytes;
static PyObject *__pyx_empty_unicode;
static int __pyx_lineno;
static int __pyx_clineno = 0;
static const char * __pyx_cfilenm= __FILE__;
static const char *__pyx_filename;


static const char *__pyx_f[] = {
  "apache_beam/transforms/stats.py",
  "apache_beam/transforms/stats.pxd",
  "stringsource",
};

/*--- Type declarations ---*/
struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileSpec;
struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileBuffer;
struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileState;
struct __pyx_obj_11apache_beam_10transforms_5stats___pyx_scope_struct____init__;
struct __pyx_obj_11apache_beam_10transforms_5stats___pyx_scope_struct_1_get_argsort_key;

/* "apache_beam/transforms/stats.pxd":21
 * from libc.stdint cimport int64_t
 * 
 * cdef class _QuantileSpec(object):             # <<<<<<<<<<<<<<
 *   cdef readonly int64_t buffer_size
 *   cdef readonly int64_t num_buffers
 */
struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileSpec {
  PyObject_HEAD
  int64_t buffer_size;
  int64_t num_buffers;
  int weighted;
  PyObject *key;
  int reverse;
  PyObject *weighted_key;
  PyObject *less_than;
};


/* "apache_beam/transforms/stats.pxd":30
 *   cdef readonly less_than
 * 
 * cdef class _QuantileBuffer(object):             # <<<<<<<<<<<<<<
 *   cdef readonly elements
 *   cdef readonly weights
 */
struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileBuffer {
  PyObject_HEAD
  PyObject *elements;
  PyObject *weights;
  int weighted;
  int64_t level;
  PyObject *min_val;
  PyObject *max_val;
  PyObject *_iter;
};


/* "apache_beam/transforms/stats.pxd":39
 *   cdef readonly _iter
 * 
 * cdef class _QuantileState(object):             # <<<<<<<<<<<<<<
 *   cdef readonly _QuantileSpec spec
 *   cdef public buffers
 */
struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileState {
  PyObject_HEAD
  struct __pyx_vtabstruct_11apache_beam_10transforms_5stats__QuantileState *__pyx_vtab;
  struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileSpec *spec;
  PyObject *buffers;
  PyObject *unbuffered_elements;
  PyObject *unbuffered_weights;
  PyObject *add_unbuffered;
};


/* "apache_beam/transforms/stats.py":436
 * class _QuantileSpec(object):
 *   """Quantiles computation specifications."""
 *   def __init__(self, buffer_size, num_buffers, weighted, key, reverse):             # <<<<<<<<<<<<<<
 *     # type: (int, int, bool, Any, bool) -> None
 *     self.buffer_size = buffer_size
 */
struct __pyx_obj_11apache_beam_10transforms_5stats___pyx_scope_struct____init__ {
  PyObject_HEAD
  PyObject *__pyx_v_key;
};


/* "apache_beam/transforms/stats.py":457
 *       self.less_than = lambda a, b: key(a) < key(b)
 * 
 *   def get_argsort_key(self, elements):             # <<<<<<<<<<<<<<
 *     # type: (List) -> Callable[[int], Any]
 * 
 */
struct __pyx_obj_11apache_beam_10transforms_5stats___pyx_scope_struct_1_get_argsort_key {
  PyObject_HEAD
  PyObject *__pyx_v_elements;
  struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileSpec *__pyx_v_self;
};



/* "apache_beam/transforms/stats.py":510
 * 
 * 
 * class _QuantileState(object):             # <<<<<<<<<<<<<<
 *   """
 *   Compact summarization of a collection on which quantiles can be estimated.
 */

struct __pyx_vtabstruct_11apache_beam_10transforms_5stats__QuantileState {
  int (*is_empty)(struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileState *, int __pyx_skip_dispatch);
  PyObject *(*_add_unbuffered)(struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileState *, PyObject *, PyObject *, int __pyx_skip_dispatch);
  PyObject *(*_add_unbuffered_weighted)(struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileState *, PyObject *, PyObject *, int __pyx_skip_dispatch);
  PyObject *(*finalize)(struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileState *, int __pyx_skip_dispatch);
  PyObject *(*collapse_if_needed)(struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileState *, PyObject *, int __pyx_skip_dispatch);
};
static struct __pyx_vtabstruct_11apache_beam_10transforms_5stats__QuantileState *__pyx_vtabptr_11apache_beam_10transforms_5stats__QuantileState;

/* --- Runtime support code (head) --- */
/* Refnanny.proto */
#ifndef CYTHON_REFNANNY
  #define CYTHON_REFNANNY 0
#endif
#if CYTHON_REFNANNY
  typedef struct {
    void (*INCREF)(void*, PyObject*, int);
    void (*DECREF)(void*, PyObject*, int);
    void (*GOTREF)(void*, PyObject*, int);
    void (*GIVEREF)(void*, PyObject*, int);
    void* (*SetupContext)(const char*, int, const char*);
    void (*FinishContext)(void**);
  } __Pyx_RefNannyAPIStruct;
  static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL;
  static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname);
  #define __Pyx_RefNannyDeclarations void *__pyx_refnanny = NULL;
#ifdef WITH_THREAD
  #define __Pyx_RefNannySetupContext(name, acquire_gil)\
          if (acquire_gil) {\
              PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();\
              __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\
              PyGILState_Release(__pyx_gilstate_save);\
          } else {\
              __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\
          }
#else
  #define __Pyx_RefNannySetupContext(name, acquire_gil)\
          __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__)
#endif
  #define __Pyx_RefNannyFinishContext()\
          __Pyx_RefNanny->FinishContext(&__pyx_refnanny)
  #define __Pyx_INCREF(r)  __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  #define __Pyx_DECREF(r)  __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  #define __Pyx_GOTREF(r)  __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  #define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  #define __Pyx_XINCREF(r)  do { if((r) != NULL) {__Pyx_INCREF(r); }} while(0)
  #define __Pyx_XDECREF(r)  do { if((r) != NULL) {__Pyx_DECREF(r); }} while(0)
  #define __Pyx_XGOTREF(r)  do { if((r) != NULL) {__Pyx_GOTREF(r); }} while(0)
  #define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);}} while(0)
#else
  #define __Pyx_RefNannyDeclarations
  #define __Pyx_RefNannySetupContext(name, acquire_gil)
  #define __Pyx_RefNannyFinishContext()
  #define __Pyx_INCREF(r) Py_INCREF(r)
  #define __Pyx_DECREF(r) Py_DECREF(r)
  #define __Pyx_GOTREF(r)
  #define __Pyx_GIVEREF(r)
  #define __Pyx_XINCREF(r) Py_XINCREF(r)
  #define __Pyx_XDECREF(r) Py_XDECREF(r)
  #define __Pyx_XGOTREF(r)
  #define __Pyx_XGIVEREF(r)
#endif
#define __Pyx_XDECREF_SET(r, v) do {\
        PyObject *tmp = (PyObject *) r;\
        r = v; __Pyx_XDECREF(tmp);\
    } while (0)
#define __Pyx_DECREF_SET(r, v) do {\
        PyObject *tmp = (PyObject *) r;\
        r = v; __Pyx_DECREF(tmp);\
    } while (0)
#define __Pyx_CLEAR(r)    do { PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);} while(0)
#define __Pyx_XCLEAR(r)   do { if((r) != NULL) {PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);}} while(0)

/* PyObjectGetAttrStr.proto */
#if CYTHON_USE_TYPE_SLOTS
static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name);
#else
#define __Pyx_PyObject_GetAttrStr(o,n) PyObject_GetAttr(o,n)
#endif

/* GetBuiltinName.proto */
static PyObject *__Pyx_GetBuiltinName(PyObject *name);

/* PyDictVersioning.proto */
#if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_TYPE_SLOTS
#define __PYX_DICT_VERSION_INIT  ((PY_UINT64_T) -1)
#define __PYX_GET_DICT_VERSION(dict)  (((PyDictObject*)(dict))->ma_version_tag)
#define __PYX_UPDATE_DICT_CACHE(dict, value, cache_var, version_var)\
    (version_var) = __PYX_GET_DICT_VERSION(dict);\
    (cache_var) = (value);
#define __PYX_PY_DICT_LOOKUP_IF_MODIFIED(VAR, DICT, LOOKUP) {\
    static PY_UINT64_T __pyx_dict_version = 0;\
    static PyObject *__pyx_dict_cached_value = NULL;\
    if (likely(__PYX_GET_DICT_VERSION(DICT) == __pyx_dict_version)) {\
        (VAR) = __pyx_dict_cached_value;\
    } else {\
        (VAR) = __pyx_dict_cached_value = (LOOKUP);\
        __pyx_dict_version = __PYX_GET_DICT_VERSION(DICT);\
    }\
}
static CYTHON_INLINE PY_UINT64_T __Pyx_get_tp_dict_version(PyObject *obj);
static CYTHON_INLINE PY_UINT64_T __Pyx_get_object_dict_version(PyObject *obj);
static CYTHON_INLINE int __Pyx_object_dict_version_matches(PyObject* obj, PY_UINT64_T tp_dict_version, PY_UINT64_T obj_dict_version);
#else
#define __PYX_GET_DICT_VERSION(dict)  (0)
#define __PYX_UPDATE_DICT_CACHE(dict, value, cache_var, version_var)
#define __PYX_PY_DICT_LOOKUP_IF_MODIFIED(VAR, DICT, LOOKUP)  (VAR) = (LOOKUP);
#endif

/* GetModuleGlobalName.proto */
#if CYTHON_USE_DICT_VERSIONS
#define __Pyx_GetModuleGlobalName(var, name)  do {\
    static PY_UINT64_T __pyx_dict_version = 0;\
    static PyObject *__pyx_dict_cached_value = NULL;\
    (var) = (likely(__pyx_dict_version == __PYX_GET_DICT_VERSION(__pyx_d))) ?\
        (likely(__pyx_dict_cached_value) ? __Pyx_NewRef(__pyx_dict_cached_value) : __Pyx_GetBuiltinName(name)) :\
        __Pyx__GetModuleGlobalName(name, &__pyx_dict_version, &__pyx_dict_cached_value);\
} while(0)
#define __Pyx_GetModuleGlobalNameUncached(var, name)  do {\
    PY_UINT64_T __pyx_dict_version;\
    PyObject *__pyx_dict_cached_value;\
    (var) = __Pyx__GetModuleGlobalName(name, &__pyx_dict_version, &__pyx_dict_cached_value);\
} while(0)
static PyObject *__Pyx__GetModuleGlobalName(PyObject *name, PY_UINT64_T *dict_version, PyObject **dict_cached_value);
#else
#define __Pyx_GetModuleGlobalName(var, name)  (var) = __Pyx__GetModuleGlobalName(name)
#define __Pyx_GetModuleGlobalNameUncached(var, name)  (var) = __Pyx__GetModuleGlobalName(name)
static CYTHON_INLINE PyObject *__Pyx__GetModuleGlobalName(PyObject *name);
#endif

/* PyObjectCall.proto */
#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw);
#else
#define __Pyx_PyObject_Call(func, arg, kw) PyObject_Call(func, arg, kw)
#endif

/* GetItemInt.proto */
#define __Pyx_GetItemInt(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
    (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
    __Pyx_GetItemInt_Fast(o, (Py_ssize_t)i, is_list, wraparound, boundscheck) :\
    (is_list ? (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL) :\
               __Pyx_GetItemInt_Generic(o, to_py_func(i))))
#define __Pyx_GetItemInt_List(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
    (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
    __Pyx_GetItemInt_List_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) :\
    (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL))
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i,
                                                              int wraparound, int boundscheck);
#define __Pyx_GetItemInt_Tuple(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
    (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
    __Pyx_GetItemInt_Tuple_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) :\
    (PyErr_SetString(PyExc_IndexError, "tuple index out of range"), (PyObject*)NULL))
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i,
                                                              int wraparound, int boundscheck);
static PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j);
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i,
                                                     int is_list, int wraparound, int boundscheck);

/* PyCFunctionFastCall.proto */
#if CYTHON_FAST_PYCCALL
static CYTHON_INLINE PyObject *__Pyx_PyCFunction_FastCall(PyObject *func, PyObject **args, Py_ssize_t nargs);
#else
#define __Pyx_PyCFunction_FastCall(func, args, nargs)  (assert(0), NULL)
#endif

/* PyFunctionFastCall.proto */
#if CYTHON_FAST_PYCALL
#define __Pyx_PyFunction_FastCall(func, args, nargs)\
    __Pyx_PyFunction_FastCallDict((func), (args), (nargs), NULL)
#if 1 || PY_VERSION_HEX < 0x030600B1
static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, Py_ssize_t nargs, PyObject *kwargs);
#else
#define __Pyx_PyFunction_FastCallDict(func, args, nargs, kwargs) _PyFunction_FastCallDict(func, args, nargs, kwargs)
#endif
#define __Pyx_BUILD_ASSERT_EXPR(cond)\
    (sizeof(char [1 - 2*!(cond)]) - 1)
#ifndef Py_MEMBER_SIZE
#define Py_MEMBER_SIZE(type, member) sizeof(((type *)0)->member)
#endif
#if CYTHON_FAST_PYCALL
  static size_t __pyx_pyframe_localsplus_offset = 0;
  #include "frameobject.h"
#if PY_VERSION_HEX >= 0x030b00a6
  #ifndef Py_BUILD_CORE
    #define Py_BUILD_CORE 1
  #endif
  #include "internal/pycore_frame.h"
#endif
  #define __Pxy_PyFrame_Initialize_Offsets()\
    ((void)__Pyx_BUILD_ASSERT_EXPR(sizeof(PyFrameObject) == offsetof(PyFrameObject, f_localsplus) + Py_MEMBER_SIZE(PyFrameObject, f_localsplus)),\
     (void)(__pyx_pyframe_localsplus_offset = ((size_t)PyFrame_Type.tp_basicsize) - Py_MEMBER_SIZE(PyFrameObject, f_localsplus)))
  #define __Pyx_PyFrame_GetLocalsplus(frame)\
    (assert(__pyx_pyframe_localsplus_offset), (PyObject **)(((char *)(frame)) + __pyx_pyframe_localsplus_offset))
#endif // CYTHON_FAST_PYCALL
#endif

/* PyObjectCall2Args.proto */
static CYTHON_UNUSED PyObject* __Pyx_PyObject_Call2Args(PyObject* function, PyObject* arg1, PyObject* arg2);

/* PyObjectCallMethO.proto */
#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg);
#endif

/* PyObjectCallOneArg.proto */
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg);

/* PyObjectCallNoArg.proto */
#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func);
#else
#define __Pyx_PyObject_CallNoArg(func) __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL)
#endif

/* SliceObject.proto */
static CYTHON_INLINE PyObject* __Pyx_PyObject_GetSlice(
        PyObject* obj, Py_ssize_t cstart, Py_ssize_t cstop,
        PyObject** py_start, PyObject** py_stop, PyObject** py_slice,
        int has_cstart, int has_cstop, int wraparound);

/* IncludeStringH.proto */
#include <string.h>

/* BytesEquals.proto */
static CYTHON_INLINE int __Pyx_PyBytes_Equals(PyObject* s1, PyObject* s2, int equals);

/* UnicodeEquals.proto */
static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int equals);

/* RaiseDoubleKeywords.proto */
static void __Pyx_RaiseDoubleKeywordsError(const char* func_name, PyObject* kw_name);

/* ParseKeywords.proto */
static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[],\
    PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args,\
    const char* function_name);

/* RaiseArgTupleInvalid.proto */
static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact,
    Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found);

/* PyThreadStateGet.proto */
#if CYTHON_FAST_THREAD_STATE
#define __Pyx_PyThreadState_declare  PyThreadState *__pyx_tstate;
#define __Pyx_PyThreadState_assign  __pyx_tstate = __Pyx_PyThreadState_Current;
#define __Pyx_PyErr_Occurred()  __pyx_tstate->curexc_type
#else
#define __Pyx_PyThreadState_declare
#define __Pyx_PyThreadState_assign
#define __Pyx_PyErr_Occurred()  PyErr_Occurred()
#endif

/* PyErrFetchRestore.proto */
#if CYTHON_FAST_THREAD_STATE
#define __Pyx_PyErr_Clear() __Pyx_ErrRestore(NULL, NULL, NULL)
#define __Pyx_ErrRestoreWithState(type, value, tb)  __Pyx_ErrRestoreInState(PyThreadState_GET(), type, value, tb)
#define __Pyx_ErrFetchWithState(type, value, tb)    __Pyx_ErrFetchInState(PyThreadState_GET(), type, value, tb)
#define __Pyx_ErrRestore(type, value, tb)  __Pyx_ErrRestoreInState(__pyx_tstate, type, value, tb)
#define __Pyx_ErrFetch(type, value, tb)    __Pyx_ErrFetchInState(__pyx_tstate, type, value, tb)
static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb);
static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
#if CYTHON_COMPILING_IN_CPYTHON
#define __Pyx_PyErr_SetNone(exc) (Py_INCREF(exc), __Pyx_ErrRestore((exc), NULL, NULL))
#else
#define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc)
#endif
#else
#define __Pyx_PyErr_Clear() PyErr_Clear()
#define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc)
#define __Pyx_ErrRestoreWithState(type, value, tb)  PyErr_Restore(type, value, tb)
#define __Pyx_ErrFetchWithState(type, value, tb)  PyErr_Fetch(type, value, tb)
#define __Pyx_ErrRestoreInState(tstate, type, value, tb)  PyErr_Restore(type, value, tb)
#define __Pyx_ErrFetchInState(tstate, type, value, tb)  PyErr_Fetch(type, value, tb)
#define __Pyx_ErrRestore(type, value, tb)  PyErr_Restore(type, value, tb)
#define __Pyx_ErrFetch(type, value, tb)  PyErr_Fetch(type, value, tb)
#endif

/* RaiseException.proto */
static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause);

/* PyFloatBinop.proto */
#if !CYTHON_COMPILING_IN_PYPY
static PyObject* __Pyx_PyFloat_TrueDivideCObj(PyObject *op1, PyObject *op2, double floatval, int inplace, int zerodivision_check);
#else
#define __Pyx_PyFloat_TrueDivideCObj(op1, op2, floatval, inplace, zerodivision_check)\
    (inplace ? PyNumber_InPlaceTrueDivide(op1, op2) : PyNumber_TrueDivide(op1, op2))
#endif

/* PyObjectSetAttrStr.proto */
#if CYTHON_USE_TYPE_SLOTS
#define __Pyx_PyObject_DelAttrStr(o,n) __Pyx_PyObject_SetAttrStr(o, n, NULL)
static CYTHON_INLINE int __Pyx_PyObject_SetAttrStr(PyObject* obj, PyObject* attr_name, PyObject* value);
#else
#define __Pyx_PyObject_DelAttrStr(o,n)   PyObject_DelAttr(o,n)
#define __Pyx_PyObject_SetAttrStr(o,n,v) PyObject_SetAttr(o,n,v)
#endif

/* PySequenceContains.proto */
static CYTHON_INLINE int __Pyx_PySequence_ContainsTF(PyObject* item, PyObject* seq, int eq) {
    int result = PySequence_Contains(seq, item);
    return unlikely(result < 0) ? result : (result == (eq == Py_EQ));
}

/* GetTopmostException.proto */
#if CYTHON_USE_EXC_INFO_STACK
static _PyErr_StackItem * __Pyx_PyErr_GetTopmostException(PyThreadState *tstate);
#endif

/* SaveResetException.proto */
#if CYTHON_FAST_THREAD_STATE
#define __Pyx_ExceptionSave(type, value, tb)  __Pyx__ExceptionSave(__pyx_tstate, type, value, tb)
static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
#define __Pyx_ExceptionReset(type, value, tb)  __Pyx__ExceptionReset(__pyx_tstate, type, value, tb)
static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb);
#else
#define __Pyx_ExceptionSave(type, value, tb)   PyErr_GetExcInfo(type, value, tb)
#define __Pyx_ExceptionReset(type, value, tb)  PyErr_SetExcInfo(type, value, tb)
#endif

/* PyErrExceptionMatches.proto */
#if CYTHON_FAST_THREAD_STATE
#define __Pyx_PyErr_ExceptionMatches(err) __Pyx_PyErr_ExceptionMatchesInState(__pyx_tstate, err)
static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err);
#else
#define __Pyx_PyErr_ExceptionMatches(err)  PyErr_ExceptionMatches(err)
#endif

/* GetException.proto */
#if CYTHON_FAST_THREAD_STATE
#define __Pyx_GetException(type, value, tb)  __Pyx__GetException(__pyx_tstate, type, value, tb)
static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
#else
static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb);
#endif

/* SwapException.proto */
#if CYTHON_FAST_THREAD_STATE
#define __Pyx_ExceptionSwap(type, value, tb)  __Pyx__ExceptionSwap(__pyx_tstate, type, value, tb)
static CYTHON_INLINE void __Pyx__ExceptionSwap(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
#else
static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb);
#endif

/* GetAttr.proto */
static CYTHON_INLINE PyObject *__Pyx_GetAttr(PyObject *, PyObject *);

/* HasAttr.proto */
static CYTHON_INLINE int __Pyx_HasAttr(PyObject *, PyObject *);

/* None.proto */
static CYTHON_INLINE void __Pyx_RaiseClosureNameError(const char *varname);

/* FetchCommonType.proto */
static PyTypeObject* __Pyx_FetchCommonType(PyTypeObject* type);

/* CythonFunctionShared.proto */
#define __Pyx_CyFunction_USED 1
#define __Pyx_CYFUNCTION_STATICMETHOD  0x01
#define __Pyx_CYFUNCTION_CLASSMETHOD   0x02
#define __Pyx_CYFUNCTION_CCLASS        0x04
#define __Pyx_CyFunction_GetClosure(f)\
    (((__pyx_CyFunctionObject *) (f))->func_closure)
#define __Pyx_CyFunction_GetClassObj(f)\
    (((__pyx_CyFunctionObject *) (f))->func_classobj)
#define __Pyx_CyFunction_Defaults(type, f)\
    ((type *)(((__pyx_CyFunctionObject *) (f))->defaults))
#define __Pyx_CyFunction_SetDefaultsGetter(f, g)\
    ((__pyx_CyFunctionObject *) (f))->defaults_getter = (g)
typedef struct {
    PyCFunctionObject func;
#if PY_VERSION_HEX < 0x030500A0
    PyObject *func_weakreflist;
#endif
    PyObject *func_dict;
    PyObject *func_name;
    PyObject *func_qualname;
    PyObject *func_doc;
    PyObject *func_globals;
    PyObject *func_code;
    PyObject *func_closure;
    PyObject *func_classobj;
    void *defaults;
    int defaults_pyobjects;
    size_t defaults_size;  // used by FusedFunction for copying defaults
    int flags;
    PyObject *defaults_tuple;
    PyObject *defaults_kwdict;
    PyObject *(*defaults_getter)(PyObject *);
    PyObject *func_annotations;
} __pyx_CyFunctionObject;
static PyTypeObject *__pyx_CyFunctionType = 0;
#define __Pyx_CyFunction_Check(obj)  (__Pyx_TypeCheck(obj, __pyx_CyFunctionType))
static PyObject *__Pyx_CyFunction_Init(__pyx_CyFunctionObject* op, PyMethodDef *ml,
                                      int flags, PyObject* qualname,
                                      PyObject *self,
                                      PyObject *module, PyObject *globals,
                                      PyObject* code);
static CYTHON_INLINE void *__Pyx_CyFunction_InitDefaults(PyObject *m,
                                                         size_t size,
                                                         int pyobjects);
static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsTuple(PyObject *m,
                                                            PyObject *tuple);
static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsKwDict(PyObject *m,
                                                             PyObject *dict);
static CYTHON_INLINE void __Pyx_CyFunction_SetAnnotationsDict(PyObject *m,
                                                              PyObject *dict);
static int __pyx_CyFunction_init(void);

/* CythonFunction.proto */
static PyObject *__Pyx_CyFunction_New(PyMethodDef *ml,
                                      int flags, PyObject* qualname,
                                      PyObject *closure,
                                      PyObject *module, PyObject *globals,
                                      PyObject* code);

/* ObjectGetItem.proto */
#if CYTHON_USE_TYPE_SLOTS
static CYTHON_INLINE PyObject *__Pyx_PyObject_GetItem(PyObject *obj, PyObject* key);
#else
#define __Pyx_PyObject_GetItem(obj, key)  PyObject_GetItem(obj, key)
#endif

/* GetAttr3.proto */
static CYTHON_INLINE PyObject *__Pyx_GetAttr3(PyObject *, PyObject *, PyObject *);

/* ExtTypeTest.proto */
static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type);

/* WriteUnraisableException.proto */
static void __Pyx_WriteUnraisable(const char *name, int clineno,
                                  int lineno, const char *filename,
                                  int full_traceback, int nogil);

/* DivInt[Py_ssize_t].proto */
static CYTHON_INLINE Py_ssize_t __Pyx_div_Py_ssize_t(Py_ssize_t, Py_ssize_t);

/* UnaryNegOverflows.proto */
#define UNARY_NEG_WOULD_OVERFLOW(x)\
        (((x) < 0) & ((unsigned long)(x) == 0-(unsigned long)(x)))

/* ListAppend.proto */
#if CYTHON_USE_PYLIST_INTERNALS && CYTHON_ASSUME_SAFE_MACROS
static CYTHON_INLINE int __Pyx_PyList_Append(PyObject* list, PyObject* x) {
    PyListObject* L = (PyListObject*) list;
    Py_ssize_t len = Py_SIZE(list);
    if (likely(L->allocated > len) & likely(len > (L->allocated >> 1))) {
        Py_INCREF(x);
        PyList_SET_ITEM(list, len, x);
        __Pyx_SET_SIZE(list, len + 1);
        return 0;
    }
    return PyList_Append(list, x);
}
#else
#define __Pyx_PyList_Append(L,x) PyList_Append(L,x)
#endif

/* PyObjectGetMethod.proto */
static int __Pyx_PyObject_GetMethod(PyObject *obj, PyObject *name, PyObject **method);

/* PyObjectCallMethod1.proto */
static PyObject* __Pyx_PyObject_CallMethod1(PyObject* obj, PyObject* method_name, PyObject* arg);

/* append.proto */
static CYTHON_INLINE int __Pyx_PyObject_Append(PyObject* L, PyObject* x);

/* ListCompAppend.proto */
#if CYTHON_USE_PYLIST_INTERNALS && CYTHON_ASSUME_SAFE_MACROS
static CYTHON_INLINE int __Pyx_ListComp_Append(PyObject* list, PyObject* x) {
    PyListObject* L = (PyListObject*) list;
    Py_ssize_t len = Py_SIZE(list);
    if (likely(L->allocated > len)) {
        Py_INCREF(x);
        PyList_SET_ITEM(list, len, x);
        __Pyx_SET_SIZE(list, len + 1);
        return 0;
    }
    return PyList_Append(list, x);
}
#else
#define __Pyx_ListComp_Append(L,x) PyList_Append(L,x)
#endif

/* PyIntBinop.proto */
#if !CYTHON_COMPILING_IN_PYPY
static PyObject* __Pyx_PyInt_AddObjC(PyObject *op1, PyObject *op2, long intval, int inplace, int zerodivision_check);
#else
#define __Pyx_PyInt_AddObjC(op1, op2, intval, inplace, zerodivision_check)\
    (inplace ? PyNumber_InPlaceAdd(op1, op2) : PyNumber_Add(op1, op2))
#endif

/* RaiseTooManyValuesToUnpack.proto */
static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected);

/* RaiseNeedMoreValuesToUnpack.proto */
static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index);

/* IterFinish.proto */
static CYTHON_INLINE int __Pyx_IterFinish(void);

/* UnpackItemEndCheck.proto */
static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected);

/* PyIntFromDouble.proto */
#if PY_MAJOR_VERSION < 3
static CYTHON_INLINE PyObject* __Pyx_PyInt_FromDouble(double value);
#else
#define __Pyx_PyInt_FromDouble(value) PyLong_FromDouble(value)
#endif

/* IterNext.proto */
#define __Pyx_PyIter_Next(obj) __Pyx_PyIter_Next2(obj, NULL)
static CYTHON_INLINE PyObject *__Pyx_PyIter_Next2(PyObject *, PyObject *);

/* PyIntBinop.proto */
#if !CYTHON_COMPILING_IN_PYPY
static PyObject* __Pyx_PyInt_SubtractObjC(PyObject *op1, PyObject *op2, long intval, int inplace, int zerodivision_check);
#else
#define __Pyx_PyInt_SubtractObjC(op1, op2, intval, inplace, zerodivision_check)\
    (inplace ? PyNumber_InPlaceSubtract(op1, op2) : PyNumber_Subtract(op1, op2))
#endif

/* PyIntCompare.proto */
static CYTHON_INLINE PyObject* __Pyx_PyInt_EqObjC(PyObject *op1, PyObject *op2, long intval, long inplace);

/* PyIntBinop.proto */
#if !CYTHON_COMPILING_IN_PYPY
static PyObject* __Pyx_PyInt_RemainderObjC(PyObject *op1, PyObject *op2, long intval, int inplace, int zerodivision_check);
#else
#define __Pyx_PyInt_RemainderObjC(op1, op2, intval, inplace, zerodivision_check)\
    (inplace ? PyNumber_InPlaceRemainder(op1, op2) : PyNumber_Remainder(op1, op2))
#endif

/* PyIntBinop.proto */
#if !CYTHON_COMPILING_IN_PYPY
static PyObject* __Pyx_PyInt_TrueDivideObjC(PyObject *op1, PyObject *op2, long intval, int inplace, int zerodivision_check);
#else
#define __Pyx_PyInt_TrueDivideObjC(op1, op2, intval, inplace, zerodivision_check)\
    (inplace ? PyNumber_InPlaceTrueDivide(op1, op2) : PyNumber_TrueDivide(op1, op2))
#endif

/* PyIntBinop.proto */
#if !CYTHON_COMPILING_IN_PYPY
static PyObject* __Pyx_PyInt_SubtractCObj(PyObject *op1, PyObject *op2, long intval, int inplace, int zerodivision_check);
#else
#define __Pyx_PyInt_SubtractCObj(op1, op2, intval, inplace, zerodivision_check)\
    (inplace ? PyNumber_InPlaceSubtract(op1, op2) : PyNumber_Subtract(op1, op2))
#endif

/* Import.proto */
static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level);

/* ImportFrom.proto */
static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name);

/* PyObject_GenericGetAttrNoDict.proto */
#if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
static CYTHON_INLINE PyObject* __Pyx_PyObject_GenericGetAttrNoDict(PyObject* obj, PyObject* attr_name);
#else
#define __Pyx_PyObject_GenericGetAttrNoDict PyObject_GenericGetAttr
#endif

/* PyObject_GenericGetAttr.proto */
#if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
static PyObject* __Pyx_PyObject_GenericGetAttr(PyObject* obj, PyObject* attr_name);
#else
#define __Pyx_PyObject_GenericGetAttr PyObject_GenericGetAttr
#endif

/* PyObjectGetAttrStrNoError.proto */
static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStrNoError(PyObject* obj, PyObject* attr_name);

/* SetupReduce.proto */
static int __Pyx_setup_reduce(PyObject* type_obj);

/* SetVTable.proto */
static int __Pyx_SetVtable(PyObject *dict, void *vtable);

/* CalculateMetaclass.proto */
static PyObject *__Pyx_CalculateMetaclass(PyTypeObject *metaclass, PyObject *bases);

/* SetNameInClass.proto */
#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1
#define __Pyx_SetNameInClass(ns, name, value)\
    (likely(PyDict_CheckExact(ns)) ? _PyDict_SetItem_KnownHash(ns, name, value, ((PyASCIIObject *) name)->hash) : PyObject_SetItem(ns, name, value))
#elif CYTHON_COMPILING_IN_CPYTHON
#define __Pyx_SetNameInClass(ns, name, value)\
    (likely(PyDict_CheckExact(ns)) ? PyDict_SetItem(ns, name, value) : PyObject_SetItem(ns, name, value))
#else
#define __Pyx_SetNameInClass(ns, name, value)  PyObject_SetItem(ns, name, value)
#endif

/* Py3ClassCreate.proto */
static PyObject *__Pyx_Py3MetaclassPrepare(PyObject *metaclass, PyObject *bases, PyObject *name, PyObject *qualname,
                                           PyObject *mkw, PyObject *modname, PyObject *doc);
static PyObject *__Pyx_Py3ClassCreate(PyObject *metaclass, PyObject *name, PyObject *bases, PyObject *dict,
                                      PyObject *mkw, int calculate_metaclass, int allow_py2_metaclass);

/* ClassMethod.proto */
#include "descrobject.h"
static CYTHON_UNUSED PyObject* __Pyx_Method_ClassMethod(PyObject *method);

/* CLineInTraceback.proto */
#ifdef CYTHON_CLINE_IN_TRACEBACK
#define __Pyx_CLineForTraceback(tstate, c_line)  (((CYTHON_CLINE_IN_TRACEBACK)) ? c_line : 0)
#else
static int __Pyx_CLineForTraceback(PyThreadState *tstate, int c_line);
#endif

/* CodeObjectCache.proto */
typedef struct {
    PyCodeObject* code_object;
    int code_line;
} __Pyx_CodeObjectCacheEntry;
struct __Pyx_CodeObjectCache {
    int count;
    int max_count;
    __Pyx_CodeObjectCacheEntry* entries;
};
static struct __Pyx_CodeObjectCache __pyx_code_cache = {0,0,NULL};
static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line);
static PyCodeObject *__pyx_find_code_object(int code_line);
static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object);

/* AddTraceback.proto */
static void __Pyx_AddTraceback(const char *funcname, int c_line,
                               int py_line, const char *filename);

/* GCCDiagnostics.proto */
#if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6))
#define __Pyx_HAS_GCC_DIAGNOSTIC
#endif

/* CIntToPy.proto */
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int64_t(int64_t value);

/* CIntFromPy.proto */
static CYTHON_INLINE int64_t __Pyx_PyInt_As_int64_t(PyObject *);

/* CIntFromPy.proto */
static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *);

/* CIntToPy.proto */
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value);

/* CIntFromPy.proto */
static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *);

/* FastTypeChecks.proto */
#if CYTHON_COMPILING_IN_CPYTHON
#define __Pyx_TypeCheck(obj, type) __Pyx_IsSubtype(Py_TYPE(obj), (PyTypeObject *)type)
static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b);
static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject *type);
static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *type1, PyObject *type2);
#else
#define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type)
#define __Pyx_PyErr_GivenExceptionMatches(err, type) PyErr_GivenExceptionMatches(err, type)
#define __Pyx_PyErr_GivenExceptionMatches2(err, type1, type2) (PyErr_GivenExceptionMatches(err, type1) || PyErr_GivenExceptionMatches(err, type2))
#endif
#define __Pyx_PyException_Check(obj) __Pyx_TypeCheck(obj, PyExc_Exception)

/* CStringEquals.proto */
static CYTHON_INLINE int __Pyx_StrEq(const char *, const char *);

/* CheckBinaryVersion.proto */
static int __Pyx_check_binary_version(void);

/* FunctionExport.proto */
static int __Pyx_ExportFunction(const char *name, void (*f)(void), const char *sig);

/* InitStrings.proto */
static int __Pyx_InitStrings(__Pyx_StringTabEntry *t);

static int __pyx_f_11apache_beam_10transforms_5stats_14_QuantileState_is_empty(struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileState *__pyx_v_self, int __pyx_skip_dispatch); /* proto*/
static PyObject *__pyx_f_11apache_beam_10transforms_5stats_14_QuantileState__add_unbuffered(struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileState *__pyx_v_self, PyObject *__pyx_v_elements, PyObject *__pyx_v_offset_fn, int __pyx_skip_dispatch); /* proto*/
static PyObject *__pyx_f_11apache_beam_10transforms_5stats_14_QuantileState__add_unbuffered_weighted(struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileState *__pyx_v_self, PyObject *__pyx_v_elements, PyObject *__pyx_v_offset_fn, int __pyx_skip_dispatch); /* proto*/
static PyObject *__pyx_f_11apache_beam_10transforms_5stats_14_QuantileState_finalize(struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileState *__pyx_v_self, int __pyx_skip_dispatch); /* proto*/
static PyObject *__pyx_f_11apache_beam_10transforms_5stats_14_QuantileState_collapse_if_needed(struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileState *__pyx_v_self, PyObject *__pyx_v_offset_fn, int __pyx_skip_dispatch); /* proto*/

/* Module declarations from 'cython' */

/* Module declarations from 'libc.stdint' */

/* Module declarations from 'apache_beam.transforms.stats' */
static PyTypeObject *__pyx_ptype_11apache_beam_10transforms_5stats__QuantileSpec = 0;
static PyTypeObject *__pyx_ptype_11apache_beam_10transforms_5stats__QuantileBuffer = 0;
static PyTypeObject *__pyx_ptype_11apache_beam_10transforms_5stats__QuantileState = 0;
static PyTypeObject *__pyx_ptype_11apache_beam_10transforms_5stats___pyx_scope_struct____init__ = 0;
static PyTypeObject *__pyx_ptype_11apache_beam_10transforms_5stats___pyx_scope_struct_1_get_argsort_key = 0;
static struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileBuffer *__pyx_f_11apache_beam_10transforms_5stats__collapse(PyObject *, PyObject *, struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileSpec *); /*proto*/
static PyObject *__pyx_f_11apache_beam_10transforms_5stats__interpolate(PyObject *, int64_t, double, double, struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileSpec *); /*proto*/
static PyObject *__pyx_f_11apache_beam_10transforms_5stats___pyx_unpickle__QuantileBuffer__set_state(struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileBuffer *, PyObject *); /*proto*/
#define __Pyx_MODULE_NAME "apache_beam.transforms.stats"
extern int __pyx_module_is_main_apache_beam__transforms__stats;
int __pyx_module_is_main_apache_beam__transforms__stats = 0;

/* Implementation of 'apache_beam.transforms.stats' */
static PyObject *__pyx_builtin_ImportError;
static PyObject *__pyx_builtin_object;
static PyObject *__pyx_builtin_staticmethod;
static PyObject *__pyx_builtin_ValueError;
static PyObject *__pyx_builtin_round;
static PyObject *__pyx_builtin_RuntimeError;
static PyObject *__pyx_builtin_zip;
static PyObject *__pyx_builtin_range;
static PyObject *__pyx_builtin_sorted;
static PyObject *__pyx_builtin_sum;
static PyObject *__pyx_builtin_StopIteration;
static const char __pyx_k_K[] = "K";
static const char __pyx_k_T[] = "T";
static const char __pyx_k_V[] = "V";
static const char __pyx_k_a[] = "a";
static const char __pyx_k_b[] = "b";
static const char __pyx_k_e[] = "e";
static const char __pyx_k_i[] = "i";
static const char __pyx_k_k[] = "k";
static const char __pyx_k__3[] = "*";
static const char __pyx_k_qs[] = "_qs";
static const char __pyx_k_Any[] = "Any";
static const char __pyx_k_add[] = "add";
static const char __pyx_k_all[] = "__all__";
static const char __pyx_k_cls[] = "cls";
static const char __pyx_k_doc[] = "__doc__";
static const char __pyx_k_est[] = "est";
static const char __pyx_k_key[] = "key";
static const char __pyx_k_md5[] = "md5";
static const char __pyx_k_new[] = "__new__";
static const char __pyx_k_pow[] = "pow";
static const char __pyx_k_sum[] = "sum";
static const char __pyx_k_zip[] = "zip";
static const char __pyx_k_List[] = "List";
static const char __pyx_k__102[] = "_";
static const char __pyx_k_args[] = "args";
static const char __pyx_k_ceil[] = "ceil";
static const char __pyx_k_dict[] = "__dict__";
static const char __pyx_k_init[] = "__init__";
static const char __pyx_k_main[] = "__main__";
static const char __pyx_k_math[] = "math";
static const char __pyx_k_mmh3[] = "mmh3";
static const char __pyx_k_name[] = "__name__";
static const char __pyx_k_qs_2[] = "qs";
static const char __pyx_k_seed[] = "seed";
static const char __pyx_k_self[] = "self";
static const char __pyx_k_size[] = "size";
static const char __pyx_k_sort[] = "sort";
static const char __pyx_k_spec[] = "spec";
static const char __pyx_k_step[] = "step";
static const char __pyx_k_temp[] = "temp";
static const char __pyx_k_test[] = "__test__";
static const char __pyx_k_Tuple[] = "Tuple";
static const char __pyx_k_Union[] = "Union";
static const char __pyx_k_chain[] = "chain";
static const char __pyx_k_class[] = "__class__";
static const char __pyx_k_coder[] = "coder";
static const char __pyx_k_error[] = "error";
static const char __pyx_k_heapq[] = "heapq";
static const char __pyx_k_key_2[] = "_key";
static const char __pyx_k_label[] = "label";
static const char __pyx_k_level[] = "level";
static const char __pyx_k_log1p[] = "log1p";
static const char __pyx_k_pcoll[] = "pcoll";
static const char __pyx_k_range[] = "range";
static const char __pyx_k_round[] = "round";
static const char __pyx_k_state[] = "state";
static const char __pyx_k_value[] = "value";
static const char __pyx_k_PerKey[] = "PerKey";
static const char __pyx_k_append[] = "append";
static const char __pyx_k_coders[] = "coders";
static const char __pyx_k_create[] = "create";
static const char __pyx_k_dict_2[] = "_dict";
static const char __pyx_k_encode[] = "encode";
static const char __pyx_k_expand[] = "expand";
static const char __pyx_k_extend[] = "extend";
static const char __pyx_k_hash64[] = "hash64";
static const char __pyx_k_import[] = "__import__";
static const char __pyx_k_kwargs[] = "kwargs";
static const char __pyx_k_module[] = "__module__";
static const char __pyx_k_object[] = "object";
static const char __pyx_k_offset[] = "_offset";
static const char __pyx_k_pickle[] = "pickle";
static const char __pyx_k_reduce[] = "__reduce__";
static const char __pyx_k_remove[] = "remove";
static const char __pyx_k_repeat[] = "repeat";
static const char __pyx_k_signed[] = "signed";
static const char __pyx_k_sorted[] = "sorted";
static const char __pyx_k_spec_2[] = "_spec";
static const char __pyx_k_typing[] = "typing";
static const char __pyx_k_update[] = "update";
static const char __pyx_k_TypeVar[] = "TypeVar";
static const char __pyx_k_buffers[] = "buffers";
static const char __pyx_k_coder_2[] = "_coder";
static const char __pyx_k_element[] = "element";
static const char __pyx_k_epsilon[] = "epsilon";
static const char __pyx_k_est_err[] = "est_err";
static const char __pyx_k_getitem[] = "__getitem__";
static const char __pyx_k_hash_fn[] = "_hash_fn";
static const char __pyx_k_hashlib[] = "hashlib";
static const char __pyx_k_heapify[] = "heapify";
static const char __pyx_k_heappop[] = "heappop";
static const char __pyx_k_logging[] = "logging";
static const char __pyx_k_max_val[] = "max_val";
static const char __pyx_k_min_val[] = "min_val";
static const char __pyx_k_prepare[] = "__prepare__";
static const char __pyx_k_reverse[] = "reverse";
static const char __pyx_k_warning[] = "warning";
static const char __pyx_k_weights[] = "weights";
static const char __pyx_k_Callable[] = "Callable";
static const char __pyx_k_Globally[] = "Globally";
static const char __pyx_k_Sequence[] = "Sequence";
static const char __pyx_k_elements[] = "elements";
static const char __pyx_k_finalize[] = "finalize";
static const char __pyx_k_getstate[] = "__getstate__";
static const char __pyx_k_heappush[] = "heappush";
static const char __pyx_k_is_empty[] = "is_empty";
static const char __pyx_k_md5_hash[] = "_md5_hash";
static const char __pyx_k_min_hash[] = "_min_hash";
static const char __pyx_k_offset_2[] = "offset";
static const char __pyx_k_pyx_type[] = "__pyx_type";
static const char __pyx_k_qualname[] = "__qualname__";
static const char __pyx_k_registry[] = "registry";
static const char __pyx_k_setstate[] = "__setstate__";
static const char __pyx_k_weighted[] = "weighted";
static const char __pyx_k_CombineFn[] = "CombineFn";
static const char __pyx_k_add_input[] = "add_input";
static const char __pyx_k_all_elems[] = "all_elems";
static const char __pyx_k_get_coder[] = "get_coder";
static const char __pyx_k_hexdigest[] = "hexdigest";
static const char __pyx_k_itertools[] = "itertools";
static const char __pyx_k_metaclass[] = "__metaclass__";
static const char __pyx_k_mmh3_hash[] = "_mmh3_hash";
static const char __pyx_k_offset_fn[] = "offset_fn";
static const char __pyx_k_pyx_state[] = "__pyx_state";
static const char __pyx_k_quantiles[] = "quantiles";
static const char __pyx_k_reduce_ex[] = "__reduce_ex__";
static const char __pyx_k_reverse_2[] = "_reverse";
static const char __pyx_k_typehints[] = "typehints";
static const char __pyx_k_PTransform[] = "PTransform";
static const char __pyx_k_ValueError[] = "ValueError";
static const char __pyx_k_add_inputs[] = "_add_inputs";
static const char __pyx_k_new_weight[] = "new_weight";
static const char __pyx_k_pyx_result[] = "__pyx_result";
static const char __pyx_k_pyx_vtable[] = "__pyx_vtable__";
static const char __pyx_k_sample_set[] = "_sample_set";
static const char __pyx_k_typecoders[] = "typecoders";
static const char __pyx_k_weighted_2[] = "_weighted";
static const char __pyx_k_ImportError[] = "ImportError";
static const char __pyx_k_Is_Reversed[] = "Is Reversed";
static const char __pyx_k_Is_Weighted[] = "Is Weighted";
static const char __pyx_k_PickleError[] = "PickleError";
static const char __pyx_k_accumulator[] = "accumulator";
static const char __pyx_k_apache_beam[] = "apache_beam";
static const char __pyx_k_buffer_elem[] = "buffer_elem";
static const char __pyx_k_buffer_size[] = "buffer_size";
static const char __pyx_k_num_buffers[] = "num_buffers";
static const char __pyx_k_sample_heap[] = "_sample_heap";
static const char __pyx_k_sample_size[] = "_sample_size";
static const char __pyx_k_QuantileSpec[] = "_QuantileSpec";
static const char __pyx_k_RuntimeError[] = "RuntimeError";
static const char __pyx_k_accumulators[] = "accumulators";
static const char __pyx_k_display_data[] = "_display_data";
static const char __pyx_k_get_estimate[] = "get_estimate";
static const char __pyx_k_hashed_value[] = "hashed_value";
static const char __pyx_k_pyx_checksum[] = "__pyx_checksum";
static const char __pyx_k_staticmethod[] = "staticmethod";
static const char __pyx_k_stringsource[] = "stringsource";
static const char __pyx_k_total_weight[] = "total_weight";
static const char __pyx_k_use_setstate[] = "use_setstate";
static const char __pyx_k_CombinePerKey[] = "CombinePerKey";
static const char __pyx_k_LargestUnique[] = "_LargestUnique";
static const char __pyx_k_QuantileState[] = "_QuantileState";
static const char __pyx_k_StopIteration[] = "StopIteration";
static const char __pyx_k_from_iterable[] = "from_iterable";
static const char __pyx_k_input_batched[] = "input_batched";
static const char __pyx_k_num_quantiles[] = "num_quantiles";
static const char __pyx_k_offset_jitter[] = "_offset_jitter";
static const char __pyx_k_reduce_cython[] = "__reduce_cython__";
static const char __pyx_k_sample_size_2[] = "sample_size";
static const char __pyx_k_QuantileBuffer[] = "_QuantileBuffer";
static const char __pyx_k_Quantile_Count[] = "Quantile Count";
static const char __pyx_k_add_unbuffered[] = "_add_unbuffered";
static const char __pyx_k_display_data_2[] = "display_data";
static const char __pyx_k_extract_output[] = "extract_output";
static const char __pyx_k_quantile_state[] = "quantile_state";
static const char __pyx_k_CombineGlobally[] = "CombineGlobally";
static const char __pyx_k_DisplayDataItem[] = "DisplayDataItem";
static const char __pyx_k_HASH_SPACE_SIZE[] = "_HASH_SPACE_SIZE";
static const char __pyx_k_default_hash_fn[] = "_default_hash_fn";
static const char __pyx_k_get_argsort_key[] = "get_argsort_key";
static const char __pyx_k_input_batched_2[] = "_input_batched";
static const char __pyx_k_num_quantiles_2[] = "_num_quantiles";
static const char __pyx_k_pyx_PickleError[] = "__pyx_PickleError";
static const char __pyx_k_setstate_cython[] = "__setstate_cython__";
static const char __pyx_k_Is_Input_Batched[] = "Is Input Batched";
static const char __pyx_k_MAX_NUM_ELEMENTS[] = "_MAX_NUM_ELEMENTS";
static const char __pyx_k_NO_VALUE_ERR_MSG[] = "_NO_VALUE_ERR_MSG";
static const char __pyx_k_add_unbuffered_2[] = "add_unbuffered";
static const char __pyx_k_max_num_elements[] = "max_num_elements";
static const char __pyx_k_with_input_types[] = "with_input_types";
static const char __pyx_k_ApproximateUnique[] = "ApproximateUnique";
static const char __pyx_k_LargestUnique_add[] = "_LargestUnique.add";
static const char __pyx_k_sample_space_size[] = "sample_space_size";
static const char __pyx_k_with_output_types[] = "with_output_types";
static const char __pyx_k_INPUT_SIZE_ERR_MSG[] = "_INPUT_SIZE_ERR_MSG";
static const char __pyx_k_cline_in_traceback[] = "cline_in_traceback";
static const char __pyx_k_collapse_if_needed[] = "collapse_if_needed";
static const char __pyx_k_create_accumulator[] = "create_accumulator";
static const char __pyx_k_merge_accumulators[] = "merge_accumulators";
static const char __pyx_k_merged_accumulator[] = "merged_accumulator";
static const char __pyx_k_parse_input_params[] = "parse_input_params";
static const char __pyx_k_unbuffered_weights[] = "unbuffered_weights";
static const char __pyx_k_INPUT_ERROR_ERR_MSG[] = "_INPUT_ERROR_ERR_MSG";
static const char __pyx_k_MULTI_VALUE_ERR_MSG[] = "_MULTI_VALUE_ERR_MSG";
static const char __pyx_k_Record_Comparer_Key[] = "Record Comparer Key";
static const char __pyx_k_Runtime_exception_s[] = "Runtime exception: %s";
static const char __pyx_k_get_default_hash_fn[] = "_get_default_hash_fn";
static const char __pyx_k_unbuffered_elements[] = "unbuffered_elements";
static const char __pyx_k_ApproximateQuantiles[] = "ApproximateQuantiles";
static const char __pyx_k_LargestUnique___init[] = "_LargestUnique.__init__";
static const char __pyx_k_default_hash_fn_type[] = "_default_hash_fn_type";
static const char __pyx_k_init___locals_lambda[] = "__init__.<locals>.<lambda>";
static const char __pyx_k_verify_deterministic[] = "verify_deterministic";
static const char __pyx_k_QuantileSpec___reduce[] = "_QuantileSpec.__reduce__";
static const char __pyx_k_QuantileState___reduce[] = "_QuantileState.__reduce__";
static const char __pyx_k_QuantileState_finalize[] = "_QuantileState.finalize";
static const char __pyx_k_QuantileState_is_empty[] = "_QuantileState.is_empty";
static const char __pyx_k_CountGlobalUniqueValues[] = "CountGlobalUniqueValues";
static const char __pyx_k_CountPerKeyUniqueValues[] = "CountPerKeyUniqueValues";
static const char __pyx_k_add_unbuffered_weighted[] = "_add_unbuffered_weighted";
static const char __pyx_k_ApproximateUnique_PerKey[] = "ApproximateUnique.PerKey";
static const char __pyx_k_ApproximateUniqueCombineFn[] = "ApproximateUniqueCombineFn";
static const char __pyx_k_ApproximateUnique_Globally[] = "ApproximateUnique.Globally";
static const char __pyx_k_LargestUnique_get_estimate[] = "_LargestUnique.get_estimate";
static const char __pyx_k_ApproximateQuantiles_PerKey[] = "ApproximateQuantiles.PerKey";
static const char __pyx_k_apache_beam_transforms_core[] = "apache_beam.transforms.core";
static const char __pyx_k_QuantileSpec_get_argsort_key[] = "_QuantileSpec.get_argsort_key";
static const char __pyx_k_apache_beam_transforms_stats[] = "apache_beam.transforms.stats";
static const char __pyx_k_pyx_unpickle__QuantileBuffer[] = "__pyx_unpickle__QuantileBuffer";
static const char __pyx_k_ApproximateQuantilesCombineFn[] = "ApproximateQuantilesCombineFn";
static const char __pyx_k_ApproximateQuantiles_Globally[] = "ApproximateQuantiles.Globally";
static const char __pyx_k_QuantileState__add_unbuffered[] = "_QuantileState._add_unbuffered";
static const char __pyx_k_get_argsort_key_locals_lambda[] = "get_argsort_key.<locals>.<lambda>";
static const char __pyx_k_Approximate_PerKey_approximate[] = " Approximate.PerKey approximate number of unique values per key";
static const char __pyx_k_Hashes_input_elements_and_uses[] = "\n  Hashes input elements and uses those to extrapolate the size of the entire\n  set of hash values by assuming the rest of the hash values are as densely\n  distributed as the sample space.\n  ";
static const char __pyx_k_QuantileBuffer___reduce_cython[] = "_QuantileBuffer.__reduce_cython__";
static const char __pyx_k_This_combiner_gives_an_idea_of[] = "\n  This combiner gives an idea of the distribution of a collection of values\n  using approximate N-tiles. The output of this combiner is the list of size of\n  the number of quantiles (num_quantiles), containing the input values of the\n  minimum value item of the list, the intermediate values (n-tiles) and the\n  maximum value item of the list, in the sort order provided via key (similar\n  to the key argument of Python's sorting methods).\n\n  If there are fewer values to combine than the number of quantile\n  (num_quantiles), then the resulting list will contain all the values being\n  combined, in sorted order.\n\n  If no `key` is provided, then the results are sorted in the natural order.\n\n  To evaluate the quantiles, we use the \"New Algorithm\" described here:\n\n  [MRL98] Manku, Rajagopalan & Lindsay, \"Approximate Medians and other\n  Quantiles in One Pass and with Limited Memory\", Proc. 1998 ACM SIGMOD,\n  Vol 27, No 2, p 426-435, June 1998.\n  http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.6.6513&rep=rep1\n  &type=pdf\n\n  Note that the weighted quantiles are evaluated using a generalized version of\n  the algorithm referenced in the paper.\n\n  The default error bound is (1 / num_quantiles) for uniformly distributed data\n  and min(1e-2, 1 / num_quantiles) for weighted case, though in practice the\n  accuracy tends to be much better.\n\n  Args:\n    num_quantiles: Number of quantiles to produce. It is the size of the final\n      output list, including the mininum and maximum value items.\n    buffer_size: The size of the buffers, corresponding to k in the referenced\n      paper.\n    num_buffers: The number of buffers, corresponding to b in the referenced\n      paper.\n    key: (optional) Key is a mapping of elements to a comparable key, similar\n      to the key argument of Python's sorting methods.\n    reverse: (optional) whether to order things smallest to largest, rather\n      than largest to smallest.\n    weighted: (optional) if"" set to True, the combiner produces weighted\n      quantiles. The input elements are then expected to be tuples of input\n      values with the corresponding weight.\n    input_batched: (optional) if set to True, inputs are expected to be batches\n      of elements.\n  ";
static const char __pyx_k_apache_beam_transforms_display[] = "apache_beam.transforms.display";
static const char __pyx_k_get_sample_size_from_est_error[] = "_get_sample_size_from_est_error";
static const char __pyx_k_An_object_to_keep_samples_and_c[] = "\n  An object to keep samples and calculate sample hash space. It is an\n  accumulator of a combine function.\n  ";
static const char __pyx_k_ApproximateQuantilesCombineFn_2[] = "ApproximateQuantilesCombineFn.__init__";
static const char __pyx_k_ApproximateQuantilesCombineFn_3[] = "ApproximateQuantilesCombineFn.__reduce__";
static const char __pyx_k_ApproximateQuantiles_Globally_2[] = "ApproximateQuantiles.Globally.__init__";
static const char __pyx_k_ApproximateUniqueCombineFn_comp[] = "\n  ApproximateUniqueCombineFn computes an estimate of the number of\n  unique values that were combined.\n  ";
static const char __pyx_k_ApproximateUnique_PerKey___init[] = "ApproximateUnique.PerKey.__init__";
static const char __pyx_k_ApproximateUnique_PerKey_expand[] = "ApproximateUnique.PerKey.expand";
static const char __pyx_k_Approximate_Globally_approximat[] = " Approximate.Globally approximate number of unique values";
static const char __pyx_k_PTransform_for_getting_the_idea[] = "\n  PTransform for getting the idea of data distribution using approximate N-tile\n  (e.g. quartiles, percentiles etc.) either globally or per-key.\n\n  Examples:\n\n    in: list(range(101)), num_quantiles=5\n\n    out: [0, 25, 50, 75, 100]\n\n    in: [(i, 1 if i<10 else 1e-5) for i in range(101)], num_quantiles=5,\n      weighted=True\n\n    out: [0, 2, 5, 7, 100]\n\n    in: [list(range(10)), ..., list(range(90, 101))], num_quantiles=5,\n      input_batched=True\n\n    out: [0, 25, 50, 75, 100]\n\n    in: [(list(range(10)), [1]*10), (list(range(10)), [0]*10), ...,\n      (list(range(90, 101)), [0]*11)], num_quantiles=5, input_batched=True,\n      weighted=True\n\n    out: [0, 2, 5, 7, 100]\n  ";
static const char __pyx_k_PTransform_takes_PCollection_an[] = "\n    PTransform takes PCollection and returns a list whose single value is\n    approximate N-tiles of the input collection globally.\n\n    Args:\n      num_quantiles: number of elements in the resulting quantiles values list.\n      key: (optional) Key is  a mapping of elements to a comparable key, similar\n        to the key argument of Python's sorting methods.\n      reverse: (optional) whether to order things smallest to largest, rather\n        than largest to smallest.\n      weighted: (optional) if set to True, the transform returns weighted\n        quantiles. The input PCollection is then expected to contain tuples of\n        input values with the corresponding weight.\n      input_batched: (optional) if set to True, the transform expects each\n        element of input PCollection to be a batch, which is a list of elements\n        for non-weighted case and a tuple of lists of elements and weights for\n        weighted. Provides a way to accumulate multiple elements at a time more\n        efficiently.\n    ";
static const char __pyx_k_PTransform_takes_PCollection_of[] = "\n    PTransform takes PCollection of KV and returns a list based on each key\n    whose single value is list of approximate N-tiles of the input element of\n    the key.\n\n    Args:\n      num_quantiles: number of elements in the resulting quantiles values list.\n      key: (optional) Key is  a mapping of elements to a comparable key, similar\n        to the key argument of Python's sorting methods.\n      reverse: (optional) whether to order things smallest to largest, rather\n        than largest to smallest.\n      weighted: (optional) if set to True, the transform returns weighted\n        quantiles. The input PCollection is then expected to contain tuples of\n        input values with the corresponding weight.\n      input_batched: (optional) if set to True, the transform expects each\n        element of input PCollection to be a batch, which is a list of elements\n        for non-weighted case and a tuple of lists of elements and weights for\n        weighted. Provides a way to accumulate multiple elements at a time more\n        efficiently.\n    ";
static const char __pyx_k_QuantileBuffer___setstate_cytho[] = "_QuantileBuffer.__setstate_cython__";
static const char __pyx_k_QuantileState__add_unbuffered_w[] = "_QuantileState._add_unbuffered_weighted";
static const char __pyx_k_QuantileState_collapse_if_neede[] = "_QuantileState.collapse_if_needed";
static const char __pyx_k_apache_beam_transforms_stats_py[] = "apache_beam/transforms/stats.py";
static const char __pyx_k_ApproximateQuantilesCombineFn__a[] = "ApproximateQuantilesCombineFn._add_inputs";
static const char __pyx_k_ApproximateQuantilesCombineFn__o[] = "ApproximateQuantilesCombineFn._offset";
static const char __pyx_k_ApproximateQuantilesCombineFn_ad[] = "ApproximateQuantilesCombineFn.add_input";
static const char __pyx_k_ApproximateQuantilesCombineFn_cr[] = "ApproximateQuantilesCombineFn.create";
static const char __pyx_k_ApproximateQuantilesCombineFn_ex[] = "ApproximateQuantilesCombineFn.extract_output";
static const char __pyx_k_ApproximateQuantilesCombineFn_me[] = "ApproximateQuantilesCombineFn.merge_accumulators";
static const char __pyx_k_ApproximateQuantiles_Globally_di[] = "ApproximateQuantiles.Globally.display_data";
static const char __pyx_k_ApproximateQuantiles_Globally_ex[] = "ApproximateQuantiles.Globally.expand";
static const char __pyx_k_ApproximateQuantiles_PerKey___in[] = "ApproximateQuantiles.PerKey.__init__";
static const char __pyx_k_ApproximateQuantiles_PerKey_disp[] = "ApproximateQuantiles.PerKey.display_data";
static const char __pyx_k_ApproximateQuantiles_PerKey_expa[] = "ApproximateQuantiles.PerKey.expand";
static const char __pyx_k_ApproximateQuantiles__display_da[] = "ApproximateQuantiles._display_data";
static const char __pyx_k_ApproximateUniqueCombineFn___ini[] = "ApproximateUniqueCombineFn.__init__";
static const char __pyx_k_ApproximateUniqueCombineFn_add_i[] = "ApproximateUniqueCombineFn.add_input";
static const char __pyx_k_ApproximateUniqueCombineFn_creat[] = "ApproximateUniqueCombineFn.create_accumulator";
static const char __pyx_k_ApproximateUniqueCombineFn_displ[] = "ApproximateUniqueCombineFn.display_data";
static const char __pyx_k_ApproximateUniqueCombineFn_extra[] = "ApproximateUniqueCombineFn.extract_output";
static const char __pyx_k_ApproximateUniqueCombineFn_merge[] = "ApproximateUniqueCombineFn.merge_accumulators";
static const char __pyx_k_ApproximateUnique_Globally___ini[] = "ApproximateUnique.Globally.__init__";
static const char __pyx_k_ApproximateUnique_Globally_expan[] = "ApproximateUnique.Globally.expand";
static const char __pyx_k_ApproximateUnique__get_sample_si[] = "ApproximateUnique._get_sample_size_from_est_error";
static const char __pyx_k_ApproximateUnique_needs_a_size_1[] = "ApproximateUnique needs a size >= 16 for an error <= 0.50. In general, the estimation error is about 2 / sqrt(sample_size). Received {size = %s}.";
static const char __pyx_k_ApproximateUnique_needs_an_estim[] = "ApproximateUnique needs an estimation error between 0.01 and 0.50. Received {error = %s}.";
static const char __pyx_k_ApproximateUnique_parse_input_pa[] = "ApproximateUnique.parse_input_params";
static const char __pyx_k_Couldn_t_find_murmurhash_Install[] = "Couldn't find murmurhash. Install mmh3 for a faster implementation ofApproximateUnique.";
static const char __pyx_k_Either_size_or_error_should_be_s[] = "Either size or error should be set. Received {}.";
static const char __pyx_k_Incompatible_checksums_0x_x_vs_0[] = "Incompatible checksums (0x%x vs (0x9fb38c7, 0x34dcb70, 0x7f9f705) = (_iter, elements, level, max_val, min_val, weighted, weights))";
static const char __pyx_k_This_module_has_all_statistic_re[] = "This module has all statistic related transforms.\n\nThis ApproximateUnique class will be deprecated [1]. PLease look into using\nHLLCount in the zetasketch extension module [2].\n\n[1] https://lists.apache.org/thread.html/501605df5027567099b81f18c080469661fb426\n4a002615fa1510502%40%3Cdev.beam.apache.org%3E\n[2] https://beam.apache.org/releases/javadoc/2.16.0/org/apache/beam/sdk/extensio\nns/zetasketch/HllCount.html\n";
static const char __pyx_k_apache_beam_transforms_ptransfor[] = "apache_beam.transforms.ptransform";
static const char __pyx_k_ApproximateQuantilesCombineFn_cr_2[] = "ApproximateQuantilesCombineFn.create_accumulator";
static const char __pyx_k_Either_size_or_error_should_be_s_2[] = "Either size or error should be set. Received {size = %s, error = %s}.";
static PyObject *__pyx_kp_s_An_object_to_keep_samples_and_c;
static PyObject *__pyx_n_s_Any;
static PyObject *__pyx_n_s_ApproximateQuantiles;
static PyObject *__pyx_n_u_ApproximateQuantiles;
static PyObject *__pyx_n_s_ApproximateQuantilesCombineFn;
static PyObject *__pyx_n_s_ApproximateQuantilesCombineFn_2;
static PyObject *__pyx_n_s_ApproximateQuantilesCombineFn_3;
static PyObject *__pyx_n_s_ApproximateQuantilesCombineFn__a;
static PyObject *__pyx_n_s_ApproximateQuantilesCombineFn__o;
static PyObject *__pyx_n_s_ApproximateQuantilesCombineFn_ad;
static PyObject *__pyx_n_s_ApproximateQuantilesCombineFn_cr;
static PyObject *__pyx_n_s_ApproximateQuantilesCombineFn_cr_2;
static PyObject *__pyx_n_s_ApproximateQuantilesCombineFn_ex;
static PyObject *__pyx_n_s_ApproximateQuantilesCombineFn_me;
static PyObject *__pyx_n_s_ApproximateQuantiles_Globally;
static PyObject *__pyx_n_s_ApproximateQuantiles_Globally_2;
static PyObject *__pyx_n_s_ApproximateQuantiles_Globally_di;
static PyObject *__pyx_n_s_ApproximateQuantiles_Globally_ex;
static PyObject *__pyx_n_s_ApproximateQuantiles_PerKey;
static PyObject *__pyx_n_s_ApproximateQuantiles_PerKey___in;
static PyObject *__pyx_n_s_ApproximateQuantiles_PerKey_disp;
static PyObject *__pyx_n_s_ApproximateQuantiles_PerKey_expa;
static PyObject *__pyx_n_s_ApproximateQuantiles__display_da;
static PyObject *__pyx_n_s_ApproximateUnique;
static PyObject *__pyx_n_u_ApproximateUnique;
static PyObject *__pyx_n_s_ApproximateUniqueCombineFn;
static PyObject *__pyx_n_u_ApproximateUniqueCombineFn;
static PyObject *__pyx_n_s_ApproximateUniqueCombineFn___ini;
static PyObject *__pyx_n_s_ApproximateUniqueCombineFn_add_i;
static PyObject *__pyx_kp_s_ApproximateUniqueCombineFn_comp;
static PyObject *__pyx_n_s_ApproximateUniqueCombineFn_creat;
static PyObject *__pyx_n_s_ApproximateUniqueCombineFn_displ;
static PyObject *__pyx_n_s_ApproximateUniqueCombineFn_extra;
static PyObject *__pyx_n_s_ApproximateUniqueCombineFn_merge;
static PyObject *__pyx_n_s_ApproximateUnique_Globally;
static PyObject *__pyx_n_s_ApproximateUnique_Globally___ini;
static PyObject *__pyx_n_s_ApproximateUnique_Globally_expan;
static PyObject *__pyx_n_s_ApproximateUnique_PerKey;
static PyObject *__pyx_n_s_ApproximateUnique_PerKey___init;
static PyObject *__pyx_n_s_ApproximateUnique_PerKey_expand;
static PyObject *__pyx_n_s_ApproximateUnique__get_sample_si;
static PyObject *__pyx_kp_u_ApproximateUnique_needs_a_size_1;
static PyObject *__pyx_kp_u_ApproximateUnique_needs_an_estim;
static PyObject *__pyx_n_s_ApproximateUnique_parse_input_pa;
static PyObject *__pyx_kp_s_Approximate_Globally_approximat;
static PyObject *__pyx_kp_s_Approximate_PerKey_approximate;
static PyObject *__pyx_n_s_Callable;
static PyObject *__pyx_n_s_CombineFn;
static PyObject *__pyx_n_s_CombineGlobally;
static PyObject *__pyx_n_s_CombinePerKey;
static PyObject *__pyx_kp_u_Couldn_t_find_murmurhash_Install;
static PyObject *__pyx_n_u_CountGlobalUniqueValues;
static PyObject *__pyx_n_u_CountPerKeyUniqueValues;
static PyObject *__pyx_n_s_DisplayDataItem;
static PyObject *__pyx_kp_u_Either_size_or_error_should_be_s;
static PyObject *__pyx_kp_u_Either_size_or_error_should_be_s_2;
static PyObject *__pyx_n_s_Globally;
static PyObject *__pyx_n_s_HASH_SPACE_SIZE;
static PyObject *__pyx_kp_s_Hashes_input_elements_and_uses;
static PyObject *__pyx_n_s_INPUT_ERROR_ERR_MSG;
static PyObject *__pyx_n_s_INPUT_SIZE_ERR_MSG;
static PyObject *__pyx_n_s_ImportError;
static PyObject *__pyx_kp_s_Incompatible_checksums_0x_x_vs_0;
static PyObject *__pyx_kp_u_Is_Input_Batched;
static PyObject *__pyx_kp_u_Is_Reversed;
static PyObject *__pyx_kp_u_Is_Weighted;
static PyObject *__pyx_n_s_K;
static PyObject *__pyx_n_u_K;
static PyObject *__pyx_n_s_LargestUnique;
static PyObject *__pyx_n_s_LargestUnique___init;
static PyObject *__pyx_n_s_LargestUnique_add;
static PyObject *__pyx_n_s_LargestUnique_get_estimate;
static PyObject *__pyx_n_s_List;
static PyObject *__pyx_n_s_MAX_NUM_ELEMENTS;
static PyObject *__pyx_n_s_MULTI_VALUE_ERR_MSG;
static PyObject *__pyx_n_s_NO_VALUE_ERR_MSG;
static PyObject *__pyx_n_s_PTransform;
static PyObject *__pyx_kp_s_PTransform_for_getting_the_idea;
static PyObject *__pyx_kp_s_PTransform_takes_PCollection_an;
static PyObject *__pyx_kp_s_PTransform_takes_PCollection_of;
static PyObject *__pyx_n_s_PerKey;
static PyObject *__pyx_n_s_PickleError;
static PyObject *__pyx_n_s_QuantileBuffer;
static PyObject *__pyx_n_s_QuantileBuffer___reduce_cython;
static PyObject *__pyx_n_s_QuantileBuffer___setstate_cytho;
static PyObject *__pyx_n_s_QuantileSpec;
static PyObject *__pyx_n_s_QuantileSpec___reduce;
static PyObject *__pyx_n_s_QuantileSpec_get_argsort_key;
static PyObject *__pyx_n_s_QuantileState;
static PyObject *__pyx_n_s_QuantileState___reduce;
static PyObject *__pyx_n_s_QuantileState__add_unbuffered;
static PyObject *__pyx_n_s_QuantileState__add_unbuffered_w;
static PyObject *__pyx_n_s_QuantileState_collapse_if_neede;
static PyObject *__pyx_n_s_QuantileState_finalize;
static PyObject *__pyx_n_s_QuantileState_is_empty;
static PyObject *__pyx_kp_u_Quantile_Count;
static PyObject *__pyx_kp_u_Record_Comparer_Key;
static PyObject *__pyx_n_s_RuntimeError;
static PyObject *__pyx_kp_u_Runtime_exception_s;
static PyObject *__pyx_n_s_Sequence;
static PyObject *__pyx_n_s_StopIteration;
static PyObject *__pyx_n_s_T;
static PyObject *__pyx_n_u_T;
static PyObject *__pyx_kp_s_This_combiner_gives_an_idea_of;
static PyObject *__pyx_n_s_Tuple;
static PyObject *__pyx_n_s_TypeVar;
static PyObject *__pyx_n_s_Union;
static PyObject *__pyx_n_s_V;
static PyObject *__pyx_n_u_V;
static PyObject *__pyx_n_s_ValueError;
static PyObject *__pyx_n_s__102;
static PyObject *__pyx_n_s__3;
static PyObject *__pyx_n_s_a;
static PyObject *__pyx_n_s_accumulator;
static PyObject *__pyx_n_s_accumulators;
static PyObject *__pyx_n_s_add;
static PyObject *__pyx_n_s_add_input;
static PyObject *__pyx_n_u_add_input;
static PyObject *__pyx_n_s_add_inputs;
static PyObject *__pyx_n_s_add_unbuffered;
static PyObject *__pyx_n_s_add_unbuffered_2;
static PyObject *__pyx_n_s_add_unbuffered_weighted;
static PyObject *__pyx_n_s_all;
static PyObject *__pyx_n_s_all_elems;
static PyObject *__pyx_n_s_apache_beam;
static PyObject *__pyx_n_s_apache_beam_transforms_core;
static PyObject *__pyx_n_s_apache_beam_transforms_display;
static PyObject *__pyx_n_s_apache_beam_transforms_ptransfor;
static PyObject *__pyx_n_s_apache_beam_transforms_stats;
static PyObject *__pyx_kp_s_apache_beam_transforms_stats_py;
static PyObject *__pyx_n_s_append;
static PyObject *__pyx_n_s_args;
static PyObject *__pyx_n_s_b;
static PyObject *__pyx_n_s_buffer_elem;
static PyObject *__pyx_n_s_buffer_size;
static PyObject *__pyx_n_s_buffers;
static PyObject *__pyx_n_s_ceil;
static PyObject *__pyx_n_s_chain;
static PyObject *__pyx_n_s_class;
static PyObject *__pyx_n_s_cline_in_traceback;
static PyObject *__pyx_n_s_cls;
static PyObject *__pyx_n_s_coder;
static PyObject *__pyx_n_s_coder_2;
static PyObject *__pyx_n_s_coders;
static PyObject *__pyx_n_s_collapse_if_needed;
static PyObject *__pyx_n_s_create;
static PyObject *__pyx_n_s_create_accumulator;
static PyObject *__pyx_n_s_default_hash_fn;
static PyObject *__pyx_n_s_default_hash_fn_type;
static PyObject *__pyx_n_s_dict;
static PyObject *__pyx_n_s_dict_2;
static PyObject *__pyx_n_s_display_data;
static PyObject *__pyx_n_s_display_data_2;
static PyObject *__pyx_n_s_doc;
static PyObject *__pyx_n_s_e;
static PyObject *__pyx_n_s_element;
static PyObject *__pyx_n_s_elements;
static PyObject *__pyx_n_s_encode;
static PyObject *__pyx_n_s_epsilon;
static PyObject *__pyx_n_s_error;
static PyObject *__pyx_n_s_est;
static PyObject *__pyx_n_s_est_err;
static PyObject *__pyx_n_s_expand;
static PyObject *__pyx_n_s_extend;
static PyObject *__pyx_n_s_extract_output;
static PyObject *__pyx_n_s_finalize;
static PyObject *__pyx_n_s_from_iterable;
static PyObject *__pyx_n_s_get_argsort_key;
static PyObject *__pyx_n_s_get_argsort_key_locals_lambda;
static PyObject *__pyx_n_s_get_coder;
static PyObject *__pyx_n_s_get_default_hash_fn;
static PyObject *__pyx_n_s_get_estimate;
static PyObject *__pyx_n_s_get_sample_size_from_est_error;
static PyObject *__pyx_n_s_getitem;
static PyObject *__pyx_n_s_getstate;
static PyObject *__pyx_n_s_hash64;
static PyObject *__pyx_n_s_hash_fn;
static PyObject *__pyx_n_s_hashed_value;
static PyObject *__pyx_n_s_hashlib;
static PyObject *__pyx_n_s_heapify;
static PyObject *__pyx_n_s_heappop;
static PyObject *__pyx_n_s_heappush;
static PyObject *__pyx_n_s_heapq;
static PyObject *__pyx_n_s_hexdigest;
static PyObject *__pyx_n_s_i;
static PyObject *__pyx_n_s_import;
static PyObject *__pyx_n_s_init;
static PyObject *__pyx_n_s_init___locals_lambda;
static PyObject *__pyx_n_s_input_batched;
static PyObject *__pyx_n_u_input_batched;
static PyObject *__pyx_n_s_input_batched_2;
static PyObject *__pyx_n_s_is_empty;
static PyObject *__pyx_n_s_itertools;
static PyObject *__pyx_n_s_k;
static PyObject *__pyx_n_s_key;
static PyObject *__pyx_n_u_key;
static PyObject *__pyx_n_s_key_2;
static PyObject *__pyx_n_s_kwargs;
static PyObject *__pyx_n_s_label;
static PyObject *__pyx_n_s_level;
static PyObject *__pyx_n_s_log1p;
static PyObject *__pyx_n_s_logging;
static PyObject *__pyx_n_s_main;
static PyObject *__pyx_n_s_math;
static PyObject *__pyx_n_s_max_num_elements;
static PyObject *__pyx_n_s_max_val;
static PyObject *__pyx_n_s_md5;
static PyObject *__pyx_n_u_md5;
static PyObject *__pyx_n_s_md5_hash;
static PyObject *__pyx_n_s_merge_accumulators;
static PyObject *__pyx_n_s_merged_accumulator;
static PyObject *__pyx_n_s_metaclass;
static PyObject *__pyx_n_s_min_hash;
static PyObject *__pyx_n_s_min_val;
static PyObject *__pyx_n_s_mmh3;
static PyObject *__pyx_n_u_mmh3;
static PyObject *__pyx_n_s_mmh3_hash;
static PyObject *__pyx_n_s_module;
static PyObject *__pyx_n_s_name;
static PyObject *__pyx_n_u_name;
static PyObject *__pyx_n_s_new;
static PyObject *__pyx_n_s_new_weight;
static PyObject *__pyx_n_s_num_buffers;
static PyObject *__pyx_n_s_num_quantiles;
static PyObject *__pyx_n_u_num_quantiles;
static PyObject *__pyx_n_s_num_quantiles_2;
static PyObject *__pyx_n_s_object;
static PyObject *__pyx_n_s_offset;
static PyObject *__pyx_n_s_offset_2;
static PyObject *__pyx_n_s_offset_fn;
static PyObject *__pyx_n_s_offset_jitter;
static PyObject *__pyx_n_s_parse_input_params;
static PyObject *__pyx_n_s_pcoll;
static PyObject *__pyx_n_s_pickle;
static PyObject *__pyx_n_s_pow;
static PyObject *__pyx_n_s_prepare;
static PyObject *__pyx_n_s_pyx_PickleError;
static PyObject *__pyx_n_s_pyx_checksum;
static PyObject *__pyx_n_s_pyx_result;
static PyObject *__pyx_n_s_pyx_state;
static PyObject *__pyx_n_s_pyx_type;
static PyObject *__pyx_n_s_pyx_unpickle__QuantileBuffer;
static PyObject *__pyx_n_s_pyx_vtable;
static PyObject *__pyx_n_s_qs;
static PyObject *__pyx_n_s_qs_2;
static PyObject *__pyx_n_s_qualname;
static PyObject *__pyx_n_s_quantile_state;
static PyObject *__pyx_n_s_quantiles;
static PyObject *__pyx_n_s_range;
static PyObject *__pyx_n_s_reduce;
static PyObject *__pyx_n_s_reduce_cython;
static PyObject *__pyx_n_s_reduce_ex;
static PyObject *__pyx_n_s_registry;
static PyObject *__pyx_n_s_remove;
static PyObject *__pyx_n_s_repeat;
static PyObject *__pyx_n_s_reverse;
static PyObject *__pyx_n_u_reverse;
static PyObject *__pyx_n_s_reverse_2;
static PyObject *__pyx_n_s_round;
static PyObject *__pyx_n_s_sample_heap;
static PyObject *__pyx_n_s_sample_set;
static PyObject *__pyx_n_s_sample_size;
static PyObject *__pyx_n_s_sample_size_2;
static PyObject *__pyx_n_u_sample_size_2;
static PyObject *__pyx_n_s_sample_space_size;
static PyObject *__pyx_n_s_seed;
static PyObject *__pyx_n_s_self;
static PyObject *__pyx_n_s_setstate;
static PyObject *__pyx_n_s_setstate_cython;
static PyObject *__pyx_n_s_signed;
static PyObject *__pyx_n_s_size;
static PyObject *__pyx_n_s_sort;
static PyObject *__pyx_n_s_sorted;
static PyObject *__pyx_n_s_spec;
static PyObject *__pyx_n_s_spec_2;
static PyObject *__pyx_n_s_state;
static PyObject *__pyx_n_s_staticmethod;
static PyObject *__pyx_n_s_step;
static PyObject *__pyx_kp_s_stringsource;
static PyObject *__pyx_n_s_sum;
static PyObject *__pyx_n_s_temp;
static PyObject *__pyx_n_s_test;
static PyObject *__pyx_n_s_total_weight;
static PyObject *__pyx_n_s_typecoders;
static PyObject *__pyx_n_s_typehints;
static PyObject *__pyx_n_s_typing;
static PyObject *__pyx_n_s_unbuffered_elements;
static PyObject *__pyx_n_s_unbuffered_weights;
static PyObject *__pyx_n_s_update;
static PyObject *__pyx_n_s_use_setstate;
static PyObject *__pyx_n_s_value;
static PyObject *__pyx_n_s_verify_deterministic;
static PyObject *__pyx_n_s_warning;
static PyObject *__pyx_n_s_weighted;
static PyObject *__pyx_n_u_weighted;
static PyObject *__pyx_n_s_weighted_2;
static PyObject *__pyx_n_s_weights;
static PyObject *__pyx_n_s_with_input_types;
static PyObject *__pyx_n_s_with_output_types;
static PyObject *__pyx_n_s_zip;
static PyObject *__pyx_pf_11apache_beam_10transforms_5stats__mmh3_hash(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_value); /* proto */
static PyObject *__pyx_pf_11apache_beam_10transforms_5stats_2_md5_hash(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_value); /* proto */
static PyObject *__pyx_pf_11apache_beam_10transforms_5stats_4_get_default_hash_fn(CYTHON_UNUSED PyObject *__pyx_self); /* proto */
static PyObject *__pyx_pf_11apache_beam_10transforms_5stats_17ApproximateUnique_parse_input_params(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_size, PyObject *__pyx_v_error); /* proto */
static PyObject *__pyx_pf_11apache_beam_10transforms_5stats_17ApproximateUnique_2_get_sample_size_from_est_error(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_est_err); /* proto */
static PyObject *__pyx_pf_11apache_beam_10transforms_5stats_8Globally___init__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_size, PyObject *__pyx_v_error); /* proto */
static PyObject *__pyx_pf_11apache_beam_10transforms_5stats_8Globally_2expand(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_pcoll); /* proto */
static PyObject *__pyx_pf_11apache_beam_10transforms_5stats_6PerKey___init__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_size, PyObject *__pyx_v_error); /* proto */
static PyObject *__pyx_pf_11apache_beam_10transforms_5stats_6PerKey_2expand(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_pcoll); /* proto */
static PyObject *__pyx_pf_11apache_beam_10transforms_5stats_14_LargestUnique___init__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_sample_size); /* proto */
static PyObject *__pyx_pf_11apache_beam_10transforms_5stats_14_LargestUnique_2add(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_element); /* proto */
static PyObject *__pyx_pf_11apache_beam_10transforms_5stats_14_LargestUnique_4get_estimate(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_11apache_beam_10transforms_5stats_26ApproximateUniqueCombineFn___init__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_sample_size, PyObject *__pyx_v_coder); /* proto */
static PyObject *__pyx_pf_11apache_beam_10transforms_5stats_26ApproximateUniqueCombineFn_2create_accumulator(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_args, CYTHON_UNUSED PyObject *__pyx_v_kwargs); /* proto */
static PyObject *__pyx_pf_11apache_beam_10transforms_5stats_26ApproximateUniqueCombineFn_4add_input(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_accumulator, PyObject *__pyx_v_element, CYTHON_UNUSED PyObject *__pyx_v_args, CYTHON_UNUSED PyObject *__pyx_v_kwargs); /* proto */
static PyObject *__pyx_pf_11apache_beam_10transforms_5stats_26ApproximateUniqueCombineFn_6merge_accumulators(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_accumulators, CYTHON_UNUSED PyObject *__pyx_v_args, CYTHON_UNUSED PyObject *__pyx_v_kwargs); /* proto */
static PyObject *__pyx_pf_11apache_beam_10transforms_5stats_26ApproximateUniqueCombineFn_8extract_output(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_accumulator); /* proto */
static PyObject *__pyx_pf_11apache_beam_10transforms_5stats_26ApproximateUniqueCombineFn_10display_data(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_11apache_beam_10transforms_5stats_20ApproximateQuantiles__display_data(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_num_quantiles, PyObject *__pyx_v_key, PyObject *__pyx_v_reverse, PyObject *__pyx_v_weighted, PyObject *__pyx_v_input_batched); /* proto */
static PyObject *__pyx_pf_11apache_beam_10transforms_5stats_8Globally_4__init__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_num_quantiles, PyObject *__pyx_v_key, PyObject *__pyx_v_reverse, PyObject *__pyx_v_weighted, PyObject *__pyx_v_input_batched); /* proto */
static PyObject *__pyx_pf_11apache_beam_10transforms_5stats_8Globally_6expand(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_pcoll); /* proto */
static PyObject *__pyx_pf_11apache_beam_10transforms_5stats_8Globally_8display_data(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_11apache_beam_10transforms_5stats_6PerKey_4__init__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_num_quantiles, PyObject *__pyx_v_key, PyObject *__pyx_v_reverse, PyObject *__pyx_v_weighted, PyObject *__pyx_v_input_batched); /* proto */
static PyObject *__pyx_pf_11apache_beam_10transforms_5stats_6PerKey_6expand(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_pcoll); /* proto */
static PyObject *__pyx_pf_11apache_beam_10transforms_5stats_6PerKey_8display_data(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self); /* proto */
static PyObject *__pyx_lambda_funcdef_lambda(PyObject *__pyx_self, PyObject *__pyx_v_x); /* proto */
static PyObject *__pyx_lambda_funcdef_lambda1(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_a, PyObject *__pyx_v_b); /* proto */
static PyObject *__pyx_lambda_funcdef_lambda2(PyObject *__pyx_self, PyObject *__pyx_v_a, PyObject *__pyx_v_b); /* proto */
static PyObject *__pyx_lambda_funcdef_lambda3(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_a, PyObject *__pyx_v_b); /* proto */
static PyObject *__pyx_lambda_funcdef_lambda4(PyObject *__pyx_self, PyObject *__pyx_v_a, PyObject *__pyx_v_b); /* proto */
static int __pyx_pf_11apache_beam_10transforms_5stats_13_QuantileSpec___init__(struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileSpec *__pyx_v_self, PyObject *__pyx_v_buffer_size, PyObject *__pyx_v_num_buffers, PyObject *__pyx_v_weighted, PyObject *__pyx_v_key, PyObject *__pyx_v_reverse); /* proto */
static PyObject *__pyx_lambda_funcdef_lambda5(PyObject *__pyx_self, PyObject *__pyx_v_idx); /* proto */
static PyObject *__pyx_pf_11apache_beam_10transforms_5stats_13_QuantileSpec_2get_argsort_key(struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileSpec *__pyx_v_self, PyObject *__pyx_v_elements); /* proto */
static PyObject *__pyx_pf_11apache_beam_10transforms_5stats_13_QuantileSpec_4__reduce__(struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileSpec *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_11apache_beam_10transforms_5stats_13_QuantileSpec_11buffer_size___get__(struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileSpec *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_11apache_beam_10transforms_5stats_13_QuantileSpec_11num_buffers___get__(struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileSpec *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_11apache_beam_10transforms_5stats_13_QuantileSpec_8weighted___get__(struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileSpec *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_11apache_beam_10transforms_5stats_13_QuantileSpec_3key___get__(struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileSpec *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_11apache_beam_10transforms_5stats_13_QuantileSpec_7reverse___get__(struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileSpec *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_11apache_beam_10transforms_5stats_13_QuantileSpec_12weighted_key___get__(struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileSpec *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_11apache_beam_10transforms_5stats_13_QuantileSpec_9less_than___get__(struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileSpec *__pyx_v_self); /* proto */
static int __pyx_pf_11apache_beam_10transforms_5stats_15_QuantileBuffer___init__(struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileBuffer *__pyx_v_self, PyObject *__pyx_v_elements, PyObject *__pyx_v_weights, PyObject *__pyx_v_weighted, PyObject *__pyx_v_level, PyObject *__pyx_v_min_val, PyObject *__pyx_v_max_val); /* proto */
static PyObject *__pyx_pf_11apache_beam_10transforms_5stats_15_QuantileBuffer_2__iter__(struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileBuffer *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_11apache_beam_10transforms_5stats_15_QuantileBuffer_4__lt__(struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileBuffer *__pyx_v_self, PyObject *__pyx_v_other); /* proto */
static PyObject *__pyx_pf_11apache_beam_10transforms_5stats_15_QuantileBuffer_8elements___get__(struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileBuffer *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_11apache_beam_10transforms_5stats_15_QuantileBuffer_7weights___get__(struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileBuffer *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_11apache_beam_10transforms_5stats_15_QuantileBuffer_8weighted___get__(struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileBuffer *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_11apache_beam_10transforms_5stats_15_QuantileBuffer_5level___get__(struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileBuffer *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_11apache_beam_10transforms_5stats_15_QuantileBuffer_7min_val___get__(struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileBuffer *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_11apache_beam_10transforms_5stats_15_QuantileBuffer_7max_val___get__(struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileBuffer *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_11apache_beam_10transforms_5stats_15_QuantileBuffer_5_iter___get__(struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileBuffer *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_11apache_beam_10transforms_5stats_15_QuantileBuffer_6__reduce_cython__(struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileBuffer *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_11apache_beam_10transforms_5stats_15_QuantileBuffer_8__setstate_cython__(struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileBuffer *__pyx_v_self, PyObject *__pyx_v___pyx_state); /* proto */
static int __pyx_pf_11apache_beam_10transforms_5stats_14_QuantileState___init__(struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileState *__pyx_v_self, PyObject *__pyx_v_unbuffered_elements, PyObject *__pyx_v_unbuffered_weights, PyObject *__pyx_v_buffers, PyObject *__pyx_v_spec); /* proto */
static PyObject *__pyx_pf_11apache_beam_10transforms_5stats_14_QuantileState_2__reduce__(struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileState *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_11apache_beam_10transforms_5stats_14_QuantileState_4is_empty(struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileState *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_11apache_beam_10transforms_5stats_14_QuantileState_6_add_unbuffered(struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileState *__pyx_v_self, PyObject *__pyx_v_elements, PyObject *__pyx_v_offset_fn); /* proto */
static PyObject *__pyx_pf_11apache_beam_10transforms_5stats_14_QuantileState_8_add_unbuffered_weighted(struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileState *__pyx_v_self, PyObject *__pyx_v_elements, PyObject *__pyx_v_offset_fn); /* proto */
static PyObject *__pyx_pf_11apache_beam_10transforms_5stats_14_QuantileState_10finalize(struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileState *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_11apache_beam_10transforms_5stats_14_QuantileState_12collapse_if_needed(struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileState *__pyx_v_self, PyObject *__pyx_v_offset_fn); /* proto */
static PyObject *__pyx_pf_11apache_beam_10transforms_5stats_14_QuantileState_4spec___get__(struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileState *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_11apache_beam_10transforms_5stats_14_QuantileState_7buffers___get__(struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileState *__pyx_v_self); /* proto */
static int __pyx_pf_11apache_beam_10transforms_5stats_14_QuantileState_7buffers_2__set__(struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileState *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
static int __pyx_pf_11apache_beam_10transforms_5stats_14_QuantileState_7buffers_4__del__(struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileState *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_11apache_beam_10transforms_5stats_14_QuantileState_19unbuffered_elements___get__(struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileState *__pyx_v_self); /* proto */
static int __pyx_pf_11apache_beam_10transforms_5stats_14_QuantileState_19unbuffered_elements_2__set__(struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileState *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
static int __pyx_pf_11apache_beam_10transforms_5stats_14_QuantileState_19unbuffered_elements_4__del__(struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileState *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_11apache_beam_10transforms_5stats_14_QuantileState_18unbuffered_weights___get__(struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileState *__pyx_v_self); /* proto */
static int __pyx_pf_11apache_beam_10transforms_5stats_14_QuantileState_18unbuffered_weights_2__set__(struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileState *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
static int __pyx_pf_11apache_beam_10transforms_5stats_14_QuantileState_18unbuffered_weights_4__del__(struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileState *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_11apache_beam_10transforms_5stats_14_QuantileState_14add_unbuffered___get__(struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileState *__pyx_v_self); /* proto */
static int __pyx_pf_11apache_beam_10transforms_5stats_14_QuantileState_14add_unbuffered_2__set__(struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileState *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
static int __pyx_pf_11apache_beam_10transforms_5stats_14_QuantileState_14add_unbuffered_4__del__(struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileState *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_11apache_beam_10transforms_5stats_29ApproximateQuantilesCombineFn___init__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_num_quantiles, PyObject *__pyx_v_buffer_size, PyObject *__pyx_v_num_buffers, PyObject *__pyx_v_key, PyObject *__pyx_v_reverse, PyObject *__pyx_v_weighted, PyObject *__pyx_v_input_batched); /* proto */
static PyObject *__pyx_pf_11apache_beam_10transforms_5stats_29ApproximateQuantilesCombineFn_2__reduce__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_11apache_beam_10transforms_5stats_29ApproximateQuantilesCombineFn_4create(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_cls, PyObject *__pyx_v_num_quantiles, PyObject *__pyx_v_epsilon, PyObject *__pyx_v_max_num_elements, PyObject *__pyx_v_key, PyObject *__pyx_v_reverse, PyObject *__pyx_v_weighted, PyObject *__pyx_v_input_batched); /* proto */
static PyObject *__pyx_pf_11apache_beam_10transforms_5stats_29ApproximateQuantilesCombineFn_6_offset(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_new_weight); /* proto */
static PyObject *__pyx_pf_11apache_beam_10transforms_5stats_29ApproximateQuantilesCombineFn_8create_accumulator(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_11apache_beam_10transforms_5stats_29ApproximateQuantilesCombineFn_10add_input(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_quantile_state, PyObject *__pyx_v_element); /* proto */
static PyObject *__pyx_pf_11apache_beam_10transforms_5stats_29ApproximateQuantilesCombineFn_12_add_inputs(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_quantile_state, PyObject *__pyx_v_elements); /* proto */
static PyObject *__pyx_pf_11apache_beam_10transforms_5stats_29ApproximateQuantilesCombineFn_14merge_accumulators(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_accumulators); /* proto */
static PyObject *__pyx_pf_11apache_beam_10transforms_5stats_29ApproximateQuantilesCombineFn_16extract_output(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_accumulator); /* proto */
static PyObject *__pyx_pf_11apache_beam_10transforms_5stats_6__pyx_unpickle__QuantileBuffer(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state); /* proto */
static PyObject *__pyx_tp_new_11apache_beam_10transforms_5stats__QuantileSpec(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_11apache_beam_10transforms_5stats__QuantileBuffer(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_11apache_beam_10transforms_5stats__QuantileState(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_11apache_beam_10transforms_5stats___pyx_scope_struct____init__(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_11apache_beam_10transforms_5stats___pyx_scope_struct_1_get_argsort_key(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_float_0_5;
static PyObject *__pyx_float_1_0;
static PyObject *__pyx_float_1e9;
static PyObject *__pyx_float_2_0;
static PyObject *__pyx_float_4_0;
static PyObject *__pyx_float_0_01;
static PyObject *__pyx_int_0;
static PyObject *__pyx_int_1;
static PyObject *__pyx_int_2;
static PyObject *__pyx_int_16;
static PyObject *__pyx_int_55430000;
static PyObject *__pyx_int_133822213;
static PyObject *__pyx_int_167459015;
static PyObject *__pyx_int_neg_1;
static PyObject *__pyx_slice_;
static PyObject *__pyx_tuple__2;
static PyObject *__pyx_tuple__4;
static PyObject *__pyx_tuple__5;
static PyObject *__pyx_tuple__6;
static PyObject *__pyx_tuple__7;
static PyObject *__pyx_tuple__9;
static PyObject *__pyx_tuple__12;
static PyObject *__pyx_tuple__13;
static PyObject *__pyx_tuple__15;
static PyObject *__pyx_tuple__16;
static PyObject *__pyx_tuple__18;
static PyObject *__pyx_tuple__20;
static PyObject *__pyx_tuple__21;
static PyObject *__pyx_tuple__23;
static PyObject *__pyx_tuple__25;
static PyObject *__pyx_tuple__26;
static PyObject *__pyx_tuple__28;
static PyObject *__pyx_tuple__29;
static PyObject *__pyx_tuple__31;
static PyObject *__pyx_tuple__33;
static PyObject *__pyx_tuple__35;
static PyObject *__pyx_tuple__37;
static PyObject *__pyx_tuple__39;
static PyObject *__pyx_tuple__41;
static PyObject *__pyx_tuple__43;
static PyObject *__pyx_tuple__45;
static PyObject *__pyx_tuple__47;
static PyObject *__pyx_tuple__48;
static PyObject *__pyx_tuple__50;
static PyObject *__pyx_tuple__52;
static PyObject *__pyx_tuple__53;
static PyObject *__pyx_tuple__55;
static PyObject *__pyx_tuple__57;
static PyObject *__pyx_tuple__59;
static PyObject *__pyx_tuple__60;
static PyObject *__pyx_tuple__62;
static PyObject *__pyx_tuple__64;
static PyObject *__pyx_tuple__66;
static PyObject *__pyx_tuple__68;
static PyObject *__pyx_tuple__70;
static PyObject *__pyx_tuple__72;
static PyObject *__pyx_tuple__74;
static PyObject *__pyx_tuple__76;
static PyObject *__pyx_tuple__78;
static PyObject *__pyx_tuple__80;
static PyObject *__pyx_tuple__82;
static PyObject *__pyx_tuple__84;
static PyObject *__pyx_tuple__86;
static PyObject *__pyx_tuple__87;
static PyObject *__pyx_tuple__89;
static PyObject *__pyx_tuple__91;
static PyObject *__pyx_tuple__92;
static PyObject *__pyx_tuple__94;
static PyObject *__pyx_tuple__96;
static PyObject *__pyx_tuple__98;
static PyObject *__pyx_codeobj__8;
static PyObject *__pyx_tuple__100;
static PyObject *__pyx_tuple__103;
static PyObject *__pyx_tuple__105;
static PyObject *__pyx_codeobj__10;
static PyObject *__pyx_codeobj__11;
static PyObject *__pyx_codeobj__14;
static PyObject *__pyx_codeobj__17;
static PyObject *__pyx_codeobj__19;
static PyObject *__pyx_codeobj__22;
static PyObject *__pyx_codeobj__24;
static PyObject *__pyx_codeobj__27;
static PyObject *__pyx_codeobj__30;
static PyObject *__pyx_codeobj__32;
static PyObject *__pyx_codeobj__34;
static PyObject *__pyx_codeobj__36;
static PyObject *__pyx_codeobj__38;
static PyObject *__pyx_codeobj__40;
static PyObject *__pyx_codeobj__42;
static PyObject *__pyx_codeobj__44;
static PyObject *__pyx_codeobj__46;
static PyObject *__pyx_codeobj__49;
static PyObject *__pyx_codeobj__51;
static PyObject *__pyx_codeobj__54;
static PyObject *__pyx_codeobj__56;
static PyObject *__pyx_codeobj__58;
static PyObject *__pyx_codeobj__61;
static PyObject *__pyx_codeobj__63;
static PyObject *__pyx_codeobj__65;
static PyObject *__pyx_codeobj__67;
static PyObject *__pyx_codeobj__69;
static PyObject *__pyx_codeobj__71;
static PyObject *__pyx_codeobj__73;
static PyObject *__pyx_codeobj__75;
static PyObject *__pyx_codeobj__77;
static PyObject *__pyx_codeobj__79;
static PyObject *__pyx_codeobj__81;
static PyObject *__pyx_codeobj__83;
static PyObject *__pyx_codeobj__85;
static PyObject *__pyx_codeobj__88;
static PyObject *__pyx_codeobj__90;
static PyObject *__pyx_codeobj__93;
static PyObject *__pyx_codeobj__95;
static PyObject *__pyx_codeobj__97;
static PyObject *__pyx_codeobj__99;
static PyObject *__pyx_codeobj__101;
static PyObject *__pyx_codeobj__104;
static PyObject *__pyx_codeobj__106;
/* Late includes */

/* "apache_beam/transforms/stats.py":63
 *   import mmh3  # pylint: disable=import-error
 * 
 *   def _mmh3_hash(value):             # <<<<<<<<<<<<<<
 *     # mmh3.hash64 returns two 64-bit unsigned integers
 *     return mmh3.hash64(value, seed=0, signed=False)[0]
 */

/* Python wrapper */
static PyObject *__pyx_pw_11apache_beam_10transforms_5stats_1_mmh3_hash(PyObject *__pyx_self, PyObject *__pyx_v_value); /*proto*/
static PyMethodDef __pyx_mdef_11apache_beam_10transforms_5stats_1_mmh3_hash = {"_mmh3_hash", (PyCFunction)__pyx_pw_11apache_beam_10transforms_5stats_1_mmh3_hash, METH_O, 0};
static PyObject *__pyx_pw_11apache_beam_10transforms_5stats_1_mmh3_hash(PyObject *__pyx_self, PyObject *__pyx_v_value) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_mmh3_hash (wrapper)", 0);
  __pyx_r = __pyx_pf_11apache_beam_10transforms_5stats__mmh3_hash(__pyx_self, ((PyObject *)__pyx_v_value));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_11apache_beam_10transforms_5stats__mmh3_hash(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_value) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_mmh3_hash", 0);

  /* "apache_beam/transforms/stats.py":65
 *   def _mmh3_hash(value):
 *     # mmh3.hash64 returns two 64-bit unsigned integers
 *     return mmh3.hash64(value, seed=0, signed=False)[0]             # <<<<<<<<<<<<<<
 * 
 *   _default_hash_fn = _mmh3_hash
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_mmh3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 65, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_hash64); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 65, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 65, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_v_value);
  __Pyx_GIVEREF(__pyx_v_value);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_value);
  __pyx_t_3 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 65, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_seed, __pyx_int_0) < 0) __PYX_ERR(0, 65, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_signed, Py_False) < 0) __PYX_ERR(0, 65, __pyx_L1_error)
  __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_1, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 65, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_GetItemInt(__pyx_t_4, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 65, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  /* "apache_beam/transforms/stats.py":63
 *   import mmh3  # pylint: disable=import-error
 * 
 *   def _mmh3_hash(value):             # <<<<<<<<<<<<<<
 *     # mmh3.hash64 returns two 64-bit unsigned integers
 *     return mmh3.hash64(value, seed=0, signed=False)[0]
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("apache_beam.transforms.stats._mmh3_hash", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "apache_beam/transforms/stats.py":71
 * except ImportError:
 * 
 *   def _md5_hash(value):             # <<<<<<<<<<<<<<
 *     # md5 is a 128-bit hash, so we truncate the hexdigest (string of 32
 *     # hexadecimal digits) to 16 digits and convert to int to get the 64-bit
 */

/* Python wrapper */
static PyObject *__pyx_pw_11apache_beam_10transforms_5stats_3_md5_hash(PyObject *__pyx_self, PyObject *__pyx_v_value); /*proto*/
static PyMethodDef __pyx_mdef_11apache_beam_10transforms_5stats_3_md5_hash = {"_md5_hash", (PyCFunction)__pyx_pw_11apache_beam_10transforms_5stats_3_md5_hash, METH_O, 0};
static PyObject *__pyx_pw_11apache_beam_10transforms_5stats_3_md5_hash(PyObject *__pyx_self, PyObject *__pyx_v_value) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_md5_hash (wrapper)", 0);
  __pyx_r = __pyx_pf_11apache_beam_10transforms_5stats_2_md5_hash(__pyx_self, ((PyObject *)__pyx_v_value));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_11apache_beam_10transforms_5stats_2_md5_hash(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_value) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_md5_hash", 0);

  /* "apache_beam/transforms/stats.py":75
 *     # hexadecimal digits) to 16 digits and convert to int to get the 64-bit
 *     # integer fingerprint.
 *     return int(hashlib.md5(value).hexdigest()[:16], 16)             # <<<<<<<<<<<<<<
 * 
 *   _default_hash_fn = _md5_hash
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_hashlib); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 75, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_md5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 75, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
    }
  }
  __pyx_t_2 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_3, __pyx_v_value) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_v_value);
  __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 75, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_hexdigest); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 75, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
    }
  }
  __pyx_t_1 = (__pyx_t_2) ? __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_2) : __Pyx_PyObject_CallNoArg(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 75, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_PyObject_GetSlice(__pyx_t_1, 0, 16, NULL, NULL, &__pyx_slice_, 0, 1, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 75, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 75, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_4);
  __Pyx_INCREF(__pyx_int_16);
  __Pyx_GIVEREF(__pyx_int_16);
  PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_int_16);
  __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_PyObject_Call(((PyObject *)(&PyInt_Type)), __pyx_t_1, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 75, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_4;
  __pyx_t_4 = 0;
  goto __pyx_L0;

  /* "apache_beam/transforms/stats.py":71
 * except ImportError:
 * 
 *   def _md5_hash(value):             # <<<<<<<<<<<<<<
 *     # md5 is a 128-bit hash, so we truncate the hexdigest (string of 32
 *     # hexadecimal digits) to 16 digits and convert to int to get the 64-bit
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("apache_beam.transforms.stats._md5_hash", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "apache_beam/transforms/stats.py":81
 * 
 * 
 * def _get_default_hash_fn():             # <<<<<<<<<<<<<<
 *   """Returns either murmurhash or md5 based on installation."""
 *   if _default_hash_fn_type == 'md5':
 */

/* Python wrapper */
static PyObject *__pyx_pw_11apache_beam_10transforms_5stats_5_get_default_hash_fn(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_11apache_beam_10transforms_5stats_4_get_default_hash_fn[] = "Returns either murmurhash or md5 based on installation.";
static PyMethodDef __pyx_mdef_11apache_beam_10transforms_5stats_5_get_default_hash_fn = {"_get_default_hash_fn", (PyCFunction)__pyx_pw_11apache_beam_10transforms_5stats_5_get_default_hash_fn, METH_NOARGS, __pyx_doc_11apache_beam_10transforms_5stats_4_get_default_hash_fn};
static PyObject *__pyx_pw_11apache_beam_10transforms_5stats_5_get_default_hash_fn(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_get_default_hash_fn (wrapper)", 0);
  __pyx_r = __pyx_pf_11apache_beam_10transforms_5stats_4_get_default_hash_fn(__pyx_self);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_11apache_beam_10transforms_5stats_4_get_default_hash_fn(CYTHON_UNUSED PyObject *__pyx_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_get_default_hash_fn", 0);

  /* "apache_beam/transforms/stats.py":83
 * def _get_default_hash_fn():
 *   """Returns either murmurhash or md5 based on installation."""
 *   if _default_hash_fn_type == 'md5':             # <<<<<<<<<<<<<<
 *     logging.warning(
 *         'Couldn\'t find murmurhash. Install mmh3 for a faster implementation of'
 */
  __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_default_hash_fn_type); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 83, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = (__Pyx_PyUnicode_Equals(__pyx_t_1, __pyx_n_u_md5, Py_EQ)); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 83, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_2) {

    /* "apache_beam/transforms/stats.py":84
 *   """Returns either murmurhash or md5 based on installation."""
 *   if _default_hash_fn_type == 'md5':
 *     logging.warning(             # <<<<<<<<<<<<<<
 *         'Couldn\'t find murmurhash. Install mmh3 for a faster implementation of'
 *         'ApproximateUnique.')
 */
    __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_logging); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 84, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_warning); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 84, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_3)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_3);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
      }
    }
    __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_3, __pyx_kp_u_Couldn_t_find_murmurhash_Install) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_kp_u_Couldn_t_find_murmurhash_Install);
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 84, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "apache_beam/transforms/stats.py":83
 * def _get_default_hash_fn():
 *   """Returns either murmurhash or md5 based on installation."""
 *   if _default_hash_fn_type == 'md5':             # <<<<<<<<<<<<<<
 *     logging.warning(
 *         'Couldn\'t find murmurhash. Install mmh3 for a faster implementation of'
 */
  }

  /* "apache_beam/transforms/stats.py":87
 *         'Couldn\'t find murmurhash. Install mmh3 for a faster implementation of'
 *         'ApproximateUnique.')
 *   return _default_hash_fn             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_default_hash_fn); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 87, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "apache_beam/transforms/stats.py":81
 * 
 * 
 * def _get_default_hash_fn():             # <<<<<<<<<<<<<<
 *   """Returns either murmurhash or md5 based on installation."""
 *   if _default_hash_fn_type == 'md5':
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("apache_beam.transforms.stats._get_default_hash_fn", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "apache_beam/transforms/stats.py":107
 * 
 *   @staticmethod
 *   def parse_input_params(size=None, error=None):             # <<<<<<<<<<<<<<
 *     """
 *     Check if input params are valid and return sample size.
 */

/* Python wrapper */
static PyObject *__pyx_pw_11apache_beam_10transforms_5stats_17ApproximateUnique_1parse_input_params(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_11apache_beam_10transforms_5stats_17ApproximateUnique_parse_input_params[] = "\n    Check if input params are valid and return sample size.\n\n    :param size: an int not smaller than 16, which we would use to estimate\n      number of unique values.\n    :param error: max estimation error, which is a float between 0.01 and 0.50.\n      If error is given, sample size will be calculated from error with\n      _get_sample_size_from_est_error function.\n    :return: sample size\n    :raises:\n      ValueError: If both size and error are given, or neither is given, or\n      values are out of range.\n    ";
static PyMethodDef __pyx_mdef_11apache_beam_10transforms_5stats_17ApproximateUnique_1parse_input_params = {"parse_input_params", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_11apache_beam_10transforms_5stats_17ApproximateUnique_1parse_input_params, METH_VARARGS|METH_KEYWORDS, __pyx_doc_11apache_beam_10transforms_5stats_17ApproximateUnique_parse_input_params};
static PyObject *__pyx_pw_11apache_beam_10transforms_5stats_17ApproximateUnique_1parse_input_params(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_size = 0;
  PyObject *__pyx_v_error = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("parse_input_params (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_size,&__pyx_n_s_error,0};
    PyObject* values[2] = {0,0};
    values[0] = ((PyObject *)((PyObject *)Py_None));
    values[1] = ((PyObject *)((PyObject *)Py_None));
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_size);
          if (value) { values[0] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  1:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_error);
          if (value) { values[1] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "parse_input_params") < 0)) __PYX_ERR(0, 107, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_size = values[0];
    __pyx_v_error = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("parse_input_params", 0, 0, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 107, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("apache_beam.transforms.stats.ApproximateUnique.parse_input_params", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_11apache_beam_10transforms_5stats_17ApproximateUnique_parse_input_params(__pyx_self, __pyx_v_size, __pyx_v_error);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_11apache_beam_10transforms_5stats_17ApproximateUnique_parse_input_params(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_size, PyObject *__pyx_v_error) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("parse_input_params", 0);

  /* "apache_beam/transforms/stats.py":122
 *     """
 * 
 *     if None not in (size, error):             # <<<<<<<<<<<<<<
 *       raise ValueError(ApproximateUnique._MULTI_VALUE_ERR_MSG % (size, error))
 *     elif size is None and error is None:
 */
  __Pyx_INCREF(Py_None);
  __pyx_t_1 = Py_None;
  __pyx_t_3 = PyObject_RichCompare(__pyx_t_1, __pyx_v_size, Py_NE); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 122, __pyx_L1_error)
  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 122, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (__pyx_t_4) {
  } else {
    __pyx_t_2 = __pyx_t_4;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_3 = PyObject_RichCompare(__pyx_t_1, __pyx_v_error, Py_NE); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 122, __pyx_L1_error)
  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 122, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_2 = __pyx_t_4;
  __pyx_L4_bool_binop_done:;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_4 = (__pyx_t_2 != 0);
  if (unlikely(__pyx_t_4)) {

    /* "apache_beam/transforms/stats.py":123
 * 
 *     if None not in (size, error):
 *       raise ValueError(ApproximateUnique._MULTI_VALUE_ERR_MSG % (size, error))             # <<<<<<<<<<<<<<
 *     elif size is None and error is None:
 *       raise ValueError(ApproximateUnique._NO_VALUE_ERR_MSG)
 */
    __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_ApproximateUnique); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 123, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_MULTI_VALUE_ERR_MSG); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 123, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 123, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_v_size);
    __Pyx_GIVEREF(__pyx_v_size);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_size);
    __Pyx_INCREF(__pyx_v_error);
    __Pyx_GIVEREF(__pyx_v_error);
    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_error);
    __pyx_t_5 = PyNumber_Remainder(__pyx_t_3, __pyx_t_1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 123, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 123, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_Raise(__pyx_t_1, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __PYX_ERR(0, 123, __pyx_L1_error)

    /* "apache_beam/transforms/stats.py":122
 *     """
 * 
 *     if None not in (size, error):             # <<<<<<<<<<<<<<
 *       raise ValueError(ApproximateUnique._MULTI_VALUE_ERR_MSG % (size, error))
 *     elif size is None and error is None:
 */
  }

  /* "apache_beam/transforms/stats.py":124
 *     if None not in (size, error):
 *       raise ValueError(ApproximateUnique._MULTI_VALUE_ERR_MSG % (size, error))
 *     elif size is None and error is None:             # <<<<<<<<<<<<<<
 *       raise ValueError(ApproximateUnique._NO_VALUE_ERR_MSG)
 *     elif size is not None:
 */
  __pyx_t_2 = (__pyx_v_size == Py_None);
  __pyx_t_6 = (__pyx_t_2 != 0);
  if (__pyx_t_6) {
  } else {
    __pyx_t_4 = __pyx_t_6;
    goto __pyx_L6_bool_binop_done;
  }
  __pyx_t_6 = (__pyx_v_error == Py_None);
  __pyx_t_2 = (__pyx_t_6 != 0);
  __pyx_t_4 = __pyx_t_2;
  __pyx_L6_bool_binop_done:;
  if (unlikely(__pyx_t_4)) {

    /* "apache_beam/transforms/stats.py":125
 *       raise ValueError(ApproximateUnique._MULTI_VALUE_ERR_MSG % (size, error))
 *     elif size is None and error is None:
 *       raise ValueError(ApproximateUnique._NO_VALUE_ERR_MSG)             # <<<<<<<<<<<<<<
 *     elif size is not None:
 *       if not isinstance(size, int) or size < 16:
 */
    __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_ApproximateUnique); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 125, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_NO_VALUE_ERR_MSG); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 125, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 125, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_Raise(__pyx_t_1, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __PYX_ERR(0, 125, __pyx_L1_error)

    /* "apache_beam/transforms/stats.py":124
 *     if None not in (size, error):
 *       raise ValueError(ApproximateUnique._MULTI_VALUE_ERR_MSG % (size, error))
 *     elif size is None and error is None:             # <<<<<<<<<<<<<<
 *       raise ValueError(ApproximateUnique._NO_VALUE_ERR_MSG)
 *     elif size is not None:
 */
  }

  /* "apache_beam/transforms/stats.py":126
 *     elif size is None and error is None:
 *       raise ValueError(ApproximateUnique._NO_VALUE_ERR_MSG)
 *     elif size is not None:             # <<<<<<<<<<<<<<
 *       if not isinstance(size, int) or size < 16:
 *         raise ValueError(ApproximateUnique._INPUT_SIZE_ERR_MSG % (size))
 */
  __pyx_t_4 = (__pyx_v_size != Py_None);
  __pyx_t_2 = (__pyx_t_4 != 0);
  if (__pyx_t_2) {

    /* "apache_beam/transforms/stats.py":127
 *       raise ValueError(ApproximateUnique._NO_VALUE_ERR_MSG)
 *     elif size is not None:
 *       if not isinstance(size, int) or size < 16:             # <<<<<<<<<<<<<<
 *         raise ValueError(ApproximateUnique._INPUT_SIZE_ERR_MSG % (size))
 *       else:
 */
    __pyx_t_4 = PyInt_Check(__pyx_v_size); 
    __pyx_t_6 = ((!(__pyx_t_4 != 0)) != 0);
    if (!__pyx_t_6) {
    } else {
      __pyx_t_2 = __pyx_t_6;
      goto __pyx_L9_bool_binop_done;
    }
    __pyx_t_1 = PyObject_RichCompare(__pyx_v_size, __pyx_int_16, Py_LT); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 127, __pyx_L1_error)
    __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 127, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_2 = __pyx_t_6;
    __pyx_L9_bool_binop_done:;
    if (unlikely(__pyx_t_2)) {

      /* "apache_beam/transforms/stats.py":128
 *     elif size is not None:
 *       if not isinstance(size, int) or size < 16:
 *         raise ValueError(ApproximateUnique._INPUT_SIZE_ERR_MSG % (size))             # <<<<<<<<<<<<<<
 *       else:
 *         return size
 */
      __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_ApproximateUnique); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 128, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_INPUT_SIZE_ERR_MSG); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 128, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_1 = PyNumber_Remainder(__pyx_t_5, __pyx_v_size); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 128, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 128, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_Raise(__pyx_t_5, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __PYX_ERR(0, 128, __pyx_L1_error)

      /* "apache_beam/transforms/stats.py":127
 *       raise ValueError(ApproximateUnique._NO_VALUE_ERR_MSG)
 *     elif size is not None:
 *       if not isinstance(size, int) or size < 16:             # <<<<<<<<<<<<<<
 *         raise ValueError(ApproximateUnique._INPUT_SIZE_ERR_MSG % (size))
 *       else:
 */
    }

    /* "apache_beam/transforms/stats.py":130
 *         raise ValueError(ApproximateUnique._INPUT_SIZE_ERR_MSG % (size))
 *       else:
 *         return size             # <<<<<<<<<<<<<<
 *     else:
 *       if error < 0.01 or error > 0.5:
 */
    /*else*/ {
      __Pyx_XDECREF(__pyx_r);
      __Pyx_INCREF(__pyx_v_size);
      __pyx_r = __pyx_v_size;
      goto __pyx_L0;
    }

    /* "apache_beam/transforms/stats.py":126
 *     elif size is None and error is None:
 *       raise ValueError(ApproximateUnique._NO_VALUE_ERR_MSG)
 *     elif size is not None:             # <<<<<<<<<<<<<<
 *       if not isinstance(size, int) or size < 16:
 *         raise ValueError(ApproximateUnique._INPUT_SIZE_ERR_MSG % (size))
 */
  }

  /* "apache_beam/transforms/stats.py":132
 *         return size
 *     else:
 *       if error < 0.01 or error > 0.5:             # <<<<<<<<<<<<<<
 *         raise ValueError(ApproximateUnique._INPUT_ERROR_ERR_MSG % (error))
 *       else:
 */
  /*else*/ {
    __pyx_t_5 = PyObject_RichCompare(__pyx_v_error, __pyx_float_0_01, Py_LT); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 132, __pyx_L1_error)
    __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 132, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    if (!__pyx_t_6) {
    } else {
      __pyx_t_2 = __pyx_t_6;
      goto __pyx_L12_bool_binop_done;
    }
    __pyx_t_5 = PyObject_RichCompare(__pyx_v_error, __pyx_float_0_5, Py_GT); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 132, __pyx_L1_error)
    __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 132, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_2 = __pyx_t_6;
    __pyx_L12_bool_binop_done:;
    if (unlikely(__pyx_t_2)) {

      /* "apache_beam/transforms/stats.py":133
 *     else:
 *       if error < 0.01 or error > 0.5:
 *         raise ValueError(ApproximateUnique._INPUT_ERROR_ERR_MSG % (error))             # <<<<<<<<<<<<<<
 *       else:
 *         return ApproximateUnique._get_sample_size_from_est_error(error)
 */
      __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_ApproximateUnique); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 133, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_INPUT_ERROR_ERR_MSG); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 133, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_5 = PyNumber_Remainder(__pyx_t_1, __pyx_v_error); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 133, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 133, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_Raise(__pyx_t_1, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __PYX_ERR(0, 133, __pyx_L1_error)

      /* "apache_beam/transforms/stats.py":132
 *         return size
 *     else:
 *       if error < 0.01 or error > 0.5:             # <<<<<<<<<<<<<<
 *         raise ValueError(ApproximateUnique._INPUT_ERROR_ERR_MSG % (error))
 *       else:
 */
    }

    /* "apache_beam/transforms/stats.py":135
 *         raise ValueError(ApproximateUnique._INPUT_ERROR_ERR_MSG % (error))
 *       else:
 *         return ApproximateUnique._get_sample_size_from_est_error(error)             # <<<<<<<<<<<<<<
 * 
 *   @staticmethod
 */
    /*else*/ {
      __Pyx_XDECREF(__pyx_r);
      __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_ApproximateUnique); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 135, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_get_sample_size_from_est_error); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 135, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_5 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
        __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_3);
        if (likely(__pyx_t_5)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
          __Pyx_INCREF(__pyx_t_5);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_3, function);
        }
      }
      __pyx_t_1 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_5, __pyx_v_error) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_error);
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 135, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_r = __pyx_t_1;
      __pyx_t_1 = 0;
      goto __pyx_L0;
    }
  }

  /* "apache_beam/transforms/stats.py":107
 * 
 *   @staticmethod
 *   def parse_input_params(size=None, error=None):             # <<<<<<<<<<<<<<
 *     """
 *     Check if input params are valid and return sample size.
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("apache_beam.transforms.stats.ApproximateUnique.parse_input_params", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "apache_beam/transforms/stats.py":138
 * 
 *   @staticmethod
 *   def _get_sample_size_from_est_error(est_err):             # <<<<<<<<<<<<<<
 *     """
 *     :return: sample size
 */

/* Python wrapper */
static PyObject *__pyx_pw_11apache_beam_10transforms_5stats_17ApproximateUnique_3_get_sample_size_from_est_error(PyObject *__pyx_self, PyObject *__pyx_v_est_err); /*proto*/
static char __pyx_doc_11apache_beam_10transforms_5stats_17ApproximateUnique_2_get_sample_size_from_est_error[] = "\n    :return: sample size\n\n    Calculate sample size from estimation error\n    ";
static PyMethodDef __pyx_mdef_11apache_beam_10transforms_5stats_17ApproximateUnique_3_get_sample_size_from_est_error = {"_get_sample_size_from_est_error", (PyCFunction)__pyx_pw_11apache_beam_10transforms_5stats_17ApproximateUnique_3_get_sample_size_from_est_error, METH_O, __pyx_doc_11apache_beam_10transforms_5stats_17ApproximateUnique_2_get_sample_size_from_est_error};
static PyObject *__pyx_pw_11apache_beam_10transforms_5stats_17ApproximateUnique_3_get_sample_size_from_est_error(PyObject *__pyx_self, PyObject *__pyx_v_est_err) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_get_sample_size_from_est_error (wrapper)", 0);
  __pyx_r = __pyx_pf_11apache_beam_10transforms_5stats_17ApproximateUnique_2_get_sample_size_from_est_error(__pyx_self, ((PyObject *)__pyx_v_est_err));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_11apache_beam_10transforms_5stats_17ApproximateUnique_2_get_sample_size_from_est_error(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_est_err) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_get_sample_size_from_est_error", 0);

  /* "apache_beam/transforms/stats.py":144
 *     Calculate sample size from estimation error
 *     """
 *     return math.ceil(4.0 / math.pow(est_err, 2.0))             # <<<<<<<<<<<<<<
 * 
 *   @typehints.with_input_types(T)
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_math); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 144, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_ceil); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 144, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_math); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 144, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_pow); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 144, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = NULL;
  __pyx_t_6 = 0;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_5);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_5, function);
      __pyx_t_6 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_5)) {
    PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_v_est_err, __pyx_float_2_0};
    __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 144, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_GOTREF(__pyx_t_2);
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) {
    PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_v_est_err, __pyx_float_2_0};
    __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 144, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_GOTREF(__pyx_t_2);
  } else
  #endif
  {
    __pyx_t_7 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 144, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    if (__pyx_t_4) {
      __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_4); __pyx_t_4 = NULL;
    }
    __Pyx_INCREF(__pyx_v_est_err);
    __Pyx_GIVEREF(__pyx_v_est_err);
    PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, __pyx_v_est_err);
    __Pyx_INCREF(__pyx_float_2_0);
    __Pyx_GIVEREF(__pyx_float_2_0);
    PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, __pyx_float_2_0);
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_7, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 144, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  }
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = __Pyx_PyFloat_TrueDivideCObj(__pyx_float_4_0, __pyx_t_2, 4.0, 0, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 144, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  __pyx_t_1 = (__pyx_t_2) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_2, __pyx_t_5) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_5);
  __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 144, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "apache_beam/transforms/stats.py":138
 * 
 *   @staticmethod
 *   def _get_sample_size_from_est_error(est_err):             # <<<<<<<<<<<<<<
 *     """
 *     :return: sample size
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("apache_beam.transforms.stats.ApproximateUnique._get_sample_size_from_est_error", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "apache_beam/transforms/stats.py":150
 *   class Globally(PTransform):
 *     """ Approximate.Globally approximate number of unique values"""
 *     def __init__(self, size=None, error=None):             # <<<<<<<<<<<<<<
 *       self._sample_size = ApproximateUnique.parse_input_params(size, error)
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_11apache_beam_10transforms_5stats_8Globally_1__init__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_11apache_beam_10transforms_5stats_8Globally_1__init__ = {"__init__", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_11apache_beam_10transforms_5stats_8Globally_1__init__, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_11apache_beam_10transforms_5stats_8Globally_1__init__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_size = 0;
  PyObject *__pyx_v_error = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_size,&__pyx_n_s_error,0};
    PyObject* values[3] = {0,0,0};
    values[1] = ((PyObject *)((PyObject *)Py_None));
    values[2] = ((PyObject *)((PyObject *)Py_None));
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_size);
          if (value) { values[1] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_error);
          if (value) { values[2] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(0, 150, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_self = values[0];
    __pyx_v_size = values[1];
    __pyx_v_error = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 0, 1, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 150, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("apache_beam.transforms.stats.Globally.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_11apache_beam_10transforms_5stats_8Globally___init__(__pyx_self, __pyx_v_self, __pyx_v_size, __pyx_v_error);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_11apache_beam_10transforms_5stats_8Globally___init__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_size, PyObject *__pyx_v_error) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "apache_beam/transforms/stats.py":151
 *     """ Approximate.Globally approximate number of unique values"""
 *     def __init__(self, size=None, error=None):
 *       self._sample_size = ApproximateUnique.parse_input_params(size, error)             # <<<<<<<<<<<<<<
 * 
 *     def expand(self, pcoll):
 */
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_ApproximateUnique); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 151, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_parse_input_params); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 151, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = NULL;
  __pyx_t_4 = 0;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
      __pyx_t_4 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_3)) {
    PyObject *__pyx_temp[3] = {__pyx_t_2, __pyx_v_size, __pyx_v_error};
    __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_4, 2+__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 151, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
    PyObject *__pyx_temp[3] = {__pyx_t_2, __pyx_v_size, __pyx_v_error};
    __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_4, 2+__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 151, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else
  #endif
  {
    __pyx_t_5 = PyTuple_New(2+__pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 151, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    if (__pyx_t_2) {
      __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_2); __pyx_t_2 = NULL;
    }
    __Pyx_INCREF(__pyx_v_size);
    __Pyx_GIVEREF(__pyx_v_size);
    PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_4, __pyx_v_size);
    __Pyx_INCREF(__pyx_v_error);
    __Pyx_GIVEREF(__pyx_v_error);
    PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_4, __pyx_v_error);
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 151, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_sample_size, __pyx_t_1) < 0) __PYX_ERR(0, 151, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "apache_beam/transforms/stats.py":150
 *   class Globally(PTransform):
 *     """ Approximate.Globally approximate number of unique values"""
 *     def __init__(self, size=None, error=None):             # <<<<<<<<<<<<<<
 *       self._sample_size = ApproximateUnique.parse_input_params(size, error)
 * 
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("apache_beam.transforms.stats.Globally.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "apache_beam/transforms/stats.py":153
 *       self._sample_size = ApproximateUnique.parse_input_params(size, error)
 * 
 *     def expand(self, pcoll):             # <<<<<<<<<<<<<<
 *       coder = coders.registry.get_coder(pcoll)
 *       return pcoll \
 */

/* Python wrapper */
static PyObject *__pyx_pw_11apache_beam_10transforms_5stats_8Globally_3expand(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_11apache_beam_10transforms_5stats_8Globally_3expand = {"expand", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_11apache_beam_10transforms_5stats_8Globally_3expand, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_11apache_beam_10transforms_5stats_8Globally_3expand(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_pcoll = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("expand (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_pcoll,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pcoll)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("expand", 1, 2, 2, 1); __PYX_ERR(0, 153, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "expand") < 0)) __PYX_ERR(0, 153, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_self = values[0];
    __pyx_v_pcoll = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("expand", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 153, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("apache_beam.transforms.stats.Globally.expand", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_11apache_beam_10transforms_5stats_8Globally_2expand(__pyx_self, __pyx_v_self, __pyx_v_pcoll);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_11apache_beam_10transforms_5stats_8Globally_2expand(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_pcoll) {
  PyObject *__pyx_v_coder = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("expand", 0);

  /* "apache_beam/transforms/stats.py":154
 * 
 *     def expand(self, pcoll):
 *       coder = coders.registry.get_coder(pcoll)             # <<<<<<<<<<<<<<
 *       return pcoll \
 *              | 'CountGlobalUniqueValues' \
 */
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_coders); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 154, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_registry); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 154, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_get_coder); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 154, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_3, __pyx_v_pcoll) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_pcoll);
  __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 154, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_coder = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "apache_beam/transforms/stats.py":155
 *     def expand(self, pcoll):
 *       coder = coders.registry.get_coder(pcoll)
 *       return pcoll \             # <<<<<<<<<<<<<<
 *              | 'CountGlobalUniqueValues' \
 *              >> (CombineGlobally(ApproximateUniqueCombineFn(self._sample_size,
 */
  __Pyx_XDECREF(__pyx_r);

  /* "apache_beam/transforms/stats.py":157
 *       return pcoll \
 *              | 'CountGlobalUniqueValues' \
 *              >> (CombineGlobally(ApproximateUniqueCombineFn(self._sample_size,             # <<<<<<<<<<<<<<
 *                                                             coder)))
 * 
 */
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_CombineGlobally); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 157, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_ApproximateUniqueCombineFn); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 157, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_sample_size); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 157, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);

  /* "apache_beam/transforms/stats.py":158
 *              | 'CountGlobalUniqueValues' \
 *              >> (CombineGlobally(ApproximateUniqueCombineFn(self._sample_size,
 *                                                             coder)))             # <<<<<<<<<<<<<<
 * 
 *   @typehints.with_input_types(typing.Tuple[K, V])
 */
  __pyx_t_6 = NULL;
  __pyx_t_7 = 0;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_6)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
      __pyx_t_7 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_4)) {
    PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_t_5, __pyx_v_coder};
    __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 157, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
    PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_t_5, __pyx_v_coder};
    __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 157, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  } else
  #endif
  {
    __pyx_t_8 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 157, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    if (__pyx_t_6) {
      __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_6); __pyx_t_6 = NULL;
    }
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_7, __pyx_t_5);
    __Pyx_INCREF(__pyx_v_coder);
    __Pyx_GIVEREF(__pyx_v_coder);
    PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_7, __pyx_v_coder);
    __pyx_t_5 = 0;
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_8, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 157, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  }
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  __pyx_t_1 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_4, __pyx_t_3) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 157, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "apache_beam/transforms/stats.py":157
 *       return pcoll \
 *              | 'CountGlobalUniqueValues' \
 *              >> (CombineGlobally(ApproximateUniqueCombineFn(self._sample_size,             # <<<<<<<<<<<<<<
 *                                                             coder)))
 * 
 */
  __pyx_t_2 = PyNumber_Rshift(__pyx_n_u_CountGlobalUniqueValues, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 157, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "apache_beam/transforms/stats.py":156
 *       coder = coders.registry.get_coder(pcoll)
 *       return pcoll \
 *              | 'CountGlobalUniqueValues' \             # <<<<<<<<<<<<<<
 *              >> (CombineGlobally(ApproximateUniqueCombineFn(self._sample_size,
 *                                                             coder)))
 */
  __pyx_t_1 = PyNumber_Or(__pyx_v_pcoll, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 156, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "apache_beam/transforms/stats.py":153
 *       self._sample_size = ApproximateUnique.parse_input_params(size, error)
 * 
 *     def expand(self, pcoll):             # <<<<<<<<<<<<<<
 *       coder = coders.registry.get_coder(pcoll)
 *       return pcoll \
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("apache_beam.transforms.stats.Globally.expand", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_coder);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "apache_beam/transforms/stats.py":164
 *   class PerKey(PTransform):
 *     """ Approximate.PerKey approximate number of unique values per key"""
 *     def __init__(self, size=None, error=None):             # <<<<<<<<<<<<<<
 *       self._sample_size = ApproximateUnique.parse_input_params(size, error)
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_11apache_beam_10transforms_5stats_6PerKey_1__init__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_11apache_beam_10transforms_5stats_6PerKey_1__init__ = {"__init__", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_11apache_beam_10transforms_5stats_6PerKey_1__init__, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_11apache_beam_10transforms_5stats_6PerKey_1__init__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_size = 0;
  PyObject *__pyx_v_error = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_size,&__pyx_n_s_error,0};
    PyObject* values[3] = {0,0,0};
    values[1] = ((PyObject *)((PyObject *)Py_None));
    values[2] = ((PyObject *)((PyObject *)Py_None));
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_size);
          if (value) { values[1] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_error);
          if (value) { values[2] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(0, 164, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_self = values[0];
    __pyx_v_size = values[1];
    __pyx_v_error = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 0, 1, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 164, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("apache_beam.transforms.stats.PerKey.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_11apache_beam_10transforms_5stats_6PerKey___init__(__pyx_self, __pyx_v_self, __pyx_v_size, __pyx_v_error);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_11apache_beam_10transforms_5stats_6PerKey___init__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_size, PyObject *__pyx_v_error) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "apache_beam/transforms/stats.py":165
 *     """ Approximate.PerKey approximate number of unique values per key"""
 *     def __init__(self, size=None, error=None):
 *       self._sample_size = ApproximateUnique.parse_input_params(size, error)             # <<<<<<<<<<<<<<
 * 
 *     def expand(self, pcoll):
 */
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_ApproximateUnique); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 165, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_parse_input_params); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 165, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = NULL;
  __pyx_t_4 = 0;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
      __pyx_t_4 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_3)) {
    PyObject *__pyx_temp[3] = {__pyx_t_2, __pyx_v_size, __pyx_v_error};
    __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_4, 2+__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 165, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
    PyObject *__pyx_temp[3] = {__pyx_t_2, __pyx_v_size, __pyx_v_error};
    __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_4, 2+__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 165, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else
  #endif
  {
    __pyx_t_5 = PyTuple_New(2+__pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 165, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    if (__pyx_t_2) {
      __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_2); __pyx_t_2 = NULL;
    }
    __Pyx_INCREF(__pyx_v_size);
    __Pyx_GIVEREF(__pyx_v_size);
    PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_4, __pyx_v_size);
    __Pyx_INCREF(__pyx_v_error);
    __Pyx_GIVEREF(__pyx_v_error);
    PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_4, __pyx_v_error);
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 165, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_sample_size, __pyx_t_1) < 0) __PYX_ERR(0, 165, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "apache_beam/transforms/stats.py":164
 *   class PerKey(PTransform):
 *     """ Approximate.PerKey approximate number of unique values per key"""
 *     def __init__(self, size=None, error=None):             # <<<<<<<<<<<<<<
 *       self._sample_size = ApproximateUnique.parse_input_params(size, error)
 * 
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("apache_beam.transforms.stats.PerKey.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "apache_beam/transforms/stats.py":167
 *       self._sample_size = ApproximateUnique.parse_input_params(size, error)
 * 
 *     def expand(self, pcoll):             # <<<<<<<<<<<<<<
 *       coder = coders.registry.get_coder(pcoll)
 *       return pcoll \
 */

/* Python wrapper */
static PyObject *__pyx_pw_11apache_beam_10transforms_5stats_6PerKey_3expand(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_11apache_beam_10transforms_5stats_6PerKey_3expand = {"expand", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_11apache_beam_10transforms_5stats_6PerKey_3expand, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_11apache_beam_10transforms_5stats_6PerKey_3expand(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_pcoll = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("expand (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_pcoll,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pcoll)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("expand", 1, 2, 2, 1); __PYX_ERR(0, 167, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "expand") < 0)) __PYX_ERR(0, 167, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_self = values[0];
    __pyx_v_pcoll = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("expand", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 167, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("apache_beam.transforms.stats.PerKey.expand", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_11apache_beam_10transforms_5stats_6PerKey_2expand(__pyx_self, __pyx_v_self, __pyx_v_pcoll);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_11apache_beam_10transforms_5stats_6PerKey_2expand(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_pcoll) {
  PyObject *__pyx_v_coder = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("expand", 0);

  /* "apache_beam/transforms/stats.py":168
 * 
 *     def expand(self, pcoll):
 *       coder = coders.registry.get_coder(pcoll)             # <<<<<<<<<<<<<<
 *       return pcoll \
 *              | 'CountPerKeyUniqueValues' \
 */
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_coders); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 168, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_registry); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 168, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_get_coder); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 168, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_3, __pyx_v_pcoll) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_pcoll);
  __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 168, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_coder = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "apache_beam/transforms/stats.py":169
 *     def expand(self, pcoll):
 *       coder = coders.registry.get_coder(pcoll)
 *       return pcoll \             # <<<<<<<<<<<<<<
 *              | 'CountPerKeyUniqueValues' \
 *              >> (CombinePerKey(ApproximateUniqueCombineFn(self._sample_size,
 */
  __Pyx_XDECREF(__pyx_r);

  /* "apache_beam/transforms/stats.py":171
 *       return pcoll \
 *              | 'CountPerKeyUniqueValues' \
 *              >> (CombinePerKey(ApproximateUniqueCombineFn(self._sample_size,             # <<<<<<<<<<<<<<
 *                                                           coder)))
 * 
 */
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_CombinePerKey); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 171, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_ApproximateUniqueCombineFn); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 171, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_sample_size); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 171, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);

  /* "apache_beam/transforms/stats.py":172
 *              | 'CountPerKeyUniqueValues' \
 *              >> (CombinePerKey(ApproximateUniqueCombineFn(self._sample_size,
 *                                                           coder)))             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_6 = NULL;
  __pyx_t_7 = 0;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_6)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
      __pyx_t_7 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_4)) {
    PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_t_5, __pyx_v_coder};
    __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 171, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
    PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_t_5, __pyx_v_coder};
    __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 171, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  } else
  #endif
  {
    __pyx_t_8 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 171, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    if (__pyx_t_6) {
      __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_6); __pyx_t_6 = NULL;
    }
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_7, __pyx_t_5);
    __Pyx_INCREF(__pyx_v_coder);
    __Pyx_GIVEREF(__pyx_v_coder);
    PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_7, __pyx_v_coder);
    __pyx_t_5 = 0;
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_8, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 171, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  }
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  __pyx_t_1 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_4, __pyx_t_3) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 171, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "apache_beam/transforms/stats.py":171
 *       return pcoll \
 *              | 'CountPerKeyUniqueValues' \
 *              >> (CombinePerKey(ApproximateUniqueCombineFn(self._sample_size,             # <<<<<<<<<<<<<<
 *                                                           coder)))
 * 
 */
  __pyx_t_2 = PyNumber_Rshift(__pyx_n_u_CountPerKeyUniqueValues, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 171, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "apache_beam/transforms/stats.py":170
 *       coder = coders.registry.get_coder(pcoll)
 *       return pcoll \
 *              | 'CountPerKeyUniqueValues' \             # <<<<<<<<<<<<<<
 *              >> (CombinePerKey(ApproximateUniqueCombineFn(self._sample_size,
 *                                                           coder)))
 */
  __pyx_t_1 = PyNumber_Or(__pyx_v_pcoll, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 170, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "apache_beam/transforms/stats.py":167
 *       self._sample_size = ApproximateUnique.parse_input_params(size, error)
 * 
 *     def expand(self, pcoll):             # <<<<<<<<<<<<<<
 *       coder = coders.registry.get_coder(pcoll)
 *       return pcoll \
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("apache_beam.transforms.stats.PerKey.expand", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_coder);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "apache_beam/transforms/stats.py":183
 *   _HASH_SPACE_SIZE = 2.0**64
 * 
 *   def __init__(self, sample_size):             # <<<<<<<<<<<<<<
 *     self._sample_size = sample_size
 *     self._min_hash = 2.0**64
 */

/* Python wrapper */
static PyObject *__pyx_pw_11apache_beam_10transforms_5stats_14_LargestUnique_1__init__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_11apache_beam_10transforms_5stats_14_LargestUnique_1__init__ = {"__init__", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_11apache_beam_10transforms_5stats_14_LargestUnique_1__init__, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_11apache_beam_10transforms_5stats_14_LargestUnique_1__init__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_sample_size = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_sample_size_2,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_sample_size_2)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 1, 2, 2, 1); __PYX_ERR(0, 183, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(0, 183, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_self = values[0];
    __pyx_v_sample_size = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 183, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("apache_beam.transforms.stats._LargestUnique.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_11apache_beam_10transforms_5stats_14_LargestUnique___init__(__pyx_self, __pyx_v_self, __pyx_v_sample_size);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_11apache_beam_10transforms_5stats_14_LargestUnique___init__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_sample_size) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "apache_beam/transforms/stats.py":184
 * 
 *   def __init__(self, sample_size):
 *     self._sample_size = sample_size             # <<<<<<<<<<<<<<
 *     self._min_hash = 2.0**64
 *     self._sample_heap = []
 */
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_sample_size, __pyx_v_sample_size) < 0) __PYX_ERR(0, 184, __pyx_L1_error)

  /* "apache_beam/transforms/stats.py":185
 *   def __init__(self, sample_size):
 *     self._sample_size = sample_size
 *     self._min_hash = 2.0**64             # <<<<<<<<<<<<<<
 *     self._sample_heap = []
 *     self._sample_set = set()
 */
  __pyx_t_1 = PyFloat_FromDouble(pow(2.0, 64.0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 185, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_min_hash, __pyx_t_1) < 0) __PYX_ERR(0, 185, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "apache_beam/transforms/stats.py":186
 *     self._sample_size = sample_size
 *     self._min_hash = 2.0**64
 *     self._sample_heap = []             # <<<<<<<<<<<<<<
 *     self._sample_set = set()
 * 
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 186, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_sample_heap, __pyx_t_1) < 0) __PYX_ERR(0, 186, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "apache_beam/transforms/stats.py":187
 *     self._min_hash = 2.0**64
 *     self._sample_heap = []
 *     self._sample_set = set()             # <<<<<<<<<<<<<<
 * 
 *   def add(self, element):
 */
  __pyx_t_1 = PySet_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 187, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_sample_set, __pyx_t_1) < 0) __PYX_ERR(0, 187, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "apache_beam/transforms/stats.py":183
 *   _HASH_SPACE_SIZE = 2.0**64
 * 
 *   def __init__(self, sample_size):             # <<<<<<<<<<<<<<
 *     self._sample_size = sample_size
 *     self._min_hash = 2.0**64
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("apache_beam.transforms.stats._LargestUnique.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "apache_beam/transforms/stats.py":189
 *     self._sample_set = set()
 * 
 *   def add(self, element):             # <<<<<<<<<<<<<<
 *     """
 *     :param an element from pcoll.
 */

/* Python wrapper */
static PyObject *__pyx_pw_11apache_beam_10transforms_5stats_14_LargestUnique_3add(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_11apache_beam_10transforms_5stats_14_LargestUnique_2add[] = "\n    :param an element from pcoll.\n    :return: boolean type whether the value is in the heap\n\n    Adds a value to the heap, returning whether the value is (large enough to\n    be) in the heap.\n    ";
static PyMethodDef __pyx_mdef_11apache_beam_10transforms_5stats_14_LargestUnique_3add = {"add", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_11apache_beam_10transforms_5stats_14_LargestUnique_3add, METH_VARARGS|METH_KEYWORDS, __pyx_doc_11apache_beam_10transforms_5stats_14_LargestUnique_2add};
static PyObject *__pyx_pw_11apache_beam_10transforms_5stats_14_LargestUnique_3add(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_element = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("add (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_element,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_element)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("add", 1, 2, 2, 1); __PYX_ERR(0, 189, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "add") < 0)) __PYX_ERR(0, 189, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_self = values[0];
    __pyx_v_element = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("add", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 189, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("apache_beam.transforms.stats._LargestUnique.add", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_11apache_beam_10transforms_5stats_14_LargestUnique_2add(__pyx_self, __pyx_v_self, __pyx_v_element);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_11apache_beam_10transforms_5stats_14_LargestUnique_2add(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_element) {
  PyObject *__pyx_v_temp = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  Py_ssize_t __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_t_8;
  PyObject *__pyx_t_9 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("add", 0);

  /* "apache_beam/transforms/stats.py":197
 *     be) in the heap.
 *     """
 *     if len(self._sample_heap) >= self._sample_size and element < self._min_hash:             # <<<<<<<<<<<<<<
 *       return False
 * 
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_sample_heap); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 197, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyObject_Length(__pyx_t_2); if (unlikely(__pyx_t_3 == ((Py_ssize_t)-1))) __PYX_ERR(0, 197, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyInt_FromSsize_t(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 197, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_sample_size); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 197, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = PyObject_RichCompare(__pyx_t_2, __pyx_t_4, Py_GE); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 197, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 197, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (__pyx_t_6) {
  } else {
    __pyx_t_1 = __pyx_t_6;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_min_hash); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 197, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_4 = PyObject_RichCompare(__pyx_v_element, __pyx_t_5, Py_LT); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 197, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 197, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_1 = __pyx_t_6;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_1) {

    /* "apache_beam/transforms/stats.py":198
 *     """
 *     if len(self._sample_heap) >= self._sample_size and element < self._min_hash:
 *       return False             # <<<<<<<<<<<<<<
 * 
 *     if element not in self._sample_set:
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(Py_False);
    __pyx_r = Py_False;
    goto __pyx_L0;

    /* "apache_beam/transforms/stats.py":197
 *     be) in the heap.
 *     """
 *     if len(self._sample_heap) >= self._sample_size and element < self._min_hash:             # <<<<<<<<<<<<<<
 *       return False
 * 
 */
  }

  /* "apache_beam/transforms/stats.py":200
 *       return False
 * 
 *     if element not in self._sample_set:             # <<<<<<<<<<<<<<
 *       self._sample_set.add(element)
 *       heapq.heappush(self._sample_heap, element)
 */
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_sample_set); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 200, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_1 = (__Pyx_PySequence_ContainsTF(__pyx_v_element, __pyx_t_4, Py_NE)); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 200, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_6 = (__pyx_t_1 != 0);
  if (__pyx_t_6) {

    /* "apache_beam/transforms/stats.py":201
 * 
 *     if element not in self._sample_set:
 *       self._sample_set.add(element)             # <<<<<<<<<<<<<<
 *       heapq.heappush(self._sample_heap, element)
 * 
 */
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_sample_set); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 201, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_add); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 201, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_2);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_2, function);
      }
    }
    __pyx_t_4 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_5, __pyx_v_element) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_element);
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 201, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "apache_beam/transforms/stats.py":202
 *     if element not in self._sample_set:
 *       self._sample_set.add(element)
 *       heapq.heappush(self._sample_heap, element)             # <<<<<<<<<<<<<<
 * 
 *       if len(self._sample_heap) > self._sample_size:
 */
    __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_heapq); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 202, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_heappush); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 202, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_sample_heap); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 202, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_7 = NULL;
    __pyx_t_8 = 0;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) {
      __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_5);
      if (likely(__pyx_t_7)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
        __Pyx_INCREF(__pyx_t_7);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_5, function);
        __pyx_t_8 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_5)) {
      PyObject *__pyx_temp[3] = {__pyx_t_7, __pyx_t_2, __pyx_v_element};
      __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 202, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) {
      PyObject *__pyx_temp[3] = {__pyx_t_7, __pyx_t_2, __pyx_v_element};
      __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 202, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    } else
    #endif
    {
      __pyx_t_9 = PyTuple_New(2+__pyx_t_8); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 202, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      if (__pyx_t_7) {
        __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_7); __pyx_t_7 = NULL;
      }
      __Pyx_GIVEREF(__pyx_t_2);
      PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_8, __pyx_t_2);
      __Pyx_INCREF(__pyx_v_element);
      __Pyx_GIVEREF(__pyx_v_element);
      PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_8, __pyx_v_element);
      __pyx_t_2 = 0;
      __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_9, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 202, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    }
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "apache_beam/transforms/stats.py":204
 *       heapq.heappush(self._sample_heap, element)
 * 
 *       if len(self._sample_heap) > self._sample_size:             # <<<<<<<<<<<<<<
 *         temp = heapq.heappop(self._sample_heap)
 *         self._sample_set.remove(temp)
 */
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_sample_heap); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 204, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_3 = PyObject_Length(__pyx_t_4); if (unlikely(__pyx_t_3 == ((Py_ssize_t)-1))) __PYX_ERR(0, 204, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = PyInt_FromSsize_t(__pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 204, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_sample_size); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 204, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_9 = PyObject_RichCompare(__pyx_t_4, __pyx_t_5, Py_GT); __Pyx_XGOTREF(__pyx_t_9); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 204, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_9); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 204, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    if (__pyx_t_6) {

      /* "apache_beam/transforms/stats.py":205
 * 
 *       if len(self._sample_heap) > self._sample_size:
 *         temp = heapq.heappop(self._sample_heap)             # <<<<<<<<<<<<<<
 *         self._sample_set.remove(temp)
 *         self._min_hash = self._sample_heap[0]
 */
      __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_heapq); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 205, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_heappop); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 205, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_sample_heap); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 205, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_2 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
        __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_4);
        if (likely(__pyx_t_2)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
          __Pyx_INCREF(__pyx_t_2);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_4, function);
        }
      }
      __pyx_t_9 = (__pyx_t_2) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_2, __pyx_t_5) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5);
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 205, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_v_temp = __pyx_t_9;
      __pyx_t_9 = 0;

      /* "apache_beam/transforms/stats.py":206
 *       if len(self._sample_heap) > self._sample_size:
 *         temp = heapq.heappop(self._sample_heap)
 *         self._sample_set.remove(temp)             # <<<<<<<<<<<<<<
 *         self._min_hash = self._sample_heap[0]
 *       elif element < self._min_hash:
 */
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_sample_set); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 206, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_remove); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 206, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_4 = NULL;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) {
        __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_5);
        if (likely(__pyx_t_4)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
          __Pyx_INCREF(__pyx_t_4);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_5, function);
        }
      }
      __pyx_t_9 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_5, __pyx_t_4, __pyx_v_temp) : __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_v_temp);
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 206, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;

      /* "apache_beam/transforms/stats.py":207
 *         temp = heapq.heappop(self._sample_heap)
 *         self._sample_set.remove(temp)
 *         self._min_hash = self._sample_heap[0]             # <<<<<<<<<<<<<<
 *       elif element < self._min_hash:
 *         self._min_hash = element
 */
      __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_sample_heap); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 207, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_5 = __Pyx_GetItemInt(__pyx_t_9, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 207, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_min_hash, __pyx_t_5) < 0) __PYX_ERR(0, 207, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

      /* "apache_beam/transforms/stats.py":204
 *       heapq.heappush(self._sample_heap, element)
 * 
 *       if len(self._sample_heap) > self._sample_size:             # <<<<<<<<<<<<<<
 *         temp = heapq.heappop(self._sample_heap)
 *         self._sample_set.remove(temp)
 */
      goto __pyx_L7;
    }

    /* "apache_beam/transforms/stats.py":208
 *         self._sample_set.remove(temp)
 *         self._min_hash = self._sample_heap[0]
 *       elif element < self._min_hash:             # <<<<<<<<<<<<<<
 *         self._min_hash = element
 *     return True
 */
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_min_hash); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 208, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_9 = PyObject_RichCompare(__pyx_v_element, __pyx_t_5, Py_LT); __Pyx_XGOTREF(__pyx_t_9); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 208, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_9); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 208, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    if (__pyx_t_6) {

      /* "apache_beam/transforms/stats.py":209
 *         self._min_hash = self._sample_heap[0]
 *       elif element < self._min_hash:
 *         self._min_hash = element             # <<<<<<<<<<<<<<
 *     return True
 * 
 */
      if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_min_hash, __pyx_v_element) < 0) __PYX_ERR(0, 209, __pyx_L1_error)

      /* "apache_beam/transforms/stats.py":208
 *         self._sample_set.remove(temp)
 *         self._min_hash = self._sample_heap[0]
 *       elif element < self._min_hash:             # <<<<<<<<<<<<<<
 *         self._min_hash = element
 *     return True
 */
    }
    __pyx_L7:;

    /* "apache_beam/transforms/stats.py":200
 *       return False
 * 
 *     if element not in self._sample_set:             # <<<<<<<<<<<<<<
 *       self._sample_set.add(element)
 *       heapq.heappush(self._sample_heap, element)
 */
  }

  /* "apache_beam/transforms/stats.py":210
 *       elif element < self._min_hash:
 *         self._min_hash = element
 *     return True             # <<<<<<<<<<<<<<
 * 
 *   def get_estimate(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(Py_True);
  __pyx_r = Py_True;
  goto __pyx_L0;

  /* "apache_beam/transforms/stats.py":189
 *     self._sample_set = set()
 * 
 *   def add(self, element):             # <<<<<<<<<<<<<<
 *     """
 *     :param an element from pcoll.
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("apache_beam.transforms.stats._LargestUnique.add", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_temp);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "apache_beam/transforms/stats.py":212
 *     return True
 * 
 *   def get_estimate(self):             # <<<<<<<<<<<<<<
 *     """
 *     :return: estimation count of unique values
 */

/* Python wrapper */
static PyObject *__pyx_pw_11apache_beam_10transforms_5stats_14_LargestUnique_5get_estimate(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/
static char __pyx_doc_11apache_beam_10transforms_5stats_14_LargestUnique_4get_estimate[] = "\n    :return: estimation count of unique values\n\n    If heap size is smaller than sample size, just return heap size.\n    Otherwise, takes into account the possibility of hash collisions,\n    which become more likely than not for 2^32 distinct elements.\n    Note that log(1+x) ~ x for small x, so for sampleSize << maxHash\n    log(1 - sample_size/sample_space) / log(1 - 1/sample_space) ~ sample_size\n    and hence estimate ~ sample_size * hash_space / sample_space\n    as one would expect.\n\n    Given sample_size / sample_space = est / hash_space\n    est = sample_size * hash_space / sample_space\n\n    Given above sample_size approximate,\n    est = log1p(-sample_size/sample_space) / log1p(-1/sample_space)\n      * hash_space / sample_space\n    ";
static PyMethodDef __pyx_mdef_11apache_beam_10transforms_5stats_14_LargestUnique_5get_estimate = {"get_estimate", (PyCFunction)__pyx_pw_11apache_beam_10transforms_5stats_14_LargestUnique_5get_estimate, METH_O, __pyx_doc_11apache_beam_10transforms_5stats_14_LargestUnique_4get_estimate};
static PyObject *__pyx_pw_11apache_beam_10transforms_5stats_14_LargestUnique_5get_estimate(PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_estimate (wrapper)", 0);
  __pyx_r = __pyx_pf_11apache_beam_10transforms_5stats_14_LargestUnique_4get_estimate(__pyx_self, ((PyObject *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_11apache_beam_10transforms_5stats_14_LargestUnique_4get_estimate(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_v_sample_space_size = NULL;
  PyObject *__pyx_v_est = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_estimate", 0);

  /* "apache_beam/transforms/stats.py":231
 *       * hash_space / sample_space
 *     """
 *     if len(self._sample_heap) < self._sample_size:             # <<<<<<<<<<<<<<
 *       return len(self._sample_heap)
 *     else:
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_sample_heap); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 231, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_2 == ((Py_ssize_t)-1))) __PYX_ERR(0, 231, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyInt_FromSsize_t(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 231, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_sample_size); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 231, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = PyObject_RichCompare(__pyx_t_1, __pyx_t_3, Py_LT); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 231, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 231, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (__pyx_t_5) {

    /* "apache_beam/transforms/stats.py":232
 *     """
 *     if len(self._sample_heap) < self._sample_size:
 *       return len(self._sample_heap)             # <<<<<<<<<<<<<<
 *     else:
 *       sample_space_size = self._HASH_SPACE_SIZE - 1.0 * self._min_hash
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_sample_heap); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 232, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_2 = PyObject_Length(__pyx_t_4); if (unlikely(__pyx_t_2 == ((Py_ssize_t)-1))) __PYX_ERR(0, 232, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = PyInt_FromSsize_t(__pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 232, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_r = __pyx_t_4;
    __pyx_t_4 = 0;
    goto __pyx_L0;

    /* "apache_beam/transforms/stats.py":231
 *       * hash_space / sample_space
 *     """
 *     if len(self._sample_heap) < self._sample_size:             # <<<<<<<<<<<<<<
 *       return len(self._sample_heap)
 *     else:
 */
  }

  /* "apache_beam/transforms/stats.py":234
 *       return len(self._sample_heap)
 *     else:
 *       sample_space_size = self._HASH_SPACE_SIZE - 1.0 * self._min_hash             # <<<<<<<<<<<<<<
 *       est = (
 *           math.log1p(-self._sample_size / sample_space_size) /
 */
  /*else*/ {
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_HASH_SPACE_SIZE); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 234, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_min_hash); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 234, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_1 = PyNumber_Multiply(__pyx_float_1_0, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 234, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = PyNumber_Subtract(__pyx_t_4, __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 234, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_v_sample_space_size = __pyx_t_3;
    __pyx_t_3 = 0;

    /* "apache_beam/transforms/stats.py":236
 *       sample_space_size = self._HASH_SPACE_SIZE - 1.0 * self._min_hash
 *       est = (
 *           math.log1p(-self._sample_size / sample_space_size) /             # <<<<<<<<<<<<<<
 *           math.log1p(-1 / sample_space_size) * self._HASH_SPACE_SIZE /
 *           sample_space_size)
 */
    __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_math); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 236, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_log1p); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 236, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_sample_size); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 236, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_6 = PyNumber_Negative(__pyx_t_1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 236, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = __Pyx_PyNumber_Divide(__pyx_t_6, __pyx_v_sample_space_size); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 236, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_6 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_6)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_6);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
      }
    }
    __pyx_t_3 = (__pyx_t_6) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_6, __pyx_t_1) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_1);
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 236, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "apache_beam/transforms/stats.py":237
 *       est = (
 *           math.log1p(-self._sample_size / sample_space_size) /
 *           math.log1p(-1 / sample_space_size) * self._HASH_SPACE_SIZE /             # <<<<<<<<<<<<<<
 *           sample_space_size)
 *       return round(est)
 */
    __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_math); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 237, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_log1p); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 237, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = __Pyx_PyNumber_Divide(__pyx_int_neg_1, __pyx_v_sample_space_size); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 237, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_7 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_6))) {
      __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_6);
      if (likely(__pyx_t_7)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
        __Pyx_INCREF(__pyx_t_7);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_6, function);
      }
    }
    __pyx_t_4 = (__pyx_t_7) ? __Pyx_PyObject_Call2Args(__pyx_t_6, __pyx_t_7, __pyx_t_1) : __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_1);
    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 237, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

    /* "apache_beam/transforms/stats.py":236
 *       sample_space_size = self._HASH_SPACE_SIZE - 1.0 * self._min_hash
 *       est = (
 *           math.log1p(-self._sample_size / sample_space_size) /             # <<<<<<<<<<<<<<
 *           math.log1p(-1 / sample_space_size) * self._HASH_SPACE_SIZE /
 *           sample_space_size)
 */
    __pyx_t_6 = __Pyx_PyNumber_Divide(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 236, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "apache_beam/transforms/stats.py":237
 *       est = (
 *           math.log1p(-self._sample_size / sample_space_size) /
 *           math.log1p(-1 / sample_space_size) * self._HASH_SPACE_SIZE /             # <<<<<<<<<<<<<<
 *           sample_space_size)
 *       return round(est)
 */
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_HASH_SPACE_SIZE); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 237, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_3 = PyNumber_Multiply(__pyx_t_6, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 237, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "apache_beam/transforms/stats.py":238
 *           math.log1p(-self._sample_size / sample_space_size) /
 *           math.log1p(-1 / sample_space_size) * self._HASH_SPACE_SIZE /
 *           sample_space_size)             # <<<<<<<<<<<<<<
 *       return round(est)
 * 
 */
    __pyx_t_4 = __Pyx_PyNumber_Divide(__pyx_t_3, __pyx_v_sample_space_size); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 237, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_v_est = __pyx_t_4;
    __pyx_t_4 = 0;

    /* "apache_beam/transforms/stats.py":239
 *           math.log1p(-1 / sample_space_size) * self._HASH_SPACE_SIZE /
 *           sample_space_size)
 *       return round(est)             # <<<<<<<<<<<<<<
 * 
 * 
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_builtin_round, __pyx_v_est); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 239, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_r = __pyx_t_4;
    __pyx_t_4 = 0;
    goto __pyx_L0;
  }

  /* "apache_beam/transforms/stats.py":212
 *     return True
 * 
 *   def get_estimate(self):             # <<<<<<<<<<<<<<
 *     """
 *     :return: estimation count of unique values
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("apache_beam.transforms.stats._LargestUnique.get_estimate", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_sample_space_size);
  __Pyx_XDECREF(__pyx_v_est);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "apache_beam/transforms/stats.py":247
 *   unique values that were combined.
 *   """
 *   def __init__(self, sample_size, coder):             # <<<<<<<<<<<<<<
 *     self._sample_size = sample_size
 *     coder = coders.typecoders.registry.verify_deterministic(
 */

/* Python wrapper */
static PyObject *__pyx_pw_11apache_beam_10transforms_5stats_26ApproximateUniqueCombineFn_1__init__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_11apache_beam_10transforms_5stats_26ApproximateUniqueCombineFn_1__init__ = {"__init__", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_11apache_beam_10transforms_5stats_26ApproximateUniqueCombineFn_1__init__, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_11apache_beam_10transforms_5stats_26ApproximateUniqueCombineFn_1__init__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_sample_size = 0;
  PyObject *__pyx_v_coder = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_sample_size_2,&__pyx_n_s_coder,0};
    PyObject* values[3] = {0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_sample_size_2)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 1, 3, 3, 1); __PYX_ERR(0, 247, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_coder)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 1, 3, 3, 2); __PYX_ERR(0, 247, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(0, 247, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
    }
    __pyx_v_self = values[0];
    __pyx_v_sample_size = values[1];
    __pyx_v_coder = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 247, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("apache_beam.transforms.stats.ApproximateUniqueCombineFn.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_11apache_beam_10transforms_5stats_26ApproximateUniqueCombineFn___init__(__pyx_self, __pyx_v_self, __pyx_v_sample_size, __pyx_v_coder);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_11apache_beam_10transforms_5stats_26ApproximateUniqueCombineFn___init__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_sample_size, PyObject *__pyx_v_coder) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__init__", 0);
  __Pyx_INCREF(__pyx_v_coder);

  /* "apache_beam/transforms/stats.py":248
 *   """
 *   def __init__(self, sample_size, coder):
 *     self._sample_size = sample_size             # <<<<<<<<<<<<<<
 *     coder = coders.typecoders.registry.verify_deterministic(
 *         coder, 'ApproximateUniqueCombineFn')
 */
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_sample_size, __pyx_v_sample_size) < 0) __PYX_ERR(0, 248, __pyx_L1_error)

  /* "apache_beam/transforms/stats.py":249
 *   def __init__(self, sample_size, coder):
 *     self._sample_size = sample_size
 *     coder = coders.typecoders.registry.verify_deterministic(             # <<<<<<<<<<<<<<
 *         coder, 'ApproximateUniqueCombineFn')
 * 
 */
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_coders); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 249, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_typecoders); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 249, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_registry); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 249, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_verify_deterministic); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 249, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "apache_beam/transforms/stats.py":250
 *     self._sample_size = sample_size
 *     coder = coders.typecoders.registry.verify_deterministic(
 *         coder, 'ApproximateUniqueCombineFn')             # <<<<<<<<<<<<<<
 * 
 *     self._coder = coder
 */
  __pyx_t_2 = NULL;
  __pyx_t_4 = 0;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
      __pyx_t_4 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_3)) {
    PyObject *__pyx_temp[3] = {__pyx_t_2, __pyx_v_coder, __pyx_n_u_ApproximateUniqueCombineFn};
    __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_4, 2+__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 249, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
    PyObject *__pyx_temp[3] = {__pyx_t_2, __pyx_v_coder, __pyx_n_u_ApproximateUniqueCombineFn};
    __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_4, 2+__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 249, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else
  #endif
  {
    __pyx_t_5 = PyTuple_New(2+__pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 249, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    if (__pyx_t_2) {
      __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_2); __pyx_t_2 = NULL;
    }
    __Pyx_INCREF(__pyx_v_coder);
    __Pyx_GIVEREF(__pyx_v_coder);
    PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_4, __pyx_v_coder);
    __Pyx_INCREF(__pyx_n_u_ApproximateUniqueCombineFn);
    __Pyx_GIVEREF(__pyx_n_u_ApproximateUniqueCombineFn);
    PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_4, __pyx_n_u_ApproximateUniqueCombineFn);
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 249, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF_SET(__pyx_v_coder, __pyx_t_1);
  __pyx_t_1 = 0;

  /* "apache_beam/transforms/stats.py":252
 *         coder, 'ApproximateUniqueCombineFn')
 * 
 *     self._coder = coder             # <<<<<<<<<<<<<<
 *     self._hash_fn = _get_default_hash_fn()
 * 
 */
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_coder_2, __pyx_v_coder) < 0) __PYX_ERR(0, 252, __pyx_L1_error)

  /* "apache_beam/transforms/stats.py":253
 * 
 *     self._coder = coder
 *     self._hash_fn = _get_default_hash_fn()             # <<<<<<<<<<<<<<
 * 
 *   def create_accumulator(self, *args, **kwargs):
 */
  __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_get_default_hash_fn); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 253, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_5 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  __pyx_t_1 = (__pyx_t_5) ? __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_5) : __Pyx_PyObject_CallNoArg(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 253, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_hash_fn, __pyx_t_1) < 0) __PYX_ERR(0, 253, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "apache_beam/transforms/stats.py":247
 *   unique values that were combined.
 *   """
 *   def __init__(self, sample_size, coder):             # <<<<<<<<<<<<<<
 *     self._sample_size = sample_size
 *     coder = coders.typecoders.registry.verify_deterministic(
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("apache_beam.transforms.stats.ApproximateUniqueCombineFn.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_coder);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "apache_beam/transforms/stats.py":255
 *     self._hash_fn = _get_default_hash_fn()
 * 
 *   def create_accumulator(self, *args, **kwargs):             # <<<<<<<<<<<<<<
 *     return _LargestUnique(self._sample_size)
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_11apache_beam_10transforms_5stats_26ApproximateUniqueCombineFn_3create_accumulator(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_11apache_beam_10transforms_5stats_26ApproximateUniqueCombineFn_3create_accumulator = {"create_accumulator", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_11apache_beam_10transforms_5stats_26ApproximateUniqueCombineFn_3create_accumulator, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_11apache_beam_10transforms_5stats_26ApproximateUniqueCombineFn_3create_accumulator(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_self = 0;
  CYTHON_UNUSED PyObject *__pyx_v_args = 0;
  CYTHON_UNUSED PyObject *__pyx_v_kwargs = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("create_accumulator (wrapper)", 0);
  __pyx_v_kwargs = PyDict_New(); if (unlikely(!__pyx_v_kwargs)) return NULL;
  __Pyx_GOTREF(__pyx_v_kwargs);
  if (PyTuple_GET_SIZE(__pyx_args) > 1) {
    __pyx_v_args = PyTuple_GetSlice(__pyx_args, 1, PyTuple_GET_SIZE(__pyx_args));
    if (unlikely(!__pyx_v_args)) {
      __Pyx_DECREF(__pyx_v_kwargs); __pyx_v_kwargs = 0;
      __Pyx_RefNannyFinishContext();
      return NULL;
    }
    __Pyx_GOTREF(__pyx_v_args);
  } else {
    __pyx_v_args = __pyx_empty_tuple; __Pyx_INCREF(__pyx_empty_tuple);
  }
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,0};
    PyObject* values[1] = {0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        default:
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
      }
      if (unlikely(kw_args > 0)) {
        const Py_ssize_t used_pos_args = (pos_args < 1) ? pos_args : 1;
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, __pyx_v_kwargs, values, used_pos_args, "create_accumulator") < 0)) __PYX_ERR(0, 255, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) < 1) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
    }
    __pyx_v_self = values[0];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("create_accumulator", 0, 1, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 255, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_DECREF(__pyx_v_args); __pyx_v_args = 0;
  __Pyx_DECREF(__pyx_v_kwargs); __pyx_v_kwargs = 0;
  __Pyx_AddTraceback("apache_beam.transforms.stats.ApproximateUniqueCombineFn.create_accumulator", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_11apache_beam_10transforms_5stats_26ApproximateUniqueCombineFn_2create_accumulator(__pyx_self, __pyx_v_self, __pyx_v_args, __pyx_v_kwargs);

  /* function exit code */
  __Pyx_XDECREF(__pyx_v_args);
  __Pyx_XDECREF(__pyx_v_kwargs);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_11apache_beam_10transforms_5stats_26ApproximateUniqueCombineFn_2create_accumulator(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_args, CYTHON_UNUSED PyObject *__pyx_v_kwargs) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("create_accumulator", 0);

  /* "apache_beam/transforms/stats.py":256
 * 
 *   def create_accumulator(self, *args, **kwargs):
 *     return _LargestUnique(self._sample_size)             # <<<<<<<<<<<<<<
 * 
 *   def add_input(self, accumulator, element, *args, **kwargs):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_LargestUnique); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 256, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_sample_size); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 256, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  __pyx_t_1 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_4, __pyx_t_3) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 256, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "apache_beam/transforms/stats.py":255
 *     self._hash_fn = _get_default_hash_fn()
 * 
 *   def create_accumulator(self, *args, **kwargs):             # <<<<<<<<<<<<<<
 *     return _LargestUnique(self._sample_size)
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("apache_beam.transforms.stats.ApproximateUniqueCombineFn.create_accumulator", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "apache_beam/transforms/stats.py":258
 *     return _LargestUnique(self._sample_size)
 * 
 *   def add_input(self, accumulator, element, *args, **kwargs):             # <<<<<<<<<<<<<<
 *     try:
 *       hashed_value = self._hash_fn(self._coder.encode(element))
 */

/* Python wrapper */
static PyObject *__pyx_pw_11apache_beam_10transforms_5stats_26ApproximateUniqueCombineFn_5add_input(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_11apache_beam_10transforms_5stats_26ApproximateUniqueCombineFn_5add_input = {"add_input", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_11apache_beam_10transforms_5stats_26ApproximateUniqueCombineFn_5add_input, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_11apache_beam_10transforms_5stats_26ApproximateUniqueCombineFn_5add_input(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_accumulator = 0;
  PyObject *__pyx_v_element = 0;
  CYTHON_UNUSED PyObject *__pyx_v_args = 0;
  CYTHON_UNUSED PyObject *__pyx_v_kwargs = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("add_input (wrapper)", 0);
  __pyx_v_kwargs = PyDict_New(); if (unlikely(!__pyx_v_kwargs)) return NULL;
  __Pyx_GOTREF(__pyx_v_kwargs);
  if (PyTuple_GET_SIZE(__pyx_args) > 3) {
    __pyx_v_args = PyTuple_GetSlice(__pyx_args, 3, PyTuple_GET_SIZE(__pyx_args));
    if (unlikely(!__pyx_v_args)) {
      __Pyx_DECREF(__pyx_v_kwargs); __pyx_v_kwargs = 0;
      __Pyx_RefNannyFinishContext();
      return NULL;
    }
    __Pyx_GOTREF(__pyx_v_args);
  } else {
    __pyx_v_args = __pyx_empty_tuple; __Pyx_INCREF(__pyx_empty_tuple);
  }
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_accumulator,&__pyx_n_s_element,0};
    PyObject* values[3] = {0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        default:
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_accumulator)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("add_input", 0, 3, 3, 1); __PYX_ERR(0, 258, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_element)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("add_input", 0, 3, 3, 2); __PYX_ERR(0, 258, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        const Py_ssize_t used_pos_args = (pos_args < 3) ? pos_args : 3;
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, __pyx_v_kwargs, values, used_pos_args, "add_input") < 0)) __PYX_ERR(0, 258, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) < 3) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
    }
    __pyx_v_self = values[0];
    __pyx_v_accumulator = values[1];
    __pyx_v_element = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("add_input", 0, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 258, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_DECREF(__pyx_v_args); __pyx_v_args = 0;
  __Pyx_DECREF(__pyx_v_kwargs); __pyx_v_kwargs = 0;
  __Pyx_AddTraceback("apache_beam.transforms.stats.ApproximateUniqueCombineFn.add_input", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_11apache_beam_10transforms_5stats_26ApproximateUniqueCombineFn_4add_input(__pyx_self, __pyx_v_self, __pyx_v_accumulator, __pyx_v_element, __pyx_v_args, __pyx_v_kwargs);

  /* function exit code */
  __Pyx_XDECREF(__pyx_v_args);
  __Pyx_XDECREF(__pyx_v_kwargs);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_11apache_beam_10transforms_5stats_26ApproximateUniqueCombineFn_4add_input(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_accumulator, PyObject *__pyx_v_element, CYTHON_UNUSED PyObject *__pyx_v_args, CYTHON_UNUSED PyObject *__pyx_v_kwargs) {
  PyObject *__pyx_v_hashed_value = NULL;
  PyObject *__pyx_v_e = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  int __pyx_t_9;
  int __pyx_t_10;
  char const *__pyx_t_11;
  PyObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  PyObject *__pyx_t_14 = NULL;
  PyObject *__pyx_t_15 = NULL;
  PyObject *__pyx_t_16 = NULL;
  PyObject *__pyx_t_17 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("add_input", 0);

  /* "apache_beam/transforms/stats.py":259
 * 
 *   def add_input(self, accumulator, element, *args, **kwargs):
 *     try:             # <<<<<<<<<<<<<<
 *       hashed_value = self._hash_fn(self._coder.encode(element))
 *       accumulator.add(hashed_value)
 */
  {
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3);
    __Pyx_XGOTREF(__pyx_t_1);
    __Pyx_XGOTREF(__pyx_t_2);
    __Pyx_XGOTREF(__pyx_t_3);
    /*try:*/ {

      /* "apache_beam/transforms/stats.py":260
 *   def add_input(self, accumulator, element, *args, **kwargs):
 *     try:
 *       hashed_value = self._hash_fn(self._coder.encode(element))             # <<<<<<<<<<<<<<
 *       accumulator.add(hashed_value)
 *       return accumulator
 */
      __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_hash_fn); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 260, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_coder_2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 260, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_encode); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 260, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_7 = NULL;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_8))) {
        __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_8);
        if (likely(__pyx_t_7)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
          __Pyx_INCREF(__pyx_t_7);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_8, function);
        }
      }
      __pyx_t_6 = (__pyx_t_7) ? __Pyx_PyObject_Call2Args(__pyx_t_8, __pyx_t_7, __pyx_v_element) : __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_v_element);
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
      if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 260, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __pyx_t_8 = NULL;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) {
        __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_5);
        if (likely(__pyx_t_8)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
          __Pyx_INCREF(__pyx_t_8);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_5, function);
        }
      }
      __pyx_t_4 = (__pyx_t_8) ? __Pyx_PyObject_Call2Args(__pyx_t_5, __pyx_t_8, __pyx_t_6) : __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_6);
      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 260, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_v_hashed_value = __pyx_t_4;
      __pyx_t_4 = 0;

      /* "apache_beam/transforms/stats.py":261
 *     try:
 *       hashed_value = self._hash_fn(self._coder.encode(element))
 *       accumulator.add(hashed_value)             # <<<<<<<<<<<<<<
 *       return accumulator
 *     except Exception as e:
 */
      __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_accumulator, __pyx_n_s_add); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 261, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_6 = NULL;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) {
        __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5);
        if (likely(__pyx_t_6)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
          __Pyx_INCREF(__pyx_t_6);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_5, function);
        }
      }
      __pyx_t_4 = (__pyx_t_6) ? __Pyx_PyObject_Call2Args(__pyx_t_5, __pyx_t_6, __pyx_v_hashed_value) : __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_v_hashed_value);
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 261, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

      /* "apache_beam/transforms/stats.py":262
 *       hashed_value = self._hash_fn(self._coder.encode(element))
 *       accumulator.add(hashed_value)
 *       return accumulator             # <<<<<<<<<<<<<<
 *     except Exception as e:
 *       raise RuntimeError("Runtime exception: %s" % e)
 */
      __Pyx_XDECREF(__pyx_r);
      __Pyx_INCREF(__pyx_v_accumulator);
      __pyx_r = __pyx_v_accumulator;
      goto __pyx_L7_try_return;

      /* "apache_beam/transforms/stats.py":259
 * 
 *   def add_input(self, accumulator, element, *args, **kwargs):
 *     try:             # <<<<<<<<<<<<<<
 *       hashed_value = self._hash_fn(self._coder.encode(element))
 *       accumulator.add(hashed_value)
 */
    }
    __pyx_L3_error:;
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;

    /* "apache_beam/transforms/stats.py":263
 *       accumulator.add(hashed_value)
 *       return accumulator
 *     except Exception as e:             # <<<<<<<<<<<<<<
 *       raise RuntimeError("Runtime exception: %s" % e)
 * 
 */
    __pyx_t_9 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])));
    if (__pyx_t_9) {
      __Pyx_AddTraceback("apache_beam.transforms.stats.ApproximateUniqueCombineFn.add_input", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_4, &__pyx_t_5, &__pyx_t_6) < 0) __PYX_ERR(0, 263, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_INCREF(__pyx_t_5);
      __pyx_v_e = __pyx_t_5;
      /*try:*/ {

        /* "apache_beam/transforms/stats.py":264
 *       return accumulator
 *     except Exception as e:
 *       raise RuntimeError("Runtime exception: %s" % e)             # <<<<<<<<<<<<<<
 * 
 *   # created an issue https://github.com/apache/beam/issues/19459 to speed up
 */
        __pyx_t_8 = __Pyx_PyUnicode_FormatSafe(__pyx_kp_u_Runtime_exception_s, __pyx_v_e); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 264, __pyx_L14_error)
        __Pyx_GOTREF(__pyx_t_8);
        __pyx_t_7 = __Pyx_PyObject_CallOneArg(__pyx_builtin_RuntimeError, __pyx_t_8); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 264, __pyx_L14_error)
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        __Pyx_Raise(__pyx_t_7, 0, 0, 0);
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        __PYX_ERR(0, 264, __pyx_L14_error)
      }

      /* "apache_beam/transforms/stats.py":263
 *       accumulator.add(hashed_value)
 *       return accumulator
 *     except Exception as e:             # <<<<<<<<<<<<<<
 *       raise RuntimeError("Runtime exception: %s" % e)
 * 
 */
      /*finally:*/ {
        __pyx_L14_error:;
        /*exception exit:*/{
          __Pyx_PyThreadState_declare
          __Pyx_PyThreadState_assign
          __pyx_t_12 = 0; __pyx_t_13 = 0; __pyx_t_14 = 0; __pyx_t_15 = 0; __pyx_t_16 = 0; __pyx_t_17 = 0;
          __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
          __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
          if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_15, &__pyx_t_16, &__pyx_t_17);
          if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_12, &__pyx_t_13, &__pyx_t_14) < 0)) __Pyx_ErrFetch(&__pyx_t_12, &__pyx_t_13, &__pyx_t_14);
          __Pyx_XGOTREF(__pyx_t_12);
          __Pyx_XGOTREF(__pyx_t_13);
          __Pyx_XGOTREF(__pyx_t_14);
          __Pyx_XGOTREF(__pyx_t_15);
          __Pyx_XGOTREF(__pyx_t_16);
          __Pyx_XGOTREF(__pyx_t_17);
          __pyx_t_9 = __pyx_lineno; __pyx_t_10 = __pyx_clineno; __pyx_t_11 = __pyx_filename;
          {
            __Pyx_DECREF(__pyx_v_e);
            __pyx_v_e = NULL;
          }
          if (PY_MAJOR_VERSION >= 3) {
            __Pyx_XGIVEREF(__pyx_t_15);
            __Pyx_XGIVEREF(__pyx_t_16);
            __Pyx_XGIVEREF(__pyx_t_17);
            __Pyx_ExceptionReset(__pyx_t_15, __pyx_t_16, __pyx_t_17);
          }
          __Pyx_XGIVEREF(__pyx_t_12);
          __Pyx_XGIVEREF(__pyx_t_13);
          __Pyx_XGIVEREF(__pyx_t_14);
          __Pyx_ErrRestore(__pyx_t_12, __pyx_t_13, __pyx_t_14);
          __pyx_t_12 = 0; __pyx_t_13 = 0; __pyx_t_14 = 0; __pyx_t_15 = 0; __pyx_t_16 = 0; __pyx_t_17 = 0;
          __pyx_lineno = __pyx_t_9; __pyx_clineno = __pyx_t_10; __pyx_filename = __pyx_t_11;
          goto __pyx_L5_except_error;
        }
      }
    }
    goto __pyx_L5_except_error;
    __pyx_L5_except_error:;

    /* "apache_beam/transforms/stats.py":259
 * 
 *   def add_input(self, accumulator, element, *args, **kwargs):
 *     try:             # <<<<<<<<<<<<<<
 *       hashed_value = self._hash_fn(self._coder.encode(element))
 *       accumulator.add(hashed_value)
 */
    __Pyx_XGIVEREF(__pyx_t_1);
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
    goto __pyx_L1_error;
    __pyx_L7_try_return:;
    __Pyx_XGIVEREF(__pyx_t_1);
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
    goto __pyx_L0;
  }

  /* "apache_beam/transforms/stats.py":258
 *     return _LargestUnique(self._sample_size)
 * 
 *   def add_input(self, accumulator, element, *args, **kwargs):             # <<<<<<<<<<<<<<
 *     try:
 *       hashed_value = self._hash_fn(self._coder.encode(element))
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("apache_beam.transforms.stats.ApproximateUniqueCombineFn.add_input", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_hashed_value);
  __Pyx_XDECREF(__pyx_v_e);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "apache_beam/transforms/stats.py":268
 *   # created an issue https://github.com/apache/beam/issues/19459 to speed up
 *   # merge process.
 *   def merge_accumulators(self, accumulators, *args, **kwargs):             # <<<<<<<<<<<<<<
 *     merged_accumulator = self.create_accumulator()
 *     for accumulator in accumulators:
 */

/* Python wrapper */
static PyObject *__pyx_pw_11apache_beam_10transforms_5stats_26ApproximateUniqueCombineFn_7merge_accumulators(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_11apache_beam_10transforms_5stats_26ApproximateUniqueCombineFn_7merge_accumulators = {"merge_accumulators", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_11apache_beam_10transforms_5stats_26ApproximateUniqueCombineFn_7merge_accumulators, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_11apache_beam_10transforms_5stats_26ApproximateUniqueCombineFn_7merge_accumulators(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_accumulators = 0;
  CYTHON_UNUSED PyObject *__pyx_v_args = 0;
  CYTHON_UNUSED PyObject *__pyx_v_kwargs = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("merge_accumulators (wrapper)", 0);
  __pyx_v_kwargs = PyDict_New(); if (unlikely(!__pyx_v_kwargs)) return NULL;
  __Pyx_GOTREF(__pyx_v_kwargs);
  if (PyTuple_GET_SIZE(__pyx_args) > 2) {
    __pyx_v_args = PyTuple_GetSlice(__pyx_args, 2, PyTuple_GET_SIZE(__pyx_args));
    if (unlikely(!__pyx_v_args)) {
      __Pyx_DECREF(__pyx_v_kwargs); __pyx_v_kwargs = 0;
      __Pyx_RefNannyFinishContext();
      return NULL;
    }
    __Pyx_GOTREF(__pyx_v_args);
  } else {
    __pyx_v_args = __pyx_empty_tuple; __Pyx_INCREF(__pyx_empty_tuple);
  }
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_accumulators,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        default:
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_accumulators)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("merge_accumulators", 0, 2, 2, 1); __PYX_ERR(0, 268, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        const Py_ssize_t used_pos_args = (pos_args < 2) ? pos_args : 2;
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, __pyx_v_kwargs, values, used_pos_args, "merge_accumulators") < 0)) __PYX_ERR(0, 268, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) < 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_self = values[0];
    __pyx_v_accumulators = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("merge_accumulators", 0, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 268, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_DECREF(__pyx_v_args); __pyx_v_args = 0;
  __Pyx_DECREF(__pyx_v_kwargs); __pyx_v_kwargs = 0;
  __Pyx_AddTraceback("apache_beam.transforms.stats.ApproximateUniqueCombineFn.merge_accumulators", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_11apache_beam_10transforms_5stats_26ApproximateUniqueCombineFn_6merge_accumulators(__pyx_self, __pyx_v_self, __pyx_v_accumulators, __pyx_v_args, __pyx_v_kwargs);

  /* function exit code */
  __Pyx_XDECREF(__pyx_v_args);
  __Pyx_XDECREF(__pyx_v_kwargs);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_11apache_beam_10transforms_5stats_26ApproximateUniqueCombineFn_6merge_accumulators(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_accumulators, CYTHON_UNUSED PyObject *__pyx_v_args, CYTHON_UNUSED PyObject *__pyx_v_kwargs) {
  PyObject *__pyx_v_merged_accumulator = NULL;
  PyObject *__pyx_v_accumulator = NULL;
  PyObject *__pyx_v_i = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  Py_ssize_t __pyx_t_4;
  PyObject *(*__pyx_t_5)(PyObject *);
  Py_ssize_t __pyx_t_6;
  PyObject *(*__pyx_t_7)(PyObject *);
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("merge_accumulators", 0);

  /* "apache_beam/transforms/stats.py":269
 *   # merge process.
 *   def merge_accumulators(self, accumulators, *args, **kwargs):
 *     merged_accumulator = self.create_accumulator()             # <<<<<<<<<<<<<<
 *     for accumulator in accumulators:
 *       for i in accumulator._sample_heap:
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_create_accumulator); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 269, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3) : __Pyx_PyObject_CallNoArg(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 269, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_merged_accumulator = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "apache_beam/transforms/stats.py":270
 *   def merge_accumulators(self, accumulators, *args, **kwargs):
 *     merged_accumulator = self.create_accumulator()
 *     for accumulator in accumulators:             # <<<<<<<<<<<<<<
 *       for i in accumulator._sample_heap:
 *         merged_accumulator.add(i)
 */
  if (likely(PyList_CheckExact(__pyx_v_accumulators)) || PyTuple_CheckExact(__pyx_v_accumulators)) {
    __pyx_t_1 = __pyx_v_accumulators; __Pyx_INCREF(__pyx_t_1); __pyx_t_4 = 0;
    __pyx_t_5 = NULL;
  } else {
    __pyx_t_4 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_accumulators); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 270, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_5 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 270, __pyx_L1_error)
  }
  for (;;) {
    if (likely(!__pyx_t_5)) {
      if (likely(PyList_CheckExact(__pyx_t_1))) {
        if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_2 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_4); __Pyx_INCREF(__pyx_t_2); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(0, 270, __pyx_L1_error)
        #else
        __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 270, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        #endif
      } else {
        if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_4); __Pyx_INCREF(__pyx_t_2); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(0, 270, __pyx_L1_error)
        #else
        __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 270, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        #endif
      }
    } else {
      __pyx_t_2 = __pyx_t_5(__pyx_t_1);
      if (unlikely(!__pyx_t_2)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(0, 270, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_2);
    }
    __Pyx_XDECREF_SET(__pyx_v_accumulator, __pyx_t_2);
    __pyx_t_2 = 0;

    /* "apache_beam/transforms/stats.py":271
 *     merged_accumulator = self.create_accumulator()
 *     for accumulator in accumulators:
 *       for i in accumulator._sample_heap:             # <<<<<<<<<<<<<<
 *         merged_accumulator.add(i)
 * 
 */
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_accumulator, __pyx_n_s_sample_heap); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 271, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    if (likely(PyList_CheckExact(__pyx_t_2)) || PyTuple_CheckExact(__pyx_t_2)) {
      __pyx_t_3 = __pyx_t_2; __Pyx_INCREF(__pyx_t_3); __pyx_t_6 = 0;
      __pyx_t_7 = NULL;
    } else {
      __pyx_t_6 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 271, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_7 = Py_TYPE(__pyx_t_3)->tp_iternext; if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 271, __pyx_L1_error)
    }
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    for (;;) {
      if (likely(!__pyx_t_7)) {
        if (likely(PyList_CheckExact(__pyx_t_3))) {
          if (__pyx_t_6 >= PyList_GET_SIZE(__pyx_t_3)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_2 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_6); __Pyx_INCREF(__pyx_t_2); __pyx_t_6++; if (unlikely(0 < 0)) __PYX_ERR(0, 271, __pyx_L1_error)
          #else
          __pyx_t_2 = PySequence_ITEM(__pyx_t_3, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 271, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_2);
          #endif
        } else {
          if (__pyx_t_6 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_6); __Pyx_INCREF(__pyx_t_2); __pyx_t_6++; if (unlikely(0 < 0)) __PYX_ERR(0, 271, __pyx_L1_error)
          #else
          __pyx_t_2 = PySequence_ITEM(__pyx_t_3, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 271, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_2);
          #endif
        }
      } else {
        __pyx_t_2 = __pyx_t_7(__pyx_t_3);
        if (unlikely(!__pyx_t_2)) {
          PyObject* exc_type = PyErr_Occurred();
          if (exc_type) {
            if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
            else __PYX_ERR(0, 271, __pyx_L1_error)
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_2);
      }
      __Pyx_XDECREF_SET(__pyx_v_i, __pyx_t_2);
      __pyx_t_2 = 0;

      /* "apache_beam/transforms/stats.py":272
 *     for accumulator in accumulators:
 *       for i in accumulator._sample_heap:
 *         merged_accumulator.add(i)             # <<<<<<<<<<<<<<
 * 
 *     return merged_accumulator
 */
      __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_merged_accumulator, __pyx_n_s_add); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 272, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_9 = NULL;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_8))) {
        __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_8);
        if (likely(__pyx_t_9)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
          __Pyx_INCREF(__pyx_t_9);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_8, function);
        }
      }
      __pyx_t_2 = (__pyx_t_9) ? __Pyx_PyObject_Call2Args(__pyx_t_8, __pyx_t_9, __pyx_v_i) : __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_v_i);
      __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
      if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 272, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

      /* "apache_beam/transforms/stats.py":271
 *     merged_accumulator = self.create_accumulator()
 *     for accumulator in accumulators:
 *       for i in accumulator._sample_heap:             # <<<<<<<<<<<<<<
 *         merged_accumulator.add(i)
 * 
 */
    }
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "apache_beam/transforms/stats.py":270
 *   def merge_accumulators(self, accumulators, *args, **kwargs):
 *     merged_accumulator = self.create_accumulator()
 *     for accumulator in accumulators:             # <<<<<<<<<<<<<<
 *       for i in accumulator._sample_heap:
 *         merged_accumulator.add(i)
 */
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "apache_beam/transforms/stats.py":274
 *         merged_accumulator.add(i)
 * 
 *     return merged_accumulator             # <<<<<<<<<<<<<<
 * 
 *   @staticmethod
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_merged_accumulator);
  __pyx_r = __pyx_v_merged_accumulator;
  goto __pyx_L0;

  /* "apache_beam/transforms/stats.py":268
 *   # created an issue https://github.com/apache/beam/issues/19459 to speed up
 *   # merge process.
 *   def merge_accumulators(self, accumulators, *args, **kwargs):             # <<<<<<<<<<<<<<
 *     merged_accumulator = self.create_accumulator()
 *     for accumulator in accumulators:
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("apache_beam.transforms.stats.ApproximateUniqueCombineFn.merge_accumulators", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_merged_accumulator);
  __Pyx_XDECREF(__pyx_v_accumulator);
  __Pyx_XDECREF(__pyx_v_i);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "apache_beam/transforms/stats.py":277
 * 
 *   @staticmethod
 *   def extract_output(accumulator):             # <<<<<<<<<<<<<<
 *     return accumulator.get_estimate()
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_11apache_beam_10transforms_5stats_26ApproximateUniqueCombineFn_9extract_output(PyObject *__pyx_self, PyObject *__pyx_v_accumulator); /*proto*/
static PyMethodDef __pyx_mdef_11apache_beam_10transforms_5stats_26ApproximateUniqueCombineFn_9extract_output = {"extract_output", (PyCFunction)__pyx_pw_11apache_beam_10transforms_5stats_26ApproximateUniqueCombineFn_9extract_output, METH_O, 0};
static PyObject *__pyx_pw_11apache_beam_10transforms_5stats_26ApproximateUniqueCombineFn_9extract_output(PyObject *__pyx_self, PyObject *__pyx_v_accumulator) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("extract_output (wrapper)", 0);
  __pyx_r = __pyx_pf_11apache_beam_10transforms_5stats_26ApproximateUniqueCombineFn_8extract_output(__pyx_self, ((PyObject *)__pyx_v_accumulator));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_11apache_beam_10transforms_5stats_26ApproximateUniqueCombineFn_8extract_output(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_accumulator) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("extract_output", 0);

  /* "apache_beam/transforms/stats.py":278
 *   @staticmethod
 *   def extract_output(accumulator):
 *     return accumulator.get_estimate()             # <<<<<<<<<<<<<<
 * 
 *   def display_data(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_accumulator, __pyx_n_s_get_estimate); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 278, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3) : __Pyx_PyObject_CallNoArg(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 278, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "apache_beam/transforms/stats.py":277
 * 
 *   @staticmethod
 *   def extract_output(accumulator):             # <<<<<<<<<<<<<<
 *     return accumulator.get_estimate()
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("apache_beam.transforms.stats.ApproximateUniqueCombineFn.extract_output", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "apache_beam/transforms/stats.py":280
 *     return accumulator.get_estimate()
 * 
 *   def display_data(self):             # <<<<<<<<<<<<<<
 *     return {'sample_size': self._sample_size}
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_11apache_beam_10transforms_5stats_26ApproximateUniqueCombineFn_11display_data(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/
static PyMethodDef __pyx_mdef_11apache_beam_10transforms_5stats_26ApproximateUniqueCombineFn_11display_data = {"display_data", (PyCFunction)__pyx_pw_11apache_beam_10transforms_5stats_26ApproximateUniqueCombineFn_11display_data, METH_O, 0};
static PyObject *__pyx_pw_11apache_beam_10transforms_5stats_26ApproximateUniqueCombineFn_11display_data(PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("display_data (wrapper)", 0);
  __pyx_r = __pyx_pf_11apache_beam_10transforms_5stats_26ApproximateUniqueCombineFn_10display_data(__pyx_self, ((PyObject *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_11apache_beam_10transforms_5stats_26ApproximateUniqueCombineFn_10display_data(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("display_data", 0);

  /* "apache_beam/transforms/stats.py":281
 * 
 *   def display_data(self):
 *     return {'sample_size': self._sample_size}             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 281, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_sample_size); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 281, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_u_sample_size_2, __pyx_t_2) < 0) __PYX_ERR(0, 281, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "apache_beam/transforms/stats.py":280
 *     return accumulator.get_estimate()
 * 
 *   def display_data(self):             # <<<<<<<<<<<<<<
 *     return {'sample_size': self._sample_size}
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("apache_beam.transforms.stats.ApproximateUniqueCombineFn.display_data", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "apache_beam/transforms/stats.py":312
 *   """
 *   @staticmethod
 *   def _display_data(num_quantiles, key, reverse, weighted, input_batched):             # <<<<<<<<<<<<<<
 *     return {
 *         'num_quantiles': DisplayDataItem(num_quantiles, label='Quantile Count'),
 */

/* Python wrapper */
static PyObject *__pyx_pw_11apache_beam_10transforms_5stats_20ApproximateQuantiles_1_display_data(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_11apache_beam_10transforms_5stats_20ApproximateQuantiles_1_display_data = {"_display_data", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_11apache_beam_10transforms_5stats_20ApproximateQuantiles_1_display_data, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_11apache_beam_10transforms_5stats_20ApproximateQuantiles_1_display_data(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_num_quantiles = 0;
  PyObject *__pyx_v_key = 0;
  PyObject *__pyx_v_reverse = 0;
  PyObject *__pyx_v_weighted = 0;
  PyObject *__pyx_v_input_batched = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_display_data (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_num_quantiles,&__pyx_n_s_key,&__pyx_n_s_reverse,&__pyx_n_s_weighted,&__pyx_n_s_input_batched,0};
    PyObject* values[5] = {0,0,0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_num_quantiles)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_key)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_display_data", 1, 5, 5, 1); __PYX_ERR(0, 312, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_reverse)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_display_data", 1, 5, 5, 2); __PYX_ERR(0, 312, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_weighted)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_display_data", 1, 5, 5, 3); __PYX_ERR(0, 312, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  4:
        if (likely((values[4] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_input_batched)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_display_data", 1, 5, 5, 4); __PYX_ERR(0, 312, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_display_data") < 0)) __PYX_ERR(0, 312, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 5) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
      values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
      values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
    }
    __pyx_v_num_quantiles = values[0];
    __pyx_v_key = values[1];
    __pyx_v_reverse = values[2];
    __pyx_v_weighted = values[3];
    __pyx_v_input_batched = values[4];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_display_data", 1, 5, 5, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 312, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("apache_beam.transforms.stats.ApproximateQuantiles._display_data", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_11apache_beam_10transforms_5stats_20ApproximateQuantiles__display_data(__pyx_self, __pyx_v_num_quantiles, __pyx_v_key, __pyx_v_reverse, __pyx_v_weighted, __pyx_v_input_batched);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_11apache_beam_10transforms_5stats_20ApproximateQuantiles__display_data(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_num_quantiles, PyObject *__pyx_v_key, PyObject *__pyx_v_reverse, PyObject *__pyx_v_weighted, PyObject *__pyx_v_input_batched) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_display_data", 0);

  /* "apache_beam/transforms/stats.py":313
 *   @staticmethod
 *   def _display_data(num_quantiles, key, reverse, weighted, input_batched):
 *     return {             # <<<<<<<<<<<<<<
 *         'num_quantiles': DisplayDataItem(num_quantiles, label='Quantile Count'),
 *         'key': DisplayDataItem(
 */
  __Pyx_XDECREF(__pyx_r);

  /* "apache_beam/transforms/stats.py":314
 *   def _display_data(num_quantiles, key, reverse, weighted, input_batched):
 *     return {
 *         'num_quantiles': DisplayDataItem(num_quantiles, label='Quantile Count'),             # <<<<<<<<<<<<<<
 *         'key': DisplayDataItem(
 *             key.__name__
 */
  __pyx_t_1 = __Pyx_PyDict_NewPresized(5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 314, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_DisplayDataItem); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 314, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 314, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(__pyx_v_num_quantiles);
  __Pyx_GIVEREF(__pyx_v_num_quantiles);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_num_quantiles);
  __pyx_t_4 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 314, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_label, __pyx_kp_u_Quantile_Count) < 0) __PYX_ERR(0, 314, __pyx_L1_error)
  __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 314, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_u_num_quantiles, __pyx_t_5) < 0) __PYX_ERR(0, 314, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

  /* "apache_beam/transforms/stats.py":315
 *     return {
 *         'num_quantiles': DisplayDataItem(num_quantiles, label='Quantile Count'),
 *         'key': DisplayDataItem(             # <<<<<<<<<<<<<<
 *             key.__name__
 *             if hasattr(key, '__name__') else key.__class__.__name__,
 */
  __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_DisplayDataItem); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 315, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);

  /* "apache_beam/transforms/stats.py":317
 *         'key': DisplayDataItem(
 *             key.__name__
 *             if hasattr(key, '__name__') else key.__class__.__name__,             # <<<<<<<<<<<<<<
 *             label='Record Comparer Key'),
 *         'reverse': DisplayDataItem(str(reverse), label='Is Reversed'),
 */
  __pyx_t_6 = __Pyx_HasAttr(__pyx_v_key, __pyx_n_u_name); if (unlikely(__pyx_t_6 == ((int)-1))) __PYX_ERR(0, 317, __pyx_L1_error)
  if ((__pyx_t_6 != 0)) {

    /* "apache_beam/transforms/stats.py":316
 *         'num_quantiles': DisplayDataItem(num_quantiles, label='Quantile Count'),
 *         'key': DisplayDataItem(
 *             key.__name__             # <<<<<<<<<<<<<<
 *             if hasattr(key, '__name__') else key.__class__.__name__,
 *             label='Record Comparer Key'),
 */
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_key, __pyx_n_s_name); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 316, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = __pyx_t_3;
    __pyx_t_3 = 0;
  } else {

    /* "apache_beam/transforms/stats.py":317
 *         'key': DisplayDataItem(
 *             key.__name__
 *             if hasattr(key, '__name__') else key.__class__.__name__,             # <<<<<<<<<<<<<<
 *             label='Record Comparer Key'),
 *         'reverse': DisplayDataItem(str(reverse), label='Is Reversed'),
 */
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_key, __pyx_n_s_class); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 317, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_name); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 317, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_4 = __pyx_t_2;
    __pyx_t_2 = 0;
  }

  /* "apache_beam/transforms/stats.py":315
 *     return {
 *         'num_quantiles': DisplayDataItem(num_quantiles, label='Quantile Count'),
 *         'key': DisplayDataItem(             # <<<<<<<<<<<<<<
 *             key.__name__
 *             if hasattr(key, '__name__') else key.__class__.__name__,
 */
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 315, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_4);
  __pyx_t_4 = 0;

  /* "apache_beam/transforms/stats.py":318
 *             key.__name__
 *             if hasattr(key, '__name__') else key.__class__.__name__,
 *             label='Record Comparer Key'),             # <<<<<<<<<<<<<<
 *         'reverse': DisplayDataItem(str(reverse), label='Is Reversed'),
 *         'weighted': DisplayDataItem(str(weighted), label='Is Weighted'),
 */
  __pyx_t_4 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 318, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_label, __pyx_kp_u_Record_Comparer_Key) < 0) __PYX_ERR(0, 318, __pyx_L1_error)

  /* "apache_beam/transforms/stats.py":315
 *     return {
 *         'num_quantiles': DisplayDataItem(num_quantiles, label='Quantile Count'),
 *         'key': DisplayDataItem(             # <<<<<<<<<<<<<<
 *             key.__name__
 *             if hasattr(key, '__name__') else key.__class__.__name__,
 */
  __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_2, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 315, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_u_key, __pyx_t_3) < 0) __PYX_ERR(0, 314, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "apache_beam/transforms/stats.py":319
 *             if hasattr(key, '__name__') else key.__class__.__name__,
 *             label='Record Comparer Key'),
 *         'reverse': DisplayDataItem(str(reverse), label='Is Reversed'),             # <<<<<<<<<<<<<<
 *         'weighted': DisplayDataItem(str(weighted), label='Is Weighted'),
 *         'input_batched': DisplayDataItem(
 */
  __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_DisplayDataItem); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 319, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyObject_CallOneArg(((PyObject *)(&PyUnicode_Type)), __pyx_v_reverse); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 319, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 319, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_4);
  __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 319, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_label, __pyx_kp_u_Is_Reversed) < 0) __PYX_ERR(0, 319, __pyx_L1_error)
  __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_2, __pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 319, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_u_reverse, __pyx_t_5) < 0) __PYX_ERR(0, 314, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

  /* "apache_beam/transforms/stats.py":320
 *             label='Record Comparer Key'),
 *         'reverse': DisplayDataItem(str(reverse), label='Is Reversed'),
 *         'weighted': DisplayDataItem(str(weighted), label='Is Weighted'),             # <<<<<<<<<<<<<<
 *         'input_batched': DisplayDataItem(
 *             str(input_batched), label='Is Input Batched'),
 */
  __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_DisplayDataItem); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 320, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_4 = __Pyx_PyObject_CallOneArg(((PyObject *)(&PyUnicode_Type)), __pyx_v_weighted); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 320, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 320, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_4);
  __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 320, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_label, __pyx_kp_u_Is_Weighted) < 0) __PYX_ERR(0, 320, __pyx_L1_error)
  __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_2, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 320, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_u_weighted, __pyx_t_3) < 0) __PYX_ERR(0, 314, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "apache_beam/transforms/stats.py":321
 *         'reverse': DisplayDataItem(str(reverse), label='Is Reversed'),
 *         'weighted': DisplayDataItem(str(weighted), label='Is Weighted'),
 *         'input_batched': DisplayDataItem(             # <<<<<<<<<<<<<<
 *             str(input_batched), label='Is Input Batched'),
 *     }
 */
  __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_DisplayDataItem); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 321, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);

  /* "apache_beam/transforms/stats.py":322
 *         'weighted': DisplayDataItem(str(weighted), label='Is Weighted'),
 *         'input_batched': DisplayDataItem(
 *             str(input_batched), label='Is Input Batched'),             # <<<<<<<<<<<<<<
 *     }
 * 
 */
  __pyx_t_4 = __Pyx_PyObject_CallOneArg(((PyObject *)(&PyUnicode_Type)), __pyx_v_input_batched); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 322, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);

  /* "apache_beam/transforms/stats.py":321
 *         'reverse': DisplayDataItem(str(reverse), label='Is Reversed'),
 *         'weighted': DisplayDataItem(str(weighted), label='Is Weighted'),
 *         'input_batched': DisplayDataItem(             # <<<<<<<<<<<<<<
 *             str(input_batched), label='Is Input Batched'),
 *     }
 */
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 321, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_4);
  __pyx_t_4 = 0;

  /* "apache_beam/transforms/stats.py":322
 *         'weighted': DisplayDataItem(str(weighted), label='Is Weighted'),
 *         'input_batched': DisplayDataItem(
 *             str(input_batched), label='Is Input Batched'),             # <<<<<<<<<<<<<<
 *     }
 * 
 */
  __pyx_t_4 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 322, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_label, __pyx_kp_u_Is_Input_Batched) < 0) __PYX_ERR(0, 322, __pyx_L1_error)

  /* "apache_beam/transforms/stats.py":321
 *         'reverse': DisplayDataItem(str(reverse), label='Is Reversed'),
 *         'weighted': DisplayDataItem(str(weighted), label='Is Weighted'),
 *         'input_batched': DisplayDataItem(             # <<<<<<<<<<<<<<
 *             str(input_batched), label='Is Input Batched'),
 *     }
 */
  __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_2, __pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 321, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_u_input_batched, __pyx_t_5) < 0) __PYX_ERR(0, 314, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "apache_beam/transforms/stats.py":312
 *   """
 *   @staticmethod
 *   def _display_data(num_quantiles, key, reverse, weighted, input_batched):             # <<<<<<<<<<<<<<
 *     return {
 *         'num_quantiles': DisplayDataItem(num_quantiles, label='Quantile Count'),
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("apache_beam.transforms.stats.ApproximateQuantiles._display_data", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "apache_beam/transforms/stats.py":348
 *         efficiently.
 *     """
 *     def __init__(             # <<<<<<<<<<<<<<
 *         self,
 *         num_quantiles,
 */

/* Python wrapper */
static PyObject *__pyx_pw_11apache_beam_10transforms_5stats_8Globally_5__init__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_11apache_beam_10transforms_5stats_8Globally_5__init__ = {"__init__", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_11apache_beam_10transforms_5stats_8Globally_5__init__, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_11apache_beam_10transforms_5stats_8Globally_5__init__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_num_quantiles = 0;
  PyObject *__pyx_v_key = 0;
  PyObject *__pyx_v_reverse = 0;
  PyObject *__pyx_v_weighted = 0;
  PyObject *__pyx_v_input_batched = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_num_quantiles,&__pyx_n_s_key,&__pyx_n_s_reverse,&__pyx_n_s_weighted,&__pyx_n_s_input_batched,0};
    PyObject* values[6] = {0,0,0,0,0,0};

    /* "apache_beam/transforms/stats.py":351
 *         self,
 *         num_quantiles,
 *         key=None,             # <<<<<<<<<<<<<<
 *         reverse=False,
 *         weighted=False,
 */
    values[2] = ((PyObject *)((PyObject *)Py_None));

    /* "apache_beam/transforms/stats.py":352
 *         num_quantiles,
 *         key=None,
 *         reverse=False,             # <<<<<<<<<<<<<<
 *         weighted=False,
 *         input_batched=False):
 */
    values[3] = ((PyObject *)((PyObject *)Py_False));

    /* "apache_beam/transforms/stats.py":353
 *         key=None,
 *         reverse=False,
 *         weighted=False,             # <<<<<<<<<<<<<<
 *         input_batched=False):
 *       self._num_quantiles = num_quantiles
 */
    values[4] = ((PyObject *)((PyObject *)Py_False));

    /* "apache_beam/transforms/stats.py":354
 *         reverse=False,
 *         weighted=False,
 *         input_batched=False):             # <<<<<<<<<<<<<<
 *       self._num_quantiles = num_quantiles
 *       self._key = key
 */
    values[5] = ((PyObject *)((PyObject *)Py_False));
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        CYTHON_FALLTHROUGH;
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_num_quantiles)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 0, 2, 6, 1); __PYX_ERR(0, 348, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_key);
          if (value) { values[2] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_reverse);
          if (value) { values[3] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  4:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_weighted);
          if (value) { values[4] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  5:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_input_batched);
          if (value) { values[5] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(0, 348, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        CYTHON_FALLTHROUGH;
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_self = values[0];
    __pyx_v_num_quantiles = values[1];
    __pyx_v_key = values[2];
    __pyx_v_reverse = values[3];
    __pyx_v_weighted = values[4];
    __pyx_v_input_batched = values[5];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 0, 2, 6, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 348, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("apache_beam.transforms.stats.Globally.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_11apache_beam_10transforms_5stats_8Globally_4__init__(__pyx_self, __pyx_v_self, __pyx_v_num_quantiles, __pyx_v_key, __pyx_v_reverse, __pyx_v_weighted, __pyx_v_input_batched);

  /* "apache_beam/transforms/stats.py":348
 *         efficiently.
 *     """
 *     def __init__(             # <<<<<<<<<<<<<<
 *         self,
 *         num_quantiles,
 */

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_11apache_beam_10transforms_5stats_8Globally_4__init__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_num_quantiles, PyObject *__pyx_v_key, PyObject *__pyx_v_reverse, PyObject *__pyx_v_weighted, PyObject *__pyx_v_input_batched) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "apache_beam/transforms/stats.py":355
 *         weighted=False,
 *         input_batched=False):
 *       self._num_quantiles = num_quantiles             # <<<<<<<<<<<<<<
 *       self._key = key
 *       self._reverse = reverse
 */
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_num_quantiles_2, __pyx_v_num_quantiles) < 0) __PYX_ERR(0, 355, __pyx_L1_error)

  /* "apache_beam/transforms/stats.py":356
 *         input_batched=False):
 *       self._num_quantiles = num_quantiles
 *       self._key = key             # <<<<<<<<<<<<<<
 *       self._reverse = reverse
 *       self._weighted = weighted
 */
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_key_2, __pyx_v_key) < 0) __PYX_ERR(0, 356, __pyx_L1_error)

  /* "apache_beam/transforms/stats.py":357
 *       self._num_quantiles = num_quantiles
 *       self._key = key
 *       self._reverse = reverse             # <<<<<<<<<<<<<<
 *       self._weighted = weighted
 *       self._input_batched = input_batched
 */
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_reverse_2, __pyx_v_reverse) < 0) __PYX_ERR(0, 357, __pyx_L1_error)

  /* "apache_beam/transforms/stats.py":358
 *       self._key = key
 *       self._reverse = reverse
 *       self._weighted = weighted             # <<<<<<<<<<<<<<
 *       self._input_batched = input_batched
 * 
 */
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_weighted_2, __pyx_v_weighted) < 0) __PYX_ERR(0, 358, __pyx_L1_error)

  /* "apache_beam/transforms/stats.py":359
 *       self._reverse = reverse
 *       self._weighted = weighted
 *       self._input_batched = input_batched             # <<<<<<<<<<<<<<
 * 
 *     def expand(self, pcoll):
 */
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_input_batched_2, __pyx_v_input_batched) < 0) __PYX_ERR(0, 359, __pyx_L1_error)

  /* "apache_beam/transforms/stats.py":348
 *         efficiently.
 *     """
 *     def __init__(             # <<<<<<<<<<<<<<
 *         self,
 *         num_quantiles,
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("apache_beam.transforms.stats.Globally.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "apache_beam/transforms/stats.py":361
 *       self._input_batched = input_batched
 * 
 *     def expand(self, pcoll):             # <<<<<<<<<<<<<<
 *       return pcoll | CombineGlobally(
 *           ApproximateQuantilesCombineFn.create(
 */

/* Python wrapper */
static PyObject *__pyx_pw_11apache_beam_10transforms_5stats_8Globally_7expand(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_11apache_beam_10transforms_5stats_8Globally_7expand = {"expand", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_11apache_beam_10transforms_5stats_8Globally_7expand, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_11apache_beam_10transforms_5stats_8Globally_7expand(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_pcoll = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("expand (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_pcoll,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pcoll)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("expand", 1, 2, 2, 1); __PYX_ERR(0, 361, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "expand") < 0)) __PYX_ERR(0, 361, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_self = values[0];
    __pyx_v_pcoll = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("expand", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 361, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("apache_beam.transforms.stats.Globally.expand", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_11apache_beam_10transforms_5stats_8Globally_6expand(__pyx_self, __pyx_v_self, __pyx_v_pcoll);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_11apache_beam_10transforms_5stats_8Globally_6expand(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_pcoll) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("expand", 0);

  /* "apache_beam/transforms/stats.py":362
 * 
 *     def expand(self, pcoll):
 *       return pcoll | CombineGlobally(             # <<<<<<<<<<<<<<
 *           ApproximateQuantilesCombineFn.create(
 *               num_quantiles=self._num_quantiles,
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_CombineGlobally); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 362, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);

  /* "apache_beam/transforms/stats.py":363
 *     def expand(self, pcoll):
 *       return pcoll | CombineGlobally(
 *           ApproximateQuantilesCombineFn.create(             # <<<<<<<<<<<<<<
 *               num_quantiles=self._num_quantiles,
 *               key=self._key,
 */
  __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_ApproximateQuantilesCombineFn); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 363, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_create); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 363, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "apache_beam/transforms/stats.py":364
 *       return pcoll | CombineGlobally(
 *           ApproximateQuantilesCombineFn.create(
 *               num_quantiles=self._num_quantiles,             # <<<<<<<<<<<<<<
 *               key=self._key,
 *               reverse=self._reverse,
 */
  __pyx_t_3 = __Pyx_PyDict_NewPresized(5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 364, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_num_quantiles_2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 364, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_num_quantiles, __pyx_t_5) < 0) __PYX_ERR(0, 364, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

  /* "apache_beam/transforms/stats.py":365
 *           ApproximateQuantilesCombineFn.create(
 *               num_quantiles=self._num_quantiles,
 *               key=self._key,             # <<<<<<<<<<<<<<
 *               reverse=self._reverse,
 *               weighted=self._weighted,
 */
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_key_2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 365, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_key, __pyx_t_5) < 0) __PYX_ERR(0, 364, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

  /* "apache_beam/transforms/stats.py":366
 *               num_quantiles=self._num_quantiles,
 *               key=self._key,
 *               reverse=self._reverse,             # <<<<<<<<<<<<<<
 *               weighted=self._weighted,
 *               input_batched=self._input_batched))
 */
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_reverse_2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 366, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_reverse, __pyx_t_5) < 0) __PYX_ERR(0, 364, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

  /* "apache_beam/transforms/stats.py":367
 *               key=self._key,
 *               reverse=self._reverse,
 *               weighted=self._weighted,             # <<<<<<<<<<<<<<
 *               input_batched=self._input_batched))
 * 
 */
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_weighted_2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 367, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_weighted, __pyx_t_5) < 0) __PYX_ERR(0, 364, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

  /* "apache_beam/transforms/stats.py":368
 *               reverse=self._reverse,
 *               weighted=self._weighted,
 *               input_batched=self._input_batched))             # <<<<<<<<<<<<<<
 * 
 *     def display_data(self):
 */
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_input_batched_2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 368, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_input_batched, __pyx_t_5) < 0) __PYX_ERR(0, 364, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

  /* "apache_beam/transforms/stats.py":363
 *     def expand(self, pcoll):
 *       return pcoll | CombineGlobally(
 *           ApproximateQuantilesCombineFn.create(             # <<<<<<<<<<<<<<
 *               num_quantiles=self._num_quantiles,
 *               key=self._key,
 */
  __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_empty_tuple, __pyx_t_3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 363, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_3, __pyx_t_5) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_5);
  __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 362, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "apache_beam/transforms/stats.py":362
 * 
 *     def expand(self, pcoll):
 *       return pcoll | CombineGlobally(             # <<<<<<<<<<<<<<
 *           ApproximateQuantilesCombineFn.create(
 *               num_quantiles=self._num_quantiles,
 */
  __pyx_t_2 = PyNumber_Or(__pyx_v_pcoll, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 362, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "apache_beam/transforms/stats.py":361
 *       self._input_batched = input_batched
 * 
 *     def expand(self, pcoll):             # <<<<<<<<<<<<<<
 *       return pcoll | CombineGlobally(
 *           ApproximateQuantilesCombineFn.create(
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("apache_beam.transforms.stats.Globally.expand", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "apache_beam/transforms/stats.py":370
 *               input_batched=self._input_batched))
 * 
 *     def display_data(self):             # <<<<<<<<<<<<<<
 *       return ApproximateQuantiles._display_data(
 *           num_quantiles=self._num_quantiles,
 */

/* Python wrapper */
static PyObject *__pyx_pw_11apache_beam_10transforms_5stats_8Globally_9display_data(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/
static PyMethodDef __pyx_mdef_11apache_beam_10transforms_5stats_8Globally_9display_data = {"display_data", (PyCFunction)__pyx_pw_11apache_beam_10transforms_5stats_8Globally_9display_data, METH_O, 0};
static PyObject *__pyx_pw_11apache_beam_10transforms_5stats_8Globally_9display_data(PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("display_data (wrapper)", 0);
  __pyx_r = __pyx_pf_11apache_beam_10transforms_5stats_8Globally_8display_data(__pyx_self, ((PyObject *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_11apache_beam_10transforms_5stats_8Globally_8display_data(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("display_data", 0);

  /* "apache_beam/transforms/stats.py":371
 * 
 *     def display_data(self):
 *       return ApproximateQuantiles._display_data(             # <<<<<<<<<<<<<<
 *           num_quantiles=self._num_quantiles,
 *           key=self._key,
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_ApproximateQuantiles); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 371, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_display_data); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 371, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "apache_beam/transforms/stats.py":372
 *     def display_data(self):
 *       return ApproximateQuantiles._display_data(
 *           num_quantiles=self._num_quantiles,             # <<<<<<<<<<<<<<
 *           key=self._key,
 *           reverse=self._reverse,
 */
  __pyx_t_1 = __Pyx_PyDict_NewPresized(5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 372, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_num_quantiles_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 372, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_num_quantiles, __pyx_t_3) < 0) __PYX_ERR(0, 372, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "apache_beam/transforms/stats.py":373
 *       return ApproximateQuantiles._display_data(
 *           num_quantiles=self._num_quantiles,
 *           key=self._key,             # <<<<<<<<<<<<<<
 *           reverse=self._reverse,
 *           weighted=self._weighted,
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_key_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 373, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_key, __pyx_t_3) < 0) __PYX_ERR(0, 372, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "apache_beam/transforms/stats.py":374
 *           num_quantiles=self._num_quantiles,
 *           key=self._key,
 *           reverse=self._reverse,             # <<<<<<<<<<<<<<
 *           weighted=self._weighted,
 *           input_batched=self._input_batched)
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_reverse_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 374, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_reverse, __pyx_t_3) < 0) __PYX_ERR(0, 372, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "apache_beam/transforms/stats.py":375
 *           key=self._key,
 *           reverse=self._reverse,
 *           weighted=self._weighted,             # <<<<<<<<<<<<<<
 *           input_batched=self._input_batched)
 * 
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_weighted_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 375, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_weighted, __pyx_t_3) < 0) __PYX_ERR(0, 372, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "apache_beam/transforms/stats.py":376
 *           reverse=self._reverse,
 *           weighted=self._weighted,
 *           input_batched=self._input_batched)             # <<<<<<<<<<<<<<
 * 
 *   @typehints.with_input_types(
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_input_batched_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 376, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_input_batched, __pyx_t_3) < 0) __PYX_ERR(0, 372, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "apache_beam/transforms/stats.py":371
 * 
 *     def display_data(self):
 *       return ApproximateQuantiles._display_data(             # <<<<<<<<<<<<<<
 *           num_quantiles=self._num_quantiles,
 *           key=self._key,
 */
  __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_empty_tuple, __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 371, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  /* "apache_beam/transforms/stats.py":370
 *               input_batched=self._input_batched))
 * 
 *     def display_data(self):             # <<<<<<<<<<<<<<
 *       return ApproximateQuantiles._display_data(
 *           num_quantiles=self._num_quantiles,
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("apache_beam.transforms.stats.Globally.display_data", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "apache_beam/transforms/stats.py":403
 *         efficiently.
 *     """
 *     def __init__(             # <<<<<<<<<<<<<<
 *         self,
 *         num_quantiles,
 */

/* Python wrapper */
static PyObject *__pyx_pw_11apache_beam_10transforms_5stats_6PerKey_5__init__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_11apache_beam_10transforms_5stats_6PerKey_5__init__ = {"__init__", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_11apache_beam_10transforms_5stats_6PerKey_5__init__, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_11apache_beam_10transforms_5stats_6PerKey_5__init__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_num_quantiles = 0;
  PyObject *__pyx_v_key = 0;
  PyObject *__pyx_v_reverse = 0;
  PyObject *__pyx_v_weighted = 0;
  PyObject *__pyx_v_input_batched = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_num_quantiles,&__pyx_n_s_key,&__pyx_n_s_reverse,&__pyx_n_s_weighted,&__pyx_n_s_input_batched,0};
    PyObject* values[6] = {0,0,0,0,0,0};

    /* "apache_beam/transforms/stats.py":406
 *         self,
 *         num_quantiles,
 *         key=None,             # <<<<<<<<<<<<<<
 *         reverse=False,
 *         weighted=False,
 */
    values[2] = ((PyObject *)((PyObject *)Py_None));

    /* "apache_beam/transforms/stats.py":407
 *         num_quantiles,
 *         key=None,
 *         reverse=False,             # <<<<<<<<<<<<<<
 *         weighted=False,
 *         input_batched=False):
 */
    values[3] = ((PyObject *)((PyObject *)Py_False));

    /* "apache_beam/transforms/stats.py":408
 *         key=None,
 *         reverse=False,
 *         weighted=False,             # <<<<<<<<<<<<<<
 *         input_batched=False):
 *       self._num_quantiles = num_quantiles
 */
    values[4] = ((PyObject *)((PyObject *)Py_False));

    /* "apache_beam/transforms/stats.py":409
 *         reverse=False,
 *         weighted=False,
 *         input_batched=False):             # <<<<<<<<<<<<<<
 *       self._num_quantiles = num_quantiles
 *       self._key = key
 */
    values[5] = ((PyObject *)((PyObject *)Py_False));
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        CYTHON_FALLTHROUGH;
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_num_quantiles)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 0, 2, 6, 1); __PYX_ERR(0, 403, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_key);
          if (value) { values[2] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_reverse);
          if (value) { values[3] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  4:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_weighted);
          if (value) { values[4] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  5:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_input_batched);
          if (value) { values[5] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(0, 403, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        CYTHON_FALLTHROUGH;
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_self = values[0];
    __pyx_v_num_quantiles = values[1];
    __pyx_v_key = values[2];
    __pyx_v_reverse = values[3];
    __pyx_v_weighted = values[4];
    __pyx_v_input_batched = values[5];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 0, 2, 6, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 403, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("apache_beam.transforms.stats.PerKey.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_11apache_beam_10transforms_5stats_6PerKey_4__init__(__pyx_self, __pyx_v_self, __pyx_v_num_quantiles, __pyx_v_key, __pyx_v_reverse, __pyx_v_weighted, __pyx_v_input_batched);

  /* "apache_beam/transforms/stats.py":403
 *         efficiently.
 *     """
 *     def __init__(             # <<<<<<<<<<<<<<
 *         self,
 *         num_quantiles,
 */

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_11apache_beam_10transforms_5stats_6PerKey_4__init__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_num_quantiles, PyObject *__pyx_v_key, PyObject *__pyx_v_reverse, PyObject *__pyx_v_weighted, PyObject *__pyx_v_input_batched) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "apache_beam/transforms/stats.py":410
 *         weighted=False,
 *         input_batched=False):
 *       self._num_quantiles = num_quantiles             # <<<<<<<<<<<<<<
 *       self._key = key
 *       self._reverse = reverse
 */
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_num_quantiles_2, __pyx_v_num_quantiles) < 0) __PYX_ERR(0, 410, __pyx_L1_error)

  /* "apache_beam/transforms/stats.py":411
 *         input_batched=False):
 *       self._num_quantiles = num_quantiles
 *       self._key = key             # <<<<<<<<<<<<<<
 *       self._reverse = reverse
 *       self._weighted = weighted
 */
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_key_2, __pyx_v_key) < 0) __PYX_ERR(0, 411, __pyx_L1_error)

  /* "apache_beam/transforms/stats.py":412
 *       self._num_quantiles = num_quantiles
 *       self._key = key
 *       self._reverse = reverse             # <<<<<<<<<<<<<<
 *       self._weighted = weighted
 *       self._input_batched = input_batched
 */
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_reverse_2, __pyx_v_reverse) < 0) __PYX_ERR(0, 412, __pyx_L1_error)

  /* "apache_beam/transforms/stats.py":413
 *       self._key = key
 *       self._reverse = reverse
 *       self._weighted = weighted             # <<<<<<<<<<<<<<
 *       self._input_batched = input_batched
 * 
 */
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_weighted_2, __pyx_v_weighted) < 0) __PYX_ERR(0, 413, __pyx_L1_error)

  /* "apache_beam/transforms/stats.py":414
 *       self._reverse = reverse
 *       self._weighted = weighted
 *       self._input_batched = input_batched             # <<<<<<<<<<<<<<
 * 
 *     def expand(self, pcoll):
 */
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_input_batched_2, __pyx_v_input_batched) < 0) __PYX_ERR(0, 414, __pyx_L1_error)

  /* "apache_beam/transforms/stats.py":403
 *         efficiently.
 *     """
 *     def __init__(             # <<<<<<<<<<<<<<
 *         self,
 *         num_quantiles,
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("apache_beam.transforms.stats.PerKey.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "apache_beam/transforms/stats.py":416
 *       self._input_batched = input_batched
 * 
 *     def expand(self, pcoll):             # <<<<<<<<<<<<<<
 *       return pcoll | CombinePerKey(
 *           ApproximateQuantilesCombineFn.create(
 */

/* Python wrapper */
static PyObject *__pyx_pw_11apache_beam_10transforms_5stats_6PerKey_7expand(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_11apache_beam_10transforms_5stats_6PerKey_7expand = {"expand", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_11apache_beam_10transforms_5stats_6PerKey_7expand, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_11apache_beam_10transforms_5stats_6PerKey_7expand(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_pcoll = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("expand (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_pcoll,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pcoll)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("expand", 1, 2, 2, 1); __PYX_ERR(0, 416, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "expand") < 0)) __PYX_ERR(0, 416, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_self = values[0];
    __pyx_v_pcoll = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("expand", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 416, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("apache_beam.transforms.stats.PerKey.expand", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_11apache_beam_10transforms_5stats_6PerKey_6expand(__pyx_self, __pyx_v_self, __pyx_v_pcoll);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_11apache_beam_10transforms_5stats_6PerKey_6expand(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_pcoll) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("expand", 0);

  /* "apache_beam/transforms/stats.py":417
 * 
 *     def expand(self, pcoll):
 *       return pcoll | CombinePerKey(             # <<<<<<<<<<<<<<
 *           ApproximateQuantilesCombineFn.create(
 *               num_quantiles=self._num_quantiles,
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_CombinePerKey); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 417, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);

  /* "apache_beam/transforms/stats.py":418
 *     def expand(self, pcoll):
 *       return pcoll | CombinePerKey(
 *           ApproximateQuantilesCombineFn.create(             # <<<<<<<<<<<<<<
 *               num_quantiles=self._num_quantiles,
 *               key=self._key,
 */
  __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_ApproximateQuantilesCombineFn); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 418, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_create); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 418, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "apache_beam/transforms/stats.py":419
 *       return pcoll | CombinePerKey(
 *           ApproximateQuantilesCombineFn.create(
 *               num_quantiles=self._num_quantiles,             # <<<<<<<<<<<<<<
 *               key=self._key,
 *               reverse=self._reverse,
 */
  __pyx_t_3 = __Pyx_PyDict_NewPresized(5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 419, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_num_quantiles_2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 419, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_num_quantiles, __pyx_t_5) < 0) __PYX_ERR(0, 419, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

  /* "apache_beam/transforms/stats.py":420
 *           ApproximateQuantilesCombineFn.create(
 *               num_quantiles=self._num_quantiles,
 *               key=self._key,             # <<<<<<<<<<<<<<
 *               reverse=self._reverse,
 *               weighted=self._weighted,
 */
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_key_2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 420, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_key, __pyx_t_5) < 0) __PYX_ERR(0, 419, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

  /* "apache_beam/transforms/stats.py":421
 *               num_quantiles=self._num_quantiles,
 *               key=self._key,
 *               reverse=self._reverse,             # <<<<<<<<<<<<<<
 *               weighted=self._weighted,
 *               input_batched=self._input_batched))
 */
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_reverse_2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 421, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_reverse, __pyx_t_5) < 0) __PYX_ERR(0, 419, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

  /* "apache_beam/transforms/stats.py":422
 *               key=self._key,
 *               reverse=self._reverse,
 *               weighted=self._weighted,             # <<<<<<<<<<<<<<
 *               input_batched=self._input_batched))
 * 
 */
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_weighted_2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 422, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_weighted, __pyx_t_5) < 0) __PYX_ERR(0, 419, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

  /* "apache_beam/transforms/stats.py":423
 *               reverse=self._reverse,
 *               weighted=self._weighted,
 *               input_batched=self._input_batched))             # <<<<<<<<<<<<<<
 * 
 *     def display_data(self):
 */
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_input_batched_2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 423, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_input_batched, __pyx_t_5) < 0) __PYX_ERR(0, 419, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

  /* "apache_beam/transforms/stats.py":418
 *     def expand(self, pcoll):
 *       return pcoll | CombinePerKey(
 *           ApproximateQuantilesCombineFn.create(             # <<<<<<<<<<<<<<
 *               num_quantiles=self._num_quantiles,
 *               key=self._key,
 */
  __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_empty_tuple, __pyx_t_3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 418, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_3, __pyx_t_5) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_5);
  __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 417, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "apache_beam/transforms/stats.py":417
 * 
 *     def expand(self, pcoll):
 *       return pcoll | CombinePerKey(             # <<<<<<<<<<<<<<
 *           ApproximateQuantilesCombineFn.create(
 *               num_quantiles=self._num_quantiles,
 */
  __pyx_t_2 = PyNumber_Or(__pyx_v_pcoll, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 417, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "apache_beam/transforms/stats.py":416
 *       self._input_batched = input_batched
 * 
 *     def expand(self, pcoll):             # <<<<<<<<<<<<<<
 *       return pcoll | CombinePerKey(
 *           ApproximateQuantilesCombineFn.create(
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("apache_beam.transforms.stats.PerKey.expand", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "apache_beam/transforms/stats.py":425
 *               input_batched=self._input_batched))
 * 
 *     def display_data(self):             # <<<<<<<<<<<<<<
 *       return ApproximateQuantiles._display_data(
 *           num_quantiles=self._num_quantiles,
 */

/* Python wrapper */
static PyObject *__pyx_pw_11apache_beam_10transforms_5stats_6PerKey_9display_data(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/
static PyMethodDef __pyx_mdef_11apache_beam_10transforms_5stats_6PerKey_9display_data = {"display_data", (PyCFunction)__pyx_pw_11apache_beam_10transforms_5stats_6PerKey_9display_data, METH_O, 0};
static PyObject *__pyx_pw_11apache_beam_10transforms_5stats_6PerKey_9display_data(PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("display_data (wrapper)", 0);
  __pyx_r = __pyx_pf_11apache_beam_10transforms_5stats_6PerKey_8display_data(__pyx_self, ((PyObject *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_11apache_beam_10transforms_5stats_6PerKey_8display_data(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("display_data", 0);

  /* "apache_beam/transforms/stats.py":426
 * 
 *     def display_data(self):
 *       return ApproximateQuantiles._display_data(             # <<<<<<<<<<<<<<
 *           num_quantiles=self._num_quantiles,
 *           key=self._key,
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_ApproximateQuantiles); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 426, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_display_data); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 426, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "apache_beam/transforms/stats.py":427
 *     def display_data(self):
 *       return ApproximateQuantiles._display_data(
 *           num_quantiles=self._num_quantiles,             # <<<<<<<<<<<<<<
 *           key=self._key,
 *           reverse=self._reverse,
 */
  __pyx_t_1 = __Pyx_PyDict_NewPresized(5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 427, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_num_quantiles_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 427, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_num_quantiles, __pyx_t_3) < 0) __PYX_ERR(0, 427, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "apache_beam/transforms/stats.py":428
 *       return ApproximateQuantiles._display_data(
 *           num_quantiles=self._num_quantiles,
 *           key=self._key,             # <<<<<<<<<<<<<<
 *           reverse=self._reverse,
 *           weighted=self._weighted,
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_key_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 428, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_key, __pyx_t_3) < 0) __PYX_ERR(0, 427, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "apache_beam/transforms/stats.py":429
 *           num_quantiles=self._num_quantiles,
 *           key=self._key,
 *           reverse=self._reverse,             # <<<<<<<<<<<<<<
 *           weighted=self._weighted,
 *           input_batched=self._input_batched)
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_reverse_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 429, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_reverse, __pyx_t_3) < 0) __PYX_ERR(0, 427, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "apache_beam/transforms/stats.py":430
 *           key=self._key,
 *           reverse=self._reverse,
 *           weighted=self._weighted,             # <<<<<<<<<<<<<<
 *           input_batched=self._input_batched)
 * 
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_weighted_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 430, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_weighted, __pyx_t_3) < 0) __PYX_ERR(0, 427, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "apache_beam/transforms/stats.py":431
 *           reverse=self._reverse,
 *           weighted=self._weighted,
 *           input_batched=self._input_batched)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_input_batched_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 431, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_input_batched, __pyx_t_3) < 0) __PYX_ERR(0, 427, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "apache_beam/transforms/stats.py":426
 * 
 *     def display_data(self):
 *       return ApproximateQuantiles._display_data(             # <<<<<<<<<<<<<<
 *           num_quantiles=self._num_quantiles,
 *           key=self._key,
 */
  __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_empty_tuple, __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 426, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  /* "apache_beam/transforms/stats.py":425
 *               input_batched=self._input_batched))
 * 
 *     def display_data(self):             # <<<<<<<<<<<<<<
 *       return ApproximateQuantiles._display_data(
 *           num_quantiles=self._num_quantiles,
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("apache_beam.transforms.stats.PerKey.display_data", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "apache_beam/transforms/stats.py":436
 * class _QuantileSpec(object):
 *   """Quantiles computation specifications."""
 *   def __init__(self, buffer_size, num_buffers, weighted, key, reverse):             # <<<<<<<<<<<<<<
 *     # type: (int, int, bool, Any, bool) -> None
 *     self.buffer_size = buffer_size
 */

/* Python wrapper */
static int __pyx_pw_11apache_beam_10transforms_5stats_13_QuantileSpec_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_11apache_beam_10transforms_5stats_13_QuantileSpec_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_buffer_size = 0;
  PyObject *__pyx_v_num_buffers = 0;
  PyObject *__pyx_v_weighted = 0;
  PyObject *__pyx_v_key = 0;
  PyObject *__pyx_v_reverse = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_buffer_size,&__pyx_n_s_num_buffers,&__pyx_n_s_weighted,&__pyx_n_s_key,&__pyx_n_s_reverse,0};
    PyObject* values[5] = {0,0,0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_buffer_size)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_num_buffers)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 1, 5, 5, 1); __PYX_ERR(0, 436, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_weighted)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 1, 5, 5, 2); __PYX_ERR(0, 436, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_key)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 1, 5, 5, 3); __PYX_ERR(0, 436, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  4:
        if (likely((values[4] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_reverse)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 1, 5, 5, 4); __PYX_ERR(0, 436, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(0, 436, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 5) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
      values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
      values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
    }
    __pyx_v_buffer_size = values[0];
    __pyx_v_num_buffers = values[1];
    __pyx_v_weighted = values[2];
    __pyx_v_key = values[3];
    __pyx_v_reverse = values[4];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 1, 5, 5, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 436, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("apache_beam.transforms.stats._QuantileSpec.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_11apache_beam_10transforms_5stats_13_QuantileSpec___init__(((struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileSpec *)__pyx_v_self), __pyx_v_buffer_size, __pyx_v_num_buffers, __pyx_v_weighted, __pyx_v_key, __pyx_v_reverse);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "apache_beam/transforms/stats.py":445
 * 
 *     # Used to sort tuples of values and weights.
 *     self.weighted_key = None if key is None else (lambda x: key(x[0]))             # <<<<<<<<<<<<<<
 * 
 *     # Used to compare values.
 */

/* Python wrapper */
static PyObject *__pyx_pw_11apache_beam_10transforms_5stats_13_QuantileSpec_8__init___lambda(PyObject *__pyx_self, PyObject *__pyx_v_x); /*proto*/
static PyMethodDef __pyx_mdef_11apache_beam_10transforms_5stats_13_QuantileSpec_8__init___lambda = {"lambda", (PyCFunction)__pyx_pw_11apache_beam_10transforms_5stats_13_QuantileSpec_8__init___lambda, METH_O, 0};
static PyObject *__pyx_pw_11apache_beam_10transforms_5stats_13_QuantileSpec_8__init___lambda(PyObject *__pyx_self, PyObject *__pyx_v_x) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("lambda (wrapper)", 0);
  __pyx_r = __pyx_lambda_funcdef_lambda(__pyx_self, ((PyObject *)__pyx_v_x));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_lambda_funcdef_lambda(PyObject *__pyx_self, PyObject *__pyx_v_x) {
  struct __pyx_obj_11apache_beam_10transforms_5stats___pyx_scope_struct____init__ *__pyx_cur_scope;
  struct __pyx_obj_11apache_beam_10transforms_5stats___pyx_scope_struct____init__ *__pyx_outer_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("lambda", 0);
  __pyx_outer_scope = (struct __pyx_obj_11apache_beam_10transforms_5stats___pyx_scope_struct____init__ *) __Pyx_CyFunction_GetClosure(__pyx_self);
  __pyx_cur_scope = __pyx_outer_scope;
  __Pyx_XDECREF(__pyx_r);
  if (unlikely(!__pyx_cur_scope->__pyx_v_key)) { __Pyx_RaiseClosureNameError("key"); __PYX_ERR(0, 445, __pyx_L1_error) }
  __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_x, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 445, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_key);
  __pyx_t_3 = __pyx_cur_scope->__pyx_v_key; __pyx_t_4 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  __pyx_t_1 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_4, __pyx_t_2) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_2);
  __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 445, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("apache_beam.transforms.stats._QuantileSpec.__init__.lambda", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "apache_beam/transforms/stats.py":449
 *     # Used to compare values.
 *     if reverse and key is None:
 *       self.less_than = lambda a, b: a > b             # <<<<<<<<<<<<<<
 *     elif reverse:
 *       self.less_than = lambda a, b: key(a) > key(b)
 */

/* Python wrapper */
static PyObject *__pyx_pw_11apache_beam_10transforms_5stats_13_QuantileSpec_8__init___1lambda1(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_11apache_beam_10transforms_5stats_13_QuantileSpec_8__init___1lambda1 = {"lambda1", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_11apache_beam_10transforms_5stats_13_QuantileSpec_8__init___1lambda1, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_11apache_beam_10transforms_5stats_13_QuantileSpec_8__init___1lambda1(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_a = 0;
  PyObject *__pyx_v_b = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("lambda1 (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_a,&__pyx_n_s_b,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_a)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_b)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("lambda1", 1, 2, 2, 1); __PYX_ERR(0, 449, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "lambda1") < 0)) __PYX_ERR(0, 449, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_a = values[0];
    __pyx_v_b = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("lambda1", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 449, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("apache_beam.transforms.stats._QuantileSpec.__init__.lambda1", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_lambda_funcdef_lambda1(__pyx_self, __pyx_v_a, __pyx_v_b);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_lambda_funcdef_lambda1(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_a, PyObject *__pyx_v_b) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("lambda1", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyObject_RichCompare(__pyx_v_a, __pyx_v_b, Py_GT); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 449, __pyx_L1_error)
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("apache_beam.transforms.stats._QuantileSpec.__init__.lambda1", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "apache_beam/transforms/stats.py":451
 *       self.less_than = lambda a, b: a > b
 *     elif reverse:
 *       self.less_than = lambda a, b: key(a) > key(b)             # <<<<<<<<<<<<<<
 *     elif key is None:
 *       self.less_than = lambda a, b: a < b
 */

/* Python wrapper */
static PyObject *__pyx_pw_11apache_beam_10transforms_5stats_13_QuantileSpec_8__init___2lambda2(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_11apache_beam_10transforms_5stats_13_QuantileSpec_8__init___2lambda2 = {"lambda2", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_11apache_beam_10transforms_5stats_13_QuantileSpec_8__init___2lambda2, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_11apache_beam_10transforms_5stats_13_QuantileSpec_8__init___2lambda2(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_a = 0;
  PyObject *__pyx_v_b = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("lambda2 (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_a,&__pyx_n_s_b,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_a)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_b)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("lambda2", 1, 2, 2, 1); __PYX_ERR(0, 451, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "lambda2") < 0)) __PYX_ERR(0, 451, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_a = values[0];
    __pyx_v_b = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("lambda2", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 451, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("apache_beam.transforms.stats._QuantileSpec.__init__.lambda2", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_lambda_funcdef_lambda2(__pyx_self, __pyx_v_a, __pyx_v_b);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_lambda_funcdef_lambda2(PyObject *__pyx_self, PyObject *__pyx_v_a, PyObject *__pyx_v_b) {
  struct __pyx_obj_11apache_beam_10transforms_5stats___pyx_scope_struct____init__ *__pyx_cur_scope;
  struct __pyx_obj_11apache_beam_10transforms_5stats___pyx_scope_struct____init__ *__pyx_outer_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("lambda2", 0);
  __pyx_outer_scope = (struct __pyx_obj_11apache_beam_10transforms_5stats___pyx_scope_struct____init__ *) __Pyx_CyFunction_GetClosure(__pyx_self);
  __pyx_cur_scope = __pyx_outer_scope;
  __Pyx_XDECREF(__pyx_r);
  if (unlikely(!__pyx_cur_scope->__pyx_v_key)) { __Pyx_RaiseClosureNameError("key"); __PYX_ERR(0, 451, __pyx_L1_error) }
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_key);
  __pyx_t_2 = __pyx_cur_scope->__pyx_v_key; __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_3, __pyx_v_a) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_a);
  __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 451, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (unlikely(!__pyx_cur_scope->__pyx_v_key)) { __Pyx_RaiseClosureNameError("key"); __PYX_ERR(0, 451, __pyx_L1_error) }
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_key);
  __pyx_t_3 = __pyx_cur_scope->__pyx_v_key; __pyx_t_4 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_4, __pyx_v_b) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_b);
  __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 451, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = PyObject_RichCompare(__pyx_t_1, __pyx_t_2, Py_GT); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 451, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("apache_beam.transforms.stats._QuantileSpec.__init__.lambda2", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "apache_beam/transforms/stats.py":453
 *       self.less_than = lambda a, b: key(a) > key(b)
 *     elif key is None:
 *       self.less_than = lambda a, b: a < b             # <<<<<<<<<<<<<<
 *     else:
 *       self.less_than = lambda a, b: key(a) < key(b)
 */

/* Python wrapper */
static PyObject *__pyx_pw_11apache_beam_10transforms_5stats_13_QuantileSpec_8__init___3lambda3(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_11apache_beam_10transforms_5stats_13_QuantileSpec_8__init___3lambda3 = {"lambda3", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_11apache_beam_10transforms_5stats_13_QuantileSpec_8__init___3lambda3, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_11apache_beam_10transforms_5stats_13_QuantileSpec_8__init___3lambda3(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_a = 0;
  PyObject *__pyx_v_b = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("lambda3 (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_a,&__pyx_n_s_b,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_a)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_b)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("lambda3", 1, 2, 2, 1); __PYX_ERR(0, 453, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "lambda3") < 0)) __PYX_ERR(0, 453, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_a = values[0];
    __pyx_v_b = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("lambda3", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 453, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("apache_beam.transforms.stats._QuantileSpec.__init__.lambda3", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_lambda_funcdef_lambda3(__pyx_self, __pyx_v_a, __pyx_v_b);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_lambda_funcdef_lambda3(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_a, PyObject *__pyx_v_b) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("lambda3", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyObject_RichCompare(__pyx_v_a, __pyx_v_b, Py_LT); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 453, __pyx_L1_error)
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("apache_beam.transforms.stats._QuantileSpec.__init__.lambda3", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "apache_beam/transforms/stats.py":455
 *       self.less_than = lambda a, b: a < b
 *     else:
 *       self.less_than = lambda a, b: key(a) < key(b)             # <<<<<<<<<<<<<<
 * 
 *   def get_argsort_key(self, elements):
 */

/* Python wrapper */
static PyObject *__pyx_pw_11apache_beam_10transforms_5stats_13_QuantileSpec_8__init___4lambda4(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_11apache_beam_10transforms_5stats_13_QuantileSpec_8__init___4lambda4 = {"lambda4", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_11apache_beam_10transforms_5stats_13_QuantileSpec_8__init___4lambda4, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_11apache_beam_10transforms_5stats_13_QuantileSpec_8__init___4lambda4(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_a = 0;
  PyObject *__pyx_v_b = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("lambda4 (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_a,&__pyx_n_s_b,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_a)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_b)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("lambda4", 1, 2, 2, 1); __PYX_ERR(0, 455, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "lambda4") < 0)) __PYX_ERR(0, 455, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_a = values[0];
    __pyx_v_b = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("lambda4", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 455, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("apache_beam.transforms.stats._QuantileSpec.__init__.lambda4", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_lambda_funcdef_lambda4(__pyx_self, __pyx_v_a, __pyx_v_b);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_lambda_funcdef_lambda4(PyObject *__pyx_self, PyObject *__pyx_v_a, PyObject *__pyx_v_b) {
  struct __pyx_obj_11apache_beam_10transforms_5stats___pyx_scope_struct____init__ *__pyx_cur_scope;
  struct __pyx_obj_11apache_beam_10transforms_5stats___pyx_scope_struct____init__ *__pyx_outer_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("lambda4", 0);
  __pyx_outer_scope = (struct __pyx_obj_11apache_beam_10transforms_5stats___pyx_scope_struct____init__ *) __Pyx_CyFunction_GetClosure(__pyx_self);
  __pyx_cur_scope = __pyx_outer_scope;
  __Pyx_XDECREF(__pyx_r);
  if (unlikely(!__pyx_cur_scope->__pyx_v_key)) { __Pyx_RaiseClosureNameError("key"); __PYX_ERR(0, 455, __pyx_L1_error) }
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_key);
  __pyx_t_2 = __pyx_cur_scope->__pyx_v_key; __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_3, __pyx_v_a) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_a);
  __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 455, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (unlikely(!__pyx_cur_scope->__pyx_v_key)) { __Pyx_RaiseClosureNameError("key"); __PYX_ERR(0, 455, __pyx_L1_error) }
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_key);
  __pyx_t_3 = __pyx_cur_scope->__pyx_v_key; __pyx_t_4 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_4, __pyx_v_b) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_b);
  __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 455, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = PyObject_RichCompare(__pyx_t_1, __pyx_t_2, Py_LT); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 455, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("apache_beam.transforms.stats._QuantileSpec.__init__.lambda4", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "apache_beam/transforms/stats.py":436
 * class _QuantileSpec(object):
 *   """Quantiles computation specifications."""
 *   def __init__(self, buffer_size, num_buffers, weighted, key, reverse):             # <<<<<<<<<<<<<<
 *     # type: (int, int, bool, Any, bool) -> None
 *     self.buffer_size = buffer_size
 */

static int __pyx_pf_11apache_beam_10transforms_5stats_13_QuantileSpec___init__(struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileSpec *__pyx_v_self, PyObject *__pyx_v_buffer_size, PyObject *__pyx_v_num_buffers, PyObject *__pyx_v_weighted, PyObject *__pyx_v_key, PyObject *__pyx_v_reverse) {
  struct __pyx_obj_11apache_beam_10transforms_5stats___pyx_scope_struct____init__ *__pyx_cur_scope;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  int64_t __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  int __pyx_t_6;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__init__", 0);
  __pyx_cur_scope = (struct __pyx_obj_11apache_beam_10transforms_5stats___pyx_scope_struct____init__ *)__pyx_tp_new_11apache_beam_10transforms_5stats___pyx_scope_struct____init__(__pyx_ptype_11apache_beam_10transforms_5stats___pyx_scope_struct____init__, __pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_11apache_beam_10transforms_5stats___pyx_scope_struct____init__ *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(0, 436, __pyx_L1_error)
  } else {
    __Pyx_GOTREF(__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_v_key = __pyx_v_key;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_key);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_key);

  /* "apache_beam/transforms/stats.py":438
 *   def __init__(self, buffer_size, num_buffers, weighted, key, reverse):
 *     # type: (int, int, bool, Any, bool) -> None
 *     self.buffer_size = buffer_size             # <<<<<<<<<<<<<<
 *     self.num_buffers = num_buffers
 *     self.weighted = weighted
 */
  __pyx_t_1 = __Pyx_PyInt_As_int64_t(__pyx_v_buffer_size); if (unlikely((__pyx_t_1 == ((int64_t)-1)) && PyErr_Occurred())) __PYX_ERR(0, 438, __pyx_L1_error)
  __pyx_v_self->buffer_size = __pyx_t_1;

  /* "apache_beam/transforms/stats.py":439
 *     # type: (int, int, bool, Any, bool) -> None
 *     self.buffer_size = buffer_size
 *     self.num_buffers = num_buffers             # <<<<<<<<<<<<<<
 *     self.weighted = weighted
 *     self.key = key
 */
  __pyx_t_1 = __Pyx_PyInt_As_int64_t(__pyx_v_num_buffers); if (unlikely((__pyx_t_1 == ((int64_t)-1)) && PyErr_Occurred())) __PYX_ERR(0, 439, __pyx_L1_error)
  __pyx_v_self->num_buffers = __pyx_t_1;

  /* "apache_beam/transforms/stats.py":440
 *     self.buffer_size = buffer_size
 *     self.num_buffers = num_buffers
 *     self.weighted = weighted             # <<<<<<<<<<<<<<
 *     self.key = key
 *     self.reverse = reverse
 */
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_weighted); if (unlikely((__pyx_t_2 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 440, __pyx_L1_error)
  __pyx_v_self->weighted = __pyx_t_2;

  /* "apache_beam/transforms/stats.py":441
 *     self.num_buffers = num_buffers
 *     self.weighted = weighted
 *     self.key = key             # <<<<<<<<<<<<<<
 *     self.reverse = reverse
 * 
 */
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_key);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_key);
  __Pyx_GOTREF(__pyx_v_self->key);
  __Pyx_DECREF(__pyx_v_self->key);
  __pyx_v_self->key = __pyx_cur_scope->__pyx_v_key;

  /* "apache_beam/transforms/stats.py":442
 *     self.weighted = weighted
 *     self.key = key
 *     self.reverse = reverse             # <<<<<<<<<<<<<<
 * 
 *     # Used to sort tuples of values and weights.
 */
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_reverse); if (unlikely((__pyx_t_2 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 442, __pyx_L1_error)
  __pyx_v_self->reverse = __pyx_t_2;

  /* "apache_beam/transforms/stats.py":445
 * 
 *     # Used to sort tuples of values and weights.
 *     self.weighted_key = None if key is None else (lambda x: key(x[0]))             # <<<<<<<<<<<<<<
 * 
 *     # Used to compare values.
 */
  __pyx_t_2 = (__pyx_cur_scope->__pyx_v_key == Py_None);
  if ((__pyx_t_2 != 0)) {
    __Pyx_INCREF(Py_None);
    __pyx_t_3 = Py_None;
  } else {
    __pyx_t_4 = __Pyx_CyFunction_New(&__pyx_mdef_11apache_beam_10transforms_5stats_13_QuantileSpec_8__init___lambda, 0, __pyx_n_s_init___locals_lambda, ((PyObject*)__pyx_cur_scope), __pyx_n_s_apache_beam_transforms_stats, __pyx_d, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 445, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_3 = __pyx_t_4;
    __pyx_t_4 = 0;
  }
  __Pyx_GIVEREF(__pyx_t_3);
  __Pyx_GOTREF(__pyx_v_self->weighted_key);
  __Pyx_DECREF(__pyx_v_self->weighted_key);
  __pyx_v_self->weighted_key = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "apache_beam/transforms/stats.py":448
 * 
 *     # Used to compare values.
 *     if reverse and key is None:             # <<<<<<<<<<<<<<
 *       self.less_than = lambda a, b: a > b
 *     elif reverse:
 */
  __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_v_reverse); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 448, __pyx_L1_error)
  if (__pyx_t_5) {
  } else {
    __pyx_t_2 = __pyx_t_5;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_5 = (__pyx_cur_scope->__pyx_v_key == Py_None);
  __pyx_t_6 = (__pyx_t_5 != 0);
  __pyx_t_2 = __pyx_t_6;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_2) {

    /* "apache_beam/transforms/stats.py":449
 *     # Used to compare values.
 *     if reverse and key is None:
 *       self.less_than = lambda a, b: a > b             # <<<<<<<<<<<<<<
 *     elif reverse:
 *       self.less_than = lambda a, b: key(a) > key(b)
 */
    __pyx_t_3 = __Pyx_CyFunction_New(&__pyx_mdef_11apache_beam_10transforms_5stats_13_QuantileSpec_8__init___1lambda1, 0, __pyx_n_s_init___locals_lambda, NULL, __pyx_n_s_apache_beam_transforms_stats, __pyx_d, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 449, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_3);
    __Pyx_GOTREF(__pyx_v_self->less_than);
    __Pyx_DECREF(__pyx_v_self->less_than);
    __pyx_v_self->less_than = __pyx_t_3;
    __pyx_t_3 = 0;

    /* "apache_beam/transforms/stats.py":448
 * 
 *     # Used to compare values.
 *     if reverse and key is None:             # <<<<<<<<<<<<<<
 *       self.less_than = lambda a, b: a > b
 *     elif reverse:
 */
    goto __pyx_L3;
  }

  /* "apache_beam/transforms/stats.py":450
 *     if reverse and key is None:
 *       self.less_than = lambda a, b: a > b
 *     elif reverse:             # <<<<<<<<<<<<<<
 *       self.less_than = lambda a, b: key(a) > key(b)
 *     elif key is None:
 */
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_reverse); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 450, __pyx_L1_error)
  if (__pyx_t_2) {

    /* "apache_beam/transforms/stats.py":451
 *       self.less_than = lambda a, b: a > b
 *     elif reverse:
 *       self.less_than = lambda a, b: key(a) > key(b)             # <<<<<<<<<<<<<<
 *     elif key is None:
 *       self.less_than = lambda a, b: a < b
 */
    __pyx_t_3 = __Pyx_CyFunction_New(&__pyx_mdef_11apache_beam_10transforms_5stats_13_QuantileSpec_8__init___2lambda2, 0, __pyx_n_s_init___locals_lambda, ((PyObject*)__pyx_cur_scope), __pyx_n_s_apache_beam_transforms_stats, __pyx_d, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 451, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_3);
    __Pyx_GOTREF(__pyx_v_self->less_than);
    __Pyx_DECREF(__pyx_v_self->less_than);
    __pyx_v_self->less_than = __pyx_t_3;
    __pyx_t_3 = 0;

    /* "apache_beam/transforms/stats.py":450
 *     if reverse and key is None:
 *       self.less_than = lambda a, b: a > b
 *     elif reverse:             # <<<<<<<<<<<<<<
 *       self.less_than = lambda a, b: key(a) > key(b)
 *     elif key is None:
 */
    goto __pyx_L3;
  }

  /* "apache_beam/transforms/stats.py":452
 *     elif reverse:
 *       self.less_than = lambda a, b: key(a) > key(b)
 *     elif key is None:             # <<<<<<<<<<<<<<
 *       self.less_than = lambda a, b: a < b
 *     else:
 */
  __pyx_t_2 = (__pyx_cur_scope->__pyx_v_key == Py_None);
  __pyx_t_6 = (__pyx_t_2 != 0);
  if (__pyx_t_6) {

    /* "apache_beam/transforms/stats.py":453
 *       self.less_than = lambda a, b: key(a) > key(b)
 *     elif key is None:
 *       self.less_than = lambda a, b: a < b             # <<<<<<<<<<<<<<
 *     else:
 *       self.less_than = lambda a, b: key(a) < key(b)
 */
    __pyx_t_3 = __Pyx_CyFunction_New(&__pyx_mdef_11apache_beam_10transforms_5stats_13_QuantileSpec_8__init___3lambda3, 0, __pyx_n_s_init___locals_lambda, NULL, __pyx_n_s_apache_beam_transforms_stats, __pyx_d, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 453, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_3);
    __Pyx_GOTREF(__pyx_v_self->less_than);
    __Pyx_DECREF(__pyx_v_self->less_than);
    __pyx_v_self->less_than = __pyx_t_3;
    __pyx_t_3 = 0;

    /* "apache_beam/transforms/stats.py":452
 *     elif reverse:
 *       self.less_than = lambda a, b: key(a) > key(b)
 *     elif key is None:             # <<<<<<<<<<<<<<
 *       self.less_than = lambda a, b: a < b
 *     else:
 */
    goto __pyx_L3;
  }

  /* "apache_beam/transforms/stats.py":455
 *       self.less_than = lambda a, b: a < b
 *     else:
 *       self.less_than = lambda a, b: key(a) < key(b)             # <<<<<<<<<<<<<<
 * 
 *   def get_argsort_key(self, elements):
 */
  /*else*/ {
    __pyx_t_3 = __Pyx_CyFunction_New(&__pyx_mdef_11apache_beam_10transforms_5stats_13_QuantileSpec_8__init___4lambda4, 0, __pyx_n_s_init___locals_lambda, ((PyObject*)__pyx_cur_scope), __pyx_n_s_apache_beam_transforms_stats, __pyx_d, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 455, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_3);
    __Pyx_GOTREF(__pyx_v_self->less_than);
    __Pyx_DECREF(__pyx_v_self->less_than);
    __pyx_v_self->less_than = __pyx_t_3;
    __pyx_t_3 = 0;
  }
  __pyx_L3:;

  /* "apache_beam/transforms/stats.py":436
 * class _QuantileSpec(object):
 *   """Quantiles computation specifications."""
 *   def __init__(self, buffer_size, num_buffers, weighted, key, reverse):             # <<<<<<<<<<<<<<
 *     # type: (int, int, bool, Any, bool) -> None
 *     self.buffer_size = buffer_size
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("apache_beam.transforms.stats._QuantileSpec.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_DECREF(((PyObject *)__pyx_cur_scope));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "apache_beam/transforms/stats.py":457
 *       self.less_than = lambda a, b: key(a) < key(b)
 * 
 *   def get_argsort_key(self, elements):             # <<<<<<<<<<<<<<
 *     # type: (List) -> Callable[[int], Any]
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_11apache_beam_10transforms_5stats_13_QuantileSpec_3get_argsort_key(PyObject *__pyx_v_self, PyObject *__pyx_v_elements); /*proto*/
static char __pyx_doc_11apache_beam_10transforms_5stats_13_QuantileSpec_2get_argsort_key[] = "Returns a key for sorting indices of elements by element's value.";
static PyMethodDef __pyx_mdef_11apache_beam_10transforms_5stats_13_QuantileSpec_3get_argsort_key = {"get_argsort_key", (PyCFunction)__pyx_pw_11apache_beam_10transforms_5stats_13_QuantileSpec_3get_argsort_key, METH_O, __pyx_doc_11apache_beam_10transforms_5stats_13_QuantileSpec_2get_argsort_key};
static PyObject *__pyx_pw_11apache_beam_10transforms_5stats_13_QuantileSpec_3get_argsort_key(PyObject *__pyx_v_self, PyObject *__pyx_v_elements) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_argsort_key (wrapper)", 0);
  __pyx_r = __pyx_pf_11apache_beam_10transforms_5stats_13_QuantileSpec_2get_argsort_key(((struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileSpec *)__pyx_v_self), ((PyObject *)__pyx_v_elements));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "apache_beam/transforms/stats.py":464
 *       return elements.__getitem__
 *     else:
 *       return lambda idx: self.key(elements[idx])             # <<<<<<<<<<<<<<
 * 
 *   def __reduce__(self):
 */

/* Python wrapper */
static PyObject *__pyx_pw_11apache_beam_10transforms_5stats_13_QuantileSpec_15get_argsort_key_lambda5(PyObject *__pyx_self, PyObject *__pyx_v_idx); /*proto*/
static PyMethodDef __pyx_mdef_11apache_beam_10transforms_5stats_13_QuantileSpec_15get_argsort_key_lambda5 = {"lambda5", (PyCFunction)__pyx_pw_11apache_beam_10transforms_5stats_13_QuantileSpec_15get_argsort_key_lambda5, METH_O, 0};
static PyObject *__pyx_pw_11apache_beam_10transforms_5stats_13_QuantileSpec_15get_argsort_key_lambda5(PyObject *__pyx_self, PyObject *__pyx_v_idx) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("lambda5 (wrapper)", 0);
  __pyx_r = __pyx_lambda_funcdef_lambda5(__pyx_self, ((PyObject *)__pyx_v_idx));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_lambda_funcdef_lambda5(PyObject *__pyx_self, PyObject *__pyx_v_idx) {
  struct __pyx_obj_11apache_beam_10transforms_5stats___pyx_scope_struct_1_get_argsort_key *__pyx_cur_scope;
  struct __pyx_obj_11apache_beam_10transforms_5stats___pyx_scope_struct_1_get_argsort_key *__pyx_outer_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("lambda5", 0);
  __pyx_outer_scope = (struct __pyx_obj_11apache_beam_10transforms_5stats___pyx_scope_struct_1_get_argsort_key *) __Pyx_CyFunction_GetClosure(__pyx_self);
  __pyx_cur_scope = __pyx_outer_scope;
  __Pyx_XDECREF(__pyx_r);
  if (unlikely(!__pyx_cur_scope->__pyx_v_self)) { __Pyx_RaiseClosureNameError("self"); __PYX_ERR(0, 464, __pyx_L1_error) }
  if (unlikely(!__pyx_cur_scope->__pyx_v_elements)) { __Pyx_RaiseClosureNameError("elements"); __PYX_ERR(0, 464, __pyx_L1_error) }
  __pyx_t_2 = __Pyx_PyObject_GetItem(__pyx_cur_scope->__pyx_v_elements, __pyx_v_idx); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 464, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_self->key);
  __pyx_t_3 = __pyx_cur_scope->__pyx_v_self->key; __pyx_t_4 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  __pyx_t_1 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_4, __pyx_t_2) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_2);
  __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 464, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("apache_beam.transforms.stats._QuantileSpec.get_argsort_key.lambda5", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "apache_beam/transforms/stats.py":457
 *       self.less_than = lambda a, b: key(a) < key(b)
 * 
 *   def get_argsort_key(self, elements):             # <<<<<<<<<<<<<<
 *     # type: (List) -> Callable[[int], Any]
 * 
 */

static PyObject *__pyx_pf_11apache_beam_10transforms_5stats_13_QuantileSpec_2get_argsort_key(struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileSpec *__pyx_v_self, PyObject *__pyx_v_elements) {
  struct __pyx_obj_11apache_beam_10transforms_5stats___pyx_scope_struct_1_get_argsort_key *__pyx_cur_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_argsort_key", 0);
  __pyx_cur_scope = (struct __pyx_obj_11apache_beam_10transforms_5stats___pyx_scope_struct_1_get_argsort_key *)__pyx_tp_new_11apache_beam_10transforms_5stats___pyx_scope_struct_1_get_argsort_key(__pyx_ptype_11apache_beam_10transforms_5stats___pyx_scope_struct_1_get_argsort_key, __pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_11apache_beam_10transforms_5stats___pyx_scope_struct_1_get_argsort_key *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(0, 457, __pyx_L1_error)
  } else {
    __Pyx_GOTREF(__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_v_self = __pyx_v_self;
  __Pyx_INCREF((PyObject *)__pyx_cur_scope->__pyx_v_self);
  __Pyx_GIVEREF((PyObject *)__pyx_cur_scope->__pyx_v_self);
  __pyx_cur_scope->__pyx_v_elements = __pyx_v_elements;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_elements);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_elements);

  /* "apache_beam/transforms/stats.py":461
 * 
 *     """Returns a key for sorting indices of elements by element's value."""
 *     if self.key is None:             # <<<<<<<<<<<<<<
 *       return elements.__getitem__
 *     else:
 */
  __pyx_t_1 = (__pyx_cur_scope->__pyx_v_self->key == Py_None);
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "apache_beam/transforms/stats.py":462
 *     """Returns a key for sorting indices of elements by element's value."""
 *     if self.key is None:
 *       return elements.__getitem__             # <<<<<<<<<<<<<<
 *     else:
 *       return lambda idx: self.key(elements[idx])
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_elements, __pyx_n_s_getitem); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 462, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_r = __pyx_t_3;
    __pyx_t_3 = 0;
    goto __pyx_L0;

    /* "apache_beam/transforms/stats.py":461
 * 
 *     """Returns a key for sorting indices of elements by element's value."""
 *     if self.key is None:             # <<<<<<<<<<<<<<
 *       return elements.__getitem__
 *     else:
 */
  }

  /* "apache_beam/transforms/stats.py":464
 *       return elements.__getitem__
 *     else:
 *       return lambda idx: self.key(elements[idx])             # <<<<<<<<<<<<<<
 * 
 *   def __reduce__(self):
 */
  /*else*/ {
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_3 = __Pyx_CyFunction_New(&__pyx_mdef_11apache_beam_10transforms_5stats_13_QuantileSpec_15get_argsort_key_lambda5, 0, __pyx_n_s_get_argsort_key_locals_lambda, ((PyObject*)__pyx_cur_scope), __pyx_n_s_apache_beam_transforms_stats, __pyx_d, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 464, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_r = __pyx_t_3;
    __pyx_t_3 = 0;
    goto __pyx_L0;
  }

  /* "apache_beam/transforms/stats.py":457
 *       self.less_than = lambda a, b: key(a) < key(b)
 * 
 *   def get_argsort_key(self, elements):             # <<<<<<<<<<<<<<
 *     # type: (List) -> Callable[[int], Any]
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("apache_beam.transforms.stats._QuantileSpec.get_argsort_key", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_DECREF(((PyObject *)__pyx_cur_scope));
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "apache_beam/transforms/stats.py":466
 *       return lambda idx: self.key(elements[idx])
 * 
 *   def __reduce__(self):             # <<<<<<<<<<<<<<
 *     return (
 *         self.__class__,
 */

/* Python wrapper */
static PyObject *__pyx_pw_11apache_beam_10transforms_5stats_13_QuantileSpec_5__reduce__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyMethodDef __pyx_mdef_11apache_beam_10transforms_5stats_13_QuantileSpec_5__reduce__ = {"__reduce__", (PyCFunction)__pyx_pw_11apache_beam_10transforms_5stats_13_QuantileSpec_5__reduce__, METH_NOARGS, 0};
static PyObject *__pyx_pw_11apache_beam_10transforms_5stats_13_QuantileSpec_5__reduce__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__reduce__ (wrapper)", 0);
  __pyx_r = __pyx_pf_11apache_beam_10transforms_5stats_13_QuantileSpec_4__reduce__(((struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileSpec *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_11apache_beam_10transforms_5stats_13_QuantileSpec_4__reduce__(struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileSpec *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__reduce__", 0);

  /* "apache_beam/transforms/stats.py":467
 * 
 *   def __reduce__(self):
 *     return (             # <<<<<<<<<<<<<<
 *         self.__class__,
 *         (
 */
  __Pyx_XDECREF(__pyx_r);

  /* "apache_beam/transforms/stats.py":468
 *   def __reduce__(self):
 *     return (
 *         self.__class__,             # <<<<<<<<<<<<<<
 *         (
 *             self.buffer_size,
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_class); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 468, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);

  /* "apache_beam/transforms/stats.py":470
 *         self.__class__,
 *         (
 *             self.buffer_size,             # <<<<<<<<<<<<<<
 *             self.num_buffers,
 *             self.weighted,
 */
  __pyx_t_2 = __Pyx_PyInt_From_int64_t(__pyx_v_self->buffer_size); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 470, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);

  /* "apache_beam/transforms/stats.py":471
 *         (
 *             self.buffer_size,
 *             self.num_buffers,             # <<<<<<<<<<<<<<
 *             self.weighted,
 *             self.key,
 */
  __pyx_t_3 = __Pyx_PyInt_From_int64_t(__pyx_v_self->num_buffers); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 471, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);

  /* "apache_beam/transforms/stats.py":472
 *             self.buffer_size,
 *             self.num_buffers,
 *             self.weighted,             # <<<<<<<<<<<<<<
 *             self.key,
 *             self.reverse))
 */
  __pyx_t_4 = __Pyx_PyBool_FromLong(__pyx_v_self->weighted); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 472, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);

  /* "apache_beam/transforms/stats.py":474
 *             self.weighted,
 *             self.key,
 *             self.reverse))             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_5 = __Pyx_PyBool_FromLong(__pyx_v_self->reverse); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 474, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);

  /* "apache_beam/transforms/stats.py":470
 *         self.__class__,
 *         (
 *             self.buffer_size,             # <<<<<<<<<<<<<<
 *             self.num_buffers,
 *             self.weighted,
 */
  __pyx_t_6 = PyTuple_New(5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 470, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_6, 2, __pyx_t_4);
  __Pyx_INCREF(__pyx_v_self->key);
  __Pyx_GIVEREF(__pyx_v_self->key);
  PyTuple_SET_ITEM(__pyx_t_6, 3, __pyx_v_self->key);
  __Pyx_GIVEREF(__pyx_t_5);
  PyTuple_SET_ITEM(__pyx_t_6, 4, __pyx_t_5);
  __pyx_t_2 = 0;
  __pyx_t_3 = 0;
  __pyx_t_4 = 0;
  __pyx_t_5 = 0;

  /* "apache_beam/transforms/stats.py":468
 *   def __reduce__(self):
 *     return (
 *         self.__class__,             # <<<<<<<<<<<<<<
 *         (
 *             self.buffer_size,
 */
  __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 468, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_6);
  PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_6);
  __pyx_t_1 = 0;
  __pyx_t_6 = 0;
  __pyx_r = __pyx_t_5;
  __pyx_t_5 = 0;
  goto __pyx_L0;

  /* "apache_beam/transforms/stats.py":466
 *       return lambda idx: self.key(elements[idx])
 * 
 *   def __reduce__(self):             # <<<<<<<<<<<<<<
 *     return (
 *         self.__class__,
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("apache_beam.transforms.stats._QuantileSpec.__reduce__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "apache_beam/transforms/stats.pxd":22
 * 
 * cdef class _QuantileSpec(object):
 *   cdef readonly int64_t buffer_size             # <<<<<<<<<<<<<<
 *   cdef readonly int64_t num_buffers
 *   cdef readonly bint weighted
 */

/* Python wrapper */
static PyObject *__pyx_pw_11apache_beam_10transforms_5stats_13_QuantileSpec_11buffer_size_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_11apache_beam_10transforms_5stats_13_QuantileSpec_11buffer_size_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_11apache_beam_10transforms_5stats_13_QuantileSpec_11buffer_size___get__(((struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileSpec *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_11apache_beam_10transforms_5stats_13_QuantileSpec_11buffer_size___get__(struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileSpec *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyInt_From_int64_t(__pyx_v_self->buffer_size); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 22, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("apache_beam.transforms.stats._QuantileSpec.buffer_size.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "apache_beam/transforms/stats.pxd":23
 * cdef class _QuantileSpec(object):
 *   cdef readonly int64_t buffer_size
 *   cdef readonly int64_t num_buffers             # <<<<<<<<<<<<<<
 *   cdef readonly bint weighted
 *   cdef readonly key
 */

/* Python wrapper */
static PyObject *__pyx_pw_11apache_beam_10transforms_5stats_13_QuantileSpec_11num_buffers_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_11apache_beam_10transforms_5stats_13_QuantileSpec_11num_buffers_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_11apache_beam_10transforms_5stats_13_QuantileSpec_11num_buffers___get__(((struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileSpec *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_11apache_beam_10transforms_5stats_13_QuantileSpec_11num_buffers___get__(struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileSpec *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyInt_From_int64_t(__pyx_v_self->num_buffers); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 23, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("apache_beam.transforms.stats._QuantileSpec.num_buffers.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "apache_beam/transforms/stats.pxd":24
 *   cdef readonly int64_t buffer_size
 *   cdef readonly int64_t num_buffers
 *   cdef readonly bint weighted             # <<<<<<<<<<<<<<
 *   cdef readonly key
 *   cdef readonly bint reverse
 */

/* Python wrapper */
static PyObject *__pyx_pw_11apache_beam_10transforms_5stats_13_QuantileSpec_8weighted_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_11apache_beam_10transforms_5stats_13_QuantileSpec_8weighted_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_11apache_beam_10transforms_5stats_13_QuantileSpec_8weighted___get__(((struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileSpec *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_11apache_beam_10transforms_5stats_13_QuantileSpec_8weighted___get__(struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileSpec *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyBool_FromLong(__pyx_v_self->weighted); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 24, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("apache_beam.transforms.stats._QuantileSpec.weighted.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "apache_beam/transforms/stats.pxd":25
 *   cdef readonly int64_t num_buffers
 *   cdef readonly bint weighted
 *   cdef readonly key             # <<<<<<<<<<<<<<
 *   cdef readonly bint reverse
 *   cdef readonly weighted_key
 */

/* Python wrapper */
static PyObject *__pyx_pw_11apache_beam_10transforms_5stats_13_QuantileSpec_3key_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_11apache_beam_10transforms_5stats_13_QuantileSpec_3key_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_11apache_beam_10transforms_5stats_13_QuantileSpec_3key___get__(((struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileSpec *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_11apache_beam_10transforms_5stats_13_QuantileSpec_3key___get__(struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileSpec *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_self->key);
  __pyx_r = __pyx_v_self->key;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "apache_beam/transforms/stats.pxd":26
 *   cdef readonly bint weighted
 *   cdef readonly key
 *   cdef readonly bint reverse             # <<<<<<<<<<<<<<
 *   cdef readonly weighted_key
 *   cdef readonly less_than
 */

/* Python wrapper */
static PyObject *__pyx_pw_11apache_beam_10transforms_5stats_13_QuantileSpec_7reverse_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_11apache_beam_10transforms_5stats_13_QuantileSpec_7reverse_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_11apache_beam_10transforms_5stats_13_QuantileSpec_7reverse___get__(((struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileSpec *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_11apache_beam_10transforms_5stats_13_QuantileSpec_7reverse___get__(struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileSpec *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyBool_FromLong(__pyx_v_self->reverse); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 26, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("apache_beam.transforms.stats._QuantileSpec.reverse.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "apache_beam/transforms/stats.pxd":27
 *   cdef readonly key
 *   cdef readonly bint reverse
 *   cdef readonly weighted_key             # <<<<<<<<<<<<<<
 *   cdef readonly less_than
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_11apache_beam_10transforms_5stats_13_QuantileSpec_12weighted_key_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_11apache_beam_10transforms_5stats_13_QuantileSpec_12weighted_key_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_11apache_beam_10transforms_5stats_13_QuantileSpec_12weighted_key___get__(((struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileSpec *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_11apache_beam_10transforms_5stats_13_QuantileSpec_12weighted_key___get__(struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileSpec *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_self->weighted_key);
  __pyx_r = __pyx_v_self->weighted_key;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "apache_beam/transforms/stats.pxd":28
 *   cdef readonly bint reverse
 *   cdef readonly weighted_key
 *   cdef readonly less_than             # <<<<<<<<<<<<<<
 * 
 * cdef class _QuantileBuffer(object):
 */

/* Python wrapper */
static PyObject *__pyx_pw_11apache_beam_10transforms_5stats_13_QuantileSpec_9less_than_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_11apache_beam_10transforms_5stats_13_QuantileSpec_9less_than_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_11apache_beam_10transforms_5stats_13_QuantileSpec_9less_than___get__(((struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileSpec *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_11apache_beam_10transforms_5stats_13_QuantileSpec_9less_than___get__(struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileSpec *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_self->less_than);
  __pyx_r = __pyx_v_self->less_than;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "apache_beam/transforms/stats.py":481
 *   (see http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.6.6513&rep=rep1
 *   &type=pdf and ApproximateQuantilesCombineFn for further information)"""
 *   def __init__(             # <<<<<<<<<<<<<<
 *       self, elements, weights, weighted, level=0, min_val=None, max_val=None):
 *     # type: (List, List, bool, int, Any, Any) -> None
 */

/* Python wrapper */
static int __pyx_pw_11apache_beam_10transforms_5stats_15_QuantileBuffer_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_11apache_beam_10transforms_5stats_15_QuantileBuffer_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_elements = 0;
  PyObject *__pyx_v_weights = 0;
  PyObject *__pyx_v_weighted = 0;
  PyObject *__pyx_v_level = 0;
  PyObject *__pyx_v_min_val = 0;
  PyObject *__pyx_v_max_val = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_elements,&__pyx_n_s_weights,&__pyx_n_s_weighted,&__pyx_n_s_level,&__pyx_n_s_min_val,&__pyx_n_s_max_val,0};
    PyObject* values[6] = {0,0,0,0,0,0};
    values[3] = ((PyObject *)__pyx_int_0);

    /* "apache_beam/transforms/stats.py":482
 *   &type=pdf and ApproximateQuantilesCombineFn for further information)"""
 *   def __init__(
 *       self, elements, weights, weighted, level=0, min_val=None, max_val=None):             # <<<<<<<<<<<<<<
 *     # type: (List, List, bool, int, Any, Any) -> None
 *     self.elements = elements
 */
    values[4] = ((PyObject *)Py_None);
    values[5] = ((PyObject *)Py_None);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        CYTHON_FALLTHROUGH;
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_elements)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_weights)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 0, 3, 6, 1); __PYX_ERR(0, 481, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_weighted)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 0, 3, 6, 2); __PYX_ERR(0, 481, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_level);
          if (value) { values[3] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  4:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_min_val);
          if (value) { values[4] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  5:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_max_val);
          if (value) { values[5] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(0, 481, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        CYTHON_FALLTHROUGH;
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_elements = values[0];
    __pyx_v_weights = values[1];
    __pyx_v_weighted = values[2];
    __pyx_v_level = values[3];
    __pyx_v_min_val = values[4];
    __pyx_v_max_val = values[5];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 0, 3, 6, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 481, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("apache_beam.transforms.stats._QuantileBuffer.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_11apache_beam_10transforms_5stats_15_QuantileBuffer___init__(((struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileBuffer *)__pyx_v_self), __pyx_v_elements, __pyx_v_weights, __pyx_v_weighted, __pyx_v_level, __pyx_v_min_val, __pyx_v_max_val);

  /* "apache_beam/transforms/stats.py":481
 *   (see http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.6.6513&rep=rep1
 *   &type=pdf and ApproximateQuantilesCombineFn for further information)"""
 *   def __init__(             # <<<<<<<<<<<<<<
 *       self, elements, weights, weighted, level=0, min_val=None, max_val=None):
 *     # type: (List, List, bool, int, Any, Any) -> None
 */

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_11apache_beam_10transforms_5stats_15_QuantileBuffer___init__(struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileBuffer *__pyx_v_self, PyObject *__pyx_v_elements, PyObject *__pyx_v_weights, PyObject *__pyx_v_weighted, PyObject *__pyx_v_level, PyObject *__pyx_v_min_val, PyObject *__pyx_v_max_val) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int64_t __pyx_t_2;
  int __pyx_t_3;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "apache_beam/transforms/stats.py":484
 *       self, elements, weights, weighted, level=0, min_val=None, max_val=None):
 *     # type: (List, List, bool, int, Any, Any) -> None
 *     self.elements = elements             # <<<<<<<<<<<<<<
 *     # In non-weighted case weights contains a single element representing weight
 *     # of the buffer in the sense of the original algorithm. In weighted case,
 */
  __Pyx_INCREF(__pyx_v_elements);
  __Pyx_GIVEREF(__pyx_v_elements);
  __Pyx_GOTREF(__pyx_v_self->elements);
  __Pyx_DECREF(__pyx_v_self->elements);
  __pyx_v_self->elements = __pyx_v_elements;

  /* "apache_beam/transforms/stats.py":488
 *     # of the buffer in the sense of the original algorithm. In weighted case,
 *     # it stores weights of individual elements.
 *     self.weights = weights             # <<<<<<<<<<<<<<
 *     self.weighted = weighted
 *     self.level = level
 */
  __Pyx_INCREF(__pyx_v_weights);
  __Pyx_GIVEREF(__pyx_v_weights);
  __Pyx_GOTREF(__pyx_v_self->weights);
  __Pyx_DECREF(__pyx_v_self->weights);
  __pyx_v_self->weights = __pyx_v_weights;

  /* "apache_beam/transforms/stats.py":489
 *     # it stores weights of individual elements.
 *     self.weights = weights
 *     self.weighted = weighted             # <<<<<<<<<<<<<<
 *     self.level = level
 *     if min_val is None or max_val is None:
 */
  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_weighted); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 489, __pyx_L1_error)
  __pyx_v_self->weighted = __pyx_t_1;

  /* "apache_beam/transforms/stats.py":490
 *     self.weights = weights
 *     self.weighted = weighted
 *     self.level = level             # <<<<<<<<<<<<<<
 *     if min_val is None or max_val is None:
 *       # Buffer is always initialized with sorted elements.
 */
  __pyx_t_2 = __Pyx_PyInt_As_int64_t(__pyx_v_level); if (unlikely((__pyx_t_2 == ((int64_t)-1)) && PyErr_Occurred())) __PYX_ERR(0, 490, __pyx_L1_error)
  __pyx_v_self->level = __pyx_t_2;

  /* "apache_beam/transforms/stats.py":491
 *     self.weighted = weighted
 *     self.level = level
 *     if min_val is None or max_val is None:             # <<<<<<<<<<<<<<
 *       # Buffer is always initialized with sorted elements.
 *       self.min_val = elements[0]
 */
  __pyx_t_3 = (__pyx_v_min_val == Py_None);
  __pyx_t_4 = (__pyx_t_3 != 0);
  if (!__pyx_t_4) {
  } else {
    __pyx_t_1 = __pyx_t_4;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_4 = (__pyx_v_max_val == Py_None);
  __pyx_t_3 = (__pyx_t_4 != 0);
  __pyx_t_1 = __pyx_t_3;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_1) {

    /* "apache_beam/transforms/stats.py":493
 *     if min_val is None or max_val is None:
 *       # Buffer is always initialized with sorted elements.
 *       self.min_val = elements[0]             # <<<<<<<<<<<<<<
 *       self.max_val = elements[-1]
 *     else:
 */
    __pyx_t_5 = __Pyx_GetItemInt(__pyx_v_elements, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 493, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_5);
    __Pyx_GOTREF(__pyx_v_self->min_val);
    __Pyx_DECREF(__pyx_v_self->min_val);
    __pyx_v_self->min_val = __pyx_t_5;
    __pyx_t_5 = 0;

    /* "apache_beam/transforms/stats.py":494
 *       # Buffer is always initialized with sorted elements.
 *       self.min_val = elements[0]
 *       self.max_val = elements[-1]             # <<<<<<<<<<<<<<
 *     else:
 *       # Note that collapsed buffer may not contain min and max in the list of
 */
    __pyx_t_5 = __Pyx_GetItemInt(__pyx_v_elements, -1L, long, 1, __Pyx_PyInt_From_long, 0, 1, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 494, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_5);
    __Pyx_GOTREF(__pyx_v_self->max_val);
    __Pyx_DECREF(__pyx_v_self->max_val);
    __pyx_v_self->max_val = __pyx_t_5;
    __pyx_t_5 = 0;

    /* "apache_beam/transforms/stats.py":491
 *     self.weighted = weighted
 *     self.level = level
 *     if min_val is None or max_val is None:             # <<<<<<<<<<<<<<
 *       # Buffer is always initialized with sorted elements.
 *       self.min_val = elements[0]
 */
    goto __pyx_L3;
  }

  /* "apache_beam/transforms/stats.py":498
 *       # Note that collapsed buffer may not contain min and max in the list of
 *       # elements.
 *       self.min_val = min_val             # <<<<<<<<<<<<<<
 *       self.max_val = max_val
 * 
 */
  /*else*/ {
    __Pyx_INCREF(__pyx_v_min_val);
    __Pyx_GIVEREF(__pyx_v_min_val);
    __Pyx_GOTREF(__pyx_v_self->min_val);
    __Pyx_DECREF(__pyx_v_self->min_val);
    __pyx_v_self->min_val = __pyx_v_min_val;

    /* "apache_beam/transforms/stats.py":499
 *       # elements.
 *       self.min_val = min_val
 *       self.max_val = max_val             # <<<<<<<<<<<<<<
 * 
 *   def __iter__(self):
 */
    __Pyx_INCREF(__pyx_v_max_val);
    __Pyx_GIVEREF(__pyx_v_max_val);
    __Pyx_GOTREF(__pyx_v_self->max_val);
    __Pyx_DECREF(__pyx_v_self->max_val);
    __pyx_v_self->max_val = __pyx_v_max_val;
  }
  __pyx_L3:;

  /* "apache_beam/transforms/stats.py":481
 *   (see http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.6.6513&rep=rep1
 *   &type=pdf and ApproximateQuantilesCombineFn for further information)"""
 *   def __init__(             # <<<<<<<<<<<<<<
 *       self, elements, weights, weighted, level=0, min_val=None, max_val=None):
 *     # type: (List, List, bool, int, Any, Any) -> None
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("apache_beam.transforms.stats._QuantileBuffer.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "apache_beam/transforms/stats.py":501
 *       self.max_val = max_val
 * 
 *   def __iter__(self):             # <<<<<<<<<<<<<<
 *     return zip(
 *         self.elements,
 */

/* Python wrapper */
static PyObject *__pyx_pw_11apache_beam_10transforms_5stats_15_QuantileBuffer_3__iter__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_11apache_beam_10transforms_5stats_15_QuantileBuffer_3__iter__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__iter__ (wrapper)", 0);
  __pyx_r = __pyx_pf_11apache_beam_10transforms_5stats_15_QuantileBuffer_2__iter__(((struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileBuffer *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_11apache_beam_10transforms_5stats_15_QuantileBuffer_2__iter__(struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileBuffer *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__iter__", 0);

  /* "apache_beam/transforms/stats.py":502
 * 
 *   def __iter__(self):
 *     return zip(             # <<<<<<<<<<<<<<
 *         self.elements,
 *         self.weights if self.weighted else itertools.repeat(self.weights[0]))
 */
  __Pyx_XDECREF(__pyx_r);

  /* "apache_beam/transforms/stats.py":504
 *     return zip(
 *         self.elements,
 *         self.weights if self.weighted else itertools.repeat(self.weights[0]))             # <<<<<<<<<<<<<<
 * 
 *   def __lt__(self, other):
 */
  if ((__pyx_v_self->weighted != 0)) {
    __Pyx_INCREF(__pyx_v_self->weights);
    __pyx_t_1 = __pyx_v_self->weights;
  } else {
    __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_itertools); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 504, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_repeat); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 504, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_self->weights, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 504, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_5 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
      }
    }
    __pyx_t_2 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_5, __pyx_t_3) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3);
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 504, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_1 = __pyx_t_2;
    __pyx_t_2 = 0;
  }

  /* "apache_beam/transforms/stats.py":502
 * 
 *   def __iter__(self):
 *     return zip(             # <<<<<<<<<<<<<<
 *         self.elements,
 *         self.weights if self.weighted else itertools.repeat(self.weights[0]))
 */
  __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 502, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_v_self->elements);
  __Pyx_GIVEREF(__pyx_v_self->elements);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_self->elements);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_1);
  __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_zip, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 502, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "apache_beam/transforms/stats.py":501
 *       self.max_val = max_val
 * 
 *   def __iter__(self):             # <<<<<<<<<<<<<<
 *     return zip(
 *         self.elements,
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("apache_beam.transforms.stats._QuantileBuffer.__iter__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "apache_beam/transforms/stats.py":506
 *         self.weights if self.weighted else itertools.repeat(self.weights[0]))
 * 
 *   def __lt__(self, other):             # <<<<<<<<<<<<<<
 *     return self.level < other.level
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_11apache_beam_10transforms_5stats_15_QuantileBuffer_5__lt__(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static PyObject *__pyx_pw_11apache_beam_10transforms_5stats_15_QuantileBuffer_5__lt__(PyObject *__pyx_v_self, PyObject *__pyx_v_other) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__lt__ (wrapper)", 0);
  __pyx_r = __pyx_pf_11apache_beam_10transforms_5stats_15_QuantileBuffer_4__lt__(((struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileBuffer *)__pyx_v_self), ((PyObject *)__pyx_v_other));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_11apache_beam_10transforms_5stats_15_QuantileBuffer_4__lt__(struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileBuffer *__pyx_v_self, PyObject *__pyx_v_other) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__lt__", 0);

  /* "apache_beam/transforms/stats.py":507
 * 
 *   def __lt__(self, other):
 *     return self.level < other.level             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyInt_From_int64_t(__pyx_v_self->level); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 507, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_other, __pyx_n_s_level); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 507, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyObject_RichCompare(__pyx_t_1, __pyx_t_2, Py_LT); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 507, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  /* "apache_beam/transforms/stats.py":506
 *         self.weights if self.weighted else itertools.repeat(self.weights[0]))
 * 
 *   def __lt__(self, other):             # <<<<<<<<<<<<<<
 *     return self.level < other.level
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("apache_beam.transforms.stats._QuantileBuffer.__lt__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "apache_beam/transforms/stats.pxd":31
 * 
 * cdef class _QuantileBuffer(object):
 *   cdef readonly elements             # <<<<<<<<<<<<<<
 *   cdef readonly weights
 *   cdef readonly bint weighted
 */

/* Python wrapper */
static PyObject *__pyx_pw_11apache_beam_10transforms_5stats_15_QuantileBuffer_8elements_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_11apache_beam_10transforms_5stats_15_QuantileBuffer_8elements_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_11apache_beam_10transforms_5stats_15_QuantileBuffer_8elements___get__(((struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileBuffer *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_11apache_beam_10transforms_5stats_15_QuantileBuffer_8elements___get__(struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileBuffer *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_self->elements);
  __pyx_r = __pyx_v_self->elements;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "apache_beam/transforms/stats.pxd":32
 * cdef class _QuantileBuffer(object):
 *   cdef readonly elements
 *   cdef readonly weights             # <<<<<<<<<<<<<<
 *   cdef readonly bint weighted
 *   cdef readonly int64_t level
 */

/* Python wrapper */
static PyObject *__pyx_pw_11apache_beam_10transforms_5stats_15_QuantileBuffer_7weights_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_11apache_beam_10transforms_5stats_15_QuantileBuffer_7weights_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_11apache_beam_10transforms_5stats_15_QuantileBuffer_7weights___get__(((struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileBuffer *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_11apache_beam_10transforms_5stats_15_QuantileBuffer_7weights___get__(struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileBuffer *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_self->weights);
  __pyx_r = __pyx_v_self->weights;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "apache_beam/transforms/stats.pxd":33
 *   cdef readonly elements
 *   cdef readonly weights
 *   cdef readonly bint weighted             # <<<<<<<<<<<<<<
 *   cdef readonly int64_t level
 *   cdef readonly min_val
 */

/* Python wrapper */
static PyObject *__pyx_pw_11apache_beam_10transforms_5stats_15_QuantileBuffer_8weighted_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_11apache_beam_10transforms_5stats_15_QuantileBuffer_8weighted_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_11apache_beam_10transforms_5stats_15_QuantileBuffer_8weighted___get__(((struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileBuffer *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_11apache_beam_10transforms_5stats_15_QuantileBuffer_8weighted___get__(struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileBuffer *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyBool_FromLong(__pyx_v_self->weighted); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 33, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("apache_beam.transforms.stats._QuantileBuffer.weighted.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "apache_beam/transforms/stats.pxd":34
 *   cdef readonly weights
 *   cdef readonly bint weighted
 *   cdef readonly int64_t level             # <<<<<<<<<<<<<<
 *   cdef readonly min_val
 *   cdef readonly max_val
 */

/* Python wrapper */
static PyObject *__pyx_pw_11apache_beam_10transforms_5stats_15_QuantileBuffer_5level_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_11apache_beam_10transforms_5stats_15_QuantileBuffer_5level_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_11apache_beam_10transforms_5stats_15_QuantileBuffer_5level___get__(((struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileBuffer *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_11apache_beam_10transforms_5stats_15_QuantileBuffer_5level___get__(struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileBuffer *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyInt_From_int64_t(__pyx_v_self->level); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 34, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("apache_beam.transforms.stats._QuantileBuffer.level.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "apache_beam/transforms/stats.pxd":35
 *   cdef readonly bint weighted
 *   cdef readonly int64_t level
 *   cdef readonly min_val             # <<<<<<<<<<<<<<
 *   cdef readonly max_val
 *   cdef readonly _iter
 */

/* Python wrapper */
static PyObject *__pyx_pw_11apache_beam_10transforms_5stats_15_QuantileBuffer_7min_val_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_11apache_beam_10transforms_5stats_15_QuantileBuffer_7min_val_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_11apache_beam_10transforms_5stats_15_QuantileBuffer_7min_val___get__(((struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileBuffer *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_11apache_beam_10transforms_5stats_15_QuantileBuffer_7min_val___get__(struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileBuffer *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_self->min_val);
  __pyx_r = __pyx_v_self->min_val;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "apache_beam/transforms/stats.pxd":36
 *   cdef readonly int64_t level
 *   cdef readonly min_val
 *   cdef readonly max_val             # <<<<<<<<<<<<<<
 *   cdef readonly _iter
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_11apache_beam_10transforms_5stats_15_QuantileBuffer_7max_val_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_11apache_beam_10transforms_5stats_15_QuantileBuffer_7max_val_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_11apache_beam_10transforms_5stats_15_QuantileBuffer_7max_val___get__(((struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileBuffer *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_11apache_beam_10transforms_5stats_15_QuantileBuffer_7max_val___get__(struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileBuffer *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_self->max_val);
  __pyx_r = __pyx_v_self->max_val;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "apache_beam/transforms/stats.pxd":37
 *   cdef readonly min_val
 *   cdef readonly max_val
 *   cdef readonly _iter             # <<<<<<<<<<<<<<
 * 
 * cdef class _QuantileState(object):
 */

/* Python wrapper */
static PyObject *__pyx_pw_11apache_beam_10transforms_5stats_15_QuantileBuffer_5_iter_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_11apache_beam_10transforms_5stats_15_QuantileBuffer_5_iter_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_11apache_beam_10transforms_5stats_15_QuantileBuffer_5_iter___get__(((struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileBuffer *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_11apache_beam_10transforms_5stats_15_QuantileBuffer_5_iter___get__(struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileBuffer *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_self->_iter);
  __pyx_r = __pyx_v_self->_iter;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     cdef tuple state
 *     cdef object _dict
 */

/* Python wrapper */
static PyObject *__pyx_pw_11apache_beam_10transforms_5stats_15_QuantileBuffer_7__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyMethodDef __pyx_mdef_11apache_beam_10transforms_5stats_15_QuantileBuffer_7__reduce_cython__ = {"__reduce_cython__", (PyCFunction)__pyx_pw_11apache_beam_10transforms_5stats_15_QuantileBuffer_7__reduce_cython__, METH_NOARGS, 0};
static PyObject *__pyx_pw_11apache_beam_10transforms_5stats_15_QuantileBuffer_7__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_11apache_beam_10transforms_5stats_15_QuantileBuffer_6__reduce_cython__(((struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileBuffer *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_11apache_beam_10transforms_5stats_15_QuantileBuffer_6__reduce_cython__(struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileBuffer *__pyx_v_self) {
  PyObject *__pyx_v_state = 0;
  PyObject *__pyx_v__dict = 0;
  int __pyx_v_use_setstate;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  int __pyx_t_5;
  int __pyx_t_6;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__reduce_cython__", 0);

  /* "(tree fragment)":5
 *     cdef object _dict
 *     cdef bint use_setstate
 *     state = (self._iter, self.elements, self.level, self.max_val, self.min_val, self.weighted, self.weights)             # <<<<<<<<<<<<<<
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:
 */
  __pyx_t_1 = __Pyx_PyInt_From_int64_t(__pyx_v_self->level); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyBool_FromLong(__pyx_v_self->weighted); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyTuple_New(7); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(__pyx_v_self->_iter);
  __Pyx_GIVEREF(__pyx_v_self->_iter);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_self->_iter);
  __Pyx_INCREF(__pyx_v_self->elements);
  __Pyx_GIVEREF(__pyx_v_self->elements);
  PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_self->elements);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_t_1);
  __Pyx_INCREF(__pyx_v_self->max_val);
  __Pyx_GIVEREF(__pyx_v_self->max_val);
  PyTuple_SET_ITEM(__pyx_t_3, 3, __pyx_v_self->max_val);
  __Pyx_INCREF(__pyx_v_self->min_val);
  __Pyx_GIVEREF(__pyx_v_self->min_val);
  PyTuple_SET_ITEM(__pyx_t_3, 4, __pyx_v_self->min_val);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_3, 5, __pyx_t_2);
  __Pyx_INCREF(__pyx_v_self->weights);
  __Pyx_GIVEREF(__pyx_v_self->weights);
  PyTuple_SET_ITEM(__pyx_t_3, 6, __pyx_v_self->weights);
  __pyx_t_1 = 0;
  __pyx_t_2 = 0;
  __pyx_v_state = ((PyObject*)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "(tree fragment)":6
 *     cdef bint use_setstate
 *     state = (self._iter, self.elements, self.level, self.max_val, self.min_val, self.weighted, self.weights)
 *     _dict = getattr(self, '__dict__', None)             # <<<<<<<<<<<<<<
 *     if _dict is not None:
 *         state += (_dict,)
 */
  __pyx_t_3 = __Pyx_GetAttr3(((PyObject *)__pyx_v_self), __pyx_n_s_dict, Py_None); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 6, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_v__dict = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "(tree fragment)":7
 *     state = (self._iter, self.elements, self.level, self.max_val, self.min_val, self.weighted, self.weights)
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:             # <<<<<<<<<<<<<<
 *         state += (_dict,)
 *         use_setstate = True
 */
  __pyx_t_4 = (__pyx_v__dict != Py_None);
  __pyx_t_5 = (__pyx_t_4 != 0);
  if (__pyx_t_5) {

    /* "(tree fragment)":8
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:
 *         state += (_dict,)             # <<<<<<<<<<<<<<
 *         use_setstate = True
 *     else:
 */
    __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 8, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_v__dict);
    __Pyx_GIVEREF(__pyx_v__dict);
    PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v__dict);
    __pyx_t_2 = PyNumber_InPlaceAdd(__pyx_v_state, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 8, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF_SET(__pyx_v_state, ((PyObject*)__pyx_t_2));
    __pyx_t_2 = 0;

    /* "(tree fragment)":9
 *     if _dict is not None:
 *         state += (_dict,)
 *         use_setstate = True             # <<<<<<<<<<<<<<
 *     else:
 *         use_setstate = self._iter is not None or self.elements is not None or self.max_val is not None or self.min_val is not None or self.weights is not None
 */
    __pyx_v_use_setstate = 1;

    /* "(tree fragment)":7
 *     state = (self._iter, self.elements, self.level, self.max_val, self.min_val, self.weighted, self.weights)
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:             # <<<<<<<<<<<<<<
 *         state += (_dict,)
 *         use_setstate = True
 */
    goto __pyx_L3;
  }

  /* "(tree fragment)":11
 *         use_setstate = True
 *     else:
 *         use_setstate = self._iter is not None or self.elements is not None or self.max_val is not None or self.min_val is not None or self.weights is not None             # <<<<<<<<<<<<<<
 *     if use_setstate:
 *         return __pyx_unpickle__QuantileBuffer, (type(self), 0x9fb38c7, None), state
 */
  /*else*/ {
    __pyx_t_4 = (__pyx_v_self->_iter != Py_None);
    __pyx_t_6 = (__pyx_t_4 != 0);
    if (!__pyx_t_6) {
    } else {
      __pyx_t_5 = __pyx_t_6;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_6 = (__pyx_v_self->elements != Py_None);
    __pyx_t_4 = (__pyx_t_6 != 0);
    if (!__pyx_t_4) {
    } else {
      __pyx_t_5 = __pyx_t_4;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_4 = (__pyx_v_self->max_val != Py_None);
    __pyx_t_6 = (__pyx_t_4 != 0);
    if (!__pyx_t_6) {
    } else {
      __pyx_t_5 = __pyx_t_6;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_6 = (__pyx_v_self->min_val != Py_None);
    __pyx_t_4 = (__pyx_t_6 != 0);
    if (!__pyx_t_4) {
    } else {
      __pyx_t_5 = __pyx_t_4;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_4 = (__pyx_v_self->weights != Py_None);
    __pyx_t_6 = (__pyx_t_4 != 0);
    __pyx_t_5 = __pyx_t_6;
    __pyx_L4_bool_binop_done:;
    __pyx_v_use_setstate = __pyx_t_5;
  }
  __pyx_L3:;

  /* "(tree fragment)":12
 *     else:
 *         use_setstate = self._iter is not None or self.elements is not None or self.max_val is not None or self.min_val is not None or self.weights is not None
 *     if use_setstate:             # <<<<<<<<<<<<<<
 *         return __pyx_unpickle__QuantileBuffer, (type(self), 0x9fb38c7, None), state
 *     else:
 */
  __pyx_t_5 = (__pyx_v_use_setstate != 0);
  if (__pyx_t_5) {

    /* "(tree fragment)":13
 *         use_setstate = self._iter is not None or self.elements is not None or self.max_val is not None or self.min_val is not None or self.weights is not None
 *     if use_setstate:
 *         return __pyx_unpickle__QuantileBuffer, (type(self), 0x9fb38c7, None), state             # <<<<<<<<<<<<<<
 *     else:
 *         return __pyx_unpickle__QuantileBuffer, (type(self), 0x9fb38c7, state)
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_pyx_unpickle__QuantileBuffer); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_INCREF(__pyx_int_167459015);
    __Pyx_GIVEREF(__pyx_int_167459015);
    PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_int_167459015);
    __Pyx_INCREF(Py_None);
    __Pyx_GIVEREF(Py_None);
    PyTuple_SET_ITEM(__pyx_t_3, 2, Py_None);
    __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_3);
    __Pyx_INCREF(__pyx_v_state);
    __Pyx_GIVEREF(__pyx_v_state);
    PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_v_state);
    __pyx_t_2 = 0;
    __pyx_t_3 = 0;
    __pyx_r = __pyx_t_1;
    __pyx_t_1 = 0;
    goto __pyx_L0;

    /* "(tree fragment)":12
 *     else:
 *         use_setstate = self._iter is not None or self.elements is not None or self.max_val is not None or self.min_val is not None or self.weights is not None
 *     if use_setstate:             # <<<<<<<<<<<<<<
 *         return __pyx_unpickle__QuantileBuffer, (type(self), 0x9fb38c7, None), state
 *     else:
 */
  }

  /* "(tree fragment)":15
 *         return __pyx_unpickle__QuantileBuffer, (type(self), 0x9fb38c7, None), state
 *     else:
 *         return __pyx_unpickle__QuantileBuffer, (type(self), 0x9fb38c7, state)             # <<<<<<<<<<<<<<
 * def __setstate_cython__(self, __pyx_state):
 *     __pyx_unpickle__QuantileBuffer__set_state(self, __pyx_state)
 */
  /*else*/ {
    __Pyx_XDECREF(__pyx_r);
    __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_pyx_unpickle__QuantileBuffer); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 15, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 15, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_INCREF(__pyx_int_167459015);
    __Pyx_GIVEREF(__pyx_int_167459015);
    PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_int_167459015);
    __Pyx_INCREF(__pyx_v_state);
    __Pyx_GIVEREF(__pyx_v_state);
    PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_v_state);
    __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 15, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_3);
    __pyx_t_1 = 0;
    __pyx_t_3 = 0;
    __pyx_r = __pyx_t_2;
    __pyx_t_2 = 0;
    goto __pyx_L0;
  }

  /* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     cdef tuple state
 *     cdef object _dict
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("apache_beam.transforms.stats._QuantileBuffer.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_state);
  __Pyx_XDECREF(__pyx_v__dict);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":16
 *     else:
 *         return __pyx_unpickle__QuantileBuffer, (type(self), 0x9fb38c7, state)
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_unpickle__QuantileBuffer__set_state(self, __pyx_state)
 */

/* Python wrapper */
static PyObject *__pyx_pw_11apache_beam_10transforms_5stats_15_QuantileBuffer_9__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/
static PyMethodDef __pyx_mdef_11apache_beam_10transforms_5stats_15_QuantileBuffer_9__setstate_cython__ = {"__setstate_cython__", (PyCFunction)__pyx_pw_11apache_beam_10transforms_5stats_15_QuantileBuffer_9__setstate_cython__, METH_O, 0};
static PyObject *__pyx_pw_11apache_beam_10transforms_5stats_15_QuantileBuffer_9__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_11apache_beam_10transforms_5stats_15_QuantileBuffer_8__setstate_cython__(((struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileBuffer *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_11apache_beam_10transforms_5stats_15_QuantileBuffer_8__setstate_cython__(struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileBuffer *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__setstate_cython__", 0);

  /* "(tree fragment)":17
 *         return __pyx_unpickle__QuantileBuffer, (type(self), 0x9fb38c7, state)
 * def __setstate_cython__(self, __pyx_state):
 *     __pyx_unpickle__QuantileBuffer__set_state(self, __pyx_state)             # <<<<<<<<<<<<<<
 */
  if (!(likely(PyTuple_CheckExact(__pyx_v___pyx_state))||((__pyx_v___pyx_state) == Py_None)||((void)PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v___pyx_state)->tp_name), 0))) __PYX_ERR(2, 17, __pyx_L1_error)
  __pyx_t_1 = __pyx_f_11apache_beam_10transforms_5stats___pyx_unpickle__QuantileBuffer__set_state(__pyx_v_self, ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 17, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "(tree fragment)":16
 *     else:
 *         return __pyx_unpickle__QuantileBuffer, (type(self), 0x9fb38c7, state)
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_unpickle__QuantileBuffer__set_state(self, __pyx_state)
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("apache_beam.transforms.stats._QuantileBuffer.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "apache_beam/transforms/stats.py":514
 *   Compact summarization of a collection on which quantiles can be estimated.
 *   """
 *   def __init__(self, unbuffered_elements, unbuffered_weights, buffers, spec):             # <<<<<<<<<<<<<<
 *     # type: (List, List, List[_QuantileBuffer], _QuantileSpec) -> None
 *     self.buffers = buffers
 */

/* Python wrapper */
static int __pyx_pw_11apache_beam_10transforms_5stats_14_QuantileState_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_11apache_beam_10transforms_5stats_14_QuantileState_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_unbuffered_elements = 0;
  PyObject *__pyx_v_unbuffered_weights = 0;
  PyObject *__pyx_v_buffers = 0;
  PyObject *__pyx_v_spec = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_unbuffered_elements,&__pyx_n_s_unbuffered_weights,&__pyx_n_s_buffers,&__pyx_n_s_spec,0};
    PyObject* values[4] = {0,0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_unbuffered_elements)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_unbuffered_weights)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 1, 4, 4, 1); __PYX_ERR(0, 514, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_buffers)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 1, 4, 4, 2); __PYX_ERR(0, 514, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_spec)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 1, 4, 4, 3); __PYX_ERR(0, 514, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(0, 514, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 4) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
      values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
    }
    __pyx_v_unbuffered_elements = values[0];
    __pyx_v_unbuffered_weights = values[1];
    __pyx_v_buffers = values[2];
    __pyx_v_spec = values[3];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 514, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("apache_beam.transforms.stats._QuantileState.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_11apache_beam_10transforms_5stats_14_QuantileState___init__(((struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileState *)__pyx_v_self), __pyx_v_unbuffered_elements, __pyx_v_unbuffered_weights, __pyx_v_buffers, __pyx_v_spec);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_11apache_beam_10transforms_5stats_14_QuantileState___init__(struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileState *__pyx_v_self, PyObject *__pyx_v_unbuffered_elements, PyObject *__pyx_v_unbuffered_weights, PyObject *__pyx_v_buffers, PyObject *__pyx_v_spec) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "apache_beam/transforms/stats.py":516
 *   def __init__(self, unbuffered_elements, unbuffered_weights, buffers, spec):
 *     # type: (List, List, List[_QuantileBuffer], _QuantileSpec) -> None
 *     self.buffers = buffers             # <<<<<<<<<<<<<<
 *     self.spec = spec
 *     if spec.weighted:
 */
  __Pyx_INCREF(__pyx_v_buffers);
  __Pyx_GIVEREF(__pyx_v_buffers);
  __Pyx_GOTREF(__pyx_v_self->buffers);
  __Pyx_DECREF(__pyx_v_self->buffers);
  __pyx_v_self->buffers = __pyx_v_buffers;

  /* "apache_beam/transforms/stats.py":517
 *     # type: (List, List, List[_QuantileBuffer], _QuantileSpec) -> None
 *     self.buffers = buffers
 *     self.spec = spec             # <<<<<<<<<<<<<<
 *     if spec.weighted:
 *       self.add_unbuffered = self._add_unbuffered_weighted
 */
  if (!(likely(((__pyx_v_spec) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_spec, __pyx_ptype_11apache_beam_10transforms_5stats__QuantileSpec))))) __PYX_ERR(0, 517, __pyx_L1_error)
  __pyx_t_1 = __pyx_v_spec;
  __Pyx_INCREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->spec);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->spec));
  __pyx_v_self->spec = ((struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileSpec *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "apache_beam/transforms/stats.py":518
 *     self.buffers = buffers
 *     self.spec = spec
 *     if spec.weighted:             # <<<<<<<<<<<<<<
 *       self.add_unbuffered = self._add_unbuffered_weighted
 *     else:
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_spec, __pyx_n_s_weighted); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 518, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 518, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_2) {

    /* "apache_beam/transforms/stats.py":519
 *     self.spec = spec
 *     if spec.weighted:
 *       self.add_unbuffered = self._add_unbuffered_weighted             # <<<<<<<<<<<<<<
 *     else:
 *       self.add_unbuffered = self._add_unbuffered
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_add_unbuffered_weighted); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 519, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_1);
    __Pyx_GOTREF(__pyx_v_self->add_unbuffered);
    __Pyx_DECREF(__pyx_v_self->add_unbuffered);
    __pyx_v_self->add_unbuffered = __pyx_t_1;
    __pyx_t_1 = 0;

    /* "apache_beam/transforms/stats.py":518
 *     self.buffers = buffers
 *     self.spec = spec
 *     if spec.weighted:             # <<<<<<<<<<<<<<
 *       self.add_unbuffered = self._add_unbuffered_weighted
 *     else:
 */
    goto __pyx_L3;
  }

  /* "apache_beam/transforms/stats.py":521
 *       self.add_unbuffered = self._add_unbuffered_weighted
 *     else:
 *       self.add_unbuffered = self._add_unbuffered             # <<<<<<<<<<<<<<
 * 
 *     # The algorithm requires that the manipulated buffers always be filled to
 */
  /*else*/ {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_add_unbuffered); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 521, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_1);
    __Pyx_GOTREF(__pyx_v_self->add_unbuffered);
    __Pyx_DECREF(__pyx_v_self->add_unbuffered);
    __pyx_v_self->add_unbuffered = __pyx_t_1;
    __pyx_t_1 = 0;
  }
  __pyx_L3:;

  /* "apache_beam/transforms/stats.py":529
 *     # into new, full buffers and then take them into account when computing the
 *     # final output.
 *     self.unbuffered_elements = unbuffered_elements             # <<<<<<<<<<<<<<
 *     self.unbuffered_weights = unbuffered_weights
 * 
 */
  __Pyx_INCREF(__pyx_v_unbuffered_elements);
  __Pyx_GIVEREF(__pyx_v_unbuffered_elements);
  __Pyx_GOTREF(__pyx_v_self->unbuffered_elements);
  __Pyx_DECREF(__pyx_v_self->unbuffered_elements);
  __pyx_v_self->unbuffered_elements = __pyx_v_unbuffered_elements;

  /* "apache_beam/transforms/stats.py":530
 *     # final output.
 *     self.unbuffered_elements = unbuffered_elements
 *     self.unbuffered_weights = unbuffered_weights             # <<<<<<<<<<<<<<
 * 
 *   # This is needed for pickling to work when Cythonization is enabled.
 */
  __Pyx_INCREF(__pyx_v_unbuffered_weights);
  __Pyx_GIVEREF(__pyx_v_unbuffered_weights);
  __Pyx_GOTREF(__pyx_v_self->unbuffered_weights);
  __Pyx_DECREF(__pyx_v_self->unbuffered_weights);
  __pyx_v_self->unbuffered_weights = __pyx_v_unbuffered_weights;

  /* "apache_beam/transforms/stats.py":514
 *   Compact summarization of a collection on which quantiles can be estimated.
 *   """
 *   def __init__(self, unbuffered_elements, unbuffered_weights, buffers, spec):             # <<<<<<<<<<<<<<
 *     # type: (List, List, List[_QuantileBuffer], _QuantileSpec) -> None
 *     self.buffers = buffers
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("apache_beam.transforms.stats._QuantileState.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "apache_beam/transforms/stats.py":533
 * 
 *   # This is needed for pickling to work when Cythonization is enabled.
 *   def __reduce__(self):             # <<<<<<<<<<<<<<
 *     return (
 *         self.__class__,
 */

/* Python wrapper */
static PyObject *__pyx_pw_11apache_beam_10transforms_5stats_14_QuantileState_3__reduce__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyMethodDef __pyx_mdef_11apache_beam_10transforms_5stats_14_QuantileState_3__reduce__ = {"__reduce__", (PyCFunction)__pyx_pw_11apache_beam_10transforms_5stats_14_QuantileState_3__reduce__, METH_NOARGS, 0};
static PyObject *__pyx_pw_11apache_beam_10transforms_5stats_14_QuantileState_3__reduce__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__reduce__ (wrapper)", 0);
  __pyx_r = __pyx_pf_11apache_beam_10transforms_5stats_14_QuantileState_2__reduce__(((struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileState *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_11apache_beam_10transforms_5stats_14_QuantileState_2__reduce__(struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileState *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__reduce__", 0);

  /* "apache_beam/transforms/stats.py":534
 *   # This is needed for pickling to work when Cythonization is enabled.
 *   def __reduce__(self):
 *     return (             # <<<<<<<<<<<<<<
 *         self.__class__,
 *         (
 */
  __Pyx_XDECREF(__pyx_r);

  /* "apache_beam/transforms/stats.py":535
 *   def __reduce__(self):
 *     return (
 *         self.__class__,             # <<<<<<<<<<<<<<
 *         (
 *             self.unbuffered_elements,
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_class); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 535, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);

  /* "apache_beam/transforms/stats.py":537
 *         self.__class__,
 *         (
 *             self.unbuffered_elements,             # <<<<<<<<<<<<<<
 *             self.unbuffered_weights,
 *             self.buffers,
 */
  __pyx_t_2 = PyTuple_New(4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 537, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_v_self->unbuffered_elements);
  __Pyx_GIVEREF(__pyx_v_self->unbuffered_elements);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_self->unbuffered_elements);
  __Pyx_INCREF(__pyx_v_self->unbuffered_weights);
  __Pyx_GIVEREF(__pyx_v_self->unbuffered_weights);
  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_self->unbuffered_weights);
  __Pyx_INCREF(__pyx_v_self->buffers);
  __Pyx_GIVEREF(__pyx_v_self->buffers);
  PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_v_self->buffers);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->spec));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->spec));
  PyTuple_SET_ITEM(__pyx_t_2, 3, ((PyObject *)__pyx_v_self->spec));

  /* "apache_beam/transforms/stats.py":535
 *   def __reduce__(self):
 *     return (
 *         self.__class__,             # <<<<<<<<<<<<<<
 *         (
 *             self.unbuffered_elements,
 */
  __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 535, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_2);
  __pyx_t_1 = 0;
  __pyx_t_2 = 0;
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  /* "apache_beam/transforms/stats.py":533
 * 
 *   # This is needed for pickling to work when Cythonization is enabled.
 *   def __reduce__(self):             # <<<<<<<<<<<<<<
 *     return (
 *         self.__class__,
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("apache_beam.transforms.stats._QuantileState.__reduce__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "apache_beam/transforms/stats.py":542
 *             self.spec))
 * 
 *   def is_empty(self):             # <<<<<<<<<<<<<<
 *     # type: () -> bool
 * 
 */

static PyObject *__pyx_pw_11apache_beam_10transforms_5stats_14_QuantileState_5is_empty(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static int __pyx_f_11apache_beam_10transforms_5stats_14_QuantileState_is_empty(struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileState *__pyx_v_self, int __pyx_skip_dispatch) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  int __pyx_t_6;
  int __pyx_t_7;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("is_empty", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely((Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) {
    #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    static PY_UINT64_T __pyx_tp_dict_version = __PYX_DICT_VERSION_INIT, __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
    if (unlikely(!__Pyx_object_dict_version_matches(((PyObject *)__pyx_v_self), __pyx_tp_dict_version, __pyx_obj_dict_version))) {
      PY_UINT64_T __pyx_type_dict_guard = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      #endif
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_is_empty); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 542, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_11apache_beam_10transforms_5stats_14_QuantileState_5is_empty)) {
        __Pyx_INCREF(__pyx_t_1);
        __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
        if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
          __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
          if (likely(__pyx_t_4)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
            __Pyx_INCREF(__pyx_t_4);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_3, function);
          }
        }
        __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4) : __Pyx_PyObject_CallNoArg(__pyx_t_3);
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 542, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 542, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __pyx_r = __pyx_t_5;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        goto __pyx_L0;
      }
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
      __pyx_tp_dict_version = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      __pyx_obj_dict_version = __Pyx_get_object_dict_version(((PyObject *)__pyx_v_self));
      if (unlikely(__pyx_type_dict_guard != __pyx_tp_dict_version)) {
        __pyx_tp_dict_version = __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
      }
      #endif
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    }
    #endif
  }

  /* "apache_beam/transforms/stats.py":546
 * 
 *     """Check if the buffered & unbuffered elements are empty or not."""
 *     return not self.unbuffered_elements and not self.buffers             # <<<<<<<<<<<<<<
 * 
 *   def _add_unbuffered(self, elements, offset_fn):
 */
  __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_v_self->unbuffered_elements); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 546, __pyx_L1_error)
  __pyx_t_7 = ((!__pyx_t_6) != 0);
  if (__pyx_t_7) {
  } else {
    __pyx_t_5 = __pyx_t_7;
    goto __pyx_L3_bool_binop_done;
  }
  __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_v_self->buffers); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 546, __pyx_L1_error)
  __pyx_t_6 = ((!__pyx_t_7) != 0);
  __pyx_t_5 = __pyx_t_6;
  __pyx_L3_bool_binop_done:;
  __pyx_r = __pyx_t_5;
  goto __pyx_L0;

  /* "apache_beam/transforms/stats.py":542
 *             self.spec))
 * 
 *   def is_empty(self):             # <<<<<<<<<<<<<<
 *     # type: () -> bool
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_WriteUnraisable("apache_beam.transforms.stats._QuantileState.is_empty", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_11apache_beam_10transforms_5stats_14_QuantileState_5is_empty(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_11apache_beam_10transforms_5stats_14_QuantileState_4is_empty[] = "Check if the buffered & unbuffered elements are empty or not.";
static PyMethodDef __pyx_mdef_11apache_beam_10transforms_5stats_14_QuantileState_5is_empty = {"is_empty", (PyCFunction)__pyx_pw_11apache_beam_10transforms_5stats_14_QuantileState_5is_empty, METH_NOARGS, __pyx_doc_11apache_beam_10transforms_5stats_14_QuantileState_4is_empty};
static PyObject *__pyx_pw_11apache_beam_10transforms_5stats_14_QuantileState_5is_empty(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("is_empty (wrapper)", 0);
  __pyx_r = __pyx_pf_11apache_beam_10transforms_5stats_14_QuantileState_4is_empty(((struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileState *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_11apache_beam_10transforms_5stats_14_QuantileState_4is_empty(struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileState *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("is_empty", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyBool_FromLong(__pyx_f_11apache_beam_10transforms_5stats_14_QuantileState_is_empty(__pyx_v_self, 1)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 542, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("apache_beam.transforms.stats._QuantileState.is_empty", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "apache_beam/transforms/stats.py":548
 *     return not self.unbuffered_elements and not self.buffers
 * 
 *   def _add_unbuffered(self, elements, offset_fn):             # <<<<<<<<<<<<<<
 *     # type: (List, Any) -> None
 * 
 */

static PyObject *__pyx_pw_11apache_beam_10transforms_5stats_14_QuantileState_7_add_unbuffered(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_11apache_beam_10transforms_5stats_14_QuantileState__add_unbuffered(struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileState *__pyx_v_self, PyObject *__pyx_v_elements, PyObject *__pyx_v_offset_fn, int __pyx_skip_dispatch) {
  int64_t __pyx_v_num_new_buffers;
  int64_t __pyx_v_idx;
  PyObject *__pyx_v_to_buffer = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  Py_ssize_t __pyx_t_7;
  int64_t __pyx_t_8;
  int64_t __pyx_t_9;
  int64_t __pyx_t_10;
  int __pyx_t_11;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_add_unbuffered", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely((Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) {
    #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    static PY_UINT64_T __pyx_tp_dict_version = __PYX_DICT_VERSION_INIT, __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
    if (unlikely(!__Pyx_object_dict_version_matches(((PyObject *)__pyx_v_self), __pyx_tp_dict_version, __pyx_obj_dict_version))) {
      PY_UINT64_T __pyx_type_dict_guard = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      #endif
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_add_unbuffered); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 548, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_11apache_beam_10transforms_5stats_14_QuantileState_7_add_unbuffered)) {
        __Pyx_XDECREF(__pyx_r);
        __Pyx_INCREF(__pyx_t_1);
        __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
        __pyx_t_5 = 0;
        if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
          __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
          if (likely(__pyx_t_4)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
            __Pyx_INCREF(__pyx_t_4);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_3, function);
            __pyx_t_5 = 1;
          }
        }
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_3)) {
          PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_v_elements, __pyx_v_offset_fn};
          __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 548, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_GOTREF(__pyx_t_2);
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
          PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_v_elements, __pyx_v_offset_fn};
          __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 548, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_GOTREF(__pyx_t_2);
        } else
        #endif
        {
          __pyx_t_6 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 548, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_6);
          if (__pyx_t_4) {
            __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __pyx_t_4 = NULL;
          }
          __Pyx_INCREF(__pyx_v_elements);
          __Pyx_GIVEREF(__pyx_v_elements);
          PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_5, __pyx_v_elements);
          __Pyx_INCREF(__pyx_v_offset_fn);
          __Pyx_GIVEREF(__pyx_v_offset_fn);
          PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_5, __pyx_v_offset_fn);
          __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 548, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        }
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __pyx_r = __pyx_t_2;
        __pyx_t_2 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        goto __pyx_L0;
      }
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
      __pyx_tp_dict_version = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      __pyx_obj_dict_version = __Pyx_get_object_dict_version(((PyObject *)__pyx_v_self));
      if (unlikely(__pyx_type_dict_guard != __pyx_tp_dict_version)) {
        __pyx_tp_dict_version = __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
      }
      #endif
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    }
    #endif
  }

  /* "apache_beam/transforms/stats.py":555
 *     collapsing if needed.
 *     """
 *     self.unbuffered_elements.extend(elements)             # <<<<<<<<<<<<<<
 *     num_new_buffers = len(self.unbuffered_elements) // self.spec.buffer_size
 *     for idx in range(num_new_buffers):
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->unbuffered_elements, __pyx_n_s_extend); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 555, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_3, __pyx_v_elements) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_elements);
  __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 555, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "apache_beam/transforms/stats.py":556
 *     """
 *     self.unbuffered_elements.extend(elements)
 *     num_new_buffers = len(self.unbuffered_elements) // self.spec.buffer_size             # <<<<<<<<<<<<<<
 *     for idx in range(num_new_buffers):
 *       to_buffer = sorted(
 */
  __pyx_t_1 = __pyx_v_self->unbuffered_elements;
  __Pyx_INCREF(__pyx_t_1);
  __pyx_t_7 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_7 == ((Py_ssize_t)-1))) __PYX_ERR(0, 556, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (unlikely(__pyx_v_self->spec->buffer_size == 0)) {
    PyErr_SetString(PyExc_ZeroDivisionError, "integer division or modulo by zero");
    __PYX_ERR(0, 556, __pyx_L1_error)
  }
  else if (sizeof(Py_ssize_t) == sizeof(long) && (!(((int64_t)-1) > 0)) && unlikely(__pyx_v_self->spec->buffer_size == (int64_t)-1)  && unlikely(UNARY_NEG_WOULD_OVERFLOW(__pyx_t_7))) {
    PyErr_SetString(PyExc_OverflowError, "value too large to perform division");
    __PYX_ERR(0, 556, __pyx_L1_error)
  }
  __pyx_v_num_new_buffers = __Pyx_div_Py_ssize_t(__pyx_t_7, __pyx_v_self->spec->buffer_size);

  /* "apache_beam/transforms/stats.py":557
 *     self.unbuffered_elements.extend(elements)
 *     num_new_buffers = len(self.unbuffered_elements) // self.spec.buffer_size
 *     for idx in range(num_new_buffers):             # <<<<<<<<<<<<<<
 *       to_buffer = sorted(
 *           self.unbuffered_elements[idx * self.spec.buffer_size:(idx + 1) *
 */
  __pyx_t_8 = __pyx_v_num_new_buffers;
  __pyx_t_9 = __pyx_t_8;
  for (__pyx_t_10 = 0; __pyx_t_10 < __pyx_t_9; __pyx_t_10+=1) {
    __pyx_v_idx = __pyx_t_10;

    /* "apache_beam/transforms/stats.py":559
 *     for idx in range(num_new_buffers):
 *       to_buffer = sorted(
 *           self.unbuffered_elements[idx * self.spec.buffer_size:(idx + 1) *             # <<<<<<<<<<<<<<
 *                                    self.spec.buffer_size],
 *           key=self.spec.key,
 */
    __pyx_t_1 = __Pyx_PyObject_GetSlice(__pyx_v_self->unbuffered_elements, (__pyx_v_idx * __pyx_v_self->spec->buffer_size), ((__pyx_v_idx + 1) * __pyx_v_self->spec->buffer_size), NULL, NULL, NULL, 1, 1, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 559, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);

    /* "apache_beam/transforms/stats.py":558
 *     num_new_buffers = len(self.unbuffered_elements) // self.spec.buffer_size
 *     for idx in range(num_new_buffers):
 *       to_buffer = sorted(             # <<<<<<<<<<<<<<
 *           self.unbuffered_elements[idx * self.spec.buffer_size:(idx + 1) *
 *                                    self.spec.buffer_size],
 */
    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 558, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
    __pyx_t_1 = 0;

    /* "apache_beam/transforms/stats.py":561
 *           self.unbuffered_elements[idx * self.spec.buffer_size:(idx + 1) *
 *                                    self.spec.buffer_size],
 *           key=self.spec.key,             # <<<<<<<<<<<<<<
 *           reverse=self.spec.reverse)
 *       heapq.heappush(
 */
    __pyx_t_1 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 561, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_key, __pyx_v_self->spec->key) < 0) __PYX_ERR(0, 561, __pyx_L1_error)

    /* "apache_beam/transforms/stats.py":562
 *                                    self.spec.buffer_size],
 *           key=self.spec.key,
 *           reverse=self.spec.reverse)             # <<<<<<<<<<<<<<
 *       heapq.heappush(
 *           self.buffers,
 */
    __pyx_t_3 = __Pyx_PyBool_FromLong(__pyx_v_self->spec->reverse); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 562, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_reverse, __pyx_t_3) < 0) __PYX_ERR(0, 561, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "apache_beam/transforms/stats.py":558
 *     num_new_buffers = len(self.unbuffered_elements) // self.spec.buffer_size
 *     for idx in range(num_new_buffers):
 *       to_buffer = sorted(             # <<<<<<<<<<<<<<
 *           self.unbuffered_elements[idx * self.spec.buffer_size:(idx + 1) *
 *                                    self.spec.buffer_size],
 */
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_sorted, __pyx_t_2, __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 558, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_XDECREF_SET(__pyx_v_to_buffer, __pyx_t_3);
    __pyx_t_3 = 0;

    /* "apache_beam/transforms/stats.py":563
 *           key=self.spec.key,
 *           reverse=self.spec.reverse)
 *       heapq.heappush(             # <<<<<<<<<<<<<<
 *           self.buffers,
 *           _QuantileBuffer(elements=to_buffer, weights=[1], weighted=False))
 */
    __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_heapq); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 563, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_heappush); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 563, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "apache_beam/transforms/stats.py":565
 *       heapq.heappush(
 *           self.buffers,
 *           _QuantileBuffer(elements=to_buffer, weights=[1], weighted=False))             # <<<<<<<<<<<<<<
 * 
 *     if num_new_buffers > 0:
 */
    __pyx_t_1 = __Pyx_PyDict_NewPresized(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 565, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_elements, __pyx_v_to_buffer) < 0) __PYX_ERR(0, 565, __pyx_L1_error)
    __pyx_t_6 = PyList_New(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 565, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_INCREF(__pyx_int_1);
    __Pyx_GIVEREF(__pyx_int_1);
    PyList_SET_ITEM(__pyx_t_6, 0, __pyx_int_1);
    if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_weights, __pyx_t_6) < 0) __PYX_ERR(0, 565, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_weighted, Py_False) < 0) __PYX_ERR(0, 565, __pyx_L1_error)
    __pyx_t_6 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_11apache_beam_10transforms_5stats__QuantileBuffer), __pyx_empty_tuple, __pyx_t_1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 565, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = NULL;
    __pyx_t_5 = 0;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
      __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_2);
      if (likely(__pyx_t_1)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
        __Pyx_INCREF(__pyx_t_1);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_2, function);
        __pyx_t_5 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_2)) {
      PyObject *__pyx_temp[3] = {__pyx_t_1, __pyx_v_self->buffers, __pyx_t_6};
      __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 563, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
      PyObject *__pyx_temp[3] = {__pyx_t_1, __pyx_v_self->buffers, __pyx_t_6};
      __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 563, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    } else
    #endif
    {
      __pyx_t_4 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 563, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      if (__pyx_t_1) {
        __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_1); __pyx_t_1 = NULL;
      }
      __Pyx_INCREF(__pyx_v_self->buffers);
      __Pyx_GIVEREF(__pyx_v_self->buffers);
      PyTuple_SET_ITEM(__pyx_t_4, 0+__pyx_t_5, __pyx_v_self->buffers);
      __Pyx_GIVEREF(__pyx_t_6);
      PyTuple_SET_ITEM(__pyx_t_4, 1+__pyx_t_5, __pyx_t_6);
      __pyx_t_6 = 0;
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 563, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    }
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  }

  /* "apache_beam/transforms/stats.py":567
 *           _QuantileBuffer(elements=to_buffer, weights=[1], weighted=False))
 * 
 *     if num_new_buffers > 0:             # <<<<<<<<<<<<<<
 *       self.unbuffered_elements = self.unbuffered_elements[num_new_buffers *
 *                                                           self.spec.
 */
  __pyx_t_11 = ((__pyx_v_num_new_buffers > 0) != 0);
  if (__pyx_t_11) {

    /* "apache_beam/transforms/stats.py":568
 * 
 *     if num_new_buffers > 0:
 *       self.unbuffered_elements = self.unbuffered_elements[num_new_buffers *             # <<<<<<<<<<<<<<
 *                                                           self.spec.
 *                                                           buffer_size:]
 */
    __pyx_t_3 = __Pyx_PyObject_GetSlice(__pyx_v_self->unbuffered_elements, (__pyx_v_num_new_buffers * __pyx_v_self->spec->buffer_size), 0, NULL, NULL, NULL, 1, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 568, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_3);
    __Pyx_GOTREF(__pyx_v_self->unbuffered_elements);
    __Pyx_DECREF(__pyx_v_self->unbuffered_elements);
    __pyx_v_self->unbuffered_elements = __pyx_t_3;
    __pyx_t_3 = 0;

    /* "apache_beam/transforms/stats.py":567
 *           _QuantileBuffer(elements=to_buffer, weights=[1], weighted=False))
 * 
 *     if num_new_buffers > 0:             # <<<<<<<<<<<<<<
 *       self.unbuffered_elements = self.unbuffered_elements[num_new_buffers *
 *                                                           self.spec.
 */
  }

  /* "apache_beam/transforms/stats.py":572
 *                                                           buffer_size:]
 * 
 *     self.collapse_if_needed(offset_fn)             # <<<<<<<<<<<<<<
 * 
 *   def _add_unbuffered_weighted(self, elements, offset_fn):
 */
  __pyx_t_3 = ((struct __pyx_vtabstruct_11apache_beam_10transforms_5stats__QuantileState *)__pyx_v_self->__pyx_vtab)->collapse_if_needed(__pyx_v_self, __pyx_v_offset_fn, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 572, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "apache_beam/transforms/stats.py":548
 *     return not self.unbuffered_elements and not self.buffers
 * 
 *   def _add_unbuffered(self, elements, offset_fn):             # <<<<<<<<<<<<<<
 *     # type: (List, Any) -> None
 * 
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("apache_beam.transforms.stats._QuantileState._add_unbuffered", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_to_buffer);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_11apache_beam_10transforms_5stats_14_QuantileState_7_add_unbuffered(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_11apache_beam_10transforms_5stats_14_QuantileState_6_add_unbuffered[] = "\n    Add elements to the unbuffered list, creating new buffers and\n    collapsing if needed.\n    ";
static PyMethodDef __pyx_mdef_11apache_beam_10transforms_5stats_14_QuantileState_7_add_unbuffered = {"_add_unbuffered", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_11apache_beam_10transforms_5stats_14_QuantileState_7_add_unbuffered, METH_VARARGS|METH_KEYWORDS, __pyx_doc_11apache_beam_10transforms_5stats_14_QuantileState_6_add_unbuffered};
static PyObject *__pyx_pw_11apache_beam_10transforms_5stats_14_QuantileState_7_add_unbuffered(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_elements = 0;
  PyObject *__pyx_v_offset_fn = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_add_unbuffered (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_elements,&__pyx_n_s_offset_fn,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_elements)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_offset_fn)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_add_unbuffered", 1, 2, 2, 1); __PYX_ERR(0, 548, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_add_unbuffered") < 0)) __PYX_ERR(0, 548, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_elements = values[0];
    __pyx_v_offset_fn = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_add_unbuffered", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 548, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("apache_beam.transforms.stats._QuantileState._add_unbuffered", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_11apache_beam_10transforms_5stats_14_QuantileState_6_add_unbuffered(((struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileState *)__pyx_v_self), __pyx_v_elements, __pyx_v_offset_fn);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_11apache_beam_10transforms_5stats_14_QuantileState_6_add_unbuffered(struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileState *__pyx_v_self, PyObject *__pyx_v_elements, PyObject *__pyx_v_offset_fn) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_add_unbuffered", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_11apache_beam_10transforms_5stats_14_QuantileState__add_unbuffered(__pyx_v_self, __pyx_v_elements, __pyx_v_offset_fn, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 548, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("apache_beam.transforms.stats._QuantileState._add_unbuffered", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "apache_beam/transforms/stats.py":574
 *     self.collapse_if_needed(offset_fn)
 * 
 *   def _add_unbuffered_weighted(self, elements, offset_fn):             # <<<<<<<<<<<<<<
 *     # type: (List, Any) -> None
 * 
 */

static PyObject *__pyx_pw_11apache_beam_10transforms_5stats_14_QuantileState_9_add_unbuffered_weighted(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_11apache_beam_10transforms_5stats_14_QuantileState__add_unbuffered_weighted(struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileState *__pyx_v_self, PyObject *__pyx_v_elements, PyObject *__pyx_v_offset_fn, int __pyx_skip_dispatch) {
  int64_t __pyx_v_num_new_buffers;
  int64_t __pyx_v_idx;
  PyObject *__pyx_v_argsort_key = NULL;
  PyObject *__pyx_v_argsort = NULL;
  PyObject *__pyx_v_elements_to_buffer = NULL;
  PyObject *__pyx_v_weights_to_buffer = NULL;
  int64_t __pyx_7genexpr__pyx_v_idx;
  int64_t __pyx_8genexpr1__pyx_v_idx;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  Py_ssize_t __pyx_t_7;
  int __pyx_t_8;
  int __pyx_t_9;
  int64_t __pyx_t_10;
  int64_t __pyx_t_11;
  int64_t __pyx_t_12;
  PyObject *(*__pyx_t_13)(PyObject *);
  int64_t __pyx_t_14;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_add_unbuffered_weighted", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely((Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) {
    #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    static PY_UINT64_T __pyx_tp_dict_version = __PYX_DICT_VERSION_INIT, __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
    if (unlikely(!__Pyx_object_dict_version_matches(((PyObject *)__pyx_v_self), __pyx_tp_dict_version, __pyx_obj_dict_version))) {
      PY_UINT64_T __pyx_type_dict_guard = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      #endif
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_add_unbuffered_weighted); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 574, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_11apache_beam_10transforms_5stats_14_QuantileState_9_add_unbuffered_weighted)) {
        __Pyx_XDECREF(__pyx_r);
        __Pyx_INCREF(__pyx_t_1);
        __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
        __pyx_t_5 = 0;
        if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
          __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
          if (likely(__pyx_t_4)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
            __Pyx_INCREF(__pyx_t_4);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_3, function);
            __pyx_t_5 = 1;
          }
        }
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_3)) {
          PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_v_elements, __pyx_v_offset_fn};
          __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 574, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_GOTREF(__pyx_t_2);
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
          PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_v_elements, __pyx_v_offset_fn};
          __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 574, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_GOTREF(__pyx_t_2);
        } else
        #endif
        {
          __pyx_t_6 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 574, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_6);
          if (__pyx_t_4) {
            __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __pyx_t_4 = NULL;
          }
          __Pyx_INCREF(__pyx_v_elements);
          __Pyx_GIVEREF(__pyx_v_elements);
          PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_5, __pyx_v_elements);
          __Pyx_INCREF(__pyx_v_offset_fn);
          __Pyx_GIVEREF(__pyx_v_offset_fn);
          PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_5, __pyx_v_offset_fn);
          __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 574, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        }
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __pyx_r = __pyx_t_2;
        __pyx_t_2 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        goto __pyx_L0;
      }
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
      __pyx_tp_dict_version = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      __pyx_obj_dict_version = __Pyx_get_object_dict_version(((PyObject *)__pyx_v_self));
      if (unlikely(__pyx_type_dict_guard != __pyx_tp_dict_version)) {
        __pyx_tp_dict_version = __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
      }
      #endif
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    }
    #endif
  }

  /* "apache_beam/transforms/stats.py":581
 *     collapsing if needed.
 *     """
 *     if len(elements) == 1:             # <<<<<<<<<<<<<<
 *       self.unbuffered_elements.append(elements[0][0])
 *       self.unbuffered_weights.append(elements[0][1])
 */
  __pyx_t_7 = PyObject_Length(__pyx_v_elements); if (unlikely(__pyx_t_7 == ((Py_ssize_t)-1))) __PYX_ERR(0, 581, __pyx_L1_error)
  __pyx_t_8 = ((__pyx_t_7 == 1) != 0);
  if (__pyx_t_8) {

    /* "apache_beam/transforms/stats.py":582
 *     """
 *     if len(elements) == 1:
 *       self.unbuffered_elements.append(elements[0][0])             # <<<<<<<<<<<<<<
 *       self.unbuffered_weights.append(elements[0][1])
 *     else:
 */
    __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_elements, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 582, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = __Pyx_GetItemInt(__pyx_t_1, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 582, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_9 = __Pyx_PyObject_Append(__pyx_v_self->unbuffered_elements, __pyx_t_2); if (unlikely(__pyx_t_9 == ((int)-1))) __PYX_ERR(0, 582, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "apache_beam/transforms/stats.py":583
 *     if len(elements) == 1:
 *       self.unbuffered_elements.append(elements[0][0])
 *       self.unbuffered_weights.append(elements[0][1])             # <<<<<<<<<<<<<<
 *     else:
 *       self.unbuffered_elements.extend(elements[0])
 */
    __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_elements, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 583, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = __Pyx_GetItemInt(__pyx_t_2, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 583, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_9 = __Pyx_PyObject_Append(__pyx_v_self->unbuffered_weights, __pyx_t_1); if (unlikely(__pyx_t_9 == ((int)-1))) __PYX_ERR(0, 583, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "apache_beam/transforms/stats.py":581
 *     collapsing if needed.
 *     """
 *     if len(elements) == 1:             # <<<<<<<<<<<<<<
 *       self.unbuffered_elements.append(elements[0][0])
 *       self.unbuffered_weights.append(elements[0][1])
 */
    goto __pyx_L3;
  }

  /* "apache_beam/transforms/stats.py":585
 *       self.unbuffered_weights.append(elements[0][1])
 *     else:
 *       self.unbuffered_elements.extend(elements[0])             # <<<<<<<<<<<<<<
 *       self.unbuffered_weights.extend(elements[1])
 *     num_new_buffers = len(self.unbuffered_elements) // self.spec.buffer_size
 */
  /*else*/ {
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->unbuffered_elements, __pyx_n_s_extend); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 585, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_elements, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 585, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_6 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
      __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_2);
      if (likely(__pyx_t_6)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
        __Pyx_INCREF(__pyx_t_6);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_2, function);
      }
    }
    __pyx_t_1 = (__pyx_t_6) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_6, __pyx_t_3) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3);
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 585, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "apache_beam/transforms/stats.py":586
 *     else:
 *       self.unbuffered_elements.extend(elements[0])
 *       self.unbuffered_weights.extend(elements[1])             # <<<<<<<<<<<<<<
 *     num_new_buffers = len(self.unbuffered_elements) // self.spec.buffer_size
 *     argsort_key = self.spec.get_argsort_key(self.unbuffered_elements)
 */
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->unbuffered_weights, __pyx_n_s_extend); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 586, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_elements, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 586, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_6 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
      __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_2);
      if (likely(__pyx_t_6)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
        __Pyx_INCREF(__pyx_t_6);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_2, function);
      }
    }
    __pyx_t_1 = (__pyx_t_6) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_6, __pyx_t_3) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3);
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 586, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }
  __pyx_L3:;

  /* "apache_beam/transforms/stats.py":587
 *       self.unbuffered_elements.extend(elements[0])
 *       self.unbuffered_weights.extend(elements[1])
 *     num_new_buffers = len(self.unbuffered_elements) // self.spec.buffer_size             # <<<<<<<<<<<<<<
 *     argsort_key = self.spec.get_argsort_key(self.unbuffered_elements)
 *     for idx in range(num_new_buffers):
 */
  __pyx_t_1 = __pyx_v_self->unbuffered_elements;
  __Pyx_INCREF(__pyx_t_1);
  __pyx_t_7 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_7 == ((Py_ssize_t)-1))) __PYX_ERR(0, 587, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (unlikely(__pyx_v_self->spec->buffer_size == 0)) {
    PyErr_SetString(PyExc_ZeroDivisionError, "integer division or modulo by zero");
    __PYX_ERR(0, 587, __pyx_L1_error)
  }
  else if (sizeof(Py_ssize_t) == sizeof(long) && (!(((int64_t)-1) > 0)) && unlikely(__pyx_v_self->spec->buffer_size == (int64_t)-1)  && unlikely(UNARY_NEG_WOULD_OVERFLOW(__pyx_t_7))) {
    PyErr_SetString(PyExc_OverflowError, "value too large to perform division");
    __PYX_ERR(0, 587, __pyx_L1_error)
  }
  __pyx_v_num_new_buffers = __Pyx_div_Py_ssize_t(__pyx_t_7, __pyx_v_self->spec->buffer_size);

  /* "apache_beam/transforms/stats.py":588
 *       self.unbuffered_weights.extend(elements[1])
 *     num_new_buffers = len(self.unbuffered_elements) // self.spec.buffer_size
 *     argsort_key = self.spec.get_argsort_key(self.unbuffered_elements)             # <<<<<<<<<<<<<<
 *     for idx in range(num_new_buffers):
 *       argsort = sorted(
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->spec), __pyx_n_s_get_argsort_key); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 588, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_3, __pyx_v_self->unbuffered_elements) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_self->unbuffered_elements);
  __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 588, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_argsort_key = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "apache_beam/transforms/stats.py":589
 *     num_new_buffers = len(self.unbuffered_elements) // self.spec.buffer_size
 *     argsort_key = self.spec.get_argsort_key(self.unbuffered_elements)
 *     for idx in range(num_new_buffers):             # <<<<<<<<<<<<<<
 *       argsort = sorted(
 *           range(idx * self.spec.buffer_size, (idx + 1) * self.spec.buffer_size),
 */
  __pyx_t_10 = __pyx_v_num_new_buffers;
  __pyx_t_11 = __pyx_t_10;
  for (__pyx_t_12 = 0; __pyx_t_12 < __pyx_t_11; __pyx_t_12+=1) {
    __pyx_v_idx = __pyx_t_12;

    /* "apache_beam/transforms/stats.py":591
 *     for idx in range(num_new_buffers):
 *       argsort = sorted(
 *           range(idx * self.spec.buffer_size, (idx + 1) * self.spec.buffer_size),             # <<<<<<<<<<<<<<
 *           key=argsort_key,
 *           reverse=self.spec.reverse)
 */
    __pyx_t_1 = __Pyx_PyInt_From_int64_t((__pyx_v_idx * __pyx_v_self->spec->buffer_size)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 591, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = __Pyx_PyInt_From_int64_t(((__pyx_v_idx + 1) * __pyx_v_self->spec->buffer_size)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 591, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 591, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_2);
    __pyx_t_1 = 0;
    __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_range, __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 591, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "apache_beam/transforms/stats.py":590
 *     argsort_key = self.spec.get_argsort_key(self.unbuffered_elements)
 *     for idx in range(num_new_buffers):
 *       argsort = sorted(             # <<<<<<<<<<<<<<
 *           range(idx * self.spec.buffer_size, (idx + 1) * self.spec.buffer_size),
 *           key=argsort_key,
 */
    __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 590, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2);
    __pyx_t_2 = 0;

    /* "apache_beam/transforms/stats.py":592
 *       argsort = sorted(
 *           range(idx * self.spec.buffer_size, (idx + 1) * self.spec.buffer_size),
 *           key=argsort_key,             # <<<<<<<<<<<<<<
 *           reverse=self.spec.reverse)
 *       elements_to_buffer = [self.unbuffered_elements[idx] for idx in argsort]
 */
    __pyx_t_2 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 592, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_key, __pyx_v_argsort_key) < 0) __PYX_ERR(0, 592, __pyx_L1_error)

    /* "apache_beam/transforms/stats.py":593
 *           range(idx * self.spec.buffer_size, (idx + 1) * self.spec.buffer_size),
 *           key=argsort_key,
 *           reverse=self.spec.reverse)             # <<<<<<<<<<<<<<
 *       elements_to_buffer = [self.unbuffered_elements[idx] for idx in argsort]
 *       weights_to_buffer = [self.unbuffered_weights[idx] for idx in argsort]
 */
    __pyx_t_1 = __Pyx_PyBool_FromLong(__pyx_v_self->spec->reverse); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 593, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_reverse, __pyx_t_1) < 0) __PYX_ERR(0, 592, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "apache_beam/transforms/stats.py":590
 *     argsort_key = self.spec.get_argsort_key(self.unbuffered_elements)
 *     for idx in range(num_new_buffers):
 *       argsort = sorted(             # <<<<<<<<<<<<<<
 *           range(idx * self.spec.buffer_size, (idx + 1) * self.spec.buffer_size),
 *           key=argsort_key,
 */
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_sorted, __pyx_t_3, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 590, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_XDECREF_SET(__pyx_v_argsort, __pyx_t_1);
    __pyx_t_1 = 0;

    /* "apache_beam/transforms/stats.py":594
 *           key=argsort_key,
 *           reverse=self.spec.reverse)
 *       elements_to_buffer = [self.unbuffered_elements[idx] for idx in argsort]             # <<<<<<<<<<<<<<
 *       weights_to_buffer = [self.unbuffered_weights[idx] for idx in argsort]
 *       heapq.heappush(
 */
    { /* enter inner scope */
      __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 594, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (likely(PyList_CheckExact(__pyx_v_argsort)) || PyTuple_CheckExact(__pyx_v_argsort)) {
        __pyx_t_2 = __pyx_v_argsort; __Pyx_INCREF(__pyx_t_2); __pyx_t_7 = 0;
        __pyx_t_13 = NULL;
      } else {
        __pyx_t_7 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_v_argsort); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 594, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_13 = Py_TYPE(__pyx_t_2)->tp_iternext; if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 594, __pyx_L1_error)
      }
      for (;;) {
        if (likely(!__pyx_t_13)) {
          if (likely(PyList_CheckExact(__pyx_t_2))) {
            if (__pyx_t_7 >= PyList_GET_SIZE(__pyx_t_2)) break;
            #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
            __pyx_t_3 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_7); __Pyx_INCREF(__pyx_t_3); __pyx_t_7++; if (unlikely(0 < 0)) __PYX_ERR(0, 594, __pyx_L1_error)
            #else
            __pyx_t_3 = PySequence_ITEM(__pyx_t_2, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 594, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_3);
            #endif
          } else {
            if (__pyx_t_7 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
            #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
            __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_7); __Pyx_INCREF(__pyx_t_3); __pyx_t_7++; if (unlikely(0 < 0)) __PYX_ERR(0, 594, __pyx_L1_error)
            #else
            __pyx_t_3 = PySequence_ITEM(__pyx_t_2, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 594, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_3);
            #endif
          }
        } else {
          __pyx_t_3 = __pyx_t_13(__pyx_t_2);
          if (unlikely(!__pyx_t_3)) {
            PyObject* exc_type = PyErr_Occurred();
            if (exc_type) {
              if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
              else __PYX_ERR(0, 594, __pyx_L1_error)
            }
            break;
          }
          __Pyx_GOTREF(__pyx_t_3);
        }
        __pyx_t_14 = __Pyx_PyInt_As_int64_t(__pyx_t_3); if (unlikely((__pyx_t_14 == ((int64_t)-1)) && PyErr_Occurred())) __PYX_ERR(0, 594, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __pyx_7genexpr__pyx_v_idx = __pyx_t_14;
        __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_self->unbuffered_elements, __pyx_7genexpr__pyx_v_idx, int64_t, 1, __Pyx_PyInt_From_int64_t, 0, 1, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 594, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        if (unlikely(__Pyx_ListComp_Append(__pyx_t_1, (PyObject*)__pyx_t_3))) __PYX_ERR(0, 594, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      }
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    } /* exit inner scope */
    __Pyx_XDECREF_SET(__pyx_v_elements_to_buffer, ((PyObject*)__pyx_t_1));
    __pyx_t_1 = 0;

    /* "apache_beam/transforms/stats.py":595
 *           reverse=self.spec.reverse)
 *       elements_to_buffer = [self.unbuffered_elements[idx] for idx in argsort]
 *       weights_to_buffer = [self.unbuffered_weights[idx] for idx in argsort]             # <<<<<<<<<<<<<<
 *       heapq.heappush(
 *           self.buffers,
 */
    { /* enter inner scope */
      __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 595, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (likely(PyList_CheckExact(__pyx_v_argsort)) || PyTuple_CheckExact(__pyx_v_argsort)) {
        __pyx_t_2 = __pyx_v_argsort; __Pyx_INCREF(__pyx_t_2); __pyx_t_7 = 0;
        __pyx_t_13 = NULL;
      } else {
        __pyx_t_7 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_v_argsort); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 595, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_13 = Py_TYPE(__pyx_t_2)->tp_iternext; if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 595, __pyx_L1_error)
      }
      for (;;) {
        if (likely(!__pyx_t_13)) {
          if (likely(PyList_CheckExact(__pyx_t_2))) {
            if (__pyx_t_7 >= PyList_GET_SIZE(__pyx_t_2)) break;
            #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
            __pyx_t_3 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_7); __Pyx_INCREF(__pyx_t_3); __pyx_t_7++; if (unlikely(0 < 0)) __PYX_ERR(0, 595, __pyx_L1_error)
            #else
            __pyx_t_3 = PySequence_ITEM(__pyx_t_2, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 595, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_3);
            #endif
          } else {
            if (__pyx_t_7 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
            #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
            __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_7); __Pyx_INCREF(__pyx_t_3); __pyx_t_7++; if (unlikely(0 < 0)) __PYX_ERR(0, 595, __pyx_L1_error)
            #else
            __pyx_t_3 = PySequence_ITEM(__pyx_t_2, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 595, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_3);
            #endif
          }
        } else {
          __pyx_t_3 = __pyx_t_13(__pyx_t_2);
          if (unlikely(!__pyx_t_3)) {
            PyObject* exc_type = PyErr_Occurred();
            if (exc_type) {
              if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
              else __PYX_ERR(0, 595, __pyx_L1_error)
            }
            break;
          }
          __Pyx_GOTREF(__pyx_t_3);
        }
        __pyx_t_14 = __Pyx_PyInt_As_int64_t(__pyx_t_3); if (unlikely((__pyx_t_14 == ((int64_t)-1)) && PyErr_Occurred())) __PYX_ERR(0, 595, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __pyx_8genexpr1__pyx_v_idx = __pyx_t_14;
        __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_self->unbuffered_weights, __pyx_8genexpr1__pyx_v_idx, int64_t, 1, __Pyx_PyInt_From_int64_t, 0, 1, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 595, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        if (unlikely(__Pyx_ListComp_Append(__pyx_t_1, (PyObject*)__pyx_t_3))) __PYX_ERR(0, 595, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      }
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    } /* exit inner scope */
    __Pyx_XDECREF_SET(__pyx_v_weights_to_buffer, ((PyObject*)__pyx_t_1));
    __pyx_t_1 = 0;

    /* "apache_beam/transforms/stats.py":596
 *       elements_to_buffer = [self.unbuffered_elements[idx] for idx in argsort]
 *       weights_to_buffer = [self.unbuffered_weights[idx] for idx in argsort]
 *       heapq.heappush(             # <<<<<<<<<<<<<<
 *           self.buffers,
 *           _QuantileBuffer(
 */
    __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_heapq); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 596, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_heappush); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 596, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "apache_beam/transforms/stats.py":599
 *           self.buffers,
 *           _QuantileBuffer(
 *               elements=elements_to_buffer,             # <<<<<<<<<<<<<<
 *               weights=weights_to_buffer,
 *               weighted=True))
 */
    __pyx_t_2 = __Pyx_PyDict_NewPresized(3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 599, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_elements, __pyx_v_elements_to_buffer) < 0) __PYX_ERR(0, 599, __pyx_L1_error)

    /* "apache_beam/transforms/stats.py":600
 *           _QuantileBuffer(
 *               elements=elements_to_buffer,
 *               weights=weights_to_buffer,             # <<<<<<<<<<<<<<
 *               weighted=True))
 * 
 */
    if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_weights, __pyx_v_weights_to_buffer) < 0) __PYX_ERR(0, 599, __pyx_L1_error)

    /* "apache_beam/transforms/stats.py":601
 *               elements=elements_to_buffer,
 *               weights=weights_to_buffer,
 *               weighted=True))             # <<<<<<<<<<<<<<
 * 
 *     if num_new_buffers > 0:
 */
    if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_weighted, Py_True) < 0) __PYX_ERR(0, 599, __pyx_L1_error)

    /* "apache_beam/transforms/stats.py":598
 *       heapq.heappush(
 *           self.buffers,
 *           _QuantileBuffer(             # <<<<<<<<<<<<<<
 *               elements=elements_to_buffer,
 *               weights=weights_to_buffer,
 */
    __pyx_t_6 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_11apache_beam_10transforms_5stats__QuantileBuffer), __pyx_empty_tuple, __pyx_t_2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 598, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = NULL;
    __pyx_t_5 = 0;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
      __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
      if (likely(__pyx_t_2)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_2);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_3, function);
        __pyx_t_5 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_3)) {
      PyObject *__pyx_temp[3] = {__pyx_t_2, __pyx_v_self->buffers, __pyx_t_6};
      __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 596, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
      PyObject *__pyx_temp[3] = {__pyx_t_2, __pyx_v_self->buffers, __pyx_t_6};
      __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 596, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    } else
    #endif
    {
      __pyx_t_4 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 596, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      if (__pyx_t_2) {
        __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2); __pyx_t_2 = NULL;
      }
      __Pyx_INCREF(__pyx_v_self->buffers);
      __Pyx_GIVEREF(__pyx_v_self->buffers);
      PyTuple_SET_ITEM(__pyx_t_4, 0+__pyx_t_5, __pyx_v_self->buffers);
      __Pyx_GIVEREF(__pyx_t_6);
      PyTuple_SET_ITEM(__pyx_t_4, 1+__pyx_t_5, __pyx_t_6);
      __pyx_t_6 = 0;
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 596, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    }
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "apache_beam/transforms/stats.py":603
 *               weighted=True))
 * 
 *     if num_new_buffers > 0:             # <<<<<<<<<<<<<<
 *       self.unbuffered_elements = self.unbuffered_elements[num_new_buffers *
 *                                                           self.spec.
 */
  __pyx_t_8 = ((__pyx_v_num_new_buffers > 0) != 0);
  if (__pyx_t_8) {

    /* "apache_beam/transforms/stats.py":604
 * 
 *     if num_new_buffers > 0:
 *       self.unbuffered_elements = self.unbuffered_elements[num_new_buffers *             # <<<<<<<<<<<<<<
 *                                                           self.spec.
 *                                                           buffer_size:]
 */
    __pyx_t_1 = __Pyx_PyObject_GetSlice(__pyx_v_self->unbuffered_elements, (__pyx_v_num_new_buffers * __pyx_v_self->spec->buffer_size), 0, NULL, NULL, NULL, 1, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 604, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_1);
    __Pyx_GOTREF(__pyx_v_self->unbuffered_elements);
    __Pyx_DECREF(__pyx_v_self->unbuffered_elements);
    __pyx_v_self->unbuffered_elements = __pyx_t_1;
    __pyx_t_1 = 0;

    /* "apache_beam/transforms/stats.py":607
 *                                                           self.spec.
 *                                                           buffer_size:]
 *       self.unbuffered_weights = self.unbuffered_weights[num_new_buffers *             # <<<<<<<<<<<<<<
 *                                                         self.spec.buffer_size:]
 * 
 */
    __pyx_t_1 = __Pyx_PyObject_GetSlice(__pyx_v_self->unbuffered_weights, (__pyx_v_num_new_buffers * __pyx_v_self->spec->buffer_size), 0, NULL, NULL, NULL, 1, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 607, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_1);
    __Pyx_GOTREF(__pyx_v_self->unbuffered_weights);
    __Pyx_DECREF(__pyx_v_self->unbuffered_weights);
    __pyx_v_self->unbuffered_weights = __pyx_t_1;
    __pyx_t_1 = 0;

    /* "apache_beam/transforms/stats.py":603
 *               weighted=True))
 * 
 *     if num_new_buffers > 0:             # <<<<<<<<<<<<<<
 *       self.unbuffered_elements = self.unbuffered_elements[num_new_buffers *
 *                                                           self.spec.
 */
  }

  /* "apache_beam/transforms/stats.py":610
 *                                                         self.spec.buffer_size:]
 * 
 *     self.collapse_if_needed(offset_fn)             # <<<<<<<<<<<<<<
 * 
 *   def finalize(self):
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_11apache_beam_10transforms_5stats__QuantileState *)__pyx_v_self->__pyx_vtab)->collapse_if_needed(__pyx_v_self, __pyx_v_offset_fn, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 610, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "apache_beam/transforms/stats.py":574
 *     self.collapse_if_needed(offset_fn)
 * 
 *   def _add_unbuffered_weighted(self, elements, offset_fn):             # <<<<<<<<<<<<<<
 *     # type: (List, Any) -> None
 * 
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("apache_beam.transforms.stats._QuantileState._add_unbuffered_weighted", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_argsort_key);
  __Pyx_XDECREF(__pyx_v_argsort);
  __Pyx_XDECREF(__pyx_v_elements_to_buffer);
  __Pyx_XDECREF(__pyx_v_weights_to_buffer);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_11apache_beam_10transforms_5stats_14_QuantileState_9_add_unbuffered_weighted(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_11apache_beam_10transforms_5stats_14_QuantileState_8_add_unbuffered_weighted[] = "\n    Add elements with weights to the unbuffered list, creating new buffers and\n    collapsing if needed.\n    ";
static PyMethodDef __pyx_mdef_11apache_beam_10transforms_5stats_14_QuantileState_9_add_unbuffered_weighted = {"_add_unbuffered_weighted", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_11apache_beam_10transforms_5stats_14_QuantileState_9_add_unbuffered_weighted, METH_VARARGS|METH_KEYWORDS, __pyx_doc_11apache_beam_10transforms_5stats_14_QuantileState_8_add_unbuffered_weighted};
static PyObject *__pyx_pw_11apache_beam_10transforms_5stats_14_QuantileState_9_add_unbuffered_weighted(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_elements = 0;
  PyObject *__pyx_v_offset_fn = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_add_unbuffered_weighted (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_elements,&__pyx_n_s_offset_fn,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_elements)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_offset_fn)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_add_unbuffered_weighted", 1, 2, 2, 1); __PYX_ERR(0, 574, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_add_unbuffered_weighted") < 0)) __PYX_ERR(0, 574, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_elements = values[0];
    __pyx_v_offset_fn = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_add_unbuffered_weighted", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 574, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("apache_beam.transforms.stats._QuantileState._add_unbuffered_weighted", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_11apache_beam_10transforms_5stats_14_QuantileState_8_add_unbuffered_weighted(((struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileState *)__pyx_v_self), __pyx_v_elements, __pyx_v_offset_fn);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_11apache_beam_10transforms_5stats_14_QuantileState_8_add_unbuffered_weighted(struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileState *__pyx_v_self, PyObject *__pyx_v_elements, PyObject *__pyx_v_offset_fn) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_add_unbuffered_weighted", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_11apache_beam_10transforms_5stats_14_QuantileState__add_unbuffered_weighted(__pyx_v_self, __pyx_v_elements, __pyx_v_offset_fn, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 574, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("apache_beam.transforms.stats._QuantileState._add_unbuffered_weighted", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "apache_beam/transforms/stats.py":612
 *     self.collapse_if_needed(offset_fn)
 * 
 *   def finalize(self):             # <<<<<<<<<<<<<<
 *     # type: () -> None
 * 
 */

static PyObject *__pyx_pw_11apache_beam_10transforms_5stats_14_QuantileState_11finalize(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_f_11apache_beam_10transforms_5stats_14_QuantileState_finalize(struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileState *__pyx_v_self, int __pyx_skip_dispatch) {
  PyObject *__pyx_v_argsort_key = NULL;
  PyObject *__pyx_v_argsort = NULL;
  PyObject *__pyx_8genexpr2__pyx_v_idx = NULL;
  PyObject *__pyx_8genexpr3__pyx_v_idx = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  int __pyx_t_6;
  Py_ssize_t __pyx_t_7;
  PyObject *(*__pyx_t_8)(PyObject *);
  int __pyx_t_9;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("finalize", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely((Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) {
    #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    static PY_UINT64_T __pyx_tp_dict_version = __PYX_DICT_VERSION_INIT, __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
    if (unlikely(!__Pyx_object_dict_version_matches(((PyObject *)__pyx_v_self), __pyx_tp_dict_version, __pyx_obj_dict_version))) {
      PY_UINT64_T __pyx_type_dict_guard = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      #endif
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_finalize); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 612, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_11apache_beam_10transforms_5stats_14_QuantileState_11finalize)) {
        __Pyx_XDECREF(__pyx_r);
        __Pyx_INCREF(__pyx_t_1);
        __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
        if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
          __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
          if (likely(__pyx_t_4)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
            __Pyx_INCREF(__pyx_t_4);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_3, function);
          }
        }
        __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4) : __Pyx_PyObject_CallNoArg(__pyx_t_3);
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 612, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __pyx_r = __pyx_t_2;
        __pyx_t_2 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        goto __pyx_L0;
      }
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
      __pyx_tp_dict_version = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      __pyx_obj_dict_version = __Pyx_get_object_dict_version(((PyObject *)__pyx_v_self));
      if (unlikely(__pyx_type_dict_guard != __pyx_tp_dict_version)) {
        __pyx_tp_dict_version = __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
      }
      #endif
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    }
    #endif
  }

  /* "apache_beam/transforms/stats.py":620
 *     proper position since _collapse is not going to be called after.
 *     """
 *     if self.unbuffered_elements and self.spec.weighted:             # <<<<<<<<<<<<<<
 *       argsort_key = self.spec.get_argsort_key(self.unbuffered_elements)
 *       argsort = sorted(
 */
  __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_v_self->unbuffered_elements); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 620, __pyx_L1_error)
  if (__pyx_t_6) {
  } else {
    __pyx_t_5 = __pyx_t_6;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_6 = (__pyx_v_self->spec->weighted != 0);
  __pyx_t_5 = __pyx_t_6;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_5) {

    /* "apache_beam/transforms/stats.py":621
 *     """
 *     if self.unbuffered_elements and self.spec.weighted:
 *       argsort_key = self.spec.get_argsort_key(self.unbuffered_elements)             # <<<<<<<<<<<<<<
 *       argsort = sorted(
 *           range(len(self.unbuffered_elements)),
 */
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->spec), __pyx_n_s_get_argsort_key); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 621, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
      __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
      if (likely(__pyx_t_3)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
        __Pyx_INCREF(__pyx_t_3);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_2, function);
      }
    }
    __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_3, __pyx_v_self->unbuffered_elements) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_self->unbuffered_elements);
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 621, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_v_argsort_key = __pyx_t_1;
    __pyx_t_1 = 0;

    /* "apache_beam/transforms/stats.py":623
 *       argsort_key = self.spec.get_argsort_key(self.unbuffered_elements)
 *       argsort = sorted(
 *           range(len(self.unbuffered_elements)),             # <<<<<<<<<<<<<<
 *           key=argsort_key,
 *           reverse=self.spec.reverse)
 */
    __pyx_t_1 = __pyx_v_self->unbuffered_elements;
    __Pyx_INCREF(__pyx_t_1);
    __pyx_t_7 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_7 == ((Py_ssize_t)-1))) __PYX_ERR(0, 623, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = PyInt_FromSsize_t(__pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 623, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_builtin_range, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 623, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "apache_beam/transforms/stats.py":622
 *     if self.unbuffered_elements and self.spec.weighted:
 *       argsort_key = self.spec.get_argsort_key(self.unbuffered_elements)
 *       argsort = sorted(             # <<<<<<<<<<<<<<
 *           range(len(self.unbuffered_elements)),
 *           key=argsort_key,
 */
    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 622, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2);
    __pyx_t_2 = 0;

    /* "apache_beam/transforms/stats.py":624
 *       argsort = sorted(
 *           range(len(self.unbuffered_elements)),
 *           key=argsort_key,             # <<<<<<<<<<<<<<
 *           reverse=self.spec.reverse)
 *       self.unbuffered_elements = [
 */
    __pyx_t_2 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 624, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_key, __pyx_v_argsort_key) < 0) __PYX_ERR(0, 624, __pyx_L1_error)

    /* "apache_beam/transforms/stats.py":625
 *           range(len(self.unbuffered_elements)),
 *           key=argsort_key,
 *           reverse=self.spec.reverse)             # <<<<<<<<<<<<<<
 *       self.unbuffered_elements = [
 *           self.unbuffered_elements[idx] for idx in argsort
 */
    __pyx_t_3 = __Pyx_PyBool_FromLong(__pyx_v_self->spec->reverse); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 625, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_reverse, __pyx_t_3) < 0) __PYX_ERR(0, 624, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "apache_beam/transforms/stats.py":622
 *     if self.unbuffered_elements and self.spec.weighted:
 *       argsort_key = self.spec.get_argsort_key(self.unbuffered_elements)
 *       argsort = sorted(             # <<<<<<<<<<<<<<
 *           range(len(self.unbuffered_elements)),
 *           key=argsort_key,
 */
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_sorted, __pyx_t_1, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 622, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_v_argsort = __pyx_t_3;
    __pyx_t_3 = 0;

    /* "apache_beam/transforms/stats.py":626
 *           key=argsort_key,
 *           reverse=self.spec.reverse)
 *       self.unbuffered_elements = [             # <<<<<<<<<<<<<<
 *           self.unbuffered_elements[idx] for idx in argsort
 *       ]
 */
    { /* enter inner scope */
      __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 626, __pyx_L8_error)
      __Pyx_GOTREF(__pyx_t_3);

      /* "apache_beam/transforms/stats.py":627
 *           reverse=self.spec.reverse)
 *       self.unbuffered_elements = [
 *           self.unbuffered_elements[idx] for idx in argsort             # <<<<<<<<<<<<<<
 *       ]
 *       self.unbuffered_weights = [
 */
      if (likely(PyList_CheckExact(__pyx_v_argsort)) || PyTuple_CheckExact(__pyx_v_argsort)) {
        __pyx_t_2 = __pyx_v_argsort; __Pyx_INCREF(__pyx_t_2); __pyx_t_7 = 0;
        __pyx_t_8 = NULL;
      } else {
        __pyx_t_7 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_v_argsort); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 627, __pyx_L8_error)
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_8 = Py_TYPE(__pyx_t_2)->tp_iternext; if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 627, __pyx_L8_error)
      }
      for (;;) {
        if (likely(!__pyx_t_8)) {
          if (likely(PyList_CheckExact(__pyx_t_2))) {
            if (__pyx_t_7 >= PyList_GET_SIZE(__pyx_t_2)) break;
            #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
            __pyx_t_1 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_7); __Pyx_INCREF(__pyx_t_1); __pyx_t_7++; if (unlikely(0 < 0)) __PYX_ERR(0, 627, __pyx_L8_error)
            #else
            __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 627, __pyx_L8_error)
            __Pyx_GOTREF(__pyx_t_1);
            #endif
          } else {
            if (__pyx_t_7 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
            #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
            __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_7); __Pyx_INCREF(__pyx_t_1); __pyx_t_7++; if (unlikely(0 < 0)) __PYX_ERR(0, 627, __pyx_L8_error)
            #else
            __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 627, __pyx_L8_error)
            __Pyx_GOTREF(__pyx_t_1);
            #endif
          }
        } else {
          __pyx_t_1 = __pyx_t_8(__pyx_t_2);
          if (unlikely(!__pyx_t_1)) {
            PyObject* exc_type = PyErr_Occurred();
            if (exc_type) {
              if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
              else __PYX_ERR(0, 627, __pyx_L8_error)
            }
            break;
          }
          __Pyx_GOTREF(__pyx_t_1);
        }
        __Pyx_XDECREF_SET(__pyx_8genexpr2__pyx_v_idx, __pyx_t_1);
        __pyx_t_1 = 0;
        __pyx_t_1 = __Pyx_PyObject_GetItem(__pyx_v_self->unbuffered_elements, __pyx_8genexpr2__pyx_v_idx); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 627, __pyx_L8_error)
        __Pyx_GOTREF(__pyx_t_1);
        if (unlikely(__Pyx_ListComp_Append(__pyx_t_3, (PyObject*)__pyx_t_1))) __PYX_ERR(0, 626, __pyx_L8_error)
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      }
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_XDECREF(__pyx_8genexpr2__pyx_v_idx); __pyx_8genexpr2__pyx_v_idx = 0;
      goto __pyx_L11_exit_scope;
      __pyx_L8_error:;
      __Pyx_XDECREF(__pyx_8genexpr2__pyx_v_idx); __pyx_8genexpr2__pyx_v_idx = 0;
      goto __pyx_L1_error;
      __pyx_L11_exit_scope:;
    } /* exit inner scope */

    /* "apache_beam/transforms/stats.py":626
 *           key=argsort_key,
 *           reverse=self.spec.reverse)
 *       self.unbuffered_elements = [             # <<<<<<<<<<<<<<
 *           self.unbuffered_elements[idx] for idx in argsort
 *       ]
 */
    __Pyx_GIVEREF(__pyx_t_3);
    __Pyx_GOTREF(__pyx_v_self->unbuffered_elements);
    __Pyx_DECREF(__pyx_v_self->unbuffered_elements);
    __pyx_v_self->unbuffered_elements = __pyx_t_3;
    __pyx_t_3 = 0;

    /* "apache_beam/transforms/stats.py":629
 *           self.unbuffered_elements[idx] for idx in argsort
 *       ]
 *       self.unbuffered_weights = [             # <<<<<<<<<<<<<<
 *           self.unbuffered_weights[idx] for idx in argsort
 *       ]
 */
    { /* enter inner scope */
      __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 629, __pyx_L14_error)
      __Pyx_GOTREF(__pyx_t_3);

      /* "apache_beam/transforms/stats.py":630
 *       ]
 *       self.unbuffered_weights = [
 *           self.unbuffered_weights[idx] for idx in argsort             # <<<<<<<<<<<<<<
 *       ]
 *       self.buffers.append(
 */
      if (likely(PyList_CheckExact(__pyx_v_argsort)) || PyTuple_CheckExact(__pyx_v_argsort)) {
        __pyx_t_2 = __pyx_v_argsort; __Pyx_INCREF(__pyx_t_2); __pyx_t_7 = 0;
        __pyx_t_8 = NULL;
      } else {
        __pyx_t_7 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_v_argsort); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 630, __pyx_L14_error)
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_8 = Py_TYPE(__pyx_t_2)->tp_iternext; if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 630, __pyx_L14_error)
      }
      for (;;) {
        if (likely(!__pyx_t_8)) {
          if (likely(PyList_CheckExact(__pyx_t_2))) {
            if (__pyx_t_7 >= PyList_GET_SIZE(__pyx_t_2)) break;
            #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
            __pyx_t_1 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_7); __Pyx_INCREF(__pyx_t_1); __pyx_t_7++; if (unlikely(0 < 0)) __PYX_ERR(0, 630, __pyx_L14_error)
            #else
            __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 630, __pyx_L14_error)
            __Pyx_GOTREF(__pyx_t_1);
            #endif
          } else {
            if (__pyx_t_7 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
            #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
            __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_7); __Pyx_INCREF(__pyx_t_1); __pyx_t_7++; if (unlikely(0 < 0)) __PYX_ERR(0, 630, __pyx_L14_error)
            #else
            __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 630, __pyx_L14_error)
            __Pyx_GOTREF(__pyx_t_1);
            #endif
          }
        } else {
          __pyx_t_1 = __pyx_t_8(__pyx_t_2);
          if (unlikely(!__pyx_t_1)) {
            PyObject* exc_type = PyErr_Occurred();
            if (exc_type) {
              if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
              else __PYX_ERR(0, 630, __pyx_L14_error)
            }
            break;
          }
          __Pyx_GOTREF(__pyx_t_1);
        }
        __Pyx_XDECREF_SET(__pyx_8genexpr3__pyx_v_idx, __pyx_t_1);
        __pyx_t_1 = 0;
        __pyx_t_1 = __Pyx_PyObject_GetItem(__pyx_v_self->unbuffered_weights, __pyx_8genexpr3__pyx_v_idx); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 630, __pyx_L14_error)
        __Pyx_GOTREF(__pyx_t_1);
        if (unlikely(__Pyx_ListComp_Append(__pyx_t_3, (PyObject*)__pyx_t_1))) __PYX_ERR(0, 629, __pyx_L14_error)
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      }
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_XDECREF(__pyx_8genexpr3__pyx_v_idx); __pyx_8genexpr3__pyx_v_idx = 0;
      goto __pyx_L17_exit_scope;
      __pyx_L14_error:;
      __Pyx_XDECREF(__pyx_8genexpr3__pyx_v_idx); __pyx_8genexpr3__pyx_v_idx = 0;
      goto __pyx_L1_error;
      __pyx_L17_exit_scope:;
    } /* exit inner scope */

    /* "apache_beam/transforms/stats.py":629
 *           self.unbuffered_elements[idx] for idx in argsort
 *       ]
 *       self.unbuffered_weights = [             # <<<<<<<<<<<<<<
 *           self.unbuffered_weights[idx] for idx in argsort
 *       ]
 */
    __Pyx_GIVEREF(__pyx_t_3);
    __Pyx_GOTREF(__pyx_v_self->unbuffered_weights);
    __Pyx_DECREF(__pyx_v_self->unbuffered_weights);
    __pyx_v_self->unbuffered_weights = __pyx_t_3;
    __pyx_t_3 = 0;

    /* "apache_beam/transforms/stats.py":633
 *       ]
 *       self.buffers.append(
 *           _QuantileBuffer(             # <<<<<<<<<<<<<<
 *               self.unbuffered_elements, self.unbuffered_weights, weighted=True))
 *       self.unbuffered_weights = []
 */
    __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 633, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_v_self->unbuffered_elements);
    __Pyx_GIVEREF(__pyx_v_self->unbuffered_elements);
    PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_self->unbuffered_elements);
    __Pyx_INCREF(__pyx_v_self->unbuffered_weights);
    __Pyx_GIVEREF(__pyx_v_self->unbuffered_weights);
    PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_self->unbuffered_weights);

    /* "apache_beam/transforms/stats.py":634
 *       self.buffers.append(
 *           _QuantileBuffer(
 *               self.unbuffered_elements, self.unbuffered_weights, weighted=True))             # <<<<<<<<<<<<<<
 *       self.unbuffered_weights = []
 *     elif self.unbuffered_elements:
 */
    __pyx_t_2 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 634, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_weighted, Py_True) < 0) __PYX_ERR(0, 634, __pyx_L1_error)

    /* "apache_beam/transforms/stats.py":633
 *       ]
 *       self.buffers.append(
 *           _QuantileBuffer(             # <<<<<<<<<<<<<<
 *               self.unbuffered_elements, self.unbuffered_weights, weighted=True))
 *       self.unbuffered_weights = []
 */
    __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_11apache_beam_10transforms_5stats__QuantileBuffer), __pyx_t_3, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 633, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "apache_beam/transforms/stats.py":632
 *           self.unbuffered_weights[idx] for idx in argsort
 *       ]
 *       self.buffers.append(             # <<<<<<<<<<<<<<
 *           _QuantileBuffer(
 *               self.unbuffered_elements, self.unbuffered_weights, weighted=True))
 */
    __pyx_t_9 = __Pyx_PyObject_Append(__pyx_v_self->buffers, __pyx_t_1); if (unlikely(__pyx_t_9 == ((int)-1))) __PYX_ERR(0, 632, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "apache_beam/transforms/stats.py":635
 *           _QuantileBuffer(
 *               self.unbuffered_elements, self.unbuffered_weights, weighted=True))
 *       self.unbuffered_weights = []             # <<<<<<<<<<<<<<
 *     elif self.unbuffered_elements:
 *       self.unbuffered_elements.sort(
 */
    __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 635, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_1);
    __Pyx_GOTREF(__pyx_v_self->unbuffered_weights);
    __Pyx_DECREF(__pyx_v_self->unbuffered_weights);
    __pyx_v_self->unbuffered_weights = __pyx_t_1;
    __pyx_t_1 = 0;

    /* "apache_beam/transforms/stats.py":620
 *     proper position since _collapse is not going to be called after.
 *     """
 *     if self.unbuffered_elements and self.spec.weighted:             # <<<<<<<<<<<<<<
 *       argsort_key = self.spec.get_argsort_key(self.unbuffered_elements)
 *       argsort = sorted(
 */
    goto __pyx_L3;
  }

  /* "apache_beam/transforms/stats.py":636
 *               self.unbuffered_elements, self.unbuffered_weights, weighted=True))
 *       self.unbuffered_weights = []
 *     elif self.unbuffered_elements:             # <<<<<<<<<<<<<<
 *       self.unbuffered_elements.sort(
 *           key=self.spec.key, reverse=self.spec.reverse)
 */
  __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_v_self->unbuffered_elements); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 636, __pyx_L1_error)
  if (__pyx_t_5) {

    /* "apache_beam/transforms/stats.py":637
 *       self.unbuffered_weights = []
 *     elif self.unbuffered_elements:
 *       self.unbuffered_elements.sort(             # <<<<<<<<<<<<<<
 *           key=self.spec.key, reverse=self.spec.reverse)
 *       self.buffers.append(
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->unbuffered_elements, __pyx_n_s_sort); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 637, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);

    /* "apache_beam/transforms/stats.py":638
 *     elif self.unbuffered_elements:
 *       self.unbuffered_elements.sort(
 *           key=self.spec.key, reverse=self.spec.reverse)             # <<<<<<<<<<<<<<
 *       self.buffers.append(
 *           _QuantileBuffer(
 */
    __pyx_t_2 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 638, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_key, __pyx_v_self->spec->key) < 0) __PYX_ERR(0, 638, __pyx_L1_error)
    __pyx_t_3 = __Pyx_PyBool_FromLong(__pyx_v_self->spec->reverse); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 638, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_reverse, __pyx_t_3) < 0) __PYX_ERR(0, 638, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "apache_beam/transforms/stats.py":637
 *       self.unbuffered_weights = []
 *     elif self.unbuffered_elements:
 *       self.unbuffered_elements.sort(             # <<<<<<<<<<<<<<
 *           key=self.spec.key, reverse=self.spec.reverse)
 *       self.buffers.append(
 */
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_empty_tuple, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 637, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "apache_beam/transforms/stats.py":640
 *           key=self.spec.key, reverse=self.spec.reverse)
 *       self.buffers.append(
 *           _QuantileBuffer(             # <<<<<<<<<<<<<<
 *               self.unbuffered_elements, weights=[1], weighted=False))
 *     self.unbuffered_elements = []
 */
    __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 640, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_v_self->unbuffered_elements);
    __Pyx_GIVEREF(__pyx_v_self->unbuffered_elements);
    PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_self->unbuffered_elements);

    /* "apache_beam/transforms/stats.py":641
 *       self.buffers.append(
 *           _QuantileBuffer(
 *               self.unbuffered_elements, weights=[1], weighted=False))             # <<<<<<<<<<<<<<
 *     self.unbuffered_elements = []
 * 
 */
    __pyx_t_2 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 641, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 641, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_int_1);
    __Pyx_GIVEREF(__pyx_int_1);
    PyList_SET_ITEM(__pyx_t_1, 0, __pyx_int_1);
    if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_weights, __pyx_t_1) < 0) __PYX_ERR(0, 641, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_weighted, Py_False) < 0) __PYX_ERR(0, 641, __pyx_L1_error)

    /* "apache_beam/transforms/stats.py":640
 *           key=self.spec.key, reverse=self.spec.reverse)
 *       self.buffers.append(
 *           _QuantileBuffer(             # <<<<<<<<<<<<<<
 *               self.unbuffered_elements, weights=[1], weighted=False))
 *     self.unbuffered_elements = []
 */
    __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_11apache_beam_10transforms_5stats__QuantileBuffer), __pyx_t_3, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 640, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "apache_beam/transforms/stats.py":639
 *       self.unbuffered_elements.sort(
 *           key=self.spec.key, reverse=self.spec.reverse)
 *       self.buffers.append(             # <<<<<<<<<<<<<<
 *           _QuantileBuffer(
 *               self.unbuffered_elements, weights=[1], weighted=False))
 */
    __pyx_t_9 = __Pyx_PyObject_Append(__pyx_v_self->buffers, __pyx_t_1); if (unlikely(__pyx_t_9 == ((int)-1))) __PYX_ERR(0, 639, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "apache_beam/transforms/stats.py":636
 *               self.unbuffered_elements, self.unbuffered_weights, weighted=True))
 *       self.unbuffered_weights = []
 *     elif self.unbuffered_elements:             # <<<<<<<<<<<<<<
 *       self.unbuffered_elements.sort(
 *           key=self.spec.key, reverse=self.spec.reverse)
 */
  }
  __pyx_L3:;

  /* "apache_beam/transforms/stats.py":642
 *           _QuantileBuffer(
 *               self.unbuffered_elements, weights=[1], weighted=False))
 *     self.unbuffered_elements = []             # <<<<<<<<<<<<<<
 * 
 *   def collapse_if_needed(self, offset_fn):
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 642, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->unbuffered_elements);
  __Pyx_DECREF(__pyx_v_self->unbuffered_elements);
  __pyx_v_self->unbuffered_elements = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "apache_beam/transforms/stats.py":612
 *     self.collapse_if_needed(offset_fn)
 * 
 *   def finalize(self):             # <<<<<<<<<<<<<<
 *     # type: () -> None
 * 
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("apache_beam.transforms.stats._QuantileState.finalize", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_argsort_key);
  __Pyx_XDECREF(__pyx_v_argsort);
  __Pyx_XDECREF(__pyx_8genexpr2__pyx_v_idx);
  __Pyx_XDECREF(__pyx_8genexpr3__pyx_v_idx);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_11apache_beam_10transforms_5stats_14_QuantileState_11finalize(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_11apache_beam_10transforms_5stats_14_QuantileState_10finalize[] = "\n    Creates a new buffer using all unbuffered elements. Called before\n    extracting an output. Note that the buffer doesn't have to be put in a\n    proper position since _collapse is not going to be called after.\n    ";
static PyMethodDef __pyx_mdef_11apache_beam_10transforms_5stats_14_QuantileState_11finalize = {"finalize", (PyCFunction)__pyx_pw_11apache_beam_10transforms_5stats_14_QuantileState_11finalize, METH_NOARGS, __pyx_doc_11apache_beam_10transforms_5stats_14_QuantileState_10finalize};
static PyObject *__pyx_pw_11apache_beam_10transforms_5stats_14_QuantileState_11finalize(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("finalize (wrapper)", 0);
  __pyx_r = __pyx_pf_11apache_beam_10transforms_5stats_14_QuantileState_10finalize(((struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileState *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_11apache_beam_10transforms_5stats_14_QuantileState_10finalize(struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileState *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("finalize", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_11apache_beam_10transforms_5stats_14_QuantileState_finalize(__pyx_v_self, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 612, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("apache_beam.transforms.stats._QuantileState.finalize", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "apache_beam/transforms/stats.py":644
 *     self.unbuffered_elements = []
 * 
 *   def collapse_if_needed(self, offset_fn):             # <<<<<<<<<<<<<<
 *     # type: (Any) -> None
 * 
 */

static PyObject *__pyx_pw_11apache_beam_10transforms_5stats_14_QuantileState_13collapse_if_needed(PyObject *__pyx_v_self, PyObject *__pyx_v_offset_fn); /*proto*/
static PyObject *__pyx_f_11apache_beam_10transforms_5stats_14_QuantileState_collapse_if_needed(struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileState *__pyx_v_self, PyObject *__pyx_v_offset_fn, int __pyx_skip_dispatch) {
  int64_t __pyx_v_min_level;
  PyObject *__pyx_v_to_collapse = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  Py_ssize_t __pyx_t_5;
  int __pyx_t_6;
  int64_t __pyx_t_7;
  int __pyx_t_8;
  int __pyx_t_9;
  int __pyx_t_10;
  PyObject *__pyx_t_11 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("collapse_if_needed", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely((Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) {
    #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    static PY_UINT64_T __pyx_tp_dict_version = __PYX_DICT_VERSION_INIT, __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
    if (unlikely(!__Pyx_object_dict_version_matches(((PyObject *)__pyx_v_self), __pyx_tp_dict_version, __pyx_obj_dict_version))) {
      PY_UINT64_T __pyx_type_dict_guard = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      #endif
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_collapse_if_needed); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 644, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_11apache_beam_10transforms_5stats_14_QuantileState_13collapse_if_needed)) {
        __Pyx_XDECREF(__pyx_r);
        __Pyx_INCREF(__pyx_t_1);
        __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
        if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
          __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
          if (likely(__pyx_t_4)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
            __Pyx_INCREF(__pyx_t_4);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_3, function);
          }
        }
        __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_4, __pyx_v_offset_fn) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_offset_fn);
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 644, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __pyx_r = __pyx_t_2;
        __pyx_t_2 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        goto __pyx_L0;
      }
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
      __pyx_tp_dict_version = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      __pyx_obj_dict_version = __Pyx_get_object_dict_version(((PyObject *)__pyx_v_self));
      if (unlikely(__pyx_type_dict_guard != __pyx_tp_dict_version)) {
        __pyx_tp_dict_version = __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
      }
      #endif
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    }
    #endif
  }

  /* "apache_beam/transforms/stats.py":651
 *     limit is restored.
 *     """
 *     while len(self.buffers) > self.spec.num_buffers:             # <<<<<<<<<<<<<<
 *       to_collapse = [heapq.heappop(self.buffers), heapq.heappop(self.buffers)]
 *       min_level = to_collapse[1].level
 */
  while (1) {
    __pyx_t_1 = __pyx_v_self->buffers;
    __Pyx_INCREF(__pyx_t_1);
    __pyx_t_5 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_5 == ((Py_ssize_t)-1))) __PYX_ERR(0, 651, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_6 = ((__pyx_t_5 > __pyx_v_self->spec->num_buffers) != 0);
    if (!__pyx_t_6) break;

    /* "apache_beam/transforms/stats.py":652
 *     """
 *     while len(self.buffers) > self.spec.num_buffers:
 *       to_collapse = [heapq.heappop(self.buffers), heapq.heappop(self.buffers)]             # <<<<<<<<<<<<<<
 *       min_level = to_collapse[1].level
 * 
 */
    __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_heapq); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 652, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_heappop); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 652, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
      __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
      if (likely(__pyx_t_2)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_2);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_3, function);
      }
    }
    __pyx_t_1 = (__pyx_t_2) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_2, __pyx_v_self->buffers) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_self->buffers);
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 652, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_heapq); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 652, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_heappop); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 652, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_2)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_2);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
      }
    }
    __pyx_t_3 = (__pyx_t_2) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_2, __pyx_v_self->buffers) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_v_self->buffers);
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 652, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = PyList_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 652, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_1);
    PyList_SET_ITEM(__pyx_t_4, 0, __pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_3);
    PyList_SET_ITEM(__pyx_t_4, 1, __pyx_t_3);
    __pyx_t_1 = 0;
    __pyx_t_3 = 0;
    __Pyx_XDECREF_SET(__pyx_v_to_collapse, ((PyObject*)__pyx_t_4));
    __pyx_t_4 = 0;

    /* "apache_beam/transforms/stats.py":653
 *     while len(self.buffers) > self.spec.num_buffers:
 *       to_collapse = [heapq.heappop(self.buffers), heapq.heappop(self.buffers)]
 *       min_level = to_collapse[1].level             # <<<<<<<<<<<<<<
 * 
 *       while self.buffers and self.buffers[0].level <= min_level:
 */
    __pyx_t_4 = __Pyx_GetItemInt_List(__pyx_v_to_collapse, 1, long, 1, __Pyx_PyInt_From_long, 1, 0, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 653, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_level); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 653, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_7 = __Pyx_PyInt_As_int64_t(__pyx_t_3); if (unlikely((__pyx_t_7 == ((int64_t)-1)) && PyErr_Occurred())) __PYX_ERR(0, 653, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_v_min_level = __pyx_t_7;

    /* "apache_beam/transforms/stats.py":655
 *       min_level = to_collapse[1].level
 * 
 *       while self.buffers and self.buffers[0].level <= min_level:             # <<<<<<<<<<<<<<
 *         to_collapse.append(heapq.heappop(self.buffers))
 * 
 */
    while (1) {
      __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_v_self->buffers); if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(0, 655, __pyx_L1_error)
      if (__pyx_t_8) {
      } else {
        __pyx_t_6 = __pyx_t_8;
        goto __pyx_L7_bool_binop_done;
      }
      __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_self->buffers, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 655, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_level); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 655, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_3 = __Pyx_PyInt_From_int64_t(__pyx_v_min_level); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 655, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_1 = PyObject_RichCompare(__pyx_t_4, __pyx_t_3, Py_LE); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 655, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(0, 655, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_6 = __pyx_t_8;
      __pyx_L7_bool_binop_done:;
      if (!__pyx_t_6) break;

      /* "apache_beam/transforms/stats.py":656
 * 
 *       while self.buffers and self.buffers[0].level <= min_level:
 *         to_collapse.append(heapq.heappop(self.buffers))             # <<<<<<<<<<<<<<
 * 
 *       heapq.heappush(self.buffers, _collapse(to_collapse, offset_fn, self.spec))
 */
      __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_heapq); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 656, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_heappop); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 656, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_3 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
        __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4);
        if (likely(__pyx_t_3)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
          __Pyx_INCREF(__pyx_t_3);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_4, function);
        }
      }
      __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_3, __pyx_v_self->buffers) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_v_self->buffers);
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 656, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_9 = __Pyx_PyList_Append(__pyx_v_to_collapse, __pyx_t_1); if (unlikely(__pyx_t_9 == ((int)-1))) __PYX_ERR(0, 656, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    }

    /* "apache_beam/transforms/stats.py":658
 *         to_collapse.append(heapq.heappop(self.buffers))
 * 
 *       heapq.heappush(self.buffers, _collapse(to_collapse, offset_fn, self.spec))             # <<<<<<<<<<<<<<
 * 
 * 
 */
    __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_heapq); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 658, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_heappush); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 658, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = ((PyObject *)__pyx_v_self->spec);
    __Pyx_INCREF(__pyx_t_4);
    __pyx_t_2 = ((PyObject *)__pyx_f_11apache_beam_10transforms_5stats__collapse(__pyx_v_to_collapse, __pyx_v_offset_fn, ((struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileSpec *)__pyx_t_4))); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 658, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = NULL;
    __pyx_t_10 = 0;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
      __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
      if (likely(__pyx_t_4)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_4);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_3, function);
        __pyx_t_10 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_3)) {
      PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_v_self->buffers, __pyx_t_2};
      __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_10, 2+__pyx_t_10); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 658, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
      PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_v_self->buffers, __pyx_t_2};
      __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_10, 2+__pyx_t_10); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 658, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    } else
    #endif
    {
      __pyx_t_11 = PyTuple_New(2+__pyx_t_10); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 658, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_11);
      if (__pyx_t_4) {
        __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_4); __pyx_t_4 = NULL;
      }
      __Pyx_INCREF(__pyx_v_self->buffers);
      __Pyx_GIVEREF(__pyx_v_self->buffers);
      PyTuple_SET_ITEM(__pyx_t_11, 0+__pyx_t_10, __pyx_v_self->buffers);
      __Pyx_GIVEREF(__pyx_t_2);
      PyTuple_SET_ITEM(__pyx_t_11, 1+__pyx_t_10, __pyx_t_2);
      __pyx_t_2 = 0;
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_11, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 658, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    }
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "apache_beam/transforms/stats.py":644
 *     self.unbuffered_elements = []
 * 
 *   def collapse_if_needed(self, offset_fn):             # <<<<<<<<<<<<<<
 *     # type: (Any) -> None
 * 
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_AddTraceback("apache_beam.transforms.stats._QuantileState.collapse_if_needed", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_to_collapse);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_11apache_beam_10transforms_5stats_14_QuantileState_13collapse_if_needed(PyObject *__pyx_v_self, PyObject *__pyx_v_offset_fn); /*proto*/
static char __pyx_doc_11apache_beam_10transforms_5stats_14_QuantileState_12collapse_if_needed[] = "\n    Checks if summary has too many buffers and collapses some of them until the\n    limit is restored.\n    ";
static PyMethodDef __pyx_mdef_11apache_beam_10transforms_5stats_14_QuantileState_13collapse_if_needed = {"collapse_if_needed", (PyCFunction)__pyx_pw_11apache_beam_10transforms_5stats_14_QuantileState_13collapse_if_needed, METH_O, __pyx_doc_11apache_beam_10transforms_5stats_14_QuantileState_12collapse_if_needed};
static PyObject *__pyx_pw_11apache_beam_10transforms_5stats_14_QuantileState_13collapse_if_needed(PyObject *__pyx_v_self, PyObject *__pyx_v_offset_fn) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("collapse_if_needed (wrapper)", 0);
  __pyx_r = __pyx_pf_11apache_beam_10transforms_5stats_14_QuantileState_12collapse_if_needed(((struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileState *)__pyx_v_self), ((PyObject *)__pyx_v_offset_fn));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_11apache_beam_10transforms_5stats_14_QuantileState_12collapse_if_needed(struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileState *__pyx_v_self, PyObject *__pyx_v_offset_fn) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("collapse_if_needed", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_11apache_beam_10transforms_5stats_14_QuantileState_collapse_if_needed(__pyx_v_self, __pyx_v_offset_fn, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 644, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("apache_beam.transforms.stats._QuantileState.collapse_if_needed", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "apache_beam/transforms/stats.pxd":40
 * 
 * cdef class _QuantileState(object):
 *   cdef readonly _QuantileSpec spec             # <<<<<<<<<<<<<<
 *   cdef public buffers
 *   cdef public unbuffered_elements
 */

/* Python wrapper */
static PyObject *__pyx_pw_11apache_beam_10transforms_5stats_14_QuantileState_4spec_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_11apache_beam_10transforms_5stats_14_QuantileState_4spec_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_11apache_beam_10transforms_5stats_14_QuantileState_4spec___get__(((struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileState *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_11apache_beam_10transforms_5stats_14_QuantileState_4spec___get__(struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileState *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->spec));
  __pyx_r = ((PyObject *)__pyx_v_self->spec);
  goto __pyx_L0;

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "apache_beam/transforms/stats.pxd":41
 * cdef class _QuantileState(object):
 *   cdef readonly _QuantileSpec spec
 *   cdef public buffers             # <<<<<<<<<<<<<<
 *   cdef public unbuffered_elements
 *   cdef public unbuffered_weights
 */

/* Python wrapper */
static PyObject *__pyx_pw_11apache_beam_10transforms_5stats_14_QuantileState_7buffers_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_11apache_beam_10transforms_5stats_14_QuantileState_7buffers_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_11apache_beam_10transforms_5stats_14_QuantileState_7buffers___get__(((struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileState *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_11apache_beam_10transforms_5stats_14_QuantileState_7buffers___get__(struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileState *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_self->buffers);
  __pyx_r = __pyx_v_self->buffers;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_11apache_beam_10transforms_5stats_14_QuantileState_7buffers_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
static int __pyx_pw_11apache_beam_10transforms_5stats_14_QuantileState_7buffers_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  __pyx_r = __pyx_pf_11apache_beam_10transforms_5stats_14_QuantileState_7buffers_2__set__(((struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileState *)__pyx_v_self), ((PyObject *)__pyx_v_value));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_11apache_beam_10transforms_5stats_14_QuantileState_7buffers_2__set__(struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileState *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__", 0);
  __Pyx_INCREF(__pyx_v_value);
  __Pyx_GIVEREF(__pyx_v_value);
  __Pyx_GOTREF(__pyx_v_self->buffers);
  __Pyx_DECREF(__pyx_v_self->buffers);
  __pyx_v_self->buffers = __pyx_v_value;

  /* function exit code */
  __pyx_r = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_11apache_beam_10transforms_5stats_14_QuantileState_7buffers_5__del__(PyObject *__pyx_v_self); /*proto*/
static int __pyx_pw_11apache_beam_10transforms_5stats_14_QuantileState_7buffers_5__del__(PyObject *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__ (wrapper)", 0);
  __pyx_r = __pyx_pf_11apache_beam_10transforms_5stats_14_QuantileState_7buffers_4__del__(((struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileState *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_11apache_beam_10transforms_5stats_14_QuantileState_7buffers_4__del__(struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileState *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__", 0);
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->buffers);
  __Pyx_DECREF(__pyx_v_self->buffers);
  __pyx_v_self->buffers = Py_None;

  /* function exit code */
  __pyx_r = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "apache_beam/transforms/stats.pxd":42
 *   cdef readonly _QuantileSpec spec
 *   cdef public buffers
 *   cdef public unbuffered_elements             # <<<<<<<<<<<<<<
 *   cdef public unbuffered_weights
 *   cdef public add_unbuffered
 */

/* Python wrapper */
static PyObject *__pyx_pw_11apache_beam_10transforms_5stats_14_QuantileState_19unbuffered_elements_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_11apache_beam_10transforms_5stats_14_QuantileState_19unbuffered_elements_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_11apache_beam_10transforms_5stats_14_QuantileState_19unbuffered_elements___get__(((struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileState *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_11apache_beam_10transforms_5stats_14_QuantileState_19unbuffered_elements___get__(struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileState *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_self->unbuffered_elements);
  __pyx_r = __pyx_v_self->unbuffered_elements;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_11apache_beam_10transforms_5stats_14_QuantileState_19unbuffered_elements_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
static int __pyx_pw_11apache_beam_10transforms_5stats_14_QuantileState_19unbuffered_elements_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  __pyx_r = __pyx_pf_11apache_beam_10transforms_5stats_14_QuantileState_19unbuffered_elements_2__set__(((struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileState *)__pyx_v_self), ((PyObject *)__pyx_v_value));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_11apache_beam_10transforms_5stats_14_QuantileState_19unbuffered_elements_2__set__(struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileState *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__", 0);
  __Pyx_INCREF(__pyx_v_value);
  __Pyx_GIVEREF(__pyx_v_value);
  __Pyx_GOTREF(__pyx_v_self->unbuffered_elements);
  __Pyx_DECREF(__pyx_v_self->unbuffered_elements);
  __pyx_v_self->unbuffered_elements = __pyx_v_value;

  /* function exit code */
  __pyx_r = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_11apache_beam_10transforms_5stats_14_QuantileState_19unbuffered_elements_5__del__(PyObject *__pyx_v_self); /*proto*/
static int __pyx_pw_11apache_beam_10transforms_5stats_14_QuantileState_19unbuffered_elements_5__del__(PyObject *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__ (wrapper)", 0);
  __pyx_r = __pyx_pf_11apache_beam_10transforms_5stats_14_QuantileState_19unbuffered_elements_4__del__(((struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileState *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_11apache_beam_10transforms_5stats_14_QuantileState_19unbuffered_elements_4__del__(struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileState *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__", 0);
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->unbuffered_elements);
  __Pyx_DECREF(__pyx_v_self->unbuffered_elements);
  __pyx_v_self->unbuffered_elements = Py_None;

  /* function exit code */
  __pyx_r = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "apache_beam/transforms/stats.pxd":43
 *   cdef public buffers
 *   cdef public unbuffered_elements
 *   cdef public unbuffered_weights             # <<<<<<<<<<<<<<
 *   cdef public add_unbuffered
 *   cpdef bint is_empty(self)
 */

/* Python wrapper */
static PyObject *__pyx_pw_11apache_beam_10transforms_5stats_14_QuantileState_18unbuffered_weights_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_11apache_beam_10transforms_5stats_14_QuantileState_18unbuffered_weights_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_11apache_beam_10transforms_5stats_14_QuantileState_18unbuffered_weights___get__(((struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileState *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_11apache_beam_10transforms_5stats_14_QuantileState_18unbuffered_weights___get__(struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileState *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_self->unbuffered_weights);
  __pyx_r = __pyx_v_self->unbuffered_weights;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_11apache_beam_10transforms_5stats_14_QuantileState_18unbuffered_weights_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
static int __pyx_pw_11apache_beam_10transforms_5stats_14_QuantileState_18unbuffered_weights_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  __pyx_r = __pyx_pf_11apache_beam_10transforms_5stats_14_QuantileState_18unbuffered_weights_2__set__(((struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileState *)__pyx_v_self), ((PyObject *)__pyx_v_value));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_11apache_beam_10transforms_5stats_14_QuantileState_18unbuffered_weights_2__set__(struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileState *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__", 0);
  __Pyx_INCREF(__pyx_v_value);
  __Pyx_GIVEREF(__pyx_v_value);
  __Pyx_GOTREF(__pyx_v_self->unbuffered_weights);
  __Pyx_DECREF(__pyx_v_self->unbuffered_weights);
  __pyx_v_self->unbuffered_weights = __pyx_v_value;

  /* function exit code */
  __pyx_r = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_11apache_beam_10transforms_5stats_14_QuantileState_18unbuffered_weights_5__del__(PyObject *__pyx_v_self); /*proto*/
static int __pyx_pw_11apache_beam_10transforms_5stats_14_QuantileState_18unbuffered_weights_5__del__(PyObject *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__ (wrapper)", 0);
  __pyx_r = __pyx_pf_11apache_beam_10transforms_5stats_14_QuantileState_18unbuffered_weights_4__del__(((struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileState *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_11apache_beam_10transforms_5stats_14_QuantileState_18unbuffered_weights_4__del__(struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileState *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__", 0);
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->unbuffered_weights);
  __Pyx_DECREF(__pyx_v_self->unbuffered_weights);
  __pyx_v_self->unbuffered_weights = Py_None;

  /* function exit code */
  __pyx_r = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "apache_beam/transforms/stats.pxd":44
 *   cdef public unbuffered_elements
 *   cdef public unbuffered_weights
 *   cdef public add_unbuffered             # <<<<<<<<<<<<<<
 *   cpdef bint is_empty(self)
 *   @cython.locals(num_new_buffers=int64_t, idx=int64_t)
 */

/* Python wrapper */
static PyObject *__pyx_pw_11apache_beam_10transforms_5stats_14_QuantileState_14add_unbuffered_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_11apache_beam_10transforms_5stats_14_QuantileState_14add_unbuffered_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_11apache_beam_10transforms_5stats_14_QuantileState_14add_unbuffered___get__(((struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileState *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_11apache_beam_10transforms_5stats_14_QuantileState_14add_unbuffered___get__(struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileState *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_self->add_unbuffered);
  __pyx_r = __pyx_v_self->add_unbuffered;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_11apache_beam_10transforms_5stats_14_QuantileState_14add_unbuffered_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
static int __pyx_pw_11apache_beam_10transforms_5stats_14_QuantileState_14add_unbuffered_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  __pyx_r = __pyx_pf_11apache_beam_10transforms_5stats_14_QuantileState_14add_unbuffered_2__set__(((struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileState *)__pyx_v_self), ((PyObject *)__pyx_v_value));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_11apache_beam_10transforms_5stats_14_QuantileState_14add_unbuffered_2__set__(struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileState *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__", 0);
  __Pyx_INCREF(__pyx_v_value);
  __Pyx_GIVEREF(__pyx_v_value);
  __Pyx_GOTREF(__pyx_v_self->add_unbuffered);
  __Pyx_DECREF(__pyx_v_self->add_unbuffered);
  __pyx_v_self->add_unbuffered = __pyx_v_value;

  /* function exit code */
  __pyx_r = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_11apache_beam_10transforms_5stats_14_QuantileState_14add_unbuffered_5__del__(PyObject *__pyx_v_self); /*proto*/
static int __pyx_pw_11apache_beam_10transforms_5stats_14_QuantileState_14add_unbuffered_5__del__(PyObject *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__ (wrapper)", 0);
  __pyx_r = __pyx_pf_11apache_beam_10transforms_5stats_14_QuantileState_14add_unbuffered_4__del__(((struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileState *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_11apache_beam_10transforms_5stats_14_QuantileState_14add_unbuffered_4__del__(struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileState *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__", 0);
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->add_unbuffered);
  __Pyx_DECREF(__pyx_v_self->add_unbuffered);
  __pyx_v_self->add_unbuffered = Py_None;

  /* function exit code */
  __pyx_r = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "apache_beam/transforms/stats.py":661
 * 
 * 
 * def _collapse(buffers, offset_fn, spec):             # <<<<<<<<<<<<<<
 *   # type: (List[_QuantileBuffer], Any, _QuantileSpec) -> _QuantileBuffer
 * 
 */

static struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileBuffer *__pyx_f_11apache_beam_10transforms_5stats__collapse(PyObject *__pyx_v_buffers, PyObject *__pyx_v_offset_fn, struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileSpec *__pyx_v_spec) {
  int64_t __pyx_v_new_level;
  double __pyx_v_new_weight;
  double __pyx_v_step;
  double __pyx_v_offset;
  PyObject *__pyx_v_buffer = NULL;
  PyObject *__pyx_v_new_elements = NULL;
  PyObject *__pyx_v_new_weights = NULL;
  PyObject *__pyx_v_min_val = NULL;
  PyObject *__pyx_v_max_val = NULL;
  struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileBuffer *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  PyObject *(*__pyx_t_3)(PyObject *);
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int64_t __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  int __pyx_t_9;
  double __pyx_t_10;
  PyObject *__pyx_t_11 = NULL;
  PyObject *(*__pyx_t_12)(PyObject *);
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_collapse", 0);

  /* "apache_beam/transforms/stats.py":667
 *   Approximates elements from multiple buffers and produces a single buffer.
 *   """
 *   new_level = 0             # <<<<<<<<<<<<<<
 *   new_weight = 0
 *   for buffer in buffers:
 */
  __pyx_v_new_level = 0;

  /* "apache_beam/transforms/stats.py":668
 *   """
 *   new_level = 0
 *   new_weight = 0             # <<<<<<<<<<<<<<
 *   for buffer in buffers:
 *     # As presented in the paper, there should always be at least two
 */
  __pyx_v_new_weight = 0.0;

  /* "apache_beam/transforms/stats.py":669
 *   new_level = 0
 *   new_weight = 0
 *   for buffer in buffers:             # <<<<<<<<<<<<<<
 *     # As presented in the paper, there should always be at least two
 *     # buffers of the same (minimal) level to collapse, but it is possible
 */
  if (likely(PyList_CheckExact(__pyx_v_buffers)) || PyTuple_CheckExact(__pyx_v_buffers)) {
    __pyx_t_1 = __pyx_v_buffers; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0;
    __pyx_t_3 = NULL;
  } else {
    __pyx_t_2 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_buffers); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 669, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 669, __pyx_L1_error)
  }
  for (;;) {
    if (likely(!__pyx_t_3)) {
      if (likely(PyList_CheckExact(__pyx_t_1))) {
        if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_4 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(0, 669, __pyx_L1_error)
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 669, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        #endif
      } else {
        if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(0, 669, __pyx_L1_error)
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 669, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        #endif
      }
    } else {
      __pyx_t_4 = __pyx_t_3(__pyx_t_1);
      if (unlikely(!__pyx_t_4)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(0, 669, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_4);
    }
    __Pyx_XDECREF_SET(__pyx_v_buffer, __pyx_t_4);
    __pyx_t_4 = 0;

    /* "apache_beam/transforms/stats.py":674
 *     # to violate this condition when combining buffers from independently
 *     # computed shards. If they differ we take the max.
 *     new_level = max([new_level, buffer.level + 1])             # <<<<<<<<<<<<<<
 *     new_weight = new_weight + sum(buffer.weights)
 *   if spec.weighted:
 */
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_buffer, __pyx_n_s_level); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 674, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = __Pyx_PyInt_AddObjC(__pyx_t_4, __pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 674, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_6 = __pyx_v_new_level;
    __pyx_t_7 = __Pyx_PyInt_From_int64_t(__pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 674, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_8 = PyObject_RichCompare(__pyx_t_5, __pyx_t_7, Py_GT); __Pyx_XGOTREF(__pyx_t_8); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 674, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_8); if (unlikely(__pyx_t_9 < 0)) __PYX_ERR(0, 674, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    if (__pyx_t_9) {
      __Pyx_INCREF(__pyx_t_5);
      __pyx_t_4 = __pyx_t_5;
    } else {
      __pyx_t_8 = __Pyx_PyInt_From_int64_t(__pyx_t_6); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 674, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_4 = __pyx_t_8;
      __pyx_t_8 = 0;
    }
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_6 = __Pyx_PyInt_As_int64_t(__pyx_t_4); if (unlikely((__pyx_t_6 == ((int64_t)-1)) && PyErr_Occurred())) __PYX_ERR(0, 674, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_v_new_level = __pyx_t_6;

    /* "apache_beam/transforms/stats.py":675
 *     # computed shards. If they differ we take the max.
 *     new_level = max([new_level, buffer.level + 1])
 *     new_weight = new_weight + sum(buffer.weights)             # <<<<<<<<<<<<<<
 *   if spec.weighted:
 *     step = new_weight / (spec.buffer_size - 1)
 */
    __pyx_t_4 = PyFloat_FromDouble(__pyx_v_new_weight); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 675, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_buffer, __pyx_n_s_weights); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 675, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_8 = __Pyx_PyObject_CallOneArg(__pyx_builtin_sum, __pyx_t_5); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 675, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = PyNumber_Add(__pyx_t_4, __pyx_t_8); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 675, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __pyx_t_10 = __pyx_PyFloat_AsDouble(__pyx_t_5); if (unlikely((__pyx_t_10 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 675, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_v_new_weight = __pyx_t_10;

    /* "apache_beam/transforms/stats.py":669
 *   new_level = 0
 *   new_weight = 0
 *   for buffer in buffers:             # <<<<<<<<<<<<<<
 *     # As presented in the paper, there should always be at least two
 *     # buffers of the same (minimal) level to collapse, but it is possible
 */
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "apache_beam/transforms/stats.py":676
 *     new_level = max([new_level, buffer.level + 1])
 *     new_weight = new_weight + sum(buffer.weights)
 *   if spec.weighted:             # <<<<<<<<<<<<<<
 *     step = new_weight / (spec.buffer_size - 1)
 *     offset = new_weight / (2 * spec.buffer_size)
 */
  __pyx_t_9 = (__pyx_v_spec->weighted != 0);
  if (__pyx_t_9) {

    /* "apache_beam/transforms/stats.py":677
 *     new_weight = new_weight + sum(buffer.weights)
 *   if spec.weighted:
 *     step = new_weight / (spec.buffer_size - 1)             # <<<<<<<<<<<<<<
 *     offset = new_weight / (2 * spec.buffer_size)
 *   else:
 */
    __pyx_t_6 = (__pyx_v_spec->buffer_size - 1);
    if (unlikely(__pyx_t_6 == 0)) {
      PyErr_SetString(PyExc_ZeroDivisionError, "float division");
      __PYX_ERR(0, 677, __pyx_L1_error)
    }
    __pyx_v_step = (__pyx_v_new_weight / ((double)__pyx_t_6));

    /* "apache_beam/transforms/stats.py":678
 *   if spec.weighted:
 *     step = new_weight / (spec.buffer_size - 1)
 *     offset = new_weight / (2 * spec.buffer_size)             # <<<<<<<<<<<<<<
 *   else:
 *     step = new_weight
 */
    __pyx_t_6 = (2 * __pyx_v_spec->buffer_size);
    if (unlikely(__pyx_t_6 == 0)) {
      PyErr_SetString(PyExc_ZeroDivisionError, "float division");
      __PYX_ERR(0, 678, __pyx_L1_error)
    }
    __pyx_v_offset = (__pyx_v_new_weight / ((double)__pyx_t_6));

    /* "apache_beam/transforms/stats.py":676
 *     new_level = max([new_level, buffer.level + 1])
 *     new_weight = new_weight + sum(buffer.weights)
 *   if spec.weighted:             # <<<<<<<<<<<<<<
 *     step = new_weight / (spec.buffer_size - 1)
 *     offset = new_weight / (2 * spec.buffer_size)
 */
    goto __pyx_L5;
  }

  /* "apache_beam/transforms/stats.py":680
 *     offset = new_weight / (2 * spec.buffer_size)
 *   else:
 *     step = new_weight             # <<<<<<<<<<<<<<
 *     offset = offset_fn(new_weight)
 *   new_elements, new_weights, min_val, max_val = \
 */
  /*else*/ {
    __pyx_v_step = __pyx_v_new_weight;

    /* "apache_beam/transforms/stats.py":681
 *   else:
 *     step = new_weight
 *     offset = offset_fn(new_weight)             # <<<<<<<<<<<<<<
 *   new_elements, new_weights, min_val, max_val = \
 *       _interpolate(buffers, spec.buffer_size, step, offset, spec)
 */
    __pyx_t_5 = PyFloat_FromDouble(__pyx_v_new_weight); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 681, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_INCREF(__pyx_v_offset_fn);
    __pyx_t_8 = __pyx_v_offset_fn; __pyx_t_4 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_8))) {
      __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_8);
      if (likely(__pyx_t_4)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
        __Pyx_INCREF(__pyx_t_4);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_8, function);
      }
    }
    __pyx_t_1 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_8, __pyx_t_4, __pyx_t_5) : __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_t_5);
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 681, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __pyx_t_10 = __pyx_PyFloat_AsDouble(__pyx_t_1); if (unlikely((__pyx_t_10 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 681, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_v_offset = __pyx_t_10;
  }
  __pyx_L5:;

  /* "apache_beam/transforms/stats.py":683
 *     offset = offset_fn(new_weight)
 *   new_elements, new_weights, min_val, max_val = \
 *       _interpolate(buffers, spec.buffer_size, step, offset, spec)             # <<<<<<<<<<<<<<
 *   if not spec.weighted:
 *     new_weights = [new_weight]
 */
  __pyx_t_1 = __pyx_f_11apache_beam_10transforms_5stats__interpolate(__pyx_v_buffers, __pyx_v_spec->buffer_size, __pyx_v_step, __pyx_v_offset, __pyx_v_spec); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 683, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if ((likely(PyTuple_CheckExact(__pyx_t_1))) || (PyList_CheckExact(__pyx_t_1))) {
    PyObject* sequence = __pyx_t_1;
    Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
    if (unlikely(size != 4)) {
      if (size > 4) __Pyx_RaiseTooManyValuesError(4);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      __PYX_ERR(0, 682, __pyx_L1_error)
    }
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    if (likely(PyTuple_CheckExact(sequence))) {
      __pyx_t_8 = PyTuple_GET_ITEM(sequence, 0); 
      __pyx_t_5 = PyTuple_GET_ITEM(sequence, 1); 
      __pyx_t_4 = PyTuple_GET_ITEM(sequence, 2); 
      __pyx_t_7 = PyTuple_GET_ITEM(sequence, 3); 
    } else {
      __pyx_t_8 = PyList_GET_ITEM(sequence, 0); 
      __pyx_t_5 = PyList_GET_ITEM(sequence, 1); 
      __pyx_t_4 = PyList_GET_ITEM(sequence, 2); 
      __pyx_t_7 = PyList_GET_ITEM(sequence, 3); 
    }
    __Pyx_INCREF(__pyx_t_8);
    __Pyx_INCREF(__pyx_t_5);
    __Pyx_INCREF(__pyx_t_4);
    __Pyx_INCREF(__pyx_t_7);
    #else
    {
      Py_ssize_t i;
      PyObject** temps[4] = {&__pyx_t_8,&__pyx_t_5,&__pyx_t_4,&__pyx_t_7};
      for (i=0; i < 4; i++) {
        PyObject* item = PySequence_ITEM(sequence, i); if (unlikely(!item)) __PYX_ERR(0, 682, __pyx_L1_error)
        __Pyx_GOTREF(item);
        *(temps[i]) = item;
      }
    }
    #endif
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  } else {
    Py_ssize_t index = -1;
    PyObject** temps[4] = {&__pyx_t_8,&__pyx_t_5,&__pyx_t_4,&__pyx_t_7};
    __pyx_t_11 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 682, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_11);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_12 = Py_TYPE(__pyx_t_11)->tp_iternext;
    for (index=0; index < 4; index++) {
      PyObject* item = __pyx_t_12(__pyx_t_11); if (unlikely(!item)) goto __pyx_L6_unpacking_failed;
      __Pyx_GOTREF(item);
      *(temps[index]) = item;
    }
    if (__Pyx_IternextUnpackEndCheck(__pyx_t_12(__pyx_t_11), 4) < 0) __PYX_ERR(0, 682, __pyx_L1_error)
    __pyx_t_12 = NULL;
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    goto __pyx_L7_unpacking_done;
    __pyx_L6_unpacking_failed:;
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    __pyx_t_12 = NULL;
    if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
    __PYX_ERR(0, 682, __pyx_L1_error)
    __pyx_L7_unpacking_done:;
  }

  /* "apache_beam/transforms/stats.py":682
 *     step = new_weight
 *     offset = offset_fn(new_weight)
 *   new_elements, new_weights, min_val, max_val = \             # <<<<<<<<<<<<<<
 *       _interpolate(buffers, spec.buffer_size, step, offset, spec)
 *   if not spec.weighted:
 */
  __pyx_v_new_elements = __pyx_t_8;
  __pyx_t_8 = 0;
  __pyx_v_new_weights = __pyx_t_5;
  __pyx_t_5 = 0;
  __pyx_v_min_val = __pyx_t_4;
  __pyx_t_4 = 0;
  __pyx_v_max_val = __pyx_t_7;
  __pyx_t_7 = 0;

  /* "apache_beam/transforms/stats.py":684
 *   new_elements, new_weights, min_val, max_val = \
 *       _interpolate(buffers, spec.buffer_size, step, offset, spec)
 *   if not spec.weighted:             # <<<<<<<<<<<<<<
 *     new_weights = [new_weight]
 *   return _QuantileBuffer(
 */
  __pyx_t_9 = ((!(__pyx_v_spec->weighted != 0)) != 0);
  if (__pyx_t_9) {

    /* "apache_beam/transforms/stats.py":685
 *       _interpolate(buffers, spec.buffer_size, step, offset, spec)
 *   if not spec.weighted:
 *     new_weights = [new_weight]             # <<<<<<<<<<<<<<
 *   return _QuantileBuffer(
 *       new_elements, new_weights, spec.weighted, new_level, min_val, max_val)
 */
    __pyx_t_1 = PyFloat_FromDouble(__pyx_v_new_weight); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 685, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_7 = PyList_New(1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 685, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_GIVEREF(__pyx_t_1);
    PyList_SET_ITEM(__pyx_t_7, 0, __pyx_t_1);
    __pyx_t_1 = 0;
    __Pyx_DECREF_SET(__pyx_v_new_weights, __pyx_t_7);
    __pyx_t_7 = 0;

    /* "apache_beam/transforms/stats.py":684
 *   new_elements, new_weights, min_val, max_val = \
 *       _interpolate(buffers, spec.buffer_size, step, offset, spec)
 *   if not spec.weighted:             # <<<<<<<<<<<<<<
 *     new_weights = [new_weight]
 *   return _QuantileBuffer(
 */
  }

  /* "apache_beam/transforms/stats.py":686
 *   if not spec.weighted:
 *     new_weights = [new_weight]
 *   return _QuantileBuffer(             # <<<<<<<<<<<<<<
 *       new_elements, new_weights, spec.weighted, new_level, min_val, max_val)
 * 
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));

  /* "apache_beam/transforms/stats.py":687
 *     new_weights = [new_weight]
 *   return _QuantileBuffer(
 *       new_elements, new_weights, spec.weighted, new_level, min_val, max_val)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_7 = __Pyx_PyBool_FromLong(__pyx_v_spec->weighted); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 687, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_1 = __Pyx_PyInt_From_int64_t(__pyx_v_new_level); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 687, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);

  /* "apache_beam/transforms/stats.py":686
 *   if not spec.weighted:
 *     new_weights = [new_weight]
 *   return _QuantileBuffer(             # <<<<<<<<<<<<<<
 *       new_elements, new_weights, spec.weighted, new_level, min_val, max_val)
 * 
 */
  __pyx_t_4 = PyTuple_New(6); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 686, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(__pyx_v_new_elements);
  __Pyx_GIVEREF(__pyx_v_new_elements);
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_new_elements);
  __Pyx_INCREF(__pyx_v_new_weights);
  __Pyx_GIVEREF(__pyx_v_new_weights);
  PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_v_new_weights);
  __Pyx_GIVEREF(__pyx_t_7);
  PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_t_7);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_4, 3, __pyx_t_1);
  __Pyx_INCREF(__pyx_v_min_val);
  __Pyx_GIVEREF(__pyx_v_min_val);
  PyTuple_SET_ITEM(__pyx_t_4, 4, __pyx_v_min_val);
  __Pyx_INCREF(__pyx_v_max_val);
  __Pyx_GIVEREF(__pyx_v_max_val);
  PyTuple_SET_ITEM(__pyx_t_4, 5, __pyx_v_max_val);
  __pyx_t_7 = 0;
  __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_11apache_beam_10transforms_5stats__QuantileBuffer), __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 686, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_r = ((struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileBuffer *)__pyx_t_1);
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "apache_beam/transforms/stats.py":661
 * 
 * 
 * def _collapse(buffers, offset_fn, spec):             # <<<<<<<<<<<<<<
 *   # type: (List[_QuantileBuffer], Any, _QuantileSpec) -> _QuantileBuffer
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_AddTraceback("apache_beam.transforms.stats._collapse", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_buffer);
  __Pyx_XDECREF(__pyx_v_new_elements);
  __Pyx_XDECREF(__pyx_v_new_weights);
  __Pyx_XDECREF(__pyx_v_min_val);
  __Pyx_XDECREF(__pyx_v_max_val);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "apache_beam/transforms/stats.py":690
 * 
 * 
 * def _interpolate(buffers, count, step, offset, spec):             # <<<<<<<<<<<<<<
 *   # type: (List[_QuantileBuffer], int, float, float, _QuantileSpec) -> Tuple[List, List, Any, Any]
 * 
 */

static PyObject *__pyx_f_11apache_beam_10transforms_5stats__interpolate(PyObject *__pyx_v_buffers, int64_t __pyx_v_count, double __pyx_v_step, double __pyx_v_offset, struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileSpec *__pyx_v_spec) {
  int64_t __pyx_v_j;
  PyObject *__pyx_v_buffer_iterators = NULL;
  PyObject *__pyx_v_min_val = NULL;
  PyObject *__pyx_v_max_val = NULL;
  PyObject *__pyx_v_buffer = NULL;
  PyObject *__pyx_v_sorted_elements = NULL;
  int __pyx_v_buffers_have_same_weight;
  PyObject *__pyx_v_weight = NULL;
  Py_ssize_t __pyx_v_max_idx;
  PyObject *__pyx_v_result = NULL;
  PyObject *__pyx_v_sorted_elements_iter = NULL;
  PyObject *__pyx_v_weighted_element = NULL;
  PyObject *__pyx_v_new_elements = NULL;
  PyObject *__pyx_v_new_weights = NULL;
  PyObject *__pyx_v_current_weight = NULL;
  PyObject *__pyx_v_previous_weight = NULL;
  double __pyx_v_target_weight;
  int64_t __pyx_8genexpr4__pyx_v_j;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  Py_ssize_t __pyx_t_3;
  PyObject *(*__pyx_t_4)(PyObject *);
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  int __pyx_t_9;
  PyObject *__pyx_t_10 = NULL;
  int __pyx_t_11;
  int __pyx_t_12;
  double __pyx_t_13;
  int64_t __pyx_t_14;
  int64_t __pyx_t_15;
  int64_t __pyx_t_16;
  PyObject *__pyx_t_17 = NULL;
  PyObject *__pyx_t_18 = NULL;
  PyObject *__pyx_t_19 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_interpolate", 0);

  /* "apache_beam/transforms/stats.py":698
 *   of this list for `0 <= k < count`.
 *   """
 *   buffer_iterators = []             # <<<<<<<<<<<<<<
 *   min_val = buffers[0].min_val
 *   max_val = buffers[0].max_val
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 698, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_buffer_iterators = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "apache_beam/transforms/stats.py":699
 *   """
 *   buffer_iterators = []
 *   min_val = buffers[0].min_val             # <<<<<<<<<<<<<<
 *   max_val = buffers[0].max_val
 *   for buffer in buffers:
 */
  __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_buffers, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 699, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_min_val); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 699, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_min_val = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "apache_beam/transforms/stats.py":700
 *   buffer_iterators = []
 *   min_val = buffers[0].min_val
 *   max_val = buffers[0].max_val             # <<<<<<<<<<<<<<
 *   for buffer in buffers:
 *     # Calculate extreme values for the union of buffers.
 */
  __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_buffers, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 700, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_max_val); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 700, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_max_val = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "apache_beam/transforms/stats.py":701
 *   min_val = buffers[0].min_val
 *   max_val = buffers[0].max_val
 *   for buffer in buffers:             # <<<<<<<<<<<<<<
 *     # Calculate extreme values for the union of buffers.
 *     min_val = buffer.min_val if spec.less_than(
 */
  if (likely(PyList_CheckExact(__pyx_v_buffers)) || PyTuple_CheckExact(__pyx_v_buffers)) {
    __pyx_t_1 = __pyx_v_buffers; __Pyx_INCREF(__pyx_t_1); __pyx_t_3 = 0;
    __pyx_t_4 = NULL;
  } else {
    __pyx_t_3 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_buffers); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 701, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 701, __pyx_L1_error)
  }
  for (;;) {
    if (likely(!__pyx_t_4)) {
      if (likely(PyList_CheckExact(__pyx_t_1))) {
        if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_2 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_3); __Pyx_INCREF(__pyx_t_2); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(0, 701, __pyx_L1_error)
        #else
        __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 701, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        #endif
      } else {
        if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_3); __Pyx_INCREF(__pyx_t_2); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(0, 701, __pyx_L1_error)
        #else
        __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 701, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        #endif
      }
    } else {
      __pyx_t_2 = __pyx_t_4(__pyx_t_1);
      if (unlikely(!__pyx_t_2)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(0, 701, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_2);
    }
    __Pyx_XDECREF_SET(__pyx_v_buffer, __pyx_t_2);
    __pyx_t_2 = 0;

    /* "apache_beam/transforms/stats.py":704
 *     # Calculate extreme values for the union of buffers.
 *     min_val = buffer.min_val if spec.less_than(
 *         buffer.min_val, min_val) else min_val             # <<<<<<<<<<<<<<
 *     max_val = buffer.max_val if spec.less_than(
 *         max_val, buffer.max_val) else max_val
 */
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_buffer, __pyx_n_s_min_val); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 704, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_INCREF(__pyx_v_spec->less_than);
    __pyx_t_7 = __pyx_v_spec->less_than; __pyx_t_8 = NULL;
    __pyx_t_9 = 0;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_7))) {
      __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_7);
      if (likely(__pyx_t_8)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
        __Pyx_INCREF(__pyx_t_8);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_7, function);
        __pyx_t_9 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_7)) {
      PyObject *__pyx_temp[3] = {__pyx_t_8, __pyx_t_6, __pyx_v_min_val};
      __pyx_t_5 = __Pyx_PyFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 703, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_7)) {
      PyObject *__pyx_temp[3] = {__pyx_t_8, __pyx_t_6, __pyx_v_min_val};
      __pyx_t_5 = __Pyx_PyCFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 703, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    } else
    #endif
    {
      __pyx_t_10 = PyTuple_New(2+__pyx_t_9); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 703, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      if (__pyx_t_8) {
        __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_8); __pyx_t_8 = NULL;
      }
      __Pyx_GIVEREF(__pyx_t_6);
      PyTuple_SET_ITEM(__pyx_t_10, 0+__pyx_t_9, __pyx_t_6);
      __Pyx_INCREF(__pyx_v_min_val);
      __Pyx_GIVEREF(__pyx_v_min_val);
      PyTuple_SET_ITEM(__pyx_t_10, 1+__pyx_t_9, __pyx_v_min_val);
      __pyx_t_6 = 0;
      __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_10, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 703, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    }
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

    /* "apache_beam/transforms/stats.py":703
 *   for buffer in buffers:
 *     # Calculate extreme values for the union of buffers.
 *     min_val = buffer.min_val if spec.less_than(             # <<<<<<<<<<<<<<
 *         buffer.min_val, min_val) else min_val
 *     max_val = buffer.max_val if spec.less_than(
 */
    __pyx_t_11 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_11 < 0)) __PYX_ERR(0, 703, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    if (__pyx_t_11) {
      __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_buffer, __pyx_n_s_min_val); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 703, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_2 = __pyx_t_5;
      __pyx_t_5 = 0;
    } else {

      /* "apache_beam/transforms/stats.py":704
 *     # Calculate extreme values for the union of buffers.
 *     min_val = buffer.min_val if spec.less_than(
 *         buffer.min_val, min_val) else min_val             # <<<<<<<<<<<<<<
 *     max_val = buffer.max_val if spec.less_than(
 *         max_val, buffer.max_val) else max_val
 */
      __Pyx_INCREF(__pyx_v_min_val);
      __pyx_t_2 = __pyx_v_min_val;
    }
    __Pyx_DECREF_SET(__pyx_v_min_val, __pyx_t_2);
    __pyx_t_2 = 0;

    /* "apache_beam/transforms/stats.py":706
 *         buffer.min_val, min_val) else min_val
 *     max_val = buffer.max_val if spec.less_than(
 *         max_val, buffer.max_val) else max_val             # <<<<<<<<<<<<<<
 *     buffer_iterators.append(iter(buffer))
 * 
 */
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_buffer, __pyx_n_s_max_val); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 706, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_INCREF(__pyx_v_spec->less_than);
    __pyx_t_10 = __pyx_v_spec->less_than; __pyx_t_6 = NULL;
    __pyx_t_9 = 0;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_10))) {
      __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_10);
      if (likely(__pyx_t_6)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10);
        __Pyx_INCREF(__pyx_t_6);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_10, function);
        __pyx_t_9 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_10)) {
      PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_v_max_val, __pyx_t_7};
      __pyx_t_5 = __Pyx_PyFunction_FastCall(__pyx_t_10, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 705, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_10)) {
      PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_v_max_val, __pyx_t_7};
      __pyx_t_5 = __Pyx_PyCFunction_FastCall(__pyx_t_10, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 705, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    } else
    #endif
    {
      __pyx_t_8 = PyTuple_New(2+__pyx_t_9); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 705, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      if (__pyx_t_6) {
        __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_6); __pyx_t_6 = NULL;
      }
      __Pyx_INCREF(__pyx_v_max_val);
      __Pyx_GIVEREF(__pyx_v_max_val);
      PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_9, __pyx_v_max_val);
      __Pyx_GIVEREF(__pyx_t_7);
      PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_9, __pyx_t_7);
      __pyx_t_7 = 0;
      __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_10, __pyx_t_8, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 705, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    }
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;

    /* "apache_beam/transforms/stats.py":705
 *     min_val = buffer.min_val if spec.less_than(
 *         buffer.min_val, min_val) else min_val
 *     max_val = buffer.max_val if spec.less_than(             # <<<<<<<<<<<<<<
 *         max_val, buffer.max_val) else max_val
 *     buffer_iterators.append(iter(buffer))
 */
    __pyx_t_11 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_11 < 0)) __PYX_ERR(0, 705, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    if (__pyx_t_11) {
      __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_buffer, __pyx_n_s_max_val); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 705, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_2 = __pyx_t_5;
      __pyx_t_5 = 0;
    } else {

      /* "apache_beam/transforms/stats.py":706
 *         buffer.min_val, min_val) else min_val
 *     max_val = buffer.max_val if spec.less_than(
 *         max_val, buffer.max_val) else max_val             # <<<<<<<<<<<<<<
 *     buffer_iterators.append(iter(buffer))
 * 
 */
      __Pyx_INCREF(__pyx_v_max_val);
      __pyx_t_2 = __pyx_v_max_val;
    }
    __Pyx_DECREF_SET(__pyx_v_max_val, __pyx_t_2);
    __pyx_t_2 = 0;

    /* "apache_beam/transforms/stats.py":707
 *     max_val = buffer.max_val if spec.less_than(
 *         max_val, buffer.max_val) else max_val
 *     buffer_iterators.append(iter(buffer))             # <<<<<<<<<<<<<<
 * 
 *   # Note that `heapq.merge` can also be used here since the buffers are sorted.
 */
    __pyx_t_2 = PyObject_GetIter(__pyx_v_buffer); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 707, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_12 = __Pyx_PyList_Append(__pyx_v_buffer_iterators, __pyx_t_2); if (unlikely(__pyx_t_12 == ((int)-1))) __PYX_ERR(0, 707, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "apache_beam/transforms/stats.py":701
 *   min_val = buffers[0].min_val
 *   max_val = buffers[0].max_val
 *   for buffer in buffers:             # <<<<<<<<<<<<<<
 *     # Calculate extreme values for the union of buffers.
 *     min_val = buffer.min_val if spec.less_than(
 */
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "apache_beam/transforms/stats.py":713
 *   # significantly outperforms `heapq.merge`.
 *   sorted_elements = sorted(
 *       itertools.chain.from_iterable(buffer_iterators),             # <<<<<<<<<<<<<<
 *       key=spec.weighted_key,
 *       reverse=spec.reverse)
 */
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_itertools); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 713, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_chain); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 713, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_from_iterable); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 713, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  __pyx_t_1 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_5, __pyx_v_buffer_iterators) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_buffer_iterators);
  __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 713, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "apache_beam/transforms/stats.py":712
 *   # In practice, however, `sorted` uses natural order in the union and
 *   # significantly outperforms `heapq.merge`.
 *   sorted_elements = sorted(             # <<<<<<<<<<<<<<
 *       itertools.chain.from_iterable(buffer_iterators),
 *       key=spec.weighted_key,
 */
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 712, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
  __pyx_t_1 = 0;

  /* "apache_beam/transforms/stats.py":714
 *   sorted_elements = sorted(
 *       itertools.chain.from_iterable(buffer_iterators),
 *       key=spec.weighted_key,             # <<<<<<<<<<<<<<
 *       reverse=spec.reverse)
 * 
 */
  __pyx_t_1 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 714, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_key, __pyx_v_spec->weighted_key) < 0) __PYX_ERR(0, 714, __pyx_L1_error)

  /* "apache_beam/transforms/stats.py":715
 *       itertools.chain.from_iterable(buffer_iterators),
 *       key=spec.weighted_key,
 *       reverse=spec.reverse)             # <<<<<<<<<<<<<<
 * 
 *   if not spec.weighted:
 */
  __pyx_t_5 = __Pyx_PyBool_FromLong(__pyx_v_spec->reverse); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 715, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_reverse, __pyx_t_5) < 0) __PYX_ERR(0, 714, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

  /* "apache_beam/transforms/stats.py":712
 *   # In practice, however, `sorted` uses natural order in the union and
 *   # significantly outperforms `heapq.merge`.
 *   sorted_elements = sorted(             # <<<<<<<<<<<<<<
 *       itertools.chain.from_iterable(buffer_iterators),
 *       key=spec.weighted_key,
 */
  __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_sorted, __pyx_t_2, __pyx_t_1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 712, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_sorted_elements = __pyx_t_5;
  __pyx_t_5 = 0;

  /* "apache_beam/transforms/stats.py":717
 *       reverse=spec.reverse)
 * 
 *   if not spec.weighted:             # <<<<<<<<<<<<<<
 *     # If all buffers have the same weight, then quantiles' indices are evenly
 *     # distributed over a range [0, len(sorted_elements)].
 */
  __pyx_t_11 = ((!(__pyx_v_spec->weighted != 0)) != 0);
  if (__pyx_t_11) {

    /* "apache_beam/transforms/stats.py":720
 *     # If all buffers have the same weight, then quantiles' indices are evenly
 *     # distributed over a range [0, len(sorted_elements)].
 *     buffers_have_same_weight = True             # <<<<<<<<<<<<<<
 *     weight = buffers[0].weights[0]
 *     for buffer in buffers:
 */
    __pyx_v_buffers_have_same_weight = 1;

    /* "apache_beam/transforms/stats.py":721
 *     # distributed over a range [0, len(sorted_elements)].
 *     buffers_have_same_weight = True
 *     weight = buffers[0].weights[0]             # <<<<<<<<<<<<<<
 *     for buffer in buffers:
 *       if buffer.weights[0] != weight:
 */
    __pyx_t_5 = __Pyx_GetItemInt(__pyx_v_buffers, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 721, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_weights); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 721, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = __Pyx_GetItemInt(__pyx_t_1, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 721, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_v_weight = __pyx_t_5;
    __pyx_t_5 = 0;

    /* "apache_beam/transforms/stats.py":722
 *     buffers_have_same_weight = True
 *     weight = buffers[0].weights[0]
 *     for buffer in buffers:             # <<<<<<<<<<<<<<
 *       if buffer.weights[0] != weight:
 *         buffers_have_same_weight = False
 */
    if (likely(PyList_CheckExact(__pyx_v_buffers)) || PyTuple_CheckExact(__pyx_v_buffers)) {
      __pyx_t_5 = __pyx_v_buffers; __Pyx_INCREF(__pyx_t_5); __pyx_t_3 = 0;
      __pyx_t_4 = NULL;
    } else {
      __pyx_t_3 = -1; __pyx_t_5 = PyObject_GetIter(__pyx_v_buffers); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 722, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_4 = Py_TYPE(__pyx_t_5)->tp_iternext; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 722, __pyx_L1_error)
    }
    for (;;) {
      if (likely(!__pyx_t_4)) {
        if (likely(PyList_CheckExact(__pyx_t_5))) {
          if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_5)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_1 = PyList_GET_ITEM(__pyx_t_5, __pyx_t_3); __Pyx_INCREF(__pyx_t_1); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(0, 722, __pyx_L1_error)
          #else
          __pyx_t_1 = PySequence_ITEM(__pyx_t_5, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 722, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_1);
          #endif
        } else {
          if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_5)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_5, __pyx_t_3); __Pyx_INCREF(__pyx_t_1); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(0, 722, __pyx_L1_error)
          #else
          __pyx_t_1 = PySequence_ITEM(__pyx_t_5, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 722, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_1);
          #endif
        }
      } else {
        __pyx_t_1 = __pyx_t_4(__pyx_t_5);
        if (unlikely(!__pyx_t_1)) {
          PyObject* exc_type = PyErr_Occurred();
          if (exc_type) {
            if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
            else __PYX_ERR(0, 722, __pyx_L1_error)
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_1);
      }
      __Pyx_XDECREF_SET(__pyx_v_buffer, __pyx_t_1);
      __pyx_t_1 = 0;

      /* "apache_beam/transforms/stats.py":723
 *     weight = buffers[0].weights[0]
 *     for buffer in buffers:
 *       if buffer.weights[0] != weight:             # <<<<<<<<<<<<<<
 *         buffers_have_same_weight = False
 *         break
 */
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_buffer, __pyx_n_s_weights); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 723, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_2 = __Pyx_GetItemInt(__pyx_t_1, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 723, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_1 = PyObject_RichCompare(__pyx_t_2, __pyx_v_weight, Py_NE); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 723, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_11 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_11 < 0)) __PYX_ERR(0, 723, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      if (__pyx_t_11) {

        /* "apache_beam/transforms/stats.py":724
 *     for buffer in buffers:
 *       if buffer.weights[0] != weight:
 *         buffers_have_same_weight = False             # <<<<<<<<<<<<<<
 *         break
 *     if buffers_have_same_weight:
 */
        __pyx_v_buffers_have_same_weight = 0;

        /* "apache_beam/transforms/stats.py":725
 *       if buffer.weights[0] != weight:
 *         buffers_have_same_weight = False
 *         break             # <<<<<<<<<<<<<<
 *     if buffers_have_same_weight:
 *       offset = offset / weight
 */
        goto __pyx_L7_break;

        /* "apache_beam/transforms/stats.py":723
 *     weight = buffers[0].weights[0]
 *     for buffer in buffers:
 *       if buffer.weights[0] != weight:             # <<<<<<<<<<<<<<
 *         buffers_have_same_weight = False
 *         break
 */
      }

      /* "apache_beam/transforms/stats.py":722
 *     buffers_have_same_weight = True
 *     weight = buffers[0].weights[0]
 *     for buffer in buffers:             # <<<<<<<<<<<<<<
 *       if buffer.weights[0] != weight:
 *         buffers_have_same_weight = False
 */
    }
    __pyx_L7_break:;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

    /* "apache_beam/transforms/stats.py":726
 *         buffers_have_same_weight = False
 *         break
 *     if buffers_have_same_weight:             # <<<<<<<<<<<<<<
 *       offset = offset / weight
 *       step = step / weight
 */
    __pyx_t_11 = (__pyx_v_buffers_have_same_weight != 0);
    if (__pyx_t_11) {

      /* "apache_beam/transforms/stats.py":727
 *         break
 *     if buffers_have_same_weight:
 *       offset = offset / weight             # <<<<<<<<<<<<<<
 *       step = step / weight
 *       max_idx = len(sorted_elements) - 1
 */
      __pyx_t_5 = PyFloat_FromDouble(__pyx_v_offset); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 727, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_1 = __Pyx_PyNumber_Divide(__pyx_t_5, __pyx_v_weight); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 727, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_13 = __pyx_PyFloat_AsDouble(__pyx_t_1); if (unlikely((__pyx_t_13 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 727, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_v_offset = __pyx_t_13;

      /* "apache_beam/transforms/stats.py":728
 *     if buffers_have_same_weight:
 *       offset = offset / weight
 *       step = step / weight             # <<<<<<<<<<<<<<
 *       max_idx = len(sorted_elements) - 1
 *       result = [
 */
      __pyx_t_1 = PyFloat_FromDouble(__pyx_v_step); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 728, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_5 = __Pyx_PyNumber_Divide(__pyx_t_1, __pyx_v_weight); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 728, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_13 = __pyx_PyFloat_AsDouble(__pyx_t_5); if (unlikely((__pyx_t_13 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 728, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_v_step = __pyx_t_13;

      /* "apache_beam/transforms/stats.py":729
 *       offset = offset / weight
 *       step = step / weight
 *       max_idx = len(sorted_elements) - 1             # <<<<<<<<<<<<<<
 *       result = [
 *           sorted_elements[min(int(j * step + offset), max_idx)][0]
 */
      __pyx_t_3 = PyObject_Length(__pyx_v_sorted_elements); if (unlikely(__pyx_t_3 == ((Py_ssize_t)-1))) __PYX_ERR(0, 729, __pyx_L1_error)
      __pyx_v_max_idx = (__pyx_t_3 - 1);

      /* "apache_beam/transforms/stats.py":730
 *       step = step / weight
 *       max_idx = len(sorted_elements) - 1
 *       result = [             # <<<<<<<<<<<<<<
 *           sorted_elements[min(int(j * step + offset), max_idx)][0]
 *           for j in range(count)
 */
      { /* enter inner scope */
        __pyx_t_5 = PyList_New(0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 730, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);

        /* "apache_beam/transforms/stats.py":732
 *       result = [
 *           sorted_elements[min(int(j * step + offset), max_idx)][0]
 *           for j in range(count)             # <<<<<<<<<<<<<<
 *       ]
 *       return result, [], min_val, max_val
 */
        __pyx_t_14 = __pyx_v_count;
        __pyx_t_15 = __pyx_t_14;
        for (__pyx_t_16 = 0; __pyx_t_16 < __pyx_t_15; __pyx_t_16+=1) {
          __pyx_8genexpr4__pyx_v_j = __pyx_t_16;

          /* "apache_beam/transforms/stats.py":731
 *       max_idx = len(sorted_elements) - 1
 *       result = [
 *           sorted_elements[min(int(j * step + offset), max_idx)][0]             # <<<<<<<<<<<<<<
 *           for j in range(count)
 *       ]
 */
          __pyx_t_3 = __pyx_v_max_idx;
          __pyx_t_1 = __Pyx_PyInt_FromDouble(((__pyx_8genexpr4__pyx_v_j * __pyx_v_step) + __pyx_v_offset)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 731, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_1);
          __pyx_t_10 = PyInt_FromSsize_t(__pyx_t_3); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 731, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_10);
          __pyx_t_8 = PyObject_RichCompare(__pyx_t_10, __pyx_t_1, Py_LT); __Pyx_XGOTREF(__pyx_t_8); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 731, __pyx_L1_error)
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
          __pyx_t_11 = __Pyx_PyObject_IsTrue(__pyx_t_8); if (unlikely(__pyx_t_11 < 0)) __PYX_ERR(0, 731, __pyx_L1_error)
          __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
          if (__pyx_t_11) {
            __pyx_t_8 = PyInt_FromSsize_t(__pyx_t_3); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 731, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_8);
            __pyx_t_2 = __pyx_t_8;
            __pyx_t_8 = 0;
          } else {
            __Pyx_INCREF(__pyx_t_1);
            __pyx_t_2 = __pyx_t_1;
          }
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          __pyx_t_1 = __Pyx_PyObject_GetItem(__pyx_v_sorted_elements, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 731, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_1);
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          __pyx_t_2 = __Pyx_GetItemInt(__pyx_t_1, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 731, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          if (unlikely(__Pyx_ListComp_Append(__pyx_t_5, (PyObject*)__pyx_t_2))) __PYX_ERR(0, 730, __pyx_L1_error)
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        }
      } /* exit inner scope */
      __pyx_v_result = ((PyObject*)__pyx_t_5);
      __pyx_t_5 = 0;

      /* "apache_beam/transforms/stats.py":734
 *           for j in range(count)
 *       ]
 *       return result, [], min_val, max_val             # <<<<<<<<<<<<<<
 * 
 *   sorted_elements_iter = iter(sorted_elements)
 */
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_5 = PyList_New(0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 734, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_2 = PyTuple_New(4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 734, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_INCREF(__pyx_v_result);
      __Pyx_GIVEREF(__pyx_v_result);
      PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_result);
      __Pyx_GIVEREF(__pyx_t_5);
      PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_5);
      __Pyx_INCREF(__pyx_v_min_val);
      __Pyx_GIVEREF(__pyx_v_min_val);
      PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_v_min_val);
      __Pyx_INCREF(__pyx_v_max_val);
      __Pyx_GIVEREF(__pyx_v_max_val);
      PyTuple_SET_ITEM(__pyx_t_2, 3, __pyx_v_max_val);
      __pyx_t_5 = 0;
      __pyx_r = __pyx_t_2;
      __pyx_t_2 = 0;
      goto __pyx_L0;

      /* "apache_beam/transforms/stats.py":726
 *         buffers_have_same_weight = False
 *         break
 *     if buffers_have_same_weight:             # <<<<<<<<<<<<<<
 *       offset = offset / weight
 *       step = step / weight
 */
    }

    /* "apache_beam/transforms/stats.py":717
 *       reverse=spec.reverse)
 * 
 *   if not spec.weighted:             # <<<<<<<<<<<<<<
 *     # If all buffers have the same weight, then quantiles' indices are evenly
 *     # distributed over a range [0, len(sorted_elements)].
 */
  }

  /* "apache_beam/transforms/stats.py":736
 *       return result, [], min_val, max_val
 * 
 *   sorted_elements_iter = iter(sorted_elements)             # <<<<<<<<<<<<<<
 *   weighted_element = next(sorted_elements_iter)
 *   new_elements = []
 */
  __pyx_t_2 = PyObject_GetIter(__pyx_v_sorted_elements); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 736, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_v_sorted_elements_iter = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "apache_beam/transforms/stats.py":737
 * 
 *   sorted_elements_iter = iter(sorted_elements)
 *   weighted_element = next(sorted_elements_iter)             # <<<<<<<<<<<<<<
 *   new_elements = []
 *   new_weights = []
 */
  __pyx_t_2 = __Pyx_PyIter_Next(__pyx_v_sorted_elements_iter); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 737, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_v_weighted_element = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "apache_beam/transforms/stats.py":738
 *   sorted_elements_iter = iter(sorted_elements)
 *   weighted_element = next(sorted_elements_iter)
 *   new_elements = []             # <<<<<<<<<<<<<<
 *   new_weights = []
 *   j = 0
 */
  __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 738, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_v_new_elements = ((PyObject*)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "apache_beam/transforms/stats.py":739
 *   weighted_element = next(sorted_elements_iter)
 *   new_elements = []
 *   new_weights = []             # <<<<<<<<<<<<<<
 *   j = 0
 *   current_weight = weighted_element[1]
 */
  __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 739, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_v_new_weights = ((PyObject*)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "apache_beam/transforms/stats.py":740
 *   new_elements = []
 *   new_weights = []
 *   j = 0             # <<<<<<<<<<<<<<
 *   current_weight = weighted_element[1]
 *   previous_weight = 0
 */
  __pyx_v_j = 0;

  /* "apache_beam/transforms/stats.py":741
 *   new_weights = []
 *   j = 0
 *   current_weight = weighted_element[1]             # <<<<<<<<<<<<<<
 *   previous_weight = 0
 *   while j < count:
 */
  __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_weighted_element, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 741, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_v_current_weight = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "apache_beam/transforms/stats.py":742
 *   j = 0
 *   current_weight = weighted_element[1]
 *   previous_weight = 0             # <<<<<<<<<<<<<<
 *   while j < count:
 *     target_weight = j * step + offset
 */
  __Pyx_INCREF(__pyx_int_0);
  __pyx_v_previous_weight = __pyx_int_0;

  /* "apache_beam/transforms/stats.py":743
 *   current_weight = weighted_element[1]
 *   previous_weight = 0
 *   while j < count:             # <<<<<<<<<<<<<<
 *     target_weight = j * step + offset
 *     j += 1
 */
  while (1) {
    __pyx_t_11 = ((__pyx_v_j < __pyx_v_count) != 0);
    if (!__pyx_t_11) break;

    /* "apache_beam/transforms/stats.py":744
 *   previous_weight = 0
 *   while j < count:
 *     target_weight = j * step + offset             # <<<<<<<<<<<<<<
 *     j += 1
 *     try:
 */
    __pyx_v_target_weight = ((__pyx_v_j * __pyx_v_step) + __pyx_v_offset);

    /* "apache_beam/transforms/stats.py":745
 *   while j < count:
 *     target_weight = j * step + offset
 *     j += 1             # <<<<<<<<<<<<<<
 *     try:
 *       while current_weight <= target_weight:
 */
    __pyx_v_j = (__pyx_v_j + 1);

    /* "apache_beam/transforms/stats.py":746
 *     target_weight = j * step + offset
 *     j += 1
 *     try:             # <<<<<<<<<<<<<<
 *       while current_weight <= target_weight:
 *         weighted_element = next(sorted_elements_iter)
 */
    {
      __Pyx_PyThreadState_declare
      __Pyx_PyThreadState_assign
      __Pyx_ExceptionSave(&__pyx_t_17, &__pyx_t_18, &__pyx_t_19);
      __Pyx_XGOTREF(__pyx_t_17);
      __Pyx_XGOTREF(__pyx_t_18);
      __Pyx_XGOTREF(__pyx_t_19);
      /*try:*/ {

        /* "apache_beam/transforms/stats.py":747
 *     j += 1
 *     try:
 *       while current_weight <= target_weight:             # <<<<<<<<<<<<<<
 *         weighted_element = next(sorted_elements_iter)
 *         current_weight += weighted_element[1]
 */
        while (1) {
          __pyx_t_2 = PyFloat_FromDouble(__pyx_v_target_weight); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 747, __pyx_L14_error)
          __Pyx_GOTREF(__pyx_t_2);
          __pyx_t_5 = PyObject_RichCompare(__pyx_v_current_weight, __pyx_t_2, Py_LE); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 747, __pyx_L14_error)
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          __pyx_t_11 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_11 < 0)) __PYX_ERR(0, 747, __pyx_L14_error)
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          if (!__pyx_t_11) break;

          /* "apache_beam/transforms/stats.py":748
 *     try:
 *       while current_weight <= target_weight:
 *         weighted_element = next(sorted_elements_iter)             # <<<<<<<<<<<<<<
 *         current_weight += weighted_element[1]
 *     except StopIteration:
 */
          __pyx_t_5 = __Pyx_PyIter_Next(__pyx_v_sorted_elements_iter); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 748, __pyx_L14_error)
          __Pyx_GOTREF(__pyx_t_5);
          __Pyx_DECREF_SET(__pyx_v_weighted_element, __pyx_t_5);
          __pyx_t_5 = 0;

          /* "apache_beam/transforms/stats.py":749
 *       while current_weight <= target_weight:
 *         weighted_element = next(sorted_elements_iter)
 *         current_weight += weighted_element[1]             # <<<<<<<<<<<<<<
 *     except StopIteration:
 *       pass
 */
          __pyx_t_5 = __Pyx_GetItemInt(__pyx_v_weighted_element, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 749, __pyx_L14_error)
          __Pyx_GOTREF(__pyx_t_5);
          __pyx_t_2 = PyNumber_InPlaceAdd(__pyx_v_current_weight, __pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 749, __pyx_L14_error)
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_DECREF_SET(__pyx_v_current_weight, __pyx_t_2);
          __pyx_t_2 = 0;
        }

        /* "apache_beam/transforms/stats.py":746
 *     target_weight = j * step + offset
 *     j += 1
 *     try:             # <<<<<<<<<<<<<<
 *       while current_weight <= target_weight:
 *         weighted_element = next(sorted_elements_iter)
 */
      }
      __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
      __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
      __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0;
      goto __pyx_L21_try_end;
      __pyx_L14_error:;
      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;

      /* "apache_beam/transforms/stats.py":750
 *         weighted_element = next(sorted_elements_iter)
 *         current_weight += weighted_element[1]
 *     except StopIteration:             # <<<<<<<<<<<<<<
 *       pass
 *     new_elements.append(weighted_element[0])
 */
      __pyx_t_9 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_StopIteration);
      if (__pyx_t_9) {
        __Pyx_ErrRestore(0,0,0);
        goto __pyx_L15_exception_handled;
      }
      goto __pyx_L16_except_error;
      __pyx_L16_except_error:;

      /* "apache_beam/transforms/stats.py":746
 *     target_weight = j * step + offset
 *     j += 1
 *     try:             # <<<<<<<<<<<<<<
 *       while current_weight <= target_weight:
 *         weighted_element = next(sorted_elements_iter)
 */
      __Pyx_XGIVEREF(__pyx_t_17);
      __Pyx_XGIVEREF(__pyx_t_18);
      __Pyx_XGIVEREF(__pyx_t_19);
      __Pyx_ExceptionReset(__pyx_t_17, __pyx_t_18, __pyx_t_19);
      goto __pyx_L1_error;
      __pyx_L15_exception_handled:;
      __Pyx_XGIVEREF(__pyx_t_17);
      __Pyx_XGIVEREF(__pyx_t_18);
      __Pyx_XGIVEREF(__pyx_t_19);
      __Pyx_ExceptionReset(__pyx_t_17, __pyx_t_18, __pyx_t_19);
      __pyx_L21_try_end:;
    }

    /* "apache_beam/transforms/stats.py":752
 *     except StopIteration:
 *       pass
 *     new_elements.append(weighted_element[0])             # <<<<<<<<<<<<<<
 *     if spec.weighted:
 *       new_weights.append(current_weight - previous_weight)
 */
    __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_weighted_element, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 752, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_12 = __Pyx_PyList_Append(__pyx_v_new_elements, __pyx_t_2); if (unlikely(__pyx_t_12 == ((int)-1))) __PYX_ERR(0, 752, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "apache_beam/transforms/stats.py":753
 *       pass
 *     new_elements.append(weighted_element[0])
 *     if spec.weighted:             # <<<<<<<<<<<<<<
 *       new_weights.append(current_weight - previous_weight)
 *       previous_weight = current_weight
 */
    __pyx_t_11 = (__pyx_v_spec->weighted != 0);
    if (__pyx_t_11) {

      /* "apache_beam/transforms/stats.py":754
 *     new_elements.append(weighted_element[0])
 *     if spec.weighted:
 *       new_weights.append(current_weight - previous_weight)             # <<<<<<<<<<<<<<
 *       previous_weight = current_weight
 * 
 */
      __pyx_t_2 = PyNumber_Subtract(__pyx_v_current_weight, __pyx_v_previous_weight); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 754, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_12 = __Pyx_PyList_Append(__pyx_v_new_weights, __pyx_t_2); if (unlikely(__pyx_t_12 == ((int)-1))) __PYX_ERR(0, 754, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

      /* "apache_beam/transforms/stats.py":755
 *     if spec.weighted:
 *       new_weights.append(current_weight - previous_weight)
 *       previous_weight = current_weight             # <<<<<<<<<<<<<<
 * 
 *   return new_elements, new_weights, min_val, max_val
 */
      __Pyx_INCREF(__pyx_v_current_weight);
      __Pyx_DECREF_SET(__pyx_v_previous_weight, __pyx_v_current_weight);

      /* "apache_beam/transforms/stats.py":753
 *       pass
 *     new_elements.append(weighted_element[0])
 *     if spec.weighted:             # <<<<<<<<<<<<<<
 *       new_weights.append(current_weight - previous_weight)
 *       previous_weight = current_weight
 */
    }
  }

  /* "apache_beam/transforms/stats.py":757
 *       previous_weight = current_weight
 * 
 *   return new_elements, new_weights, min_val, max_val             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = PyTuple_New(4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 757, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_v_new_elements);
  __Pyx_GIVEREF(__pyx_v_new_elements);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_new_elements);
  __Pyx_INCREF(__pyx_v_new_weights);
  __Pyx_GIVEREF(__pyx_v_new_weights);
  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_new_weights);
  __Pyx_INCREF(__pyx_v_min_val);
  __Pyx_GIVEREF(__pyx_v_min_val);
  PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_v_min_val);
  __Pyx_INCREF(__pyx_v_max_val);
  __Pyx_GIVEREF(__pyx_v_max_val);
  PyTuple_SET_ITEM(__pyx_t_2, 3, __pyx_v_max_val);
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "apache_beam/transforms/stats.py":690
 * 
 * 
 * def _interpolate(buffers, count, step, offset, spec):             # <<<<<<<<<<<<<<
 *   # type: (List[_QuantileBuffer], int, float, float, _QuantileSpec) -> Tuple[List, List, Any, Any]
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_AddTraceback("apache_beam.transforms.stats._interpolate", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_buffer_iterators);
  __Pyx_XDECREF(__pyx_v_min_val);
  __Pyx_XDECREF(__pyx_v_max_val);
  __Pyx_XDECREF(__pyx_v_buffer);
  __Pyx_XDECREF(__pyx_v_sorted_elements);
  __Pyx_XDECREF(__pyx_v_weight);
  __Pyx_XDECREF(__pyx_v_result);
  __Pyx_XDECREF(__pyx_v_sorted_elements_iter);
  __Pyx_XDECREF(__pyx_v_weighted_element);
  __Pyx_XDECREF(__pyx_v_new_elements);
  __Pyx_XDECREF(__pyx_v_new_weights);
  __Pyx_XDECREF(__pyx_v_current_weight);
  __Pyx_XDECREF(__pyx_v_previous_weight);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "apache_beam/transforms/stats.py":821
 *   _qs = None  # type: _QuantileState
 * 
 *   def __init__(             # <<<<<<<<<<<<<<
 *       self,
 *       num_quantiles,  # type: int
 */

/* Python wrapper */
static PyObject *__pyx_pw_11apache_beam_10transforms_5stats_29ApproximateQuantilesCombineFn_1__init__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_11apache_beam_10transforms_5stats_29ApproximateQuantilesCombineFn_1__init__ = {"__init__", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_11apache_beam_10transforms_5stats_29ApproximateQuantilesCombineFn_1__init__, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_11apache_beam_10transforms_5stats_29ApproximateQuantilesCombineFn_1__init__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_num_quantiles = 0;
  PyObject *__pyx_v_buffer_size = 0;
  PyObject *__pyx_v_num_buffers = 0;
  PyObject *__pyx_v_key = 0;
  PyObject *__pyx_v_reverse = 0;
  PyObject *__pyx_v_weighted = 0;
  PyObject *__pyx_v_input_batched = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_num_quantiles,&__pyx_n_s_buffer_size,&__pyx_n_s_num_buffers,&__pyx_n_s_key,&__pyx_n_s_reverse,&__pyx_n_s_weighted,&__pyx_n_s_input_batched,0};
    PyObject* values[8] = {0,0,0,0,0,0,0,0};

    /* "apache_beam/transforms/stats.py":826
 *       buffer_size,  # type: int
 *       num_buffers,  # type: int
 *       key=None,             # <<<<<<<<<<<<<<
 *       reverse=False,
 *       weighted=False,
 */
    values[4] = ((PyObject *)((PyObject *)Py_None));

    /* "apache_beam/transforms/stats.py":827
 *       num_buffers,  # type: int
 *       key=None,
 *       reverse=False,             # <<<<<<<<<<<<<<
 *       weighted=False,
 *       input_batched=False):
 */
    values[5] = ((PyObject *)((PyObject *)Py_False));

    /* "apache_beam/transforms/stats.py":828
 *       key=None,
 *       reverse=False,
 *       weighted=False,             # <<<<<<<<<<<<<<
 *       input_batched=False):
 *     self._num_quantiles = num_quantiles
 */
    values[6] = ((PyObject *)((PyObject *)Py_False));

    /* "apache_beam/transforms/stats.py":829
 *       reverse=False,
 *       weighted=False,
 *       input_batched=False):             # <<<<<<<<<<<<<<
 *     self._num_quantiles = num_quantiles
 *     self._spec = _QuantileSpec(buffer_size, num_buffers, weighted, key, reverse)
 */
    values[7] = ((PyObject *)((PyObject *)Py_False));
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
        CYTHON_FALLTHROUGH;
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        CYTHON_FALLTHROUGH;
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        CYTHON_FALLTHROUGH;
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_num_quantiles)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 0, 4, 8, 1); __PYX_ERR(0, 821, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_buffer_size)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 0, 4, 8, 2); __PYX_ERR(0, 821, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_num_buffers)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 0, 4, 8, 3); __PYX_ERR(0, 821, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  4:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_key);
          if (value) { values[4] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  5:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_reverse);
          if (value) { values[5] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  6:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_weighted);
          if (value) { values[6] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  7:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_input_batched);
          if (value) { values[7] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(0, 821, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
        CYTHON_FALLTHROUGH;
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        CYTHON_FALLTHROUGH;
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        CYTHON_FALLTHROUGH;
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_self = values[0];
    __pyx_v_num_quantiles = values[1];
    __pyx_v_buffer_size = values[2];
    __pyx_v_num_buffers = values[3];
    __pyx_v_key = values[4];
    __pyx_v_reverse = values[5];
    __pyx_v_weighted = values[6];
    __pyx_v_input_batched = values[7];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 0, 4, 8, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 821, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("apache_beam.transforms.stats.ApproximateQuantilesCombineFn.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_11apache_beam_10transforms_5stats_29ApproximateQuantilesCombineFn___init__(__pyx_self, __pyx_v_self, __pyx_v_num_quantiles, __pyx_v_buffer_size, __pyx_v_num_buffers, __pyx_v_key, __pyx_v_reverse, __pyx_v_weighted, __pyx_v_input_batched);

  /* "apache_beam/transforms/stats.py":821
 *   _qs = None  # type: _QuantileState
 * 
 *   def __init__(             # <<<<<<<<<<<<<<
 *       self,
 *       num_quantiles,  # type: int
 */

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_11apache_beam_10transforms_5stats_29ApproximateQuantilesCombineFn___init__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_num_quantiles, PyObject *__pyx_v_buffer_size, PyObject *__pyx_v_num_buffers, PyObject *__pyx_v_key, PyObject *__pyx_v_reverse, PyObject *__pyx_v_weighted, PyObject *__pyx_v_input_batched) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  int __pyx_t_4;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "apache_beam/transforms/stats.py":830
 *       weighted=False,
 *       input_batched=False):
 *     self._num_quantiles = num_quantiles             # <<<<<<<<<<<<<<
 *     self._spec = _QuantileSpec(buffer_size, num_buffers, weighted, key, reverse)
 *     self._input_batched = input_batched
 */
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_num_quantiles_2, __pyx_v_num_quantiles) < 0) __PYX_ERR(0, 830, __pyx_L1_error)

  /* "apache_beam/transforms/stats.py":831
 *       input_batched=False):
 *     self._num_quantiles = num_quantiles
 *     self._spec = _QuantileSpec(buffer_size, num_buffers, weighted, key, reverse)             # <<<<<<<<<<<<<<
 *     self._input_batched = input_batched
 *     if self._input_batched:
 */
  __pyx_t_1 = PyTuple_New(5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 831, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_v_buffer_size);
  __Pyx_GIVEREF(__pyx_v_buffer_size);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_buffer_size);
  __Pyx_INCREF(__pyx_v_num_buffers);
  __Pyx_GIVEREF(__pyx_v_num_buffers);
  PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_num_buffers);
  __Pyx_INCREF(__pyx_v_weighted);
  __Pyx_GIVEREF(__pyx_v_weighted);
  PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_v_weighted);
  __Pyx_INCREF(__pyx_v_key);
  __Pyx_GIVEREF(__pyx_v_key);
  PyTuple_SET_ITEM(__pyx_t_1, 3, __pyx_v_key);
  __Pyx_INCREF(__pyx_v_reverse);
  __Pyx_GIVEREF(__pyx_v_reverse);
  PyTuple_SET_ITEM(__pyx_t_1, 4, __pyx_v_reverse);
  __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_11apache_beam_10transforms_5stats__QuantileSpec), __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 831, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_spec_2, __pyx_t_2) < 0) __PYX_ERR(0, 831, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "apache_beam/transforms/stats.py":832
 *     self._num_quantiles = num_quantiles
 *     self._spec = _QuantileSpec(buffer_size, num_buffers, weighted, key, reverse)
 *     self._input_batched = input_batched             # <<<<<<<<<<<<<<
 *     if self._input_batched:
 *       setattr(self, 'add_input', self._add_inputs)
 */
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_input_batched_2, __pyx_v_input_batched) < 0) __PYX_ERR(0, 832, __pyx_L1_error)

  /* "apache_beam/transforms/stats.py":833
 *     self._spec = _QuantileSpec(buffer_size, num_buffers, weighted, key, reverse)
 *     self._input_batched = input_batched
 *     if self._input_batched:             # <<<<<<<<<<<<<<
 *       setattr(self, 'add_input', self._add_inputs)
 * 
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_input_batched_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 833, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 833, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (__pyx_t_3) {

    /* "apache_beam/transforms/stats.py":834
 *     self._input_batched = input_batched
 *     if self._input_batched:
 *       setattr(self, 'add_input', self._add_inputs)             # <<<<<<<<<<<<<<
 * 
 *   def __reduce__(self):
 */
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_add_inputs); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 834, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = PyObject_SetAttr(__pyx_v_self, __pyx_n_u_add_input, __pyx_t_2); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(0, 834, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "apache_beam/transforms/stats.py":833
 *     self._spec = _QuantileSpec(buffer_size, num_buffers, weighted, key, reverse)
 *     self._input_batched = input_batched
 *     if self._input_batched:             # <<<<<<<<<<<<<<
 *       setattr(self, 'add_input', self._add_inputs)
 * 
 */
  }

  /* "apache_beam/transforms/stats.py":821
 *   _qs = None  # type: _QuantileState
 * 
 *   def __init__(             # <<<<<<<<<<<<<<
 *       self,
 *       num_quantiles,  # type: int
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("apache_beam.transforms.stats.ApproximateQuantilesCombineFn.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "apache_beam/transforms/stats.py":836
 *       setattr(self, 'add_input', self._add_inputs)
 * 
 *   def __reduce__(self):             # <<<<<<<<<<<<<<
 *     return (
 *         self.__class__,
 */

/* Python wrapper */
static PyObject *__pyx_pw_11apache_beam_10transforms_5stats_29ApproximateQuantilesCombineFn_3__reduce__(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/
static PyMethodDef __pyx_mdef_11apache_beam_10transforms_5stats_29ApproximateQuantilesCombineFn_3__reduce__ = {"__reduce__", (PyCFunction)__pyx_pw_11apache_beam_10transforms_5stats_29ApproximateQuantilesCombineFn_3__reduce__, METH_O, 0};
static PyObject *__pyx_pw_11apache_beam_10transforms_5stats_29ApproximateQuantilesCombineFn_3__reduce__(PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__reduce__ (wrapper)", 0);
  __pyx_r = __pyx_pf_11apache_beam_10transforms_5stats_29ApproximateQuantilesCombineFn_2__reduce__(__pyx_self, ((PyObject *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_11apache_beam_10transforms_5stats_29ApproximateQuantilesCombineFn_2__reduce__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__reduce__", 0);

  /* "apache_beam/transforms/stats.py":837
 * 
 *   def __reduce__(self):
 *     return (             # <<<<<<<<<<<<<<
 *         self.__class__,
 *         (
 */
  __Pyx_XDECREF(__pyx_r);

  /* "apache_beam/transforms/stats.py":838
 *   def __reduce__(self):
 *     return (
 *         self.__class__,             # <<<<<<<<<<<<<<
 *         (
 *             self._num_quantiles,
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_class); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 838, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);

  /* "apache_beam/transforms/stats.py":840
 *         self.__class__,
 *         (
 *             self._num_quantiles,             # <<<<<<<<<<<<<<
 *             self._spec.buffer_size,
 *             self._spec.num_buffers,
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_num_quantiles_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 840, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);

  /* "apache_beam/transforms/stats.py":841
 *         (
 *             self._num_quantiles,
 *             self._spec.buffer_size,             # <<<<<<<<<<<<<<
 *             self._spec.num_buffers,
 *             self._spec.key,
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_spec_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 841, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_buffer_size); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 841, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "apache_beam/transforms/stats.py":842
 *             self._num_quantiles,
 *             self._spec.buffer_size,
 *             self._spec.num_buffers,             # <<<<<<<<<<<<<<
 *             self._spec.key,
 *             self._spec.reverse,
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_spec_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 842, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_num_buffers); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 842, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "apache_beam/transforms/stats.py":843
 *             self._spec.buffer_size,
 *             self._spec.num_buffers,
 *             self._spec.key,             # <<<<<<<<<<<<<<
 *             self._spec.reverse,
 *             self._spec.weighted,
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_spec_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 843, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_key); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 843, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "apache_beam/transforms/stats.py":844
 *             self._spec.num_buffers,
 *             self._spec.key,
 *             self._spec.reverse,             # <<<<<<<<<<<<<<
 *             self._spec.weighted,
 *             self._input_batched))
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_spec_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 844, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_reverse); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 844, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "apache_beam/transforms/stats.py":845
 *             self._spec.key,
 *             self._spec.reverse,
 *             self._spec.weighted,             # <<<<<<<<<<<<<<
 *             self._input_batched))
 * 
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_spec_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 845, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_weighted); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 845, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "apache_beam/transforms/stats.py":846
 *             self._spec.reverse,
 *             self._spec.weighted,
 *             self._input_batched))             # <<<<<<<<<<<<<<
 * 
 *   @classmethod
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_input_batched_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 846, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);

  /* "apache_beam/transforms/stats.py":840
 *         self.__class__,
 *         (
 *             self._num_quantiles,             # <<<<<<<<<<<<<<
 *             self._spec.buffer_size,
 *             self._spec.num_buffers,
 */
  __pyx_t_9 = PyTuple_New(7); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 840, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_5);
  PyTuple_SET_ITEM(__pyx_t_9, 2, __pyx_t_5);
  __Pyx_GIVEREF(__pyx_t_6);
  PyTuple_SET_ITEM(__pyx_t_9, 3, __pyx_t_6);
  __Pyx_GIVEREF(__pyx_t_7);
  PyTuple_SET_ITEM(__pyx_t_9, 4, __pyx_t_7);
  __Pyx_GIVEREF(__pyx_t_8);
  PyTuple_SET_ITEM(__pyx_t_9, 5, __pyx_t_8);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_9, 6, __pyx_t_3);
  __pyx_t_2 = 0;
  __pyx_t_4 = 0;
  __pyx_t_5 = 0;
  __pyx_t_6 = 0;
  __pyx_t_7 = 0;
  __pyx_t_8 = 0;
  __pyx_t_3 = 0;

  /* "apache_beam/transforms/stats.py":838
 *   def __reduce__(self):
 *     return (
 *         self.__class__,             # <<<<<<<<<<<<<<
 *         (
 *             self._num_quantiles,
 */
  __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 838, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_9);
  PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_9);
  __pyx_t_1 = 0;
  __pyx_t_9 = 0;
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  /* "apache_beam/transforms/stats.py":836
 *       setattr(self, 'add_input', self._add_inputs)
 * 
 *   def __reduce__(self):             # <<<<<<<<<<<<<<
 *     return (
 *         self.__class__,
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("apache_beam.transforms.stats.ApproximateQuantilesCombineFn.__reduce__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "apache_beam/transforms/stats.py":849
 * 
 *   @classmethod
 *   def create(             # <<<<<<<<<<<<<<
 *       cls,
 *       num_quantiles,  # type: int
 */

/* Python wrapper */
static PyObject *__pyx_pw_11apache_beam_10transforms_5stats_29ApproximateQuantilesCombineFn_5create(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_11apache_beam_10transforms_5stats_29ApproximateQuantilesCombineFn_4create[] = "\n    Creates an approximate quantiles combiner with the given key and desired\n    number of quantiles.\n\n    Args:\n      num_quantiles: Number of quantiles to produce. It is the size of the\n        final output list, including the mininum and maximum value items.\n      epsilon: (optional) The default error bound is `epsilon`, which holds as\n        long as the number of elements is less than `_MAX_NUM_ELEMENTS`.\n        Specifically, if one considers the input as a sorted list x_1, ...,\n        x_N, then the distance between each exact quantile x_c and its\n        approximation x_c' is bounded by `|c - c'| < epsilon * N`. Note that\n        these errors are worst-case scenarios. In practice the accuracy tends\n        to be much better.\n      max_num_elements: (optional) The cost (in time and space) to compute\n        quantiles to a given accuracy is a function of the total number of\n        elements in the data set.\n      key: (optional) Key is a mapping of elements to a comparable key, similar\n        to the key argument of Python's sorting methods.\n      reverse: (optional) whether to order things smallest to largest, rather\n        than largest to smallest.\n      weighted: (optional) if set to True, the combiner produces weighted\n        quantiles. The input elements are then expected to be tuples of values\n        with the corresponding weight.\n      input_batched: (optional) if set to True, inputs are expected to be\n        batches of elements.\n    ";
static PyMethodDef __pyx_mdef_11apache_beam_10transforms_5stats_29ApproximateQuantilesCombineFn_5create = {"create", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_11apache_beam_10transforms_5stats_29ApproximateQuantilesCombineFn_5create, METH_VARARGS|METH_KEYWORDS, __pyx_doc_11apache_beam_10transforms_5stats_29ApproximateQuantilesCombineFn_4create};
static PyObject *__pyx_pw_11apache_beam_10transforms_5stats_29ApproximateQuantilesCombineFn_5create(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_cls = 0;
  PyObject *__pyx_v_num_quantiles = 0;
  PyObject *__pyx_v_epsilon = 0;
  PyObject *__pyx_v_max_num_elements = 0;
  PyObject *__pyx_v_key = 0;
  PyObject *__pyx_v_reverse = 0;
  PyObject *__pyx_v_weighted = 0;
  PyObject *__pyx_v_input_batched = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("create (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_cls,&__pyx_n_s_num_quantiles,&__pyx_n_s_epsilon,&__pyx_n_s_max_num_elements,&__pyx_n_s_key,&__pyx_n_s_reverse,&__pyx_n_s_weighted,&__pyx_n_s_input_batched,0};
    PyObject* values[8] = {0,0,0,0,0,0,0,0};

    /* "apache_beam/transforms/stats.py":852
 *       cls,
 *       num_quantiles,  # type: int
 *       epsilon=None,             # <<<<<<<<<<<<<<
 *       max_num_elements=None,
 *       key=None,
 */
    values[2] = ((PyObject *)((PyObject *)Py_None));

    /* "apache_beam/transforms/stats.py":853
 *       num_quantiles,  # type: int
 *       epsilon=None,
 *       max_num_elements=None,             # <<<<<<<<<<<<<<
 *       key=None,
 *       reverse=False,
 */
    values[3] = ((PyObject *)((PyObject *)Py_None));

    /* "apache_beam/transforms/stats.py":854
 *       epsilon=None,
 *       max_num_elements=None,
 *       key=None,             # <<<<<<<<<<<<<<
 *       reverse=False,
 *       weighted=False,
 */
    values[4] = ((PyObject *)((PyObject *)Py_None));

    /* "apache_beam/transforms/stats.py":855
 *       max_num_elements=None,
 *       key=None,
 *       reverse=False,             # <<<<<<<<<<<<<<
 *       weighted=False,
 *       input_batched=False):
 */
    values[5] = ((PyObject *)((PyObject *)Py_False));

    /* "apache_beam/transforms/stats.py":856
 *       key=None,
 *       reverse=False,
 *       weighted=False,             # <<<<<<<<<<<<<<
 *       input_batched=False):
 *     # type: (...) -> ApproximateQuantilesCombineFn
 */
    values[6] = ((PyObject *)((PyObject *)Py_False));

    /* "apache_beam/transforms/stats.py":857
 *       reverse=False,
 *       weighted=False,
 *       input_batched=False):             # <<<<<<<<<<<<<<
 *     # type: (...) -> ApproximateQuantilesCombineFn
 * 
 */
    values[7] = ((PyObject *)((PyObject *)Py_False));
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
        CYTHON_FALLTHROUGH;
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        CYTHON_FALLTHROUGH;
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        CYTHON_FALLTHROUGH;
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_cls)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_num_quantiles)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("create", 0, 2, 8, 1); __PYX_ERR(0, 849, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_epsilon);
          if (value) { values[2] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_max_num_elements);
          if (value) { values[3] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  4:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_key);
          if (value) { values[4] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  5:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_reverse);
          if (value) { values[5] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  6:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_weighted);
          if (value) { values[6] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  7:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_input_batched);
          if (value) { values[7] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "create") < 0)) __PYX_ERR(0, 849, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
        CYTHON_FALLTHROUGH;
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        CYTHON_FALLTHROUGH;
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        CYTHON_FALLTHROUGH;
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_cls = values[0];
    __pyx_v_num_quantiles = values[1];
    __pyx_v_epsilon = values[2];
    __pyx_v_max_num_elements = values[3];
    __pyx_v_key = values[4];
    __pyx_v_reverse = values[5];
    __pyx_v_weighted = values[6];
    __pyx_v_input_batched = values[7];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("create", 0, 2, 8, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 849, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("apache_beam.transforms.stats.ApproximateQuantilesCombineFn.create", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_11apache_beam_10transforms_5stats_29ApproximateQuantilesCombineFn_4create(__pyx_self, __pyx_v_cls, __pyx_v_num_quantiles, __pyx_v_epsilon, __pyx_v_max_num_elements, __pyx_v_key, __pyx_v_reverse, __pyx_v_weighted, __pyx_v_input_batched);

  /* "apache_beam/transforms/stats.py":849
 * 
 *   @classmethod
 *   def create(             # <<<<<<<<<<<<<<
 *       cls,
 *       num_quantiles,  # type: int
 */

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_11apache_beam_10transforms_5stats_29ApproximateQuantilesCombineFn_4create(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_cls, PyObject *__pyx_v_num_quantiles, PyObject *__pyx_v_epsilon, PyObject *__pyx_v_max_num_elements, PyObject *__pyx_v_key, PyObject *__pyx_v_reverse, PyObject *__pyx_v_weighted, PyObject *__pyx_v_input_batched) {
  PyObject *__pyx_v_b = NULL;
  PyObject *__pyx_v_k = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  double __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  long __pyx_t_9;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("create", 0);
  __Pyx_INCREF(__pyx_v_epsilon);
  __Pyx_INCREF(__pyx_v_max_num_elements);

  /* "apache_beam/transforms/stats.py":887
 *         batches of elements.
 *     """
 *     max_num_elements = max_num_elements or cls._MAX_NUM_ELEMENTS             # <<<<<<<<<<<<<<
 *     if not epsilon:
 *       epsilon = min(1e-2, 1.0 / num_quantiles) \
 */
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_max_num_elements); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 887, __pyx_L1_error)
  if (!__pyx_t_2) {
  } else {
    __Pyx_INCREF(__pyx_v_max_num_elements);
    __pyx_t_1 = __pyx_v_max_num_elements;
    goto __pyx_L3_bool_binop_done;
  }
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_cls, __pyx_n_s_MAX_NUM_ELEMENTS); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 887, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(__pyx_t_3);
  __pyx_t_1 = __pyx_t_3;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_L3_bool_binop_done:;
  __Pyx_DECREF_SET(__pyx_v_max_num_elements, __pyx_t_1);
  __pyx_t_1 = 0;

  /* "apache_beam/transforms/stats.py":888
 *     """
 *     max_num_elements = max_num_elements or cls._MAX_NUM_ELEMENTS
 *     if not epsilon:             # <<<<<<<<<<<<<<
 *       epsilon = min(1e-2, 1.0 / num_quantiles) \
 *         if weighted else (1.0 / num_quantiles)
 */
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_epsilon); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 888, __pyx_L1_error)
  __pyx_t_4 = ((!__pyx_t_2) != 0);
  if (__pyx_t_4) {

    /* "apache_beam/transforms/stats.py":890
 *     if not epsilon:
 *       epsilon = min(1e-2, 1.0 / num_quantiles) \
 *         if weighted else (1.0 / num_quantiles)             # <<<<<<<<<<<<<<
 *     # Note that calculation of the buffer size and the number of buffers here
 *     # is based on technique used in the Munro-Paterson algorithm. Switching to
 */
    __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_v_weighted); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 890, __pyx_L1_error)
    if (__pyx_t_4) {

      /* "apache_beam/transforms/stats.py":889
 *     max_num_elements = max_num_elements or cls._MAX_NUM_ELEMENTS
 *     if not epsilon:
 *       epsilon = min(1e-2, 1.0 / num_quantiles) \             # <<<<<<<<<<<<<<
 *         if weighted else (1.0 / num_quantiles)
 *     # Note that calculation of the buffer size and the number of buffers here
 */
      __pyx_t_3 = __Pyx_PyFloat_TrueDivideCObj(__pyx_float_1_0, __pyx_v_num_quantiles, 1.0, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 889, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_5 = 1e-2;
      __pyx_t_7 = PyFloat_FromDouble(__pyx_t_5); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 889, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_8 = PyObject_RichCompare(__pyx_t_3, __pyx_t_7, Py_LT); __Pyx_XGOTREF(__pyx_t_8); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 889, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_8); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 889, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      if (__pyx_t_2) {
        __Pyx_INCREF(__pyx_t_3);
        __pyx_t_6 = __pyx_t_3;
      } else {
        __pyx_t_8 = PyFloat_FromDouble(__pyx_t_5); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 889, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_8);
        __pyx_t_6 = __pyx_t_8;
        __pyx_t_8 = 0;
      }
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_INCREF(__pyx_t_6);
      __pyx_t_1 = __pyx_t_6;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    } else {

      /* "apache_beam/transforms/stats.py":890
 *     if not epsilon:
 *       epsilon = min(1e-2, 1.0 / num_quantiles) \
 *         if weighted else (1.0 / num_quantiles)             # <<<<<<<<<<<<<<
 *     # Note that calculation of the buffer size and the number of buffers here
 *     # is based on technique used in the Munro-Paterson algorithm. Switching to
 */
      __pyx_t_6 = __Pyx_PyFloat_TrueDivideCObj(__pyx_float_1_0, __pyx_v_num_quantiles, 1.0, 0, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 890, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_1 = __pyx_t_6;
      __pyx_t_6 = 0;
    }
    __Pyx_DECREF_SET(__pyx_v_epsilon, __pyx_t_1);
    __pyx_t_1 = 0;

    /* "apache_beam/transforms/stats.py":888
 *     """
 *     max_num_elements = max_num_elements or cls._MAX_NUM_ELEMENTS
 *     if not epsilon:             # <<<<<<<<<<<<<<
 *       epsilon = min(1e-2, 1.0 / num_quantiles) \
 *         if weighted else (1.0 / num_quantiles)
 */
  }

  /* "apache_beam/transforms/stats.py":895
 *     # the logic used in the "New Algorithm" may result in memory savings since
 *     # it results in lower values for b and k in practice.
 *     b = 2             # <<<<<<<<<<<<<<
 *     while (b - 2) * (1 << (b - 2)) < epsilon * max_num_elements:
 *       b = b + 1
 */
  __Pyx_INCREF(__pyx_int_2);
  __pyx_v_b = __pyx_int_2;

  /* "apache_beam/transforms/stats.py":896
 *     # it results in lower values for b and k in practice.
 *     b = 2
 *     while (b - 2) * (1 << (b - 2)) < epsilon * max_num_elements:             # <<<<<<<<<<<<<<
 *       b = b + 1
 *     b = b - 1
 */
  while (1) {
    __pyx_t_1 = __Pyx_PyInt_SubtractObjC(__pyx_v_b, __pyx_int_2, 2, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 896, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_6 = __Pyx_PyInt_SubtractObjC(__pyx_v_b, __pyx_int_2, 2, 0, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 896, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_3 = PyNumber_Lshift(__pyx_int_1, __pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 896, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_6 = PyNumber_Multiply(__pyx_t_1, __pyx_t_3); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 896, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = PyNumber_Multiply(__pyx_v_epsilon, __pyx_v_max_num_elements); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 896, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_1 = PyObject_RichCompare(__pyx_t_6, __pyx_t_3, Py_LT); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 896, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 896, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (!__pyx_t_4) break;

    /* "apache_beam/transforms/stats.py":897
 *     b = 2
 *     while (b - 2) * (1 << (b - 2)) < epsilon * max_num_elements:
 *       b = b + 1             # <<<<<<<<<<<<<<
 *     b = b - 1
 *     k = max(2, int(math.ceil(max_num_elements / float(1 << (b - 1)))))
 */
    __pyx_t_1 = __Pyx_PyInt_AddObjC(__pyx_v_b, __pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 897, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF_SET(__pyx_v_b, __pyx_t_1);
    __pyx_t_1 = 0;
  }

  /* "apache_beam/transforms/stats.py":898
 *     while (b - 2) * (1 << (b - 2)) < epsilon * max_num_elements:
 *       b = b + 1
 *     b = b - 1             # <<<<<<<<<<<<<<
 *     k = max(2, int(math.ceil(max_num_elements / float(1 << (b - 1)))))
 *     return cls(
 */
  __pyx_t_1 = __Pyx_PyInt_SubtractObjC(__pyx_v_b, __pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 898, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF_SET(__pyx_v_b, __pyx_t_1);
  __pyx_t_1 = 0;

  /* "apache_beam/transforms/stats.py":899
 *       b = b + 1
 *     b = b - 1
 *     k = max(2, int(math.ceil(max_num_elements / float(1 << (b - 1)))))             # <<<<<<<<<<<<<<
 *     return cls(
 *         num_quantiles=num_quantiles,
 */
  __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_math); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 899, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_ceil); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 899, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyInt_SubtractObjC(__pyx_v_b, __pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 899, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_8 = PyNumber_Lshift(__pyx_int_1, __pyx_t_3); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 899, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyNumber_Float(__pyx_t_8); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 899, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __pyx_t_8 = __Pyx_PyNumber_Divide(__pyx_v_max_num_elements, __pyx_t_3); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 899, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_6))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_6);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_6, function);
    }
  }
  __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_6, __pyx_t_3, __pyx_t_8) : __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_8);
  __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 899, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = __Pyx_PyNumber_Int(__pyx_t_1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 899, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_9 = 2;
  __pyx_t_8 = __Pyx_PyInt_From_long(__pyx_t_9); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 899, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_3 = PyObject_RichCompare(__pyx_t_6, __pyx_t_8, Py_GT); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 899, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 899, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (__pyx_t_4) {
    __Pyx_INCREF(__pyx_t_6);
    __pyx_t_1 = __pyx_t_6;
  } else {
    __pyx_t_3 = __Pyx_PyInt_From_long(__pyx_t_9); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 899, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_1 = __pyx_t_3;
    __pyx_t_3 = 0;
  }
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = __pyx_t_1;
  __Pyx_INCREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_k = __pyx_t_6;
  __pyx_t_6 = 0;

  /* "apache_beam/transforms/stats.py":900
 *     b = b - 1
 *     k = max(2, int(math.ceil(max_num_elements / float(1 << (b - 1)))))
 *     return cls(             # <<<<<<<<<<<<<<
 *         num_quantiles=num_quantiles,
 *         buffer_size=k,
 */
  __Pyx_XDECREF(__pyx_r);

  /* "apache_beam/transforms/stats.py":901
 *     k = max(2, int(math.ceil(max_num_elements / float(1 << (b - 1)))))
 *     return cls(
 *         num_quantiles=num_quantiles,             # <<<<<<<<<<<<<<
 *         buffer_size=k,
 *         num_buffers=b,
 */
  __pyx_t_6 = __Pyx_PyDict_NewPresized(7); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 901, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  if (PyDict_SetItem(__pyx_t_6, __pyx_n_s_num_quantiles, __pyx_v_num_quantiles) < 0) __PYX_ERR(0, 901, __pyx_L1_error)

  /* "apache_beam/transforms/stats.py":902
 *     return cls(
 *         num_quantiles=num_quantiles,
 *         buffer_size=k,             # <<<<<<<<<<<<<<
 *         num_buffers=b,
 *         key=key,
 */
  if (PyDict_SetItem(__pyx_t_6, __pyx_n_s_buffer_size, __pyx_v_k) < 0) __PYX_ERR(0, 901, __pyx_L1_error)

  /* "apache_beam/transforms/stats.py":903
 *         num_quantiles=num_quantiles,
 *         buffer_size=k,
 *         num_buffers=b,             # <<<<<<<<<<<<<<
 *         key=key,
 *         reverse=reverse,
 */
  if (PyDict_SetItem(__pyx_t_6, __pyx_n_s_num_buffers, __pyx_v_b) < 0) __PYX_ERR(0, 901, __pyx_L1_error)

  /* "apache_beam/transforms/stats.py":904
 *         buffer_size=k,
 *         num_buffers=b,
 *         key=key,             # <<<<<<<<<<<<<<
 *         reverse=reverse,
 *         weighted=weighted,
 */
  if (PyDict_SetItem(__pyx_t_6, __pyx_n_s_key, __pyx_v_key) < 0) __PYX_ERR(0, 901, __pyx_L1_error)

  /* "apache_beam/transforms/stats.py":905
 *         num_buffers=b,
 *         key=key,
 *         reverse=reverse,             # <<<<<<<<<<<<<<
 *         weighted=weighted,
 *         input_batched=input_batched)
 */
  if (PyDict_SetItem(__pyx_t_6, __pyx_n_s_reverse, __pyx_v_reverse) < 0) __PYX_ERR(0, 901, __pyx_L1_error)

  /* "apache_beam/transforms/stats.py":906
 *         key=key,
 *         reverse=reverse,
 *         weighted=weighted,             # <<<<<<<<<<<<<<
 *         input_batched=input_batched)
 * 
 */
  if (PyDict_SetItem(__pyx_t_6, __pyx_n_s_weighted, __pyx_v_weighted) < 0) __PYX_ERR(0, 901, __pyx_L1_error)

  /* "apache_beam/transforms/stats.py":907
 *         reverse=reverse,
 *         weighted=weighted,
 *         input_batched=input_batched)             # <<<<<<<<<<<<<<
 * 
 *   def _offset(self, new_weight):
 */
  if (PyDict_SetItem(__pyx_t_6, __pyx_n_s_input_batched, __pyx_v_input_batched) < 0) __PYX_ERR(0, 901, __pyx_L1_error)

  /* "apache_beam/transforms/stats.py":900
 *     b = b - 1
 *     k = max(2, int(math.ceil(max_num_elements / float(1 << (b - 1)))))
 *     return cls(             # <<<<<<<<<<<<<<
 *         num_quantiles=num_quantiles,
 *         buffer_size=k,
 */
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_v_cls, __pyx_empty_tuple, __pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 900, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "apache_beam/transforms/stats.py":849
 * 
 *   @classmethod
 *   def create(             # <<<<<<<<<<<<<<
 *       cls,
 *       num_quantiles,  # type: int
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("apache_beam.transforms.stats.ApproximateQuantilesCombineFn.create", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_b);
  __Pyx_XDECREF(__pyx_v_k);
  __Pyx_XDECREF(__pyx_v_epsilon);
  __Pyx_XDECREF(__pyx_v_max_num_elements);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "apache_beam/transforms/stats.py":909
 *         input_batched=input_batched)
 * 
 *   def _offset(self, new_weight):             # <<<<<<<<<<<<<<
 *     # type: (int) -> float
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_11apache_beam_10transforms_5stats_29ApproximateQuantilesCombineFn_7_offset(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_11apache_beam_10transforms_5stats_29ApproximateQuantilesCombineFn_6_offset[] = "\n    If the weight is even, we must round up or down. Alternate between these\n    two options to avoid a bias.\n    ";
static PyMethodDef __pyx_mdef_11apache_beam_10transforms_5stats_29ApproximateQuantilesCombineFn_7_offset = {"_offset", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_11apache_beam_10transforms_5stats_29ApproximateQuantilesCombineFn_7_offset, METH_VARARGS|METH_KEYWORDS, __pyx_doc_11apache_beam_10transforms_5stats_29ApproximateQuantilesCombineFn_6_offset};
static PyObject *__pyx_pw_11apache_beam_10transforms_5stats_29ApproximateQuantilesCombineFn_7_offset(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_new_weight = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_offset (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_new_weight,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_new_weight)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_offset", 1, 2, 2, 1); __PYX_ERR(0, 909, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_offset") < 0)) __PYX_ERR(0, 909, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_self = values[0];
    __pyx_v_new_weight = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_offset", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 909, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("apache_beam.transforms.stats.ApproximateQuantilesCombineFn._offset", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_11apache_beam_10transforms_5stats_29ApproximateQuantilesCombineFn_6_offset(__pyx_self, __pyx_v_self, __pyx_v_new_weight);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_11apache_beam_10transforms_5stats_29ApproximateQuantilesCombineFn_6_offset(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_new_weight) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_offset", 0);

  /* "apache_beam/transforms/stats.py":916
 *     two options to avoid a bias.
 *     """
 *     if new_weight % 2 == 1:             # <<<<<<<<<<<<<<
 *       return (new_weight + 1) / 2
 *     else:
 */
  __pyx_t_1 = __Pyx_PyInt_RemainderObjC(__pyx_v_new_weight, __pyx_int_2, 2, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 916, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyInt_EqObjC(__pyx_t_1, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 916, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 916, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (__pyx_t_3) {

    /* "apache_beam/transforms/stats.py":917
 *     """
 *     if new_weight % 2 == 1:
 *       return (new_weight + 1) / 2             # <<<<<<<<<<<<<<
 *     else:
 *       self._offset_jitter = 2 - self._offset_jitter
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_2 = __Pyx_PyInt_AddObjC(__pyx_v_new_weight, __pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 917, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = __Pyx_PyInt_TrueDivideObjC(__pyx_t_2, __pyx_int_2, 2, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 917, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_r = __pyx_t_1;
    __pyx_t_1 = 0;
    goto __pyx_L0;

    /* "apache_beam/transforms/stats.py":916
 *     two options to avoid a bias.
 *     """
 *     if new_weight % 2 == 1:             # <<<<<<<<<<<<<<
 *       return (new_weight + 1) / 2
 *     else:
 */
  }

  /* "apache_beam/transforms/stats.py":919
 *       return (new_weight + 1) / 2
 *     else:
 *       self._offset_jitter = 2 - self._offset_jitter             # <<<<<<<<<<<<<<
 *       return (new_weight + self._offset_jitter) / 2
 * 
 */
  /*else*/ {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_offset_jitter); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 919, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = __Pyx_PyInt_SubtractCObj(__pyx_int_2, __pyx_t_1, 2, 0, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 919, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_offset_jitter, __pyx_t_2) < 0) __PYX_ERR(0, 919, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "apache_beam/transforms/stats.py":920
 *     else:
 *       self._offset_jitter = 2 - self._offset_jitter
 *       return (new_weight + self._offset_jitter) / 2             # <<<<<<<<<<<<<<
 * 
 *   # TODO(https://github.com/apache/beam/issues/19737): Signature incompatible
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_offset_jitter); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 920, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = PyNumber_Add(__pyx_v_new_weight, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 920, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_PyInt_TrueDivideObjC(__pyx_t_1, __pyx_int_2, 2, 0, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 920, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_r = __pyx_t_2;
    __pyx_t_2 = 0;
    goto __pyx_L0;
  }

  /* "apache_beam/transforms/stats.py":909
 *         input_batched=input_batched)
 * 
 *   def _offset(self, new_weight):             # <<<<<<<<<<<<<<
 *     # type: (int) -> float
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("apache_beam.transforms.stats.ApproximateQuantilesCombineFn._offset", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "apache_beam/transforms/stats.py":924
 *   # TODO(https://github.com/apache/beam/issues/19737): Signature incompatible
 *   # with supertype
 *   def create_accumulator(self):  # type: ignore[override]             # <<<<<<<<<<<<<<
 *     # type: () -> _QuantileState
 *     self._qs = _QuantileState(
 */

/* Python wrapper */
static PyObject *__pyx_pw_11apache_beam_10transforms_5stats_29ApproximateQuantilesCombineFn_9create_accumulator(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/
static PyMethodDef __pyx_mdef_11apache_beam_10transforms_5stats_29ApproximateQuantilesCombineFn_9create_accumulator = {"create_accumulator", (PyCFunction)__pyx_pw_11apache_beam_10transforms_5stats_29ApproximateQuantilesCombineFn_9create_accumulator, METH_O, 0};
static PyObject *__pyx_pw_11apache_beam_10transforms_5stats_29ApproximateQuantilesCombineFn_9create_accumulator(PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("create_accumulator (wrapper)", 0);
  __pyx_r = __pyx_pf_11apache_beam_10transforms_5stats_29ApproximateQuantilesCombineFn_8create_accumulator(__pyx_self, ((PyObject *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_11apache_beam_10transforms_5stats_29ApproximateQuantilesCombineFn_8create_accumulator(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("create_accumulator", 0);

  /* "apache_beam/transforms/stats.py":927
 *     # type: () -> _QuantileState
 *     self._qs = _QuantileState(
 *         unbuffered_elements=[],             # <<<<<<<<<<<<<<
 *         unbuffered_weights=[],
 *         buffers=[],
 */
  __pyx_t_1 = __Pyx_PyDict_NewPresized(4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 927, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 927, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_unbuffered_elements, __pyx_t_2) < 0) __PYX_ERR(0, 927, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "apache_beam/transforms/stats.py":928
 *     self._qs = _QuantileState(
 *         unbuffered_elements=[],
 *         unbuffered_weights=[],             # <<<<<<<<<<<<<<
 *         buffers=[],
 *         spec=self._spec)
 */
  __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 928, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_unbuffered_weights, __pyx_t_2) < 0) __PYX_ERR(0, 927, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "apache_beam/transforms/stats.py":929
 *         unbuffered_elements=[],
 *         unbuffered_weights=[],
 *         buffers=[],             # <<<<<<<<<<<<<<
 *         spec=self._spec)
 *     return self._qs
 */
  __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 929, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_buffers, __pyx_t_2) < 0) __PYX_ERR(0, 927, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "apache_beam/transforms/stats.py":930
 *         unbuffered_weights=[],
 *         buffers=[],
 *         spec=self._spec)             # <<<<<<<<<<<<<<
 *     return self._qs
 * 
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_spec_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 930, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_spec, __pyx_t_2) < 0) __PYX_ERR(0, 927, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "apache_beam/transforms/stats.py":926
 *   def create_accumulator(self):  # type: ignore[override]
 *     # type: () -> _QuantileState
 *     self._qs = _QuantileState(             # <<<<<<<<<<<<<<
 *         unbuffered_elements=[],
 *         unbuffered_weights=[],
 */
  __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_11apache_beam_10transforms_5stats__QuantileState), __pyx_empty_tuple, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 926, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_qs, __pyx_t_2) < 0) __PYX_ERR(0, 926, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "apache_beam/transforms/stats.py":931
 *         buffers=[],
 *         spec=self._spec)
 *     return self._qs             # <<<<<<<<<<<<<<
 * 
 *   def add_input(self, quantile_state, element):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_qs); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 931, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "apache_beam/transforms/stats.py":924
 *   # TODO(https://github.com/apache/beam/issues/19737): Signature incompatible
 *   # with supertype
 *   def create_accumulator(self):  # type: ignore[override]             # <<<<<<<<<<<<<<
 *     # type: () -> _QuantileState
 *     self._qs = _QuantileState(
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("apache_beam.transforms.stats.ApproximateQuantilesCombineFn.create_accumulator", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "apache_beam/transforms/stats.py":933
 *     return self._qs
 * 
 *   def add_input(self, quantile_state, element):             # <<<<<<<<<<<<<<
 *     """
 *     Add a new element to the collection being summarized by quantile state.
 */

/* Python wrapper */
static PyObject *__pyx_pw_11apache_beam_10transforms_5stats_29ApproximateQuantilesCombineFn_11add_input(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_11apache_beam_10transforms_5stats_29ApproximateQuantilesCombineFn_10add_input[] = "\n    Add a new element to the collection being summarized by quantile state.\n    ";
static PyMethodDef __pyx_mdef_11apache_beam_10transforms_5stats_29ApproximateQuantilesCombineFn_11add_input = {"add_input", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_11apache_beam_10transforms_5stats_29ApproximateQuantilesCombineFn_11add_input, METH_VARARGS|METH_KEYWORDS, __pyx_doc_11apache_beam_10transforms_5stats_29ApproximateQuantilesCombineFn_10add_input};
static PyObject *__pyx_pw_11apache_beam_10transforms_5stats_29ApproximateQuantilesCombineFn_11add_input(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_quantile_state = 0;
  PyObject *__pyx_v_element = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("add_input (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_quantile_state,&__pyx_n_s_element,0};
    PyObject* values[3] = {0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_quantile_state)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("add_input", 1, 3, 3, 1); __PYX_ERR(0, 933, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_element)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("add_input", 1, 3, 3, 2); __PYX_ERR(0, 933, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "add_input") < 0)) __PYX_ERR(0, 933, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
    }
    __pyx_v_self = values[0];
    __pyx_v_quantile_state = values[1];
    __pyx_v_element = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("add_input", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 933, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("apache_beam.transforms.stats.ApproximateQuantilesCombineFn.add_input", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_11apache_beam_10transforms_5stats_29ApproximateQuantilesCombineFn_10add_input(__pyx_self, __pyx_v_self, __pyx_v_quantile_state, __pyx_v_element);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_11apache_beam_10transforms_5stats_29ApproximateQuantilesCombineFn_10add_input(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_quantile_state, PyObject *__pyx_v_element) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("add_input", 0);

  /* "apache_beam/transforms/stats.py":937
 *     Add a new element to the collection being summarized by quantile state.
 *     """
 *     quantile_state.add_unbuffered([element], self._offset)             # <<<<<<<<<<<<<<
 *     return quantile_state
 * 
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_quantile_state, __pyx_n_s_add_unbuffered_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 937, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyList_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 937, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(__pyx_v_element);
  __Pyx_GIVEREF(__pyx_v_element);
  PyList_SET_ITEM(__pyx_t_3, 0, __pyx_v_element);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_offset); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 937, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = NULL;
  __pyx_t_6 = 0;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
      __pyx_t_6 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_2)) {
    PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_t_3, __pyx_t_4};
    __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 937, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
    PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_t_3, __pyx_t_4};
    __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 937, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  } else
  #endif
  {
    __pyx_t_7 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 937, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    if (__pyx_t_5) {
      __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5); __pyx_t_5 = NULL;
    }
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, __pyx_t_4);
    __pyx_t_3 = 0;
    __pyx_t_4 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_7, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 937, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "apache_beam/transforms/stats.py":938
 *     """
 *     quantile_state.add_unbuffered([element], self._offset)
 *     return quantile_state             # <<<<<<<<<<<<<<
 * 
 *   def _add_inputs(self, quantile_state, elements):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_quantile_state);
  __pyx_r = __pyx_v_quantile_state;
  goto __pyx_L0;

  /* "apache_beam/transforms/stats.py":933
 *     return self._qs
 * 
 *   def add_input(self, quantile_state, element):             # <<<<<<<<<<<<<<
 *     """
 *     Add a new element to the collection being summarized by quantile state.
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("apache_beam.transforms.stats.ApproximateQuantilesCombineFn.add_input", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "apache_beam/transforms/stats.py":940
 *     return quantile_state
 * 
 *   def _add_inputs(self, quantile_state, elements):             # <<<<<<<<<<<<<<
 *     # type: (_QuantileState, List) -> _QuantileState
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_11apache_beam_10transforms_5stats_29ApproximateQuantilesCombineFn_13_add_inputs(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_11apache_beam_10transforms_5stats_29ApproximateQuantilesCombineFn_12_add_inputs[] = "\n    Add a batch of elements to the collection being summarized by quantile\n    state.\n    ";
static PyMethodDef __pyx_mdef_11apache_beam_10transforms_5stats_29ApproximateQuantilesCombineFn_13_add_inputs = {"_add_inputs", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_11apache_beam_10transforms_5stats_29ApproximateQuantilesCombineFn_13_add_inputs, METH_VARARGS|METH_KEYWORDS, __pyx_doc_11apache_beam_10transforms_5stats_29ApproximateQuantilesCombineFn_12_add_inputs};
static PyObject *__pyx_pw_11apache_beam_10transforms_5stats_29ApproximateQuantilesCombineFn_13_add_inputs(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_quantile_state = 0;
  PyObject *__pyx_v_elements = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_add_inputs (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_quantile_state,&__pyx_n_s_elements,0};
    PyObject* values[3] = {0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_quantile_state)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_add_inputs", 1, 3, 3, 1); __PYX_ERR(0, 940, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_elements)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_add_inputs", 1, 3, 3, 2); __PYX_ERR(0, 940, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_add_inputs") < 0)) __PYX_ERR(0, 940, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
    }
    __pyx_v_self = values[0];
    __pyx_v_quantile_state = values[1];
    __pyx_v_elements = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_add_inputs", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 940, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("apache_beam.transforms.stats.ApproximateQuantilesCombineFn._add_inputs", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_11apache_beam_10transforms_5stats_29ApproximateQuantilesCombineFn_12_add_inputs(__pyx_self, __pyx_v_self, __pyx_v_quantile_state, __pyx_v_elements);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_11apache_beam_10transforms_5stats_29ApproximateQuantilesCombineFn_12_add_inputs(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_quantile_state, PyObject *__pyx_v_elements) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  Py_ssize_t __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_add_inputs", 0);

  /* "apache_beam/transforms/stats.py":947
 *     state.
 *     """
 *     if len(elements) == 0:             # <<<<<<<<<<<<<<
 *       return quantile_state
 *     quantile_state.add_unbuffered(elements, self._offset)
 */
  __pyx_t_1 = PyObject_Length(__pyx_v_elements); if (unlikely(__pyx_t_1 == ((Py_ssize_t)-1))) __PYX_ERR(0, 947, __pyx_L1_error)
  __pyx_t_2 = ((__pyx_t_1 == 0) != 0);
  if (__pyx_t_2) {

    /* "apache_beam/transforms/stats.py":948
 *     """
 *     if len(elements) == 0:
 *       return quantile_state             # <<<<<<<<<<<<<<
 *     quantile_state.add_unbuffered(elements, self._offset)
 *     return quantile_state
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(__pyx_v_quantile_state);
    __pyx_r = __pyx_v_quantile_state;
    goto __pyx_L0;

    /* "apache_beam/transforms/stats.py":947
 *     state.
 *     """
 *     if len(elements) == 0:             # <<<<<<<<<<<<<<
 *       return quantile_state
 *     quantile_state.add_unbuffered(elements, self._offset)
 */
  }

  /* "apache_beam/transforms/stats.py":949
 *     if len(elements) == 0:
 *       return quantile_state
 *     quantile_state.add_unbuffered(elements, self._offset)             # <<<<<<<<<<<<<<
 *     return quantile_state
 * 
 */
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_quantile_state, __pyx_n_s_add_unbuffered_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 949, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_offset); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 949, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_6 = NULL;
  __pyx_t_7 = 0;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_6)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
      __pyx_t_7 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_4)) {
    PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_v_elements, __pyx_t_5};
    __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 949, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
    PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_v_elements, __pyx_t_5};
    __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 949, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  } else
  #endif
  {
    __pyx_t_8 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 949, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    if (__pyx_t_6) {
      __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_6); __pyx_t_6 = NULL;
    }
    __Pyx_INCREF(__pyx_v_elements);
    __Pyx_GIVEREF(__pyx_v_elements);
    PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_7, __pyx_v_elements);
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_7, __pyx_t_5);
    __pyx_t_5 = 0;
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_8, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 949, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  }
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "apache_beam/transforms/stats.py":950
 *       return quantile_state
 *     quantile_state.add_unbuffered(elements, self._offset)
 *     return quantile_state             # <<<<<<<<<<<<<<
 * 
 *   def merge_accumulators(self, accumulators):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_quantile_state);
  __pyx_r = __pyx_v_quantile_state;
  goto __pyx_L0;

  /* "apache_beam/transforms/stats.py":940
 *     return quantile_state
 * 
 *   def _add_inputs(self, quantile_state, elements):             # <<<<<<<<<<<<<<
 *     # type: (_QuantileState, List) -> _QuantileState
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("apache_beam.transforms.stats.ApproximateQuantilesCombineFn._add_inputs", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "apache_beam/transforms/stats.py":952
 *     return quantile_state
 * 
 *   def merge_accumulators(self, accumulators):             # <<<<<<<<<<<<<<
 *     """Merges all the accumulators (quantile state) as one."""
 *     qs = self.create_accumulator()
 */

/* Python wrapper */
static PyObject *__pyx_pw_11apache_beam_10transforms_5stats_29ApproximateQuantilesCombineFn_15merge_accumulators(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_11apache_beam_10transforms_5stats_29ApproximateQuantilesCombineFn_14merge_accumulators[] = "Merges all the accumulators (quantile state) as one.";
static PyMethodDef __pyx_mdef_11apache_beam_10transforms_5stats_29ApproximateQuantilesCombineFn_15merge_accumulators = {"merge_accumulators", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_11apache_beam_10transforms_5stats_29ApproximateQuantilesCombineFn_15merge_accumulators, METH_VARARGS|METH_KEYWORDS, __pyx_doc_11apache_beam_10transforms_5stats_29ApproximateQuantilesCombineFn_14merge_accumulators};
static PyObject *__pyx_pw_11apache_beam_10transforms_5stats_29ApproximateQuantilesCombineFn_15merge_accumulators(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_accumulators = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("merge_accumulators (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_accumulators,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_accumulators)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("merge_accumulators", 1, 2, 2, 1); __PYX_ERR(0, 952, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "merge_accumulators") < 0)) __PYX_ERR(0, 952, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_self = values[0];
    __pyx_v_accumulators = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("merge_accumulators", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 952, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("apache_beam.transforms.stats.ApproximateQuantilesCombineFn.merge_accumulators", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_11apache_beam_10transforms_5stats_29ApproximateQuantilesCombineFn_14merge_accumulators(__pyx_self, __pyx_v_self, __pyx_v_accumulators);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_11apache_beam_10transforms_5stats_29ApproximateQuantilesCombineFn_14merge_accumulators(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_accumulators) {
  PyObject *__pyx_v_qs = NULL;
  PyObject *__pyx_v_accumulator = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  Py_ssize_t __pyx_t_4;
  PyObject *(*__pyx_t_5)(PyObject *);
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  int __pyx_t_10;
  PyObject *__pyx_t_11 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("merge_accumulators", 0);

  /* "apache_beam/transforms/stats.py":954
 *   def merge_accumulators(self, accumulators):
 *     """Merges all the accumulators (quantile state) as one."""
 *     qs = self.create_accumulator()             # <<<<<<<<<<<<<<
 *     for accumulator in accumulators:
 *       if accumulator.is_empty():
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_create_accumulator); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 954, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3) : __Pyx_PyObject_CallNoArg(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 954, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_qs = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "apache_beam/transforms/stats.py":955
 *     """Merges all the accumulators (quantile state) as one."""
 *     qs = self.create_accumulator()
 *     for accumulator in accumulators:             # <<<<<<<<<<<<<<
 *       if accumulator.is_empty():
 *         continue
 */
  if (likely(PyList_CheckExact(__pyx_v_accumulators)) || PyTuple_CheckExact(__pyx_v_accumulators)) {
    __pyx_t_1 = __pyx_v_accumulators; __Pyx_INCREF(__pyx_t_1); __pyx_t_4 = 0;
    __pyx_t_5 = NULL;
  } else {
    __pyx_t_4 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_accumulators); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 955, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_5 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 955, __pyx_L1_error)
  }
  for (;;) {
    if (likely(!__pyx_t_5)) {
      if (likely(PyList_CheckExact(__pyx_t_1))) {
        if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_2 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_4); __Pyx_INCREF(__pyx_t_2); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(0, 955, __pyx_L1_error)
        #else
        __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 955, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        #endif
      } else {
        if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_4); __Pyx_INCREF(__pyx_t_2); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(0, 955, __pyx_L1_error)
        #else
        __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 955, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        #endif
      }
    } else {
      __pyx_t_2 = __pyx_t_5(__pyx_t_1);
      if (unlikely(!__pyx_t_2)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(0, 955, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_2);
    }
    __Pyx_XDECREF_SET(__pyx_v_accumulator, __pyx_t_2);
    __pyx_t_2 = 0;

    /* "apache_beam/transforms/stats.py":956
 *     qs = self.create_accumulator()
 *     for accumulator in accumulators:
 *       if accumulator.is_empty():             # <<<<<<<<<<<<<<
 *         continue
 *       if self._spec.weighted:
 */
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_accumulator, __pyx_n_s_is_empty); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 956, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_6 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
      __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_3);
      if (likely(__pyx_t_6)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_6);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_3, function);
      }
    }
    __pyx_t_2 = (__pyx_t_6) ? __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_6) : __Pyx_PyObject_CallNoArg(__pyx_t_3);
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 956, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 956, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (__pyx_t_7) {

      /* "apache_beam/transforms/stats.py":957
 *     for accumulator in accumulators:
 *       if accumulator.is_empty():
 *         continue             # <<<<<<<<<<<<<<
 *       if self._spec.weighted:
 *         qs.add_unbuffered(
 */
      goto __pyx_L3_continue;

      /* "apache_beam/transforms/stats.py":956
 *     qs = self.create_accumulator()
 *     for accumulator in accumulators:
 *       if accumulator.is_empty():             # <<<<<<<<<<<<<<
 *         continue
 *       if self._spec.weighted:
 */
    }

    /* "apache_beam/transforms/stats.py":958
 *       if accumulator.is_empty():
 *         continue
 *       if self._spec.weighted:             # <<<<<<<<<<<<<<
 *         qs.add_unbuffered(
 *             [accumulator.unbuffered_elements, accumulator.unbuffered_weights],
 */
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_spec_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 958, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_weighted); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 958, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 958, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (__pyx_t_7) {

      /* "apache_beam/transforms/stats.py":959
 *         continue
 *       if self._spec.weighted:
 *         qs.add_unbuffered(             # <<<<<<<<<<<<<<
 *             [accumulator.unbuffered_elements, accumulator.unbuffered_weights],
 *             self._offset)
 */
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_qs, __pyx_n_s_add_unbuffered_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 959, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);

      /* "apache_beam/transforms/stats.py":960
 *       if self._spec.weighted:
 *         qs.add_unbuffered(
 *             [accumulator.unbuffered_elements, accumulator.unbuffered_weights],             # <<<<<<<<<<<<<<
 *             self._offset)
 *       else:
 */
      __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_accumulator, __pyx_n_s_unbuffered_elements); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 960, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_accumulator, __pyx_n_s_unbuffered_weights); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 960, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_9 = PyList_New(2); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 960, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_GIVEREF(__pyx_t_6);
      PyList_SET_ITEM(__pyx_t_9, 0, __pyx_t_6);
      __Pyx_GIVEREF(__pyx_t_8);
      PyList_SET_ITEM(__pyx_t_9, 1, __pyx_t_8);
      __pyx_t_6 = 0;
      __pyx_t_8 = 0;

      /* "apache_beam/transforms/stats.py":961
 *         qs.add_unbuffered(
 *             [accumulator.unbuffered_elements, accumulator.unbuffered_weights],
 *             self._offset)             # <<<<<<<<<<<<<<
 *       else:
 *         qs.add_unbuffered(accumulator.unbuffered_elements, self._offset)
 */
      __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_offset); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 961, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_6 = NULL;
      __pyx_t_10 = 0;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
        __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_2);
        if (likely(__pyx_t_6)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
          __Pyx_INCREF(__pyx_t_6);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_2, function);
          __pyx_t_10 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_2)) {
        PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_t_9, __pyx_t_8};
        __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_10, 2+__pyx_t_10); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 959, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
        PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_t_9, __pyx_t_8};
        __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_10, 2+__pyx_t_10); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 959, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      } else
      #endif
      {
        __pyx_t_11 = PyTuple_New(2+__pyx_t_10); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 959, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_11);
        if (__pyx_t_6) {
          __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_6); __pyx_t_6 = NULL;
        }
        __Pyx_GIVEREF(__pyx_t_9);
        PyTuple_SET_ITEM(__pyx_t_11, 0+__pyx_t_10, __pyx_t_9);
        __Pyx_GIVEREF(__pyx_t_8);
        PyTuple_SET_ITEM(__pyx_t_11, 1+__pyx_t_10, __pyx_t_8);
        __pyx_t_9 = 0;
        __pyx_t_8 = 0;
        __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_11, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 959, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      }
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

      /* "apache_beam/transforms/stats.py":958
 *       if accumulator.is_empty():
 *         continue
 *       if self._spec.weighted:             # <<<<<<<<<<<<<<
 *         qs.add_unbuffered(
 *             [accumulator.unbuffered_elements, accumulator.unbuffered_weights],
 */
      goto __pyx_L6;
    }

    /* "apache_beam/transforms/stats.py":963
 *             self._offset)
 *       else:
 *         qs.add_unbuffered(accumulator.unbuffered_elements, self._offset)             # <<<<<<<<<<<<<<
 * 
 *       qs.buffers.extend(accumulator.buffers)
 */
    /*else*/ {
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_qs, __pyx_n_s_add_unbuffered_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 963, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_v_accumulator, __pyx_n_s_unbuffered_elements); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 963, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_11);
      __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_offset); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 963, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_9 = NULL;
      __pyx_t_10 = 0;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
        __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_2);
        if (likely(__pyx_t_9)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
          __Pyx_INCREF(__pyx_t_9);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_2, function);
          __pyx_t_10 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_2)) {
        PyObject *__pyx_temp[3] = {__pyx_t_9, __pyx_t_11, __pyx_t_8};
        __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_10, 2+__pyx_t_10); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 963, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
        PyObject *__pyx_temp[3] = {__pyx_t_9, __pyx_t_11, __pyx_t_8};
        __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_10, 2+__pyx_t_10); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 963, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      } else
      #endif
      {
        __pyx_t_6 = PyTuple_New(2+__pyx_t_10); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 963, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        if (__pyx_t_9) {
          __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_9); __pyx_t_9 = NULL;
        }
        __Pyx_GIVEREF(__pyx_t_11);
        PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_10, __pyx_t_11);
        __Pyx_GIVEREF(__pyx_t_8);
        PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_10, __pyx_t_8);
        __pyx_t_11 = 0;
        __pyx_t_8 = 0;
        __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_6, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 963, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      }
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    }
    __pyx_L6:;

    /* "apache_beam/transforms/stats.py":965
 *         qs.add_unbuffered(accumulator.unbuffered_elements, self._offset)
 * 
 *       qs.buffers.extend(accumulator.buffers)             # <<<<<<<<<<<<<<
 *     heapq.heapify(qs.buffers)
 *     qs.collapse_if_needed(self._offset)
 */
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_qs, __pyx_n_s_buffers); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 965, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_extend); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 965, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_accumulator, __pyx_n_s_buffers); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 965, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_8 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) {
      __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_6);
      if (likely(__pyx_t_8)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
        __Pyx_INCREF(__pyx_t_8);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_6, function);
      }
    }
    __pyx_t_3 = (__pyx_t_8) ? __Pyx_PyObject_Call2Args(__pyx_t_6, __pyx_t_8, __pyx_t_2) : __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_2);
    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 965, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "apache_beam/transforms/stats.py":955
 *     """Merges all the accumulators (quantile state) as one."""
 *     qs = self.create_accumulator()
 *     for accumulator in accumulators:             # <<<<<<<<<<<<<<
 *       if accumulator.is_empty():
 *         continue
 */
    __pyx_L3_continue:;
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "apache_beam/transforms/stats.py":966
 * 
 *       qs.buffers.extend(accumulator.buffers)
 *     heapq.heapify(qs.buffers)             # <<<<<<<<<<<<<<
 *     qs.collapse_if_needed(self._offset)
 *     return qs
 */
  __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_heapq); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 966, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_heapify); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 966, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_qs, __pyx_n_s_buffers); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 966, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_2 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_6))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_6);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_6, function);
    }
  }
  __pyx_t_1 = (__pyx_t_2) ? __Pyx_PyObject_Call2Args(__pyx_t_6, __pyx_t_2, __pyx_t_3) : __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_3);
  __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 966, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "apache_beam/transforms/stats.py":967
 *       qs.buffers.extend(accumulator.buffers)
 *     heapq.heapify(qs.buffers)
 *     qs.collapse_if_needed(self._offset)             # <<<<<<<<<<<<<<
 *     return qs
 * 
 */
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_qs, __pyx_n_s_collapse_if_needed); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 967, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_offset); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 967, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_2 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_6);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_6, function);
    }
  }
  __pyx_t_1 = (__pyx_t_2) ? __Pyx_PyObject_Call2Args(__pyx_t_6, __pyx_t_2, __pyx_t_3) : __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_3);
  __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 967, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "apache_beam/transforms/stats.py":968
 *     heapq.heapify(qs.buffers)
 *     qs.collapse_if_needed(self._offset)
 *     return qs             # <<<<<<<<<<<<<<
 * 
 *   def extract_output(self, accumulator):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_qs);
  __pyx_r = __pyx_v_qs;
  goto __pyx_L0;

  /* "apache_beam/transforms/stats.py":952
 *     return quantile_state
 * 
 *   def merge_accumulators(self, accumulators):             # <<<<<<<<<<<<<<
 *     """Merges all the accumulators (quantile state) as one."""
 *     qs = self.create_accumulator()
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_AddTraceback("apache_beam.transforms.stats.ApproximateQuantilesCombineFn.merge_accumulators", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_qs);
  __Pyx_XDECREF(__pyx_v_accumulator);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "apache_beam/transforms/stats.py":970
 *     return qs
 * 
 *   def extract_output(self, accumulator):             # <<<<<<<<<<<<<<
 *     """
 *     Outputs num_quantiles elements consisting of the minimum, maximum and
 */

/* Python wrapper */
static PyObject *__pyx_pw_11apache_beam_10transforms_5stats_29ApproximateQuantilesCombineFn_17extract_output(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_11apache_beam_10transforms_5stats_29ApproximateQuantilesCombineFn_16extract_output[] = "\n    Outputs num_quantiles elements consisting of the minimum, maximum and\n    num_quantiles - 2 evenly spaced intermediate elements. Returns the empty\n    list if no elements have been added.\n    ";
static PyMethodDef __pyx_mdef_11apache_beam_10transforms_5stats_29ApproximateQuantilesCombineFn_17extract_output = {"extract_output", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_11apache_beam_10transforms_5stats_29ApproximateQuantilesCombineFn_17extract_output, METH_VARARGS|METH_KEYWORDS, __pyx_doc_11apache_beam_10transforms_5stats_29ApproximateQuantilesCombineFn_16extract_output};
static PyObject *__pyx_pw_11apache_beam_10transforms_5stats_29ApproximateQuantilesCombineFn_17extract_output(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_accumulator = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("extract_output (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_accumulator,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_accumulator)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("extract_output", 1, 2, 2, 1); __PYX_ERR(0, 970, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "extract_output") < 0)) __PYX_ERR(0, 970, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_self = values[0];
    __pyx_v_accumulator = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("extract_output", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 970, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("apache_beam.transforms.stats.ApproximateQuantilesCombineFn.extract_output", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_11apache_beam_10transforms_5stats_29ApproximateQuantilesCombineFn_16extract_output(__pyx_self, __pyx_v_self, __pyx_v_accumulator);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_11apache_beam_10transforms_5stats_29ApproximateQuantilesCombineFn_16extract_output(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_accumulator) {
  PyObject *__pyx_v_all_elems = NULL;
  PyObject *__pyx_v_total_weight = NULL;
  PyObject *__pyx_v_buffer_elem = NULL;
  PyObject *__pyx_v_step = NULL;
  PyObject *__pyx_v_offset = NULL;
  PyObject *__pyx_v_quantiles = NULL;
  CYTHON_UNUSED PyObject *__pyx_v__ = NULL;
  PyObject *__pyx_v_min_val = NULL;
  PyObject *__pyx_v_max_val = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  Py_ssize_t __pyx_t_5;
  PyObject *(*__pyx_t_6)(PyObject *);
  Py_ssize_t __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  int64_t __pyx_t_9;
  double __pyx_t_10;
  double __pyx_t_11;
  PyObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  PyObject *(*__pyx_t_14)(PyObject *);
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("extract_output", 0);

  /* "apache_beam/transforms/stats.py":976
 *     list if no elements have been added.
 *     """
 *     if accumulator.is_empty():             # <<<<<<<<<<<<<<
 *       return []
 *     accumulator.finalize()
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_accumulator, __pyx_n_s_is_empty); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 976, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3) : __Pyx_PyObject_CallNoArg(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 976, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 976, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_4) {

    /* "apache_beam/transforms/stats.py":977
 *     """
 *     if accumulator.is_empty():
 *       return []             # <<<<<<<<<<<<<<
 *     accumulator.finalize()
 *     all_elems = accumulator.buffers
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 977, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_r = __pyx_t_1;
    __pyx_t_1 = 0;
    goto __pyx_L0;

    /* "apache_beam/transforms/stats.py":976
 *     list if no elements have been added.
 *     """
 *     if accumulator.is_empty():             # <<<<<<<<<<<<<<
 *       return []
 *     accumulator.finalize()
 */
  }

  /* "apache_beam/transforms/stats.py":978
 *     if accumulator.is_empty():
 *       return []
 *     accumulator.finalize()             # <<<<<<<<<<<<<<
 *     all_elems = accumulator.buffers
 *     total_weight = 0
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_accumulator, __pyx_n_s_finalize); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 978, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3) : __Pyx_PyObject_CallNoArg(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 978, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "apache_beam/transforms/stats.py":979
 *       return []
 *     accumulator.finalize()
 *     all_elems = accumulator.buffers             # <<<<<<<<<<<<<<
 *     total_weight = 0
 *     if self._spec.weighted:
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_accumulator, __pyx_n_s_buffers); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 979, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_all_elems = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "apache_beam/transforms/stats.py":980
 *     accumulator.finalize()
 *     all_elems = accumulator.buffers
 *     total_weight = 0             # <<<<<<<<<<<<<<
 *     if self._spec.weighted:
 *       for buffer_elem in all_elems:
 */
  __Pyx_INCREF(__pyx_int_0);
  __pyx_v_total_weight = __pyx_int_0;

  /* "apache_beam/transforms/stats.py":981
 *     all_elems = accumulator.buffers
 *     total_weight = 0
 *     if self._spec.weighted:             # <<<<<<<<<<<<<<
 *       for buffer_elem in all_elems:
 *         total_weight += sum(buffer_elem.weights)
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_spec_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 981, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_weighted); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 981, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 981, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (__pyx_t_4) {

    /* "apache_beam/transforms/stats.py":982
 *     total_weight = 0
 *     if self._spec.weighted:
 *       for buffer_elem in all_elems:             # <<<<<<<<<<<<<<
 *         total_weight += sum(buffer_elem.weights)
 *     else:
 */
    if (likely(PyList_CheckExact(__pyx_v_all_elems)) || PyTuple_CheckExact(__pyx_v_all_elems)) {
      __pyx_t_2 = __pyx_v_all_elems; __Pyx_INCREF(__pyx_t_2); __pyx_t_5 = 0;
      __pyx_t_6 = NULL;
    } else {
      __pyx_t_5 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_v_all_elems); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 982, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_6 = Py_TYPE(__pyx_t_2)->tp_iternext; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 982, __pyx_L1_error)
    }
    for (;;) {
      if (likely(!__pyx_t_6)) {
        if (likely(PyList_CheckExact(__pyx_t_2))) {
          if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_2)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_1 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_5); __Pyx_INCREF(__pyx_t_1); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(0, 982, __pyx_L1_error)
          #else
          __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 982, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_1);
          #endif
        } else {
          if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_5); __Pyx_INCREF(__pyx_t_1); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(0, 982, __pyx_L1_error)
          #else
          __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 982, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_1);
          #endif
        }
      } else {
        __pyx_t_1 = __pyx_t_6(__pyx_t_2);
        if (unlikely(!__pyx_t_1)) {
          PyObject* exc_type = PyErr_Occurred();
          if (exc_type) {
            if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
            else __PYX_ERR(0, 982, __pyx_L1_error)
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_1);
      }
      __Pyx_XDECREF_SET(__pyx_v_buffer_elem, __pyx_t_1);
      __pyx_t_1 = 0;

      /* "apache_beam/transforms/stats.py":983
 *     if self._spec.weighted:
 *       for buffer_elem in all_elems:
 *         total_weight += sum(buffer_elem.weights)             # <<<<<<<<<<<<<<
 *     else:
 *       for buffer_elem in all_elems:
 */
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_buffer_elem, __pyx_n_s_weights); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 983, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_builtin_sum, __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 983, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_1 = PyNumber_InPlaceAdd(__pyx_v_total_weight, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 983, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF_SET(__pyx_v_total_weight, __pyx_t_1);
      __pyx_t_1 = 0;

      /* "apache_beam/transforms/stats.py":982
 *     total_weight = 0
 *     if self._spec.weighted:
 *       for buffer_elem in all_elems:             # <<<<<<<<<<<<<<
 *         total_weight += sum(buffer_elem.weights)
 *     else:
 */
    }
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "apache_beam/transforms/stats.py":981
 *     all_elems = accumulator.buffers
 *     total_weight = 0
 *     if self._spec.weighted:             # <<<<<<<<<<<<<<
 *       for buffer_elem in all_elems:
 *         total_weight += sum(buffer_elem.weights)
 */
    goto __pyx_L4;
  }

  /* "apache_beam/transforms/stats.py":985
 *         total_weight += sum(buffer_elem.weights)
 *     else:
 *       for buffer_elem in all_elems:             # <<<<<<<<<<<<<<
 *         total_weight += len(buffer_elem.elements) * buffer_elem.weights[0]
 * 
 */
  /*else*/ {
    if (likely(PyList_CheckExact(__pyx_v_all_elems)) || PyTuple_CheckExact(__pyx_v_all_elems)) {
      __pyx_t_2 = __pyx_v_all_elems; __Pyx_INCREF(__pyx_t_2); __pyx_t_5 = 0;
      __pyx_t_6 = NULL;
    } else {
      __pyx_t_5 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_v_all_elems); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 985, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_6 = Py_TYPE(__pyx_t_2)->tp_iternext; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 985, __pyx_L1_error)
    }
    for (;;) {
      if (likely(!__pyx_t_6)) {
        if (likely(PyList_CheckExact(__pyx_t_2))) {
          if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_2)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_1 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_5); __Pyx_INCREF(__pyx_t_1); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(0, 985, __pyx_L1_error)
          #else
          __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 985, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_1);
          #endif
        } else {
          if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_5); __Pyx_INCREF(__pyx_t_1); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(0, 985, __pyx_L1_error)
          #else
          __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 985, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_1);
          #endif
        }
      } else {
        __pyx_t_1 = __pyx_t_6(__pyx_t_2);
        if (unlikely(!__pyx_t_1)) {
          PyObject* exc_type = PyErr_Occurred();
          if (exc_type) {
            if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
            else __PYX_ERR(0, 985, __pyx_L1_error)
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_1);
      }
      __Pyx_XDECREF_SET(__pyx_v_buffer_elem, __pyx_t_1);
      __pyx_t_1 = 0;

      /* "apache_beam/transforms/stats.py":986
 *     else:
 *       for buffer_elem in all_elems:
 *         total_weight += len(buffer_elem.elements) * buffer_elem.weights[0]             # <<<<<<<<<<<<<<
 * 
 *     step = total_weight / (self._num_quantiles - 1)
 */
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_buffer_elem, __pyx_n_s_elements); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 986, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_7 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_7 == ((Py_ssize_t)-1))) __PYX_ERR(0, 986, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_1 = PyInt_FromSsize_t(__pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 986, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_buffer_elem, __pyx_n_s_weights); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 986, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_8 = __Pyx_GetItemInt(__pyx_t_3, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 986, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_3 = PyNumber_Multiply(__pyx_t_1, __pyx_t_8); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 986, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __pyx_t_8 = PyNumber_InPlaceAdd(__pyx_v_total_weight, __pyx_t_3); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 986, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF_SET(__pyx_v_total_weight, __pyx_t_8);
      __pyx_t_8 = 0;

      /* "apache_beam/transforms/stats.py":985
 *         total_weight += sum(buffer_elem.weights)
 *     else:
 *       for buffer_elem in all_elems:             # <<<<<<<<<<<<<<
 *         total_weight += len(buffer_elem.elements) * buffer_elem.weights[0]
 * 
 */
    }
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  }
  __pyx_L4:;

  /* "apache_beam/transforms/stats.py":988
 *         total_weight += len(buffer_elem.elements) * buffer_elem.weights[0]
 * 
 *     step = total_weight / (self._num_quantiles - 1)             # <<<<<<<<<<<<<<
 *     offset = (total_weight - 1) / (self._num_quantiles - 1)
 * 
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_num_quantiles_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 988, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_8 = __Pyx_PyInt_SubtractObjC(__pyx_t_2, __pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 988, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyNumber_Divide(__pyx_v_total_weight, __pyx_t_8); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 988, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __pyx_v_step = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "apache_beam/transforms/stats.py":989
 * 
 *     step = total_weight / (self._num_quantiles - 1)
 *     offset = (total_weight - 1) / (self._num_quantiles - 1)             # <<<<<<<<<<<<<<
 * 
 *     quantiles, _, min_val, max_val = \
 */
  __pyx_t_2 = __Pyx_PyInt_SubtractObjC(__pyx_v_total_weight, __pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 989, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_num_quantiles_2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 989, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_3 = __Pyx_PyInt_SubtractObjC(__pyx_t_8, __pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 989, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __pyx_t_8 = __Pyx_PyNumber_Divide(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 989, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_offset = __pyx_t_8;
  __pyx_t_8 = 0;

  /* "apache_beam/transforms/stats.py":992
 * 
 *     quantiles, _, min_val, max_val = \
 *         _interpolate(all_elems, self._num_quantiles - 2, step, offset,             # <<<<<<<<<<<<<<
 *                      self._spec)
 * 
 */
  __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_num_quantiles_2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 992, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_3 = __Pyx_PyInt_SubtractObjC(__pyx_t_8, __pyx_int_2, 2, 0, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 992, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __pyx_t_9 = __Pyx_PyInt_As_int64_t(__pyx_t_3); if (unlikely((__pyx_t_9 == ((int64_t)-1)) && PyErr_Occurred())) __PYX_ERR(0, 992, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_10 = __pyx_PyFloat_AsDouble(__pyx_v_step); if (unlikely((__pyx_t_10 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 992, __pyx_L1_error)
  __pyx_t_11 = __pyx_PyFloat_AsDouble(__pyx_v_offset); if (unlikely((__pyx_t_11 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 992, __pyx_L1_error)

  /* "apache_beam/transforms/stats.py":993
 *     quantiles, _, min_val, max_val = \
 *         _interpolate(all_elems, self._num_quantiles - 2, step, offset,
 *                      self._spec)             # <<<<<<<<<<<<<<
 * 
 *     return [min_val] + quantiles + [max_val]
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_spec_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 993, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_11apache_beam_10transforms_5stats__QuantileSpec))))) __PYX_ERR(0, 993, __pyx_L1_error)

  /* "apache_beam/transforms/stats.py":992
 * 
 *     quantiles, _, min_val, max_val = \
 *         _interpolate(all_elems, self._num_quantiles - 2, step, offset,             # <<<<<<<<<<<<<<
 *                      self._spec)
 * 
 */
  __pyx_t_8 = __pyx_f_11apache_beam_10transforms_5stats__interpolate(__pyx_v_all_elems, __pyx_t_9, __pyx_t_10, __pyx_t_11, ((struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileSpec *)__pyx_t_3)); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 992, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if ((likely(PyTuple_CheckExact(__pyx_t_8))) || (PyList_CheckExact(__pyx_t_8))) {
    PyObject* sequence = __pyx_t_8;
    Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
    if (unlikely(size != 4)) {
      if (size > 4) __Pyx_RaiseTooManyValuesError(4);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      __PYX_ERR(0, 991, __pyx_L1_error)
    }
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    if (likely(PyTuple_CheckExact(sequence))) {
      __pyx_t_3 = PyTuple_GET_ITEM(sequence, 0); 
      __pyx_t_2 = PyTuple_GET_ITEM(sequence, 1); 
      __pyx_t_1 = PyTuple_GET_ITEM(sequence, 2); 
      __pyx_t_12 = PyTuple_GET_ITEM(sequence, 3); 
    } else {
      __pyx_t_3 = PyList_GET_ITEM(sequence, 0); 
      __pyx_t_2 = PyList_GET_ITEM(sequence, 1); 
      __pyx_t_1 = PyList_GET_ITEM(sequence, 2); 
      __pyx_t_12 = PyList_GET_ITEM(sequence, 3); 
    }
    __Pyx_INCREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_t_12);
    #else
    {
      Py_ssize_t i;
      PyObject** temps[4] = {&__pyx_t_3,&__pyx_t_2,&__pyx_t_1,&__pyx_t_12};
      for (i=0; i < 4; i++) {
        PyObject* item = PySequence_ITEM(sequence, i); if (unlikely(!item)) __PYX_ERR(0, 991, __pyx_L1_error)
        __Pyx_GOTREF(item);
        *(temps[i]) = item;
      }
    }
    #endif
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  } else {
    Py_ssize_t index = -1;
    PyObject** temps[4] = {&__pyx_t_3,&__pyx_t_2,&__pyx_t_1,&__pyx_t_12};
    __pyx_t_13 = PyObject_GetIter(__pyx_t_8); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 991, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_13);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __pyx_t_14 = Py_TYPE(__pyx_t_13)->tp_iternext;
    for (index=0; index < 4; index++) {
      PyObject* item = __pyx_t_14(__pyx_t_13); if (unlikely(!item)) goto __pyx_L9_unpacking_failed;
      __Pyx_GOTREF(item);
      *(temps[index]) = item;
    }
    if (__Pyx_IternextUnpackEndCheck(__pyx_t_14(__pyx_t_13), 4) < 0) __PYX_ERR(0, 991, __pyx_L1_error)
    __pyx_t_14 = NULL;
    __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
    goto __pyx_L10_unpacking_done;
    __pyx_L9_unpacking_failed:;
    __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
    __pyx_t_14 = NULL;
    if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
    __PYX_ERR(0, 991, __pyx_L1_error)
    __pyx_L10_unpacking_done:;
  }

  /* "apache_beam/transforms/stats.py":991
 *     offset = (total_weight - 1) / (self._num_quantiles - 1)
 * 
 *     quantiles, _, min_val, max_val = \             # <<<<<<<<<<<<<<
 *         _interpolate(all_elems, self._num_quantiles - 2, step, offset,
 *                      self._spec)
 */
  __pyx_v_quantiles = __pyx_t_3;
  __pyx_t_3 = 0;
  __pyx_v__ = __pyx_t_2;
  __pyx_t_2 = 0;
  __pyx_v_min_val = __pyx_t_1;
  __pyx_t_1 = 0;
  __pyx_v_max_val = __pyx_t_12;
  __pyx_t_12 = 0;

  /* "apache_beam/transforms/stats.py":995
 *                      self._spec)
 * 
 *     return [min_val] + quantiles + [max_val]             # <<<<<<<<<<<<<<
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_8 = PyList_New(1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 995, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_INCREF(__pyx_v_min_val);
  __Pyx_GIVEREF(__pyx_v_min_val);
  PyList_SET_ITEM(__pyx_t_8, 0, __pyx_v_min_val);
  __pyx_t_12 = PyNumber_Add(__pyx_t_8, __pyx_v_quantiles); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 995, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __pyx_t_8 = PyList_New(1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 995, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_INCREF(__pyx_v_max_val);
  __Pyx_GIVEREF(__pyx_v_max_val);
  PyList_SET_ITEM(__pyx_t_8, 0, __pyx_v_max_val);
  __pyx_t_1 = PyNumber_Add(__pyx_t_12, __pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 995, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "apache_beam/transforms/stats.py":970
 *     return qs
 * 
 *   def extract_output(self, accumulator):             # <<<<<<<<<<<<<<
 *     """
 *     Outputs num_quantiles elements consisting of the minimum, maximum and
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_XDECREF(__pyx_t_13);
  __Pyx_AddTraceback("apache_beam.transforms.stats.ApproximateQuantilesCombineFn.extract_output", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_all_elems);
  __Pyx_XDECREF(__pyx_v_total_weight);
  __Pyx_XDECREF(__pyx_v_buffer_elem);
  __Pyx_XDECREF(__pyx_v_step);
  __Pyx_XDECREF(__pyx_v_offset);
  __Pyx_XDECREF(__pyx_v_quantiles);
  __Pyx_XDECREF(__pyx_v__);
  __Pyx_XDECREF(__pyx_v_min_val);
  __Pyx_XDECREF(__pyx_v_max_val);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":1
 * def __pyx_unpickle__QuantileBuffer(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 */

/* Python wrapper */
static PyObject *__pyx_pw_11apache_beam_10transforms_5stats_7__pyx_unpickle__QuantileBuffer(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_11apache_beam_10transforms_5stats_7__pyx_unpickle__QuantileBuffer = {"__pyx_unpickle__QuantileBuffer", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_11apache_beam_10transforms_5stats_7__pyx_unpickle__QuantileBuffer, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_11apache_beam_10transforms_5stats_7__pyx_unpickle__QuantileBuffer(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v___pyx_type = 0;
  long __pyx_v___pyx_checksum;
  PyObject *__pyx_v___pyx_state = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__pyx_unpickle__QuantileBuffer (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_pyx_type,&__pyx_n_s_pyx_checksum,&__pyx_n_s_pyx_state,0};
    PyObject* values[3] = {0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_type)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_checksum)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__pyx_unpickle__QuantileBuffer", 1, 3, 3, 1); __PYX_ERR(2, 1, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_state)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__pyx_unpickle__QuantileBuffer", 1, 3, 3, 2); __PYX_ERR(2, 1, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__pyx_unpickle__QuantileBuffer") < 0)) __PYX_ERR(2, 1, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
    }
    __pyx_v___pyx_type = values[0];
    __pyx_v___pyx_checksum = __Pyx_PyInt_As_long(values[1]); if (unlikely((__pyx_v___pyx_checksum == (long)-1) && PyErr_Occurred())) __PYX_ERR(2, 1, __pyx_L3_error)
    __pyx_v___pyx_state = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__pyx_unpickle__QuantileBuffer", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(2, 1, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("apache_beam.transforms.stats.__pyx_unpickle__QuantileBuffer", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_11apache_beam_10transforms_5stats_6__pyx_unpickle__QuantileBuffer(__pyx_self, __pyx_v___pyx_type, __pyx_v___pyx_checksum, __pyx_v___pyx_state);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_11apache_beam_10transforms_5stats_6__pyx_unpickle__QuantileBuffer(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_v___pyx_PickleError = 0;
  PyObject *__pyx_v___pyx_result = 0;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__pyx_unpickle__QuantileBuffer", 0);

  /* "(tree fragment)":4
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 *     if __pyx_checksum not in (0x9fb38c7, 0x34dcb70, 0x7f9f705):             # <<<<<<<<<<<<<<
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (0x%x vs (0x9fb38c7, 0x34dcb70, 0x7f9f705) = (_iter, elements, level, max_val, min_val, weighted, weights))" % __pyx_checksum)
 */
  __pyx_t_1 = __Pyx_PyInt_From_long(__pyx_v___pyx_checksum); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 4, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = (__Pyx_PySequence_ContainsTF(__pyx_t_1, __pyx_tuple__2, Py_NE)); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(2, 4, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_3 = (__pyx_t_2 != 0);
  if (__pyx_t_3) {

    /* "(tree fragment)":5
 *     cdef object __pyx_result
 *     if __pyx_checksum not in (0x9fb38c7, 0x34dcb70, 0x7f9f705):
 *         from pickle import PickleError as __pyx_PickleError             # <<<<<<<<<<<<<<
 *         raise __pyx_PickleError("Incompatible checksums (0x%x vs (0x9fb38c7, 0x34dcb70, 0x7f9f705) = (_iter, elements, level, max_val, min_val, weighted, weights))" % __pyx_checksum)
 *     __pyx_result = _QuantileBuffer.__new__(__pyx_type)
 */
    __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 5, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_n_s_PickleError);
    __Pyx_GIVEREF(__pyx_n_s_PickleError);
    PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_PickleError);
    __pyx_t_4 = __Pyx_Import(__pyx_n_s_pickle, __pyx_t_1, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 5, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_4, __pyx_n_s_PickleError); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 5, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_t_1);
    __pyx_v___pyx_PickleError = __pyx_t_1;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "(tree fragment)":6
 *     if __pyx_checksum not in (0x9fb38c7, 0x34dcb70, 0x7f9f705):
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (0x%x vs (0x9fb38c7, 0x34dcb70, 0x7f9f705) = (_iter, elements, level, max_val, min_val, weighted, weights))" % __pyx_checksum)             # <<<<<<<<<<<<<<
 *     __pyx_result = _QuantileBuffer.__new__(__pyx_type)
 *     if __pyx_state is not None:
 */
    __pyx_t_1 = __Pyx_PyInt_From_long(__pyx_v___pyx_checksum); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_5 = __Pyx_PyString_Format(__pyx_kp_s_Incompatible_checksums_0x_x_vs_0, __pyx_t_1); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_INCREF(__pyx_v___pyx_PickleError);
    __pyx_t_1 = __pyx_v___pyx_PickleError; __pyx_t_6 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
      __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_1);
      if (likely(__pyx_t_6)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
        __Pyx_INCREF(__pyx_t_6);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_1, function);
      }
    }
    __pyx_t_4 = (__pyx_t_6) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_6, __pyx_t_5) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_5);
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_Raise(__pyx_t_4, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __PYX_ERR(2, 6, __pyx_L1_error)

    /* "(tree fragment)":4
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 *     if __pyx_checksum not in (0x9fb38c7, 0x34dcb70, 0x7f9f705):             # <<<<<<<<<<<<<<
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (0x%x vs (0x9fb38c7, 0x34dcb70, 0x7f9f705) = (_iter, elements, level, max_val, min_val, weighted, weights))" % __pyx_checksum)
 */
  }

  /* "(tree fragment)":7
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (0x%x vs (0x9fb38c7, 0x34dcb70, 0x7f9f705) = (_iter, elements, level, max_val, min_val, weighted, weights))" % __pyx_checksum)
 *     __pyx_result = _QuantileBuffer.__new__(__pyx_type)             # <<<<<<<<<<<<<<
 *     if __pyx_state is not None:
 *         __pyx_unpickle__QuantileBuffer__set_state(<_QuantileBuffer> __pyx_result, __pyx_state)
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_ptype_11apache_beam_10transforms_5stats__QuantileBuffer), __pyx_n_s_new); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 7, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_5 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_1);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_1, function);
    }
  }
  __pyx_t_4 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_5, __pyx_v___pyx_type) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_v___pyx_type);
  __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 7, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v___pyx_result = __pyx_t_4;
  __pyx_t_4 = 0;

  /* "(tree fragment)":8
 *         raise __pyx_PickleError("Incompatible checksums (0x%x vs (0x9fb38c7, 0x34dcb70, 0x7f9f705) = (_iter, elements, level, max_val, min_val, weighted, weights))" % __pyx_checksum)
 *     __pyx_result = _QuantileBuffer.__new__(__pyx_type)
 *     if __pyx_state is not None:             # <<<<<<<<<<<<<<
 *         __pyx_unpickle__QuantileBuffer__set_state(<_QuantileBuffer> __pyx_result, __pyx_state)
 *     return __pyx_result
 */
  __pyx_t_3 = (__pyx_v___pyx_state != Py_None);
  __pyx_t_2 = (__pyx_t_3 != 0);
  if (__pyx_t_2) {

    /* "(tree fragment)":9
 *     __pyx_result = _QuantileBuffer.__new__(__pyx_type)
 *     if __pyx_state is not None:
 *         __pyx_unpickle__QuantileBuffer__set_state(<_QuantileBuffer> __pyx_result, __pyx_state)             # <<<<<<<<<<<<<<
 *     return __pyx_result
 * cdef __pyx_unpickle__QuantileBuffer__set_state(_QuantileBuffer __pyx_result, tuple __pyx_state):
 */
    if (!(likely(PyTuple_CheckExact(__pyx_v___pyx_state))||((__pyx_v___pyx_state) == Py_None)||((void)PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v___pyx_state)->tp_name), 0))) __PYX_ERR(2, 9, __pyx_L1_error)
    __pyx_t_4 = __pyx_f_11apache_beam_10transforms_5stats___pyx_unpickle__QuantileBuffer__set_state(((struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileBuffer *)__pyx_v___pyx_result), ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 9, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "(tree fragment)":8
 *         raise __pyx_PickleError("Incompatible checksums (0x%x vs (0x9fb38c7, 0x34dcb70, 0x7f9f705) = (_iter, elements, level, max_val, min_val, weighted, weights))" % __pyx_checksum)
 *     __pyx_result = _QuantileBuffer.__new__(__pyx_type)
 *     if __pyx_state is not None:             # <<<<<<<<<<<<<<
 *         __pyx_unpickle__QuantileBuffer__set_state(<_QuantileBuffer> __pyx_result, __pyx_state)
 *     return __pyx_result
 */
  }

  /* "(tree fragment)":10
 *     if __pyx_state is not None:
 *         __pyx_unpickle__QuantileBuffer__set_state(<_QuantileBuffer> __pyx_result, __pyx_state)
 *     return __pyx_result             # <<<<<<<<<<<<<<
 * cdef __pyx_unpickle__QuantileBuffer__set_state(_QuantileBuffer __pyx_result, tuple __pyx_state):
 *     __pyx_result._iter = __pyx_state[0]; __pyx_result.elements = __pyx_state[1]; __pyx_result.level = __pyx_state[2]; __pyx_result.max_val = __pyx_state[3]; __pyx_result.min_val = __pyx_state[4]; __pyx_result.weighted = __pyx_state[5]; __pyx_result.weights = __pyx_state[6]
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v___pyx_result);
  __pyx_r = __pyx_v___pyx_result;
  goto __pyx_L0;

  /* "(tree fragment)":1
 * def __pyx_unpickle__QuantileBuffer(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("apache_beam.transforms.stats.__pyx_unpickle__QuantileBuffer", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v___pyx_PickleError);
  __Pyx_XDECREF(__pyx_v___pyx_result);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":11
 *         __pyx_unpickle__QuantileBuffer__set_state(<_QuantileBuffer> __pyx_result, __pyx_state)
 *     return __pyx_result
 * cdef __pyx_unpickle__QuantileBuffer__set_state(_QuantileBuffer __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_result._iter = __pyx_state[0]; __pyx_result.elements = __pyx_state[1]; __pyx_result.level = __pyx_state[2]; __pyx_result.max_val = __pyx_state[3]; __pyx_result.min_val = __pyx_state[4]; __pyx_result.weighted = __pyx_state[5]; __pyx_result.weights = __pyx_state[6]
 *     if len(__pyx_state) > 7 and hasattr(__pyx_result, '__dict__'):
 */

static PyObject *__pyx_f_11apache_beam_10transforms_5stats___pyx_unpickle__QuantileBuffer__set_state(struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileBuffer *__pyx_v___pyx_result, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int64_t __pyx_t_2;
  int __pyx_t_3;
  Py_ssize_t __pyx_t_4;
  int __pyx_t_5;
  int __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__pyx_unpickle__QuantileBuffer__set_state", 0);

  /* "(tree fragment)":12
 *     return __pyx_result
 * cdef __pyx_unpickle__QuantileBuffer__set_state(_QuantileBuffer __pyx_result, tuple __pyx_state):
 *     __pyx_result._iter = __pyx_state[0]; __pyx_result.elements = __pyx_state[1]; __pyx_result.level = __pyx_state[2]; __pyx_result.max_val = __pyx_state[3]; __pyx_result.min_val = __pyx_state[4]; __pyx_result.weighted = __pyx_state[5]; __pyx_result.weights = __pyx_state[6]             # <<<<<<<<<<<<<<
 *     if len(__pyx_state) > 7 and hasattr(__pyx_result, '__dict__'):
 *         __pyx_result.__dict__.update(__pyx_state[7])
 */
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->_iter);
  __Pyx_DECREF(__pyx_v___pyx_result->_iter);
  __pyx_v___pyx_result->_iter = __pyx_t_1;
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->elements);
  __Pyx_DECREF(__pyx_v___pyx_result->elements);
  __pyx_v___pyx_result->elements = __pyx_t_1;
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 2, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyInt_As_int64_t(__pyx_t_1); if (unlikely((__pyx_t_2 == ((int64_t)-1)) && PyErr_Occurred())) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v___pyx_result->level = __pyx_t_2;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 3, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->max_val);
  __Pyx_DECREF(__pyx_v___pyx_result->max_val);
  __pyx_v___pyx_result->max_val = __pyx_t_1;
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 4, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->min_val);
  __Pyx_DECREF(__pyx_v___pyx_result->min_val);
  __pyx_v___pyx_result->min_val = __pyx_t_1;
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 5, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v___pyx_result->weighted = __pyx_t_3;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 6, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->weights);
  __Pyx_DECREF(__pyx_v___pyx_result->weights);
  __pyx_v___pyx_result->weights = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "(tree fragment)":13
 * cdef __pyx_unpickle__QuantileBuffer__set_state(_QuantileBuffer __pyx_result, tuple __pyx_state):
 *     __pyx_result._iter = __pyx_state[0]; __pyx_result.elements = __pyx_state[1]; __pyx_result.level = __pyx_state[2]; __pyx_result.max_val = __pyx_state[3]; __pyx_result.min_val = __pyx_state[4]; __pyx_result.weighted = __pyx_state[5]; __pyx_result.weights = __pyx_state[6]
 *     if len(__pyx_state) > 7 and hasattr(__pyx_result, '__dict__'):             # <<<<<<<<<<<<<<
 *         __pyx_result.__dict__.update(__pyx_state[7])
 */
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    __PYX_ERR(2, 13, __pyx_L1_error)
  }
  __pyx_t_4 = PyTuple_GET_SIZE(__pyx_v___pyx_state); if (unlikely(__pyx_t_4 == ((Py_ssize_t)-1))) __PYX_ERR(2, 13, __pyx_L1_error)
  __pyx_t_5 = ((__pyx_t_4 > 7) != 0);
  if (__pyx_t_5) {
  } else {
    __pyx_t_3 = __pyx_t_5;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_5 = __Pyx_HasAttr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(__pyx_t_5 == ((int)-1))) __PYX_ERR(2, 13, __pyx_L1_error)
  __pyx_t_6 = (__pyx_t_5 != 0);
  __pyx_t_3 = __pyx_t_6;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_3) {

    /* "(tree fragment)":14
 *     __pyx_result._iter = __pyx_state[0]; __pyx_result.elements = __pyx_state[1]; __pyx_result.level = __pyx_state[2]; __pyx_result.max_val = __pyx_state[3]; __pyx_result.min_val = __pyx_state[4]; __pyx_result.weighted = __pyx_state[5]; __pyx_result.weights = __pyx_state[6]
 *     if len(__pyx_state) > 7 and hasattr(__pyx_result, '__dict__'):
 *         __pyx_result.__dict__.update(__pyx_state[7])             # <<<<<<<<<<<<<<
 */
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(!__pyx_t_7)) __PYX_ERR(2, 14, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_update); if (unlikely(!__pyx_t_8)) __PYX_ERR(2, 14, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    if (unlikely(__pyx_v___pyx_state == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(2, 14, __pyx_L1_error)
    }
    __pyx_t_7 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 7, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_7)) __PYX_ERR(2, 14, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_9 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_8))) {
      __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_8);
      if (likely(__pyx_t_9)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
        __Pyx_INCREF(__pyx_t_9);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_8, function);
      }
    }
    __pyx_t_1 = (__pyx_t_9) ? __Pyx_PyObject_Call2Args(__pyx_t_8, __pyx_t_9, __pyx_t_7) : __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_t_7);
    __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 14, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "(tree fragment)":13
 * cdef __pyx_unpickle__QuantileBuffer__set_state(_QuantileBuffer __pyx_result, tuple __pyx_state):
 *     __pyx_result._iter = __pyx_state[0]; __pyx_result.elements = __pyx_state[1]; __pyx_result.level = __pyx_state[2]; __pyx_result.max_val = __pyx_state[3]; __pyx_result.min_val = __pyx_state[4]; __pyx_result.weighted = __pyx_state[5]; __pyx_result.weights = __pyx_state[6]
 *     if len(__pyx_state) > 7 and hasattr(__pyx_result, '__dict__'):             # <<<<<<<<<<<<<<
 *         __pyx_result.__dict__.update(__pyx_state[7])
 */
  }

  /* "(tree fragment)":11
 *         __pyx_unpickle__QuantileBuffer__set_state(<_QuantileBuffer> __pyx_result, __pyx_state)
 *     return __pyx_result
 * cdef __pyx_unpickle__QuantileBuffer__set_state(_QuantileBuffer __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_result._iter = __pyx_state[0]; __pyx_result.elements = __pyx_state[1]; __pyx_result.level = __pyx_state[2]; __pyx_result.max_val = __pyx_state[3]; __pyx_result.min_val = __pyx_state[4]; __pyx_result.weighted = __pyx_state[5]; __pyx_result.weights = __pyx_state[6]
 *     if len(__pyx_state) > 7 and hasattr(__pyx_result, '__dict__'):
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("apache_beam.transforms.stats.__pyx_unpickle__QuantileBuffer__set_state", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_tp_new_11apache_beam_10transforms_5stats__QuantileSpec(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileSpec *p;
  PyObject *o;
  if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {
    o = (*t->tp_alloc)(t, 0);
  } else {
    o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0);
  }
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileSpec *)o);
  p->key = Py_None; Py_INCREF(Py_None);
  p->weighted_key = Py_None; Py_INCREF(Py_None);
  p->less_than = Py_None; Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_11apache_beam_10transforms_5stats__QuantileSpec(PyObject *o) {
  struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileSpec *p = (struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileSpec *)o;
  #if CYTHON_USE_TP_FINALIZE
  if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !__Pyx_PyObject_GC_IsFinalized(o)) {
    if (PyObject_CallFinalizerFromDealloc(o)) return;
  }
  #endif
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->key);
  Py_CLEAR(p->weighted_key);
  Py_CLEAR(p->less_than);
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_11apache_beam_10transforms_5stats__QuantileSpec(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileSpec *p = (struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileSpec *)o;
  if (p->key) {
    e = (*v)(p->key, a); if (e) return e;
  }
  if (p->weighted_key) {
    e = (*v)(p->weighted_key, a); if (e) return e;
  }
  if (p->less_than) {
    e = (*v)(p->less_than, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_11apache_beam_10transforms_5stats__QuantileSpec(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileSpec *p = (struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileSpec *)o;
  tmp = ((PyObject*)p->key);
  p->key = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->weighted_key);
  p->weighted_key = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->less_than);
  p->less_than = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyObject *__pyx_getprop_11apache_beam_10transforms_5stats_13_QuantileSpec_buffer_size(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_11apache_beam_10transforms_5stats_13_QuantileSpec_11buffer_size_1__get__(o);
}

static PyObject *__pyx_getprop_11apache_beam_10transforms_5stats_13_QuantileSpec_num_buffers(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_11apache_beam_10transforms_5stats_13_QuantileSpec_11num_buffers_1__get__(o);
}

static PyObject *__pyx_getprop_11apache_beam_10transforms_5stats_13_QuantileSpec_weighted(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_11apache_beam_10transforms_5stats_13_QuantileSpec_8weighted_1__get__(o);
}

static PyObject *__pyx_getprop_11apache_beam_10transforms_5stats_13_QuantileSpec_key(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_11apache_beam_10transforms_5stats_13_QuantileSpec_3key_1__get__(o);
}

static PyObject *__pyx_getprop_11apache_beam_10transforms_5stats_13_QuantileSpec_reverse(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_11apache_beam_10transforms_5stats_13_QuantileSpec_7reverse_1__get__(o);
}

static PyObject *__pyx_getprop_11apache_beam_10transforms_5stats_13_QuantileSpec_weighted_key(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_11apache_beam_10transforms_5stats_13_QuantileSpec_12weighted_key_1__get__(o);
}

static PyObject *__pyx_getprop_11apache_beam_10transforms_5stats_13_QuantileSpec_less_than(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_11apache_beam_10transforms_5stats_13_QuantileSpec_9less_than_1__get__(o);
}

static PyMethodDef __pyx_methods_11apache_beam_10transforms_5stats__QuantileSpec[] = {
  {"get_argsort_key", (PyCFunction)__pyx_pw_11apache_beam_10transforms_5stats_13_QuantileSpec_3get_argsort_key, METH_O, __pyx_doc_11apache_beam_10transforms_5stats_13_QuantileSpec_2get_argsort_key},
  {"__reduce__", (PyCFunction)__pyx_pw_11apache_beam_10transforms_5stats_13_QuantileSpec_5__reduce__, METH_NOARGS, 0},
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_11apache_beam_10transforms_5stats__QuantileSpec[] = {
  {(char *)"buffer_size", __pyx_getprop_11apache_beam_10transforms_5stats_13_QuantileSpec_buffer_size, 0, (char *)0, 0},
  {(char *)"num_buffers", __pyx_getprop_11apache_beam_10transforms_5stats_13_QuantileSpec_num_buffers, 0, (char *)0, 0},
  {(char *)"weighted", __pyx_getprop_11apache_beam_10transforms_5stats_13_QuantileSpec_weighted, 0, (char *)0, 0},
  {(char *)"key", __pyx_getprop_11apache_beam_10transforms_5stats_13_QuantileSpec_key, 0, (char *)0, 0},
  {(char *)"reverse", __pyx_getprop_11apache_beam_10transforms_5stats_13_QuantileSpec_reverse, 0, (char *)0, 0},
  {(char *)"weighted_key", __pyx_getprop_11apache_beam_10transforms_5stats_13_QuantileSpec_weighted_key, 0, (char *)0, 0},
  {(char *)"less_than", __pyx_getprop_11apache_beam_10transforms_5stats_13_QuantileSpec_less_than, 0, (char *)0, 0},
  {0, 0, 0, 0, 0}
};

static PyTypeObject __pyx_type_11apache_beam_10transforms_5stats__QuantileSpec = {
  PyVarObject_HEAD_INIT(0, 0)
  "apache_beam.transforms.stats._QuantileSpec", /*tp_name*/
  sizeof(struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileSpec), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_11apache_beam_10transforms_5stats__QuantileSpec, /*tp_dealloc*/
  #if PY_VERSION_HEX < 0x030800b4
  0, /*tp_print*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4
  0, /*tp_vectorcall_offset*/
  #endif
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #endif
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  "Quantiles computation specifications.", /*tp_doc*/
  __pyx_tp_traverse_11apache_beam_10transforms_5stats__QuantileSpec, /*tp_traverse*/
  __pyx_tp_clear_11apache_beam_10transforms_5stats__QuantileSpec, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_11apache_beam_10transforms_5stats__QuantileSpec, /*tp_methods*/
  0, /*tp_members*/
  __pyx_getsets_11apache_beam_10transforms_5stats__QuantileSpec, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_11apache_beam_10transforms_5stats_13_QuantileSpec_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_11apache_beam_10transforms_5stats__QuantileSpec, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b1 && (!CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800)
  0, /*tp_vectorcall*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
  0, /*tp_print*/
  #endif
  #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000 && PY_VERSION_HEX < 0x030a0000
  0, /*tp_pypy_flags*/
  #endif
};

static PyObject *__pyx_tp_new_11apache_beam_10transforms_5stats__QuantileBuffer(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileBuffer *p;
  PyObject *o;
  if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {
    o = (*t->tp_alloc)(t, 0);
  } else {
    o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0);
  }
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileBuffer *)o);
  p->elements = Py_None; Py_INCREF(Py_None);
  p->weights = Py_None; Py_INCREF(Py_None);
  p->min_val = Py_None; Py_INCREF(Py_None);
  p->max_val = Py_None; Py_INCREF(Py_None);
  p->_iter = Py_None; Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_11apache_beam_10transforms_5stats__QuantileBuffer(PyObject *o) {
  struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileBuffer *p = (struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileBuffer *)o;
  #if CYTHON_USE_TP_FINALIZE
  if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !__Pyx_PyObject_GC_IsFinalized(o)) {
    if (PyObject_CallFinalizerFromDealloc(o)) return;
  }
  #endif
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->elements);
  Py_CLEAR(p->weights);
  Py_CLEAR(p->min_val);
  Py_CLEAR(p->max_val);
  Py_CLEAR(p->_iter);
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_11apache_beam_10transforms_5stats__QuantileBuffer(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileBuffer *p = (struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileBuffer *)o;
  if (p->elements) {
    e = (*v)(p->elements, a); if (e) return e;
  }
  if (p->weights) {
    e = (*v)(p->weights, a); if (e) return e;
  }
  if (p->min_val) {
    e = (*v)(p->min_val, a); if (e) return e;
  }
  if (p->max_val) {
    e = (*v)(p->max_val, a); if (e) return e;
  }
  if (p->_iter) {
    e = (*v)(p->_iter, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_11apache_beam_10transforms_5stats__QuantileBuffer(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileBuffer *p = (struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileBuffer *)o;
  tmp = ((PyObject*)p->elements);
  p->elements = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->weights);
  p->weights = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->min_val);
  p->min_val = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->max_val);
  p->max_val = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->_iter);
  p->_iter = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyObject *__pyx_tp_richcompare_11apache_beam_10transforms_5stats__QuantileBuffer(PyObject *o1, PyObject *o2, int op) {
  switch (op) {
    case Py_LT: {
      return __pyx_pw_11apache_beam_10transforms_5stats_15_QuantileBuffer_5__lt__(o1, o2);
    }
    default: {
      return __Pyx_NewRef(Py_NotImplemented);
    }
  }
}

static PyObject *__pyx_getprop_11apache_beam_10transforms_5stats_15_QuantileBuffer_elements(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_11apache_beam_10transforms_5stats_15_QuantileBuffer_8elements_1__get__(o);
}

static PyObject *__pyx_getprop_11apache_beam_10transforms_5stats_15_QuantileBuffer_weights(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_11apache_beam_10transforms_5stats_15_QuantileBuffer_7weights_1__get__(o);
}

static PyObject *__pyx_getprop_11apache_beam_10transforms_5stats_15_QuantileBuffer_weighted(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_11apache_beam_10transforms_5stats_15_QuantileBuffer_8weighted_1__get__(o);
}

static PyObject *__pyx_getprop_11apache_beam_10transforms_5stats_15_QuantileBuffer_level(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_11apache_beam_10transforms_5stats_15_QuantileBuffer_5level_1__get__(o);
}

static PyObject *__pyx_getprop_11apache_beam_10transforms_5stats_15_QuantileBuffer_min_val(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_11apache_beam_10transforms_5stats_15_QuantileBuffer_7min_val_1__get__(o);
}

static PyObject *__pyx_getprop_11apache_beam_10transforms_5stats_15_QuantileBuffer_max_val(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_11apache_beam_10transforms_5stats_15_QuantileBuffer_7max_val_1__get__(o);
}

static PyObject *__pyx_getprop_11apache_beam_10transforms_5stats_15_QuantileBuffer__iter(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_11apache_beam_10transforms_5stats_15_QuantileBuffer_5_iter_1__get__(o);
}

static PyMethodDef __pyx_methods_11apache_beam_10transforms_5stats__QuantileBuffer[] = {
  {"__reduce_cython__", (PyCFunction)__pyx_pw_11apache_beam_10transforms_5stats_15_QuantileBuffer_7__reduce_cython__, METH_NOARGS, 0},
  {"__setstate_cython__", (PyCFunction)__pyx_pw_11apache_beam_10transforms_5stats_15_QuantileBuffer_9__setstate_cython__, METH_O, 0},
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_11apache_beam_10transforms_5stats__QuantileBuffer[] = {
  {(char *)"elements", __pyx_getprop_11apache_beam_10transforms_5stats_15_QuantileBuffer_elements, 0, (char *)0, 0},
  {(char *)"weights", __pyx_getprop_11apache_beam_10transforms_5stats_15_QuantileBuffer_weights, 0, (char *)0, 0},
  {(char *)"weighted", __pyx_getprop_11apache_beam_10transforms_5stats_15_QuantileBuffer_weighted, 0, (char *)0, 0},
  {(char *)"level", __pyx_getprop_11apache_beam_10transforms_5stats_15_QuantileBuffer_level, 0, (char *)0, 0},
  {(char *)"min_val", __pyx_getprop_11apache_beam_10transforms_5stats_15_QuantileBuffer_min_val, 0, (char *)0, 0},
  {(char *)"max_val", __pyx_getprop_11apache_beam_10transforms_5stats_15_QuantileBuffer_max_val, 0, (char *)0, 0},
  {(char *)"_iter", __pyx_getprop_11apache_beam_10transforms_5stats_15_QuantileBuffer__iter, 0, (char *)0, 0},
  {0, 0, 0, 0, 0}
};

static PyTypeObject __pyx_type_11apache_beam_10transforms_5stats__QuantileBuffer = {
  PyVarObject_HEAD_INIT(0, 0)
  "apache_beam.transforms.stats._QuantileBuffer", /*tp_name*/
  sizeof(struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileBuffer), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_11apache_beam_10transforms_5stats__QuantileBuffer, /*tp_dealloc*/
  #if PY_VERSION_HEX < 0x030800b4
  0, /*tp_print*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4
  0, /*tp_vectorcall_offset*/
  #endif
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #endif
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  "A single buffer in the sense of the referenced algorithm.\n  (see http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.6.6513&rep=rep1\n  &type=pdf and ApproximateQuantilesCombineFn for further information)", /*tp_doc*/
  __pyx_tp_traverse_11apache_beam_10transforms_5stats__QuantileBuffer, /*tp_traverse*/
  __pyx_tp_clear_11apache_beam_10transforms_5stats__QuantileBuffer, /*tp_clear*/
  __pyx_tp_richcompare_11apache_beam_10transforms_5stats__QuantileBuffer, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  __pyx_pw_11apache_beam_10transforms_5stats_15_QuantileBuffer_3__iter__, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_11apache_beam_10transforms_5stats__QuantileBuffer, /*tp_methods*/
  0, /*tp_members*/
  __pyx_getsets_11apache_beam_10transforms_5stats__QuantileBuffer, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_11apache_beam_10transforms_5stats_15_QuantileBuffer_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_11apache_beam_10transforms_5stats__QuantileBuffer, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b1 && (!CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800)
  0, /*tp_vectorcall*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
  0, /*tp_print*/
  #endif
  #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000 && PY_VERSION_HEX < 0x030a0000
  0, /*tp_pypy_flags*/
  #endif
};
static struct __pyx_vtabstruct_11apache_beam_10transforms_5stats__QuantileState __pyx_vtable_11apache_beam_10transforms_5stats__QuantileState;

static PyObject *__pyx_tp_new_11apache_beam_10transforms_5stats__QuantileState(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileState *p;
  PyObject *o;
  if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {
    o = (*t->tp_alloc)(t, 0);
  } else {
    o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0);
  }
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileState *)o);
  p->__pyx_vtab = __pyx_vtabptr_11apache_beam_10transforms_5stats__QuantileState;
  p->spec = ((struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileSpec *)Py_None); Py_INCREF(Py_None);
  p->buffers = Py_None; Py_INCREF(Py_None);
  p->unbuffered_elements = Py_None; Py_INCREF(Py_None);
  p->unbuffered_weights = Py_None; Py_INCREF(Py_None);
  p->add_unbuffered = Py_None; Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_11apache_beam_10transforms_5stats__QuantileState(PyObject *o) {
  struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileState *p = (struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileState *)o;
  #if CYTHON_USE_TP_FINALIZE
  if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !__Pyx_PyObject_GC_IsFinalized(o)) {
    if (PyObject_CallFinalizerFromDealloc(o)) return;
  }
  #endif
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->spec);
  Py_CLEAR(p->buffers);
  Py_CLEAR(p->unbuffered_elements);
  Py_CLEAR(p->unbuffered_weights);
  Py_CLEAR(p->add_unbuffered);
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_11apache_beam_10transforms_5stats__QuantileState(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileState *p = (struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileState *)o;
  if (p->spec) {
    e = (*v)(((PyObject *)p->spec), a); if (e) return e;
  }
  if (p->buffers) {
    e = (*v)(p->buffers, a); if (e) return e;
  }
  if (p->unbuffered_elements) {
    e = (*v)(p->unbuffered_elements, a); if (e) return e;
  }
  if (p->unbuffered_weights) {
    e = (*v)(p->unbuffered_weights, a); if (e) return e;
  }
  if (p->add_unbuffered) {
    e = (*v)(p->add_unbuffered, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_11apache_beam_10transforms_5stats__QuantileState(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileState *p = (struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileState *)o;
  tmp = ((PyObject*)p->spec);
  p->spec = ((struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileSpec *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->buffers);
  p->buffers = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->unbuffered_elements);
  p->unbuffered_elements = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->unbuffered_weights);
  p->unbuffered_weights = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->add_unbuffered);
  p->add_unbuffered = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyObject *__pyx_getprop_11apache_beam_10transforms_5stats_14_QuantileState_spec(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_11apache_beam_10transforms_5stats_14_QuantileState_4spec_1__get__(o);
}

static PyObject *__pyx_getprop_11apache_beam_10transforms_5stats_14_QuantileState_buffers(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_11apache_beam_10transforms_5stats_14_QuantileState_7buffers_1__get__(o);
}

static int __pyx_setprop_11apache_beam_10transforms_5stats_14_QuantileState_buffers(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_11apache_beam_10transforms_5stats_14_QuantileState_7buffers_3__set__(o, v);
  }
  else {
    return __pyx_pw_11apache_beam_10transforms_5stats_14_QuantileState_7buffers_5__del__(o);
  }
}

static PyObject *__pyx_getprop_11apache_beam_10transforms_5stats_14_QuantileState_unbuffered_elements(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_11apache_beam_10transforms_5stats_14_QuantileState_19unbuffered_elements_1__get__(o);
}

static int __pyx_setprop_11apache_beam_10transforms_5stats_14_QuantileState_unbuffered_elements(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_11apache_beam_10transforms_5stats_14_QuantileState_19unbuffered_elements_3__set__(o, v);
  }
  else {
    return __pyx_pw_11apache_beam_10transforms_5stats_14_QuantileState_19unbuffered_elements_5__del__(o);
  }
}

static PyObject *__pyx_getprop_11apache_beam_10transforms_5stats_14_QuantileState_unbuffered_weights(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_11apache_beam_10transforms_5stats_14_QuantileState_18unbuffered_weights_1__get__(o);
}

static int __pyx_setprop_11apache_beam_10transforms_5stats_14_QuantileState_unbuffered_weights(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_11apache_beam_10transforms_5stats_14_QuantileState_18unbuffered_weights_3__set__(o, v);
  }
  else {
    return __pyx_pw_11apache_beam_10transforms_5stats_14_QuantileState_18unbuffered_weights_5__del__(o);
  }
}

static PyObject *__pyx_getprop_11apache_beam_10transforms_5stats_14_QuantileState_add_unbuffered(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_11apache_beam_10transforms_5stats_14_QuantileState_14add_unbuffered_1__get__(o);
}

static int __pyx_setprop_11apache_beam_10transforms_5stats_14_QuantileState_add_unbuffered(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_11apache_beam_10transforms_5stats_14_QuantileState_14add_unbuffered_3__set__(o, v);
  }
  else {
    return __pyx_pw_11apache_beam_10transforms_5stats_14_QuantileState_14add_unbuffered_5__del__(o);
  }
}

static PyMethodDef __pyx_methods_11apache_beam_10transforms_5stats__QuantileState[] = {
  {"__reduce__", (PyCFunction)__pyx_pw_11apache_beam_10transforms_5stats_14_QuantileState_3__reduce__, METH_NOARGS, 0},
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_11apache_beam_10transforms_5stats__QuantileState[] = {
  {(char *)"spec", __pyx_getprop_11apache_beam_10transforms_5stats_14_QuantileState_spec, 0, (char *)0, 0},
  {(char *)"buffers", __pyx_getprop_11apache_beam_10transforms_5stats_14_QuantileState_buffers, __pyx_setprop_11apache_beam_10transforms_5stats_14_QuantileState_buffers, (char *)0, 0},
  {(char *)"unbuffered_elements", __pyx_getprop_11apache_beam_10transforms_5stats_14_QuantileState_unbuffered_elements, __pyx_setprop_11apache_beam_10transforms_5stats_14_QuantileState_unbuffered_elements, (char *)0, 0},
  {(char *)"unbuffered_weights", __pyx_getprop_11apache_beam_10transforms_5stats_14_QuantileState_unbuffered_weights, __pyx_setprop_11apache_beam_10transforms_5stats_14_QuantileState_unbuffered_weights, (char *)0, 0},
  {(char *)"add_unbuffered", __pyx_getprop_11apache_beam_10transforms_5stats_14_QuantileState_add_unbuffered, __pyx_setprop_11apache_beam_10transforms_5stats_14_QuantileState_add_unbuffered, (char *)0, 0},
  {0, 0, 0, 0, 0}
};

static PyTypeObject __pyx_type_11apache_beam_10transforms_5stats__QuantileState = {
  PyVarObject_HEAD_INIT(0, 0)
  "apache_beam.transforms.stats._QuantileState", /*tp_name*/
  sizeof(struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileState), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_11apache_beam_10transforms_5stats__QuantileState, /*tp_dealloc*/
  #if PY_VERSION_HEX < 0x030800b4
  0, /*tp_print*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4
  0, /*tp_vectorcall_offset*/
  #endif
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #endif
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  "\n  Compact summarization of a collection on which quantiles can be estimated.\n  ", /*tp_doc*/
  __pyx_tp_traverse_11apache_beam_10transforms_5stats__QuantileState, /*tp_traverse*/
  __pyx_tp_clear_11apache_beam_10transforms_5stats__QuantileState, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_11apache_beam_10transforms_5stats__QuantileState, /*tp_methods*/
  0, /*tp_members*/
  __pyx_getsets_11apache_beam_10transforms_5stats__QuantileState, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_11apache_beam_10transforms_5stats_14_QuantileState_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_11apache_beam_10transforms_5stats__QuantileState, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b1 && (!CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800)
  0, /*tp_vectorcall*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
  0, /*tp_print*/
  #endif
  #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000 && PY_VERSION_HEX < 0x030a0000
  0, /*tp_pypy_flags*/
  #endif
};

static struct __pyx_obj_11apache_beam_10transforms_5stats___pyx_scope_struct____init__ *__pyx_freelist_11apache_beam_10transforms_5stats___pyx_scope_struct____init__[8];
static int __pyx_freecount_11apache_beam_10transforms_5stats___pyx_scope_struct____init__ = 0;

static PyObject *__pyx_tp_new_11apache_beam_10transforms_5stats___pyx_scope_struct____init__(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_11apache_beam_10transforms_5stats___pyx_scope_struct____init__ > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_11apache_beam_10transforms_5stats___pyx_scope_struct____init__)))) {
    o = (PyObject*)__pyx_freelist_11apache_beam_10transforms_5stats___pyx_scope_struct____init__[--__pyx_freecount_11apache_beam_10transforms_5stats___pyx_scope_struct____init__];
    memset(o, 0, sizeof(struct __pyx_obj_11apache_beam_10transforms_5stats___pyx_scope_struct____init__));
    (void) PyObject_INIT(o, t);
    PyObject_GC_Track(o);
  } else {
    o = (*t->tp_alloc)(t, 0);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_11apache_beam_10transforms_5stats___pyx_scope_struct____init__(PyObject *o) {
  struct __pyx_obj_11apache_beam_10transforms_5stats___pyx_scope_struct____init__ *p = (struct __pyx_obj_11apache_beam_10transforms_5stats___pyx_scope_struct____init__ *)o;
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_v_key);
  if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_11apache_beam_10transforms_5stats___pyx_scope_struct____init__ < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_11apache_beam_10transforms_5stats___pyx_scope_struct____init__)))) {
    __pyx_freelist_11apache_beam_10transforms_5stats___pyx_scope_struct____init__[__pyx_freecount_11apache_beam_10transforms_5stats___pyx_scope_struct____init__++] = ((struct __pyx_obj_11apache_beam_10transforms_5stats___pyx_scope_struct____init__ *)o);
  } else {
    (*Py_TYPE(o)->tp_free)(o);
  }
}

static int __pyx_tp_traverse_11apache_beam_10transforms_5stats___pyx_scope_struct____init__(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_11apache_beam_10transforms_5stats___pyx_scope_struct____init__ *p = (struct __pyx_obj_11apache_beam_10transforms_5stats___pyx_scope_struct____init__ *)o;
  if (p->__pyx_v_key) {
    e = (*v)(p->__pyx_v_key, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_11apache_beam_10transforms_5stats___pyx_scope_struct____init__(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_11apache_beam_10transforms_5stats___pyx_scope_struct____init__ *p = (struct __pyx_obj_11apache_beam_10transforms_5stats___pyx_scope_struct____init__ *)o;
  tmp = ((PyObject*)p->__pyx_v_key);
  p->__pyx_v_key = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyTypeObject __pyx_type_11apache_beam_10transforms_5stats___pyx_scope_struct____init__ = {
  PyVarObject_HEAD_INIT(0, 0)
  "apache_beam.transforms.stats.__pyx_scope_struct____init__", /*tp_name*/
  sizeof(struct __pyx_obj_11apache_beam_10transforms_5stats___pyx_scope_struct____init__), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_11apache_beam_10transforms_5stats___pyx_scope_struct____init__, /*tp_dealloc*/
  #if PY_VERSION_HEX < 0x030800b4
  0, /*tp_print*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4
  0, /*tp_vectorcall_offset*/
  #endif
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #endif
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_11apache_beam_10transforms_5stats___pyx_scope_struct____init__, /*tp_traverse*/
  __pyx_tp_clear_11apache_beam_10transforms_5stats___pyx_scope_struct____init__, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  0, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_11apache_beam_10transforms_5stats___pyx_scope_struct____init__, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b1 && (!CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800)
  0, /*tp_vectorcall*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
  0, /*tp_print*/
  #endif
  #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000 && PY_VERSION_HEX < 0x030a0000
  0, /*tp_pypy_flags*/
  #endif
};

static struct __pyx_obj_11apache_beam_10transforms_5stats___pyx_scope_struct_1_get_argsort_key *__pyx_freelist_11apache_beam_10transforms_5stats___pyx_scope_struct_1_get_argsort_key[8];
static int __pyx_freecount_11apache_beam_10transforms_5stats___pyx_scope_struct_1_get_argsort_key = 0;

static PyObject *__pyx_tp_new_11apache_beam_10transforms_5stats___pyx_scope_struct_1_get_argsort_key(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_11apache_beam_10transforms_5stats___pyx_scope_struct_1_get_argsort_key > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_11apache_beam_10transforms_5stats___pyx_scope_struct_1_get_argsort_key)))) {
    o = (PyObject*)__pyx_freelist_11apache_beam_10transforms_5stats___pyx_scope_struct_1_get_argsort_key[--__pyx_freecount_11apache_beam_10transforms_5stats___pyx_scope_struct_1_get_argsort_key];
    memset(o, 0, sizeof(struct __pyx_obj_11apache_beam_10transforms_5stats___pyx_scope_struct_1_get_argsort_key));
    (void) PyObject_INIT(o, t);
    PyObject_GC_Track(o);
  } else {
    o = (*t->tp_alloc)(t, 0);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_11apache_beam_10transforms_5stats___pyx_scope_struct_1_get_argsort_key(PyObject *o) {
  struct __pyx_obj_11apache_beam_10transforms_5stats___pyx_scope_struct_1_get_argsort_key *p = (struct __pyx_obj_11apache_beam_10transforms_5stats___pyx_scope_struct_1_get_argsort_key *)o;
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_v_elements);
  Py_CLEAR(p->__pyx_v_self);
  if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_11apache_beam_10transforms_5stats___pyx_scope_struct_1_get_argsort_key < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_11apache_beam_10transforms_5stats___pyx_scope_struct_1_get_argsort_key)))) {
    __pyx_freelist_11apache_beam_10transforms_5stats___pyx_scope_struct_1_get_argsort_key[__pyx_freecount_11apache_beam_10transforms_5stats___pyx_scope_struct_1_get_argsort_key++] = ((struct __pyx_obj_11apache_beam_10transforms_5stats___pyx_scope_struct_1_get_argsort_key *)o);
  } else {
    (*Py_TYPE(o)->tp_free)(o);
  }
}

static int __pyx_tp_traverse_11apache_beam_10transforms_5stats___pyx_scope_struct_1_get_argsort_key(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_11apache_beam_10transforms_5stats___pyx_scope_struct_1_get_argsort_key *p = (struct __pyx_obj_11apache_beam_10transforms_5stats___pyx_scope_struct_1_get_argsort_key *)o;
  if (p->__pyx_v_elements) {
    e = (*v)(p->__pyx_v_elements, a); if (e) return e;
  }
  if (p->__pyx_v_self) {
    e = (*v)(((PyObject *)p->__pyx_v_self), a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_11apache_beam_10transforms_5stats___pyx_scope_struct_1_get_argsort_key(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_11apache_beam_10transforms_5stats___pyx_scope_struct_1_get_argsort_key *p = (struct __pyx_obj_11apache_beam_10transforms_5stats___pyx_scope_struct_1_get_argsort_key *)o;
  tmp = ((PyObject*)p->__pyx_v_elements);
  p->__pyx_v_elements = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->__pyx_v_self);
  p->__pyx_v_self = ((struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileSpec *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyTypeObject __pyx_type_11apache_beam_10transforms_5stats___pyx_scope_struct_1_get_argsort_key = {
  PyVarObject_HEAD_INIT(0, 0)
  "apache_beam.transforms.stats.__pyx_scope_struct_1_get_argsort_key", /*tp_name*/
  sizeof(struct __pyx_obj_11apache_beam_10transforms_5stats___pyx_scope_struct_1_get_argsort_key), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_11apache_beam_10transforms_5stats___pyx_scope_struct_1_get_argsort_key, /*tp_dealloc*/
  #if PY_VERSION_HEX < 0x030800b4
  0, /*tp_print*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4
  0, /*tp_vectorcall_offset*/
  #endif
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #endif
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_11apache_beam_10transforms_5stats___pyx_scope_struct_1_get_argsort_key, /*tp_traverse*/
  __pyx_tp_clear_11apache_beam_10transforms_5stats___pyx_scope_struct_1_get_argsort_key, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  0, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_11apache_beam_10transforms_5stats___pyx_scope_struct_1_get_argsort_key, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b1 && (!CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800)
  0, /*tp_vectorcall*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
  0, /*tp_print*/
  #endif
  #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000 && PY_VERSION_HEX < 0x030a0000
  0, /*tp_pypy_flags*/
  #endif
};

static PyMethodDef __pyx_methods[] = {
  {0, 0, 0, 0}
};

static int __pyx_import_star_set(PyObject *o, PyObject* py_name, char *name) {
  static const char* internal_type_names[] = {
    "_QuantileBuffer",
    "_QuantileSpec",
    "_QuantileState",
    "__pyx_ctuple_Py_ssize_t",
    "__pyx_ctuple_Py_ssize_t_struct",
    "__pyx_ctuple_double",
    "__pyx_ctuple_double_struct",
    "__pyx_ctuple_int64_t",
    "__pyx_ctuple_int64_t__and_int64_t",
    "__pyx_ctuple_int64_t__and_int64_t_struct",
    "__pyx_ctuple_int64_t_struct",
    "__pyx_ctuple_long__and_long__and_long",
    "__pyx_ctuple_long__and_long__and_long_struct",
    "__pyx_scope_struct_1_get_argsort_key",
    "__pyx_scope_struct____init__",
    "int64_t",
    0
  };
  const char** type_name = internal_type_names;
  while (*type_name) {
    if (__Pyx_StrEq(name, *type_name)) {
      PyErr_Format(PyExc_TypeError, "Cannot overwrite C type %s", name);
      goto bad;
    }
    type_name++;
  }
  if (0);
  else {
    if (PyObject_SetAttr(__pyx_m, py_name, o) < 0) goto bad;
  }
  return 0;
  bad:
  return -1;
}

static int
__Pyx_import_all_from(PyObject *locals, PyObject *v)
{
    PyObject *all = PyObject_GetAttrString(v, "__all__");
    PyObject *dict, *name, *value;
    int skip_leading_underscores = 0;
    int pos, err;
    if (all == NULL) {
        if (!PyErr_ExceptionMatches(PyExc_AttributeError))
            return -1;
        PyErr_Clear();
        dict = PyObject_GetAttrString(v, "__dict__");
        if (dict == NULL) {
            if (!PyErr_ExceptionMatches(PyExc_AttributeError))
                return -1;
            PyErr_SetString(PyExc_ImportError,
            "from-import-* object has no __dict__ and no __all__");
            return -1;
        }
#if PY_MAJOR_VERSION < 3
        all = PyObject_CallMethod(dict, (char *)"keys", NULL);
#else
        all = PyMapping_Keys(dict);
#endif
        Py_DECREF(dict);
        if (all == NULL)
            return -1;
        skip_leading_underscores = 1;
    }
    for (pos = 0, err = 0; ; pos++) {
        name = PySequence_GetItem(all, pos);
        if (name == NULL) {
            if (!PyErr_ExceptionMatches(PyExc_IndexError))
                err = -1;
            else
                PyErr_Clear();
            break;
        }
        if (skip_leading_underscores &&
#if PY_MAJOR_VERSION < 3
            likely(PyString_Check(name)) &&
            PyString_AS_STRING(name)[0] == '_')
#else
            likely(PyUnicode_Check(name)) &&
            likely(__Pyx_PyUnicode_GET_LENGTH(name)) &&
            __Pyx_PyUnicode_READ_CHAR(name, 0) == '_')
#endif
        {
            Py_DECREF(name);
            continue;
        }
        value = PyObject_GetAttr(v, name);
        if (value == NULL)
            err = -1;
        else if (PyDict_CheckExact(locals))
            err = PyDict_SetItem(locals, name, value);
        else
            err = PyObject_SetItem(locals, name, value);
        Py_DECREF(name);
        Py_XDECREF(value);
        if (err != 0)
            break;
    }
    Py_DECREF(all);
    return err;
}
static int __pyx_import_star(PyObject* m) {
    int i;
    int ret = -1;
    char* s;
    PyObject *locals = 0;
    PyObject *list = 0;
#if PY_MAJOR_VERSION >= 3
    PyObject *utf8_name = 0;
#endif
    PyObject *name;
    PyObject *item;
    locals = PyDict_New();              if (!locals) goto bad;
    if (__Pyx_import_all_from(locals, m) < 0) goto bad;
    list = PyDict_Items(locals);        if (!list) goto bad;
    for(i=0; i<PyList_GET_SIZE(list); i++) {
        name = PyTuple_GET_ITEM(PyList_GET_ITEM(list, i), 0);
        item = PyTuple_GET_ITEM(PyList_GET_ITEM(list, i), 1);
#if PY_MAJOR_VERSION >= 3
        utf8_name = PyUnicode_AsUTF8String(name);
        if (!utf8_name) goto bad;
        s = PyBytes_AS_STRING(utf8_name);
        if (__pyx_import_star_set(item, name, s) < 0) goto bad;
        Py_DECREF(utf8_name); utf8_name = 0;
#else
        s = PyString_AsString(name);
        if (!s) goto bad;
        if (__pyx_import_star_set(item, name, s) < 0) goto bad;
#endif
    }
    ret = 0;
bad:
    Py_XDECREF(locals);
    Py_XDECREF(list);
#if PY_MAJOR_VERSION >= 3
    Py_XDECREF(utf8_name);
#endif
    return ret;
}



#if PY_MAJOR_VERSION >= 3
#if CYTHON_PEP489_MULTI_PHASE_INIT
static PyObject* __pyx_pymod_create(PyObject *spec, PyModuleDef *def); /*proto*/
static int __pyx_pymod_exec_stats(PyObject* module); /*proto*/
static PyModuleDef_Slot __pyx_moduledef_slots[] = {
  {Py_mod_create, (void*)__pyx_pymod_create},
  {Py_mod_exec, (void*)__pyx_pymod_exec_stats},
  {0, NULL}
};
#endif

static struct PyModuleDef __pyx_moduledef = {
    PyModuleDef_HEAD_INIT,
    "stats",
    __pyx_k_This_module_has_all_statistic_re, /* m_doc */
  #if CYTHON_PEP489_MULTI_PHASE_INIT
    0, /* m_size */
  #else
    -1, /* m_size */
  #endif
    __pyx_methods /* m_methods */,
  #if CYTHON_PEP489_MULTI_PHASE_INIT
    __pyx_moduledef_slots, /* m_slots */
  #else
    NULL, /* m_reload */
  #endif
    NULL, /* m_traverse */
    NULL, /* m_clear */
    NULL /* m_free */
};
#endif
#ifndef CYTHON_SMALL_CODE
#if defined(__clang__)
    #define CYTHON_SMALL_CODE
#elif defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))
    #define CYTHON_SMALL_CODE __attribute__((cold))
#else
    #define CYTHON_SMALL_CODE
#endif
#endif

static __Pyx_StringTabEntry __pyx_string_tab[] = {
  {&__pyx_kp_s_An_object_to_keep_samples_and_c, __pyx_k_An_object_to_keep_samples_and_c, sizeof(__pyx_k_An_object_to_keep_samples_and_c), 0, 0, 1, 0},
  {&__pyx_n_s_Any, __pyx_k_Any, sizeof(__pyx_k_Any), 0, 0, 1, 1},
  {&__pyx_n_s_ApproximateQuantiles, __pyx_k_ApproximateQuantiles, sizeof(__pyx_k_ApproximateQuantiles), 0, 0, 1, 1},
  {&__pyx_n_u_ApproximateQuantiles, __pyx_k_ApproximateQuantiles, sizeof(__pyx_k_ApproximateQuantiles), 0, 1, 0, 1},
  {&__pyx_n_s_ApproximateQuantilesCombineFn, __pyx_k_ApproximateQuantilesCombineFn, sizeof(__pyx_k_ApproximateQuantilesCombineFn), 0, 0, 1, 1},
  {&__pyx_n_s_ApproximateQuantilesCombineFn_2, __pyx_k_ApproximateQuantilesCombineFn_2, sizeof(__pyx_k_ApproximateQuantilesCombineFn_2), 0, 0, 1, 1},
  {&__pyx_n_s_ApproximateQuantilesCombineFn_3, __pyx_k_ApproximateQuantilesCombineFn_3, sizeof(__pyx_k_ApproximateQuantilesCombineFn_3), 0, 0, 1, 1},
  {&__pyx_n_s_ApproximateQuantilesCombineFn__a, __pyx_k_ApproximateQuantilesCombineFn__a, sizeof(__pyx_k_ApproximateQuantilesCombineFn__a), 0, 0, 1, 1},
  {&__pyx_n_s_ApproximateQuantilesCombineFn__o, __pyx_k_ApproximateQuantilesCombineFn__o, sizeof(__pyx_k_ApproximateQuantilesCombineFn__o), 0, 0, 1, 1},
  {&__pyx_n_s_ApproximateQuantilesCombineFn_ad, __pyx_k_ApproximateQuantilesCombineFn_ad, sizeof(__pyx_k_ApproximateQuantilesCombineFn_ad), 0, 0, 1, 1},
  {&__pyx_n_s_ApproximateQuantilesCombineFn_cr, __pyx_k_ApproximateQuantilesCombineFn_cr, sizeof(__pyx_k_ApproximateQuantilesCombineFn_cr), 0, 0, 1, 1},
  {&__pyx_n_s_ApproximateQuantilesCombineFn_cr_2, __pyx_k_ApproximateQuantilesCombineFn_cr_2, sizeof(__pyx_k_ApproximateQuantilesCombineFn_cr_2), 0, 0, 1, 1},
  {&__pyx_n_s_ApproximateQuantilesCombineFn_ex, __pyx_k_ApproximateQuantilesCombineFn_ex, sizeof(__pyx_k_ApproximateQuantilesCombineFn_ex), 0, 0, 1, 1},
  {&__pyx_n_s_ApproximateQuantilesCombineFn_me, __pyx_k_ApproximateQuantilesCombineFn_me, sizeof(__pyx_k_ApproximateQuantilesCombineFn_me), 0, 0, 1, 1},
  {&__pyx_n_s_ApproximateQuantiles_Globally, __pyx_k_ApproximateQuantiles_Globally, sizeof(__pyx_k_ApproximateQuantiles_Globally), 0, 0, 1, 1},
  {&__pyx_n_s_ApproximateQuantiles_Globally_2, __pyx_k_ApproximateQuantiles_Globally_2, sizeof(__pyx_k_ApproximateQuantiles_Globally_2), 0, 0, 1, 1},
  {&__pyx_n_s_ApproximateQuantiles_Globally_di, __pyx_k_ApproximateQuantiles_Globally_di, sizeof(__pyx_k_ApproximateQuantiles_Globally_di), 0, 0, 1, 1},
  {&__pyx_n_s_ApproximateQuantiles_Globally_ex, __pyx_k_ApproximateQuantiles_Globally_ex, sizeof(__pyx_k_ApproximateQuantiles_Globally_ex), 0, 0, 1, 1},
  {&__pyx_n_s_ApproximateQuantiles_PerKey, __pyx_k_ApproximateQuantiles_PerKey, sizeof(__pyx_k_ApproximateQuantiles_PerKey), 0, 0, 1, 1},
  {&__pyx_n_s_ApproximateQuantiles_PerKey___in, __pyx_k_ApproximateQuantiles_PerKey___in, sizeof(__pyx_k_ApproximateQuantiles_PerKey___in), 0, 0, 1, 1},
  {&__pyx_n_s_ApproximateQuantiles_PerKey_disp, __pyx_k_ApproximateQuantiles_PerKey_disp, sizeof(__pyx_k_ApproximateQuantiles_PerKey_disp), 0, 0, 1, 1},
  {&__pyx_n_s_ApproximateQuantiles_PerKey_expa, __pyx_k_ApproximateQuantiles_PerKey_expa, sizeof(__pyx_k_ApproximateQuantiles_PerKey_expa), 0, 0, 1, 1},
  {&__pyx_n_s_ApproximateQuantiles__display_da, __pyx_k_ApproximateQuantiles__display_da, sizeof(__pyx_k_ApproximateQuantiles__display_da), 0, 0, 1, 1},
  {&__pyx_n_s_ApproximateUnique, __pyx_k_ApproximateUnique, sizeof(__pyx_k_ApproximateUnique), 0, 0, 1, 1},
  {&__pyx_n_u_ApproximateUnique, __pyx_k_ApproximateUnique, sizeof(__pyx_k_ApproximateUnique), 0, 1, 0, 1},
  {&__pyx_n_s_ApproximateUniqueCombineFn, __pyx_k_ApproximateUniqueCombineFn, sizeof(__pyx_k_ApproximateUniqueCombineFn), 0, 0, 1, 1},
  {&__pyx_n_u_ApproximateUniqueCombineFn, __pyx_k_ApproximateUniqueCombineFn, sizeof(__pyx_k_ApproximateUniqueCombineFn), 0, 1, 0, 1},
  {&__pyx_n_s_ApproximateUniqueCombineFn___ini, __pyx_k_ApproximateUniqueCombineFn___ini, sizeof(__pyx_k_ApproximateUniqueCombineFn___ini), 0, 0, 1, 1},
  {&__pyx_n_s_ApproximateUniqueCombineFn_add_i, __pyx_k_ApproximateUniqueCombineFn_add_i, sizeof(__pyx_k_ApproximateUniqueCombineFn_add_i), 0, 0, 1, 1},
  {&__pyx_kp_s_ApproximateUniqueCombineFn_comp, __pyx_k_ApproximateUniqueCombineFn_comp, sizeof(__pyx_k_ApproximateUniqueCombineFn_comp), 0, 0, 1, 0},
  {&__pyx_n_s_ApproximateUniqueCombineFn_creat, __pyx_k_ApproximateUniqueCombineFn_creat, sizeof(__pyx_k_ApproximateUniqueCombineFn_creat), 0, 0, 1, 1},
  {&__pyx_n_s_ApproximateUniqueCombineFn_displ, __pyx_k_ApproximateUniqueCombineFn_displ, sizeof(__pyx_k_ApproximateUniqueCombineFn_displ), 0, 0, 1, 1},
  {&__pyx_n_s_ApproximateUniqueCombineFn_extra, __pyx_k_ApproximateUniqueCombineFn_extra, sizeof(__pyx_k_ApproximateUniqueCombineFn_extra), 0, 0, 1, 1},
  {&__pyx_n_s_ApproximateUniqueCombineFn_merge, __pyx_k_ApproximateUniqueCombineFn_merge, sizeof(__pyx_k_ApproximateUniqueCombineFn_merge), 0, 0, 1, 1},
  {&__pyx_n_s_ApproximateUnique_Globally, __pyx_k_ApproximateUnique_Globally, sizeof(__pyx_k_ApproximateUnique_Globally), 0, 0, 1, 1},
  {&__pyx_n_s_ApproximateUnique_Globally___ini, __pyx_k_ApproximateUnique_Globally___ini, sizeof(__pyx_k_ApproximateUnique_Globally___ini), 0, 0, 1, 1},
  {&__pyx_n_s_ApproximateUnique_Globally_expan, __pyx_k_ApproximateUnique_Globally_expan, sizeof(__pyx_k_ApproximateUnique_Globally_expan), 0, 0, 1, 1},
  {&__pyx_n_s_ApproximateUnique_PerKey, __pyx_k_ApproximateUnique_PerKey, sizeof(__pyx_k_ApproximateUnique_PerKey), 0, 0, 1, 1},
  {&__pyx_n_s_ApproximateUnique_PerKey___init, __pyx_k_ApproximateUnique_PerKey___init, sizeof(__pyx_k_ApproximateUnique_PerKey___init), 0, 0, 1, 1},
  {&__pyx_n_s_ApproximateUnique_PerKey_expand, __pyx_k_ApproximateUnique_PerKey_expand, sizeof(__pyx_k_ApproximateUnique_PerKey_expand), 0, 0, 1, 1},
  {&__pyx_n_s_ApproximateUnique__get_sample_si, __pyx_k_ApproximateUnique__get_sample_si, sizeof(__pyx_k_ApproximateUnique__get_sample_si), 0, 0, 1, 1},
  {&__pyx_kp_u_ApproximateUnique_needs_a_size_1, __pyx_k_ApproximateUnique_needs_a_size_1, sizeof(__pyx_k_ApproximateUnique_needs_a_size_1), 0, 1, 0, 0},
  {&__pyx_kp_u_ApproximateUnique_needs_an_estim, __pyx_k_ApproximateUnique_needs_an_estim, sizeof(__pyx_k_ApproximateUnique_needs_an_estim), 0, 1, 0, 0},
  {&__pyx_n_s_ApproximateUnique_parse_input_pa, __pyx_k_ApproximateUnique_parse_input_pa, sizeof(__pyx_k_ApproximateUnique_parse_input_pa), 0, 0, 1, 1},
  {&__pyx_kp_s_Approximate_Globally_approximat, __pyx_k_Approximate_Globally_approximat, sizeof(__pyx_k_Approximate_Globally_approximat), 0, 0, 1, 0},
  {&__pyx_kp_s_Approximate_PerKey_approximate, __pyx_k_Approximate_PerKey_approximate, sizeof(__pyx_k_Approximate_PerKey_approximate), 0, 0, 1, 0},
  {&__pyx_n_s_Callable, __pyx_k_Callable, sizeof(__pyx_k_Callable), 0, 0, 1, 1},
  {&__pyx_n_s_CombineFn, __pyx_k_CombineFn, sizeof(__pyx_k_CombineFn), 0, 0, 1, 1},
  {&__pyx_n_s_CombineGlobally, __pyx_k_CombineGlobally, sizeof(__pyx_k_CombineGlobally), 0, 0, 1, 1},
  {&__pyx_n_s_CombinePerKey, __pyx_k_CombinePerKey, sizeof(__pyx_k_CombinePerKey), 0, 0, 1, 1},
  {&__pyx_kp_u_Couldn_t_find_murmurhash_Install, __pyx_k_Couldn_t_find_murmurhash_Install, sizeof(__pyx_k_Couldn_t_find_murmurhash_Install), 0, 1, 0, 0},
  {&__pyx_n_u_CountGlobalUniqueValues, __pyx_k_CountGlobalUniqueValues, sizeof(__pyx_k_CountGlobalUniqueValues), 0, 1, 0, 1},
  {&__pyx_n_u_CountPerKeyUniqueValues, __pyx_k_CountPerKeyUniqueValues, sizeof(__pyx_k_CountPerKeyUniqueValues), 0, 1, 0, 1},
  {&__pyx_n_s_DisplayDataItem, __pyx_k_DisplayDataItem, sizeof(__pyx_k_DisplayDataItem), 0, 0, 1, 1},
  {&__pyx_kp_u_Either_size_or_error_should_be_s, __pyx_k_Either_size_or_error_should_be_s, sizeof(__pyx_k_Either_size_or_error_should_be_s), 0, 1, 0, 0},
  {&__pyx_kp_u_Either_size_or_error_should_be_s_2, __pyx_k_Either_size_or_error_should_be_s_2, sizeof(__pyx_k_Either_size_or_error_should_be_s_2), 0, 1, 0, 0},
  {&__pyx_n_s_Globally, __pyx_k_Globally, sizeof(__pyx_k_Globally), 0, 0, 1, 1},
  {&__pyx_n_s_HASH_SPACE_SIZE, __pyx_k_HASH_SPACE_SIZE, sizeof(__pyx_k_HASH_SPACE_SIZE), 0, 0, 1, 1},
  {&__pyx_kp_s_Hashes_input_elements_and_uses, __pyx_k_Hashes_input_elements_and_uses, sizeof(__pyx_k_Hashes_input_elements_and_uses), 0, 0, 1, 0},
  {&__pyx_n_s_INPUT_ERROR_ERR_MSG, __pyx_k_INPUT_ERROR_ERR_MSG, sizeof(__pyx_k_INPUT_ERROR_ERR_MSG), 0, 0, 1, 1},
  {&__pyx_n_s_INPUT_SIZE_ERR_MSG, __pyx_k_INPUT_SIZE_ERR_MSG, sizeof(__pyx_k_INPUT_SIZE_ERR_MSG), 0, 0, 1, 1},
  {&__pyx_n_s_ImportError, __pyx_k_ImportError, sizeof(__pyx_k_ImportError), 0, 0, 1, 1},
  {&__pyx_kp_s_Incompatible_checksums_0x_x_vs_0, __pyx_k_Incompatible_checksums_0x_x_vs_0, sizeof(__pyx_k_Incompatible_checksums_0x_x_vs_0), 0, 0, 1, 0},
  {&__pyx_kp_u_Is_Input_Batched, __pyx_k_Is_Input_Batched, sizeof(__pyx_k_Is_Input_Batched), 0, 1, 0, 0},
  {&__pyx_kp_u_Is_Reversed, __pyx_k_Is_Reversed, sizeof(__pyx_k_Is_Reversed), 0, 1, 0, 0},
  {&__pyx_kp_u_Is_Weighted, __pyx_k_Is_Weighted, sizeof(__pyx_k_Is_Weighted), 0, 1, 0, 0},
  {&__pyx_n_s_K, __pyx_k_K, sizeof(__pyx_k_K), 0, 0, 1, 1},
  {&__pyx_n_u_K, __pyx_k_K, sizeof(__pyx_k_K), 0, 1, 0, 1},
  {&__pyx_n_s_LargestUnique, __pyx_k_LargestUnique, sizeof(__pyx_k_LargestUnique), 0, 0, 1, 1},
  {&__pyx_n_s_LargestUnique___init, __pyx_k_LargestUnique___init, sizeof(__pyx_k_LargestUnique___init), 0, 0, 1, 1},
  {&__pyx_n_s_LargestUnique_add, __pyx_k_LargestUnique_add, sizeof(__pyx_k_LargestUnique_add), 0, 0, 1, 1},
  {&__pyx_n_s_LargestUnique_get_estimate, __pyx_k_LargestUnique_get_estimate, sizeof(__pyx_k_LargestUnique_get_estimate), 0, 0, 1, 1},
  {&__pyx_n_s_List, __pyx_k_List, sizeof(__pyx_k_List), 0, 0, 1, 1},
  {&__pyx_n_s_MAX_NUM_ELEMENTS, __pyx_k_MAX_NUM_ELEMENTS, sizeof(__pyx_k_MAX_NUM_ELEMENTS), 0, 0, 1, 1},
  {&__pyx_n_s_MULTI_VALUE_ERR_MSG, __pyx_k_MULTI_VALUE_ERR_MSG, sizeof(__pyx_k_MULTI_VALUE_ERR_MSG), 0, 0, 1, 1},
  {&__pyx_n_s_NO_VALUE_ERR_MSG, __pyx_k_NO_VALUE_ERR_MSG, sizeof(__pyx_k_NO_VALUE_ERR_MSG), 0, 0, 1, 1},
  {&__pyx_n_s_PTransform, __pyx_k_PTransform, sizeof(__pyx_k_PTransform), 0, 0, 1, 1},
  {&__pyx_kp_s_PTransform_for_getting_the_idea, __pyx_k_PTransform_for_getting_the_idea, sizeof(__pyx_k_PTransform_for_getting_the_idea), 0, 0, 1, 0},
  {&__pyx_kp_s_PTransform_takes_PCollection_an, __pyx_k_PTransform_takes_PCollection_an, sizeof(__pyx_k_PTransform_takes_PCollection_an), 0, 0, 1, 0},
  {&__pyx_kp_s_PTransform_takes_PCollection_of, __pyx_k_PTransform_takes_PCollection_of, sizeof(__pyx_k_PTransform_takes_PCollection_of), 0, 0, 1, 0},
  {&__pyx_n_s_PerKey, __pyx_k_PerKey, sizeof(__pyx_k_PerKey), 0, 0, 1, 1},
  {&__pyx_n_s_PickleError, __pyx_k_PickleError, sizeof(__pyx_k_PickleError), 0, 0, 1, 1},
  {&__pyx_n_s_QuantileBuffer, __pyx_k_QuantileBuffer, sizeof(__pyx_k_QuantileBuffer), 0, 0, 1, 1},
  {&__pyx_n_s_QuantileBuffer___reduce_cython, __pyx_k_QuantileBuffer___reduce_cython, sizeof(__pyx_k_QuantileBuffer___reduce_cython), 0, 0, 1, 1},
  {&__pyx_n_s_QuantileBuffer___setstate_cytho, __pyx_k_QuantileBuffer___setstate_cytho, sizeof(__pyx_k_QuantileBuffer___setstate_cytho), 0, 0, 1, 1},
  {&__pyx_n_s_QuantileSpec, __pyx_k_QuantileSpec, sizeof(__pyx_k_QuantileSpec), 0, 0, 1, 1},
  {&__pyx_n_s_QuantileSpec___reduce, __pyx_k_QuantileSpec___reduce, sizeof(__pyx_k_QuantileSpec___reduce), 0, 0, 1, 1},
  {&__pyx_n_s_QuantileSpec_get_argsort_key, __pyx_k_QuantileSpec_get_argsort_key, sizeof(__pyx_k_QuantileSpec_get_argsort_key), 0, 0, 1, 1},
  {&__pyx_n_s_QuantileState, __pyx_k_QuantileState, sizeof(__pyx_k_QuantileState), 0, 0, 1, 1},
  {&__pyx_n_s_QuantileState___reduce, __pyx_k_QuantileState___reduce, sizeof(__pyx_k_QuantileState___reduce), 0, 0, 1, 1},
  {&__pyx_n_s_QuantileState__add_unbuffered, __pyx_k_QuantileState__add_unbuffered, sizeof(__pyx_k_QuantileState__add_unbuffered), 0, 0, 1, 1},
  {&__pyx_n_s_QuantileState__add_unbuffered_w, __pyx_k_QuantileState__add_unbuffered_w, sizeof(__pyx_k_QuantileState__add_unbuffered_w), 0, 0, 1, 1},
  {&__pyx_n_s_QuantileState_collapse_if_neede, __pyx_k_QuantileState_collapse_if_neede, sizeof(__pyx_k_QuantileState_collapse_if_neede), 0, 0, 1, 1},
  {&__pyx_n_s_QuantileState_finalize, __pyx_k_QuantileState_finalize, sizeof(__pyx_k_QuantileState_finalize), 0, 0, 1, 1},
  {&__pyx_n_s_QuantileState_is_empty, __pyx_k_QuantileState_is_empty, sizeof(__pyx_k_QuantileState_is_empty), 0, 0, 1, 1},
  {&__pyx_kp_u_Quantile_Count, __pyx_k_Quantile_Count, sizeof(__pyx_k_Quantile_Count), 0, 1, 0, 0},
  {&__pyx_kp_u_Record_Comparer_Key, __pyx_k_Record_Comparer_Key, sizeof(__pyx_k_Record_Comparer_Key), 0, 1, 0, 0},
  {&__pyx_n_s_RuntimeError, __pyx_k_RuntimeError, sizeof(__pyx_k_RuntimeError), 0, 0, 1, 1},
  {&__pyx_kp_u_Runtime_exception_s, __pyx_k_Runtime_exception_s, sizeof(__pyx_k_Runtime_exception_s), 0, 1, 0, 0},
  {&__pyx_n_s_Sequence, __pyx_k_Sequence, sizeof(__pyx_k_Sequence), 0, 0, 1, 1},
  {&__pyx_n_s_StopIteration, __pyx_k_StopIteration, sizeof(__pyx_k_StopIteration), 0, 0, 1, 1},
  {&__pyx_n_s_T, __pyx_k_T, sizeof(__pyx_k_T), 0, 0, 1, 1},
  {&__pyx_n_u_T, __pyx_k_T, sizeof(__pyx_k_T), 0, 1, 0, 1},
  {&__pyx_kp_s_This_combiner_gives_an_idea_of, __pyx_k_This_combiner_gives_an_idea_of, sizeof(__pyx_k_This_combiner_gives_an_idea_of), 0, 0, 1, 0},
  {&__pyx_n_s_Tuple, __pyx_k_Tuple, sizeof(__pyx_k_Tuple), 0, 0, 1, 1},
  {&__pyx_n_s_TypeVar, __pyx_k_TypeVar, sizeof(__pyx_k_TypeVar), 0, 0, 1, 1},
  {&__pyx_n_s_Union, __pyx_k_Union, sizeof(__pyx_k_Union), 0, 0, 1, 1},
  {&__pyx_n_s_V, __pyx_k_V, sizeof(__pyx_k_V), 0, 0, 1, 1},
  {&__pyx_n_u_V, __pyx_k_V, sizeof(__pyx_k_V), 0, 1, 0, 1},
  {&__pyx_n_s_ValueError, __pyx_k_ValueError, sizeof(__pyx_k_ValueError), 0, 0, 1, 1},
  {&__pyx_n_s__102, __pyx_k__102, sizeof(__pyx_k__102), 0, 0, 1, 1},
  {&__pyx_n_s__3, __pyx_k__3, sizeof(__pyx_k__3), 0, 0, 1, 1},
  {&__pyx_n_s_a, __pyx_k_a, sizeof(__pyx_k_a), 0, 0, 1, 1},
  {&__pyx_n_s_accumulator, __pyx_k_accumulator, sizeof(__pyx_k_accumulator), 0, 0, 1, 1},
  {&__pyx_n_s_accumulators, __pyx_k_accumulators, sizeof(__pyx_k_accumulators), 0, 0, 1, 1},
  {&__pyx_n_s_add, __pyx_k_add, sizeof(__pyx_k_add), 0, 0, 1, 1},
  {&__pyx_n_s_add_input, __pyx_k_add_input, sizeof(__pyx_k_add_input), 0, 0, 1, 1},
  {&__pyx_n_u_add_input, __pyx_k_add_input, sizeof(__pyx_k_add_input), 0, 1, 0, 1},
  {&__pyx_n_s_add_inputs, __pyx_k_add_inputs, sizeof(__pyx_k_add_inputs), 0, 0, 1, 1},
  {&__pyx_n_s_add_unbuffered, __pyx_k_add_unbuffered, sizeof(__pyx_k_add_unbuffered), 0, 0, 1, 1},
  {&__pyx_n_s_add_unbuffered_2, __pyx_k_add_unbuffered_2, sizeof(__pyx_k_add_unbuffered_2), 0, 0, 1, 1},
  {&__pyx_n_s_add_unbuffered_weighted, __pyx_k_add_unbuffered_weighted, sizeof(__pyx_k_add_unbuffered_weighted), 0, 0, 1, 1},
  {&__pyx_n_s_all, __pyx_k_all, sizeof(__pyx_k_all), 0, 0, 1, 1},
  {&__pyx_n_s_all_elems, __pyx_k_all_elems, sizeof(__pyx_k_all_elems), 0, 0, 1, 1},
  {&__pyx_n_s_apache_beam, __pyx_k_apache_beam, sizeof(__pyx_k_apache_beam), 0, 0, 1, 1},
  {&__pyx_n_s_apache_beam_transforms_core, __pyx_k_apache_beam_transforms_core, sizeof(__pyx_k_apache_beam_transforms_core), 0, 0, 1, 1},
  {&__pyx_n_s_apache_beam_transforms_display, __pyx_k_apache_beam_transforms_display, sizeof(__pyx_k_apache_beam_transforms_display), 0, 0, 1, 1},
  {&__pyx_n_s_apache_beam_transforms_ptransfor, __pyx_k_apache_beam_transforms_ptransfor, sizeof(__pyx_k_apache_beam_transforms_ptransfor), 0, 0, 1, 1},
  {&__pyx_n_s_apache_beam_transforms_stats, __pyx_k_apache_beam_transforms_stats, sizeof(__pyx_k_apache_beam_transforms_stats), 0, 0, 1, 1},
  {&__pyx_kp_s_apache_beam_transforms_stats_py, __pyx_k_apache_beam_transforms_stats_py, sizeof(__pyx_k_apache_beam_transforms_stats_py), 0, 0, 1, 0},
  {&__pyx_n_s_append, __pyx_k_append, sizeof(__pyx_k_append), 0, 0, 1, 1},
  {&__pyx_n_s_args, __pyx_k_args, sizeof(__pyx_k_args), 0, 0, 1, 1},
  {&__pyx_n_s_b, __pyx_k_b, sizeof(__pyx_k_b), 0, 0, 1, 1},
  {&__pyx_n_s_buffer_elem, __pyx_k_buffer_elem, sizeof(__pyx_k_buffer_elem), 0, 0, 1, 1},
  {&__pyx_n_s_buffer_size, __pyx_k_buffer_size, sizeof(__pyx_k_buffer_size), 0, 0, 1, 1},
  {&__pyx_n_s_buffers, __pyx_k_buffers, sizeof(__pyx_k_buffers), 0, 0, 1, 1},
  {&__pyx_n_s_ceil, __pyx_k_ceil, sizeof(__pyx_k_ceil), 0, 0, 1, 1},
  {&__pyx_n_s_chain, __pyx_k_chain, sizeof(__pyx_k_chain), 0, 0, 1, 1},
  {&__pyx_n_s_class, __pyx_k_class, sizeof(__pyx_k_class), 0, 0, 1, 1},
  {&__pyx_n_s_cline_in_traceback, __pyx_k_cline_in_traceback, sizeof(__pyx_k_cline_in_traceback), 0, 0, 1, 1},
  {&__pyx_n_s_cls, __pyx_k_cls, sizeof(__pyx_k_cls), 0, 0, 1, 1},
  {&__pyx_n_s_coder, __pyx_k_coder, sizeof(__pyx_k_coder), 0, 0, 1, 1},
  {&__pyx_n_s_coder_2, __pyx_k_coder_2, sizeof(__pyx_k_coder_2), 0, 0, 1, 1},
  {&__pyx_n_s_coders, __pyx_k_coders, sizeof(__pyx_k_coders), 0, 0, 1, 1},
  {&__pyx_n_s_collapse_if_needed, __pyx_k_collapse_if_needed, sizeof(__pyx_k_collapse_if_needed), 0, 0, 1, 1},
  {&__pyx_n_s_create, __pyx_k_create, sizeof(__pyx_k_create), 0, 0, 1, 1},
  {&__pyx_n_s_create_accumulator, __pyx_k_create_accumulator, sizeof(__pyx_k_create_accumulator), 0, 0, 1, 1},
  {&__pyx_n_s_default_hash_fn, __pyx_k_default_hash_fn, sizeof(__pyx_k_default_hash_fn), 0, 0, 1, 1},
  {&__pyx_n_s_default_hash_fn_type, __pyx_k_default_hash_fn_type, sizeof(__pyx_k_default_hash_fn_type), 0, 0, 1, 1},
  {&__pyx_n_s_dict, __pyx_k_dict, sizeof(__pyx_k_dict), 0, 0, 1, 1},
  {&__pyx_n_s_dict_2, __pyx_k_dict_2, sizeof(__pyx_k_dict_2), 0, 0, 1, 1},
  {&__pyx_n_s_display_data, __pyx_k_display_data, sizeof(__pyx_k_display_data), 0, 0, 1, 1},
  {&__pyx_n_s_display_data_2, __pyx_k_display_data_2, sizeof(__pyx_k_display_data_2), 0, 0, 1, 1},
  {&__pyx_n_s_doc, __pyx_k_doc, sizeof(__pyx_k_doc), 0, 0, 1, 1},
  {&__pyx_n_s_e, __pyx_k_e, sizeof(__pyx_k_e), 0, 0, 1, 1},
  {&__pyx_n_s_element, __pyx_k_element, sizeof(__pyx_k_element), 0, 0, 1, 1},
  {&__pyx_n_s_elements, __pyx_k_elements, sizeof(__pyx_k_elements), 0, 0, 1, 1},
  {&__pyx_n_s_encode, __pyx_k_encode, sizeof(__pyx_k_encode), 0, 0, 1, 1},
  {&__pyx_n_s_epsilon, __pyx_k_epsilon, sizeof(__pyx_k_epsilon), 0, 0, 1, 1},
  {&__pyx_n_s_error, __pyx_k_error, sizeof(__pyx_k_error), 0, 0, 1, 1},
  {&__pyx_n_s_est, __pyx_k_est, sizeof(__pyx_k_est), 0, 0, 1, 1},
  {&__pyx_n_s_est_err, __pyx_k_est_err, sizeof(__pyx_k_est_err), 0, 0, 1, 1},
  {&__pyx_n_s_expand, __pyx_k_expand, sizeof(__pyx_k_expand), 0, 0, 1, 1},
  {&__pyx_n_s_extend, __pyx_k_extend, sizeof(__pyx_k_extend), 0, 0, 1, 1},
  {&__pyx_n_s_extract_output, __pyx_k_extract_output, sizeof(__pyx_k_extract_output), 0, 0, 1, 1},
  {&__pyx_n_s_finalize, __pyx_k_finalize, sizeof(__pyx_k_finalize), 0, 0, 1, 1},
  {&__pyx_n_s_from_iterable, __pyx_k_from_iterable, sizeof(__pyx_k_from_iterable), 0, 0, 1, 1},
  {&__pyx_n_s_get_argsort_key, __pyx_k_get_argsort_key, sizeof(__pyx_k_get_argsort_key), 0, 0, 1, 1},
  {&__pyx_n_s_get_argsort_key_locals_lambda, __pyx_k_get_argsort_key_locals_lambda, sizeof(__pyx_k_get_argsort_key_locals_lambda), 0, 0, 1, 1},
  {&__pyx_n_s_get_coder, __pyx_k_get_coder, sizeof(__pyx_k_get_coder), 0, 0, 1, 1},
  {&__pyx_n_s_get_default_hash_fn, __pyx_k_get_default_hash_fn, sizeof(__pyx_k_get_default_hash_fn), 0, 0, 1, 1},
  {&__pyx_n_s_get_estimate, __pyx_k_get_estimate, sizeof(__pyx_k_get_estimate), 0, 0, 1, 1},
  {&__pyx_n_s_get_sample_size_from_est_error, __pyx_k_get_sample_size_from_est_error, sizeof(__pyx_k_get_sample_size_from_est_error), 0, 0, 1, 1},
  {&__pyx_n_s_getitem, __pyx_k_getitem, sizeof(__pyx_k_getitem), 0, 0, 1, 1},
  {&__pyx_n_s_getstate, __pyx_k_getstate, sizeof(__pyx_k_getstate), 0, 0, 1, 1},
  {&__pyx_n_s_hash64, __pyx_k_hash64, sizeof(__pyx_k_hash64), 0, 0, 1, 1},
  {&__pyx_n_s_hash_fn, __pyx_k_hash_fn, sizeof(__pyx_k_hash_fn), 0, 0, 1, 1},
  {&__pyx_n_s_hashed_value, __pyx_k_hashed_value, sizeof(__pyx_k_hashed_value), 0, 0, 1, 1},
  {&__pyx_n_s_hashlib, __pyx_k_hashlib, sizeof(__pyx_k_hashlib), 0, 0, 1, 1},
  {&__pyx_n_s_heapify, __pyx_k_heapify, sizeof(__pyx_k_heapify), 0, 0, 1, 1},
  {&__pyx_n_s_heappop, __pyx_k_heappop, sizeof(__pyx_k_heappop), 0, 0, 1, 1},
  {&__pyx_n_s_heappush, __pyx_k_heappush, sizeof(__pyx_k_heappush), 0, 0, 1, 1},
  {&__pyx_n_s_heapq, __pyx_k_heapq, sizeof(__pyx_k_heapq), 0, 0, 1, 1},
  {&__pyx_n_s_hexdigest, __pyx_k_hexdigest, sizeof(__pyx_k_hexdigest), 0, 0, 1, 1},
  {&__pyx_n_s_i, __pyx_k_i, sizeof(__pyx_k_i), 0, 0, 1, 1},
  {&__pyx_n_s_import, __pyx_k_import, sizeof(__pyx_k_import), 0, 0, 1, 1},
  {&__pyx_n_s_init, __pyx_k_init, sizeof(__pyx_k_init), 0, 0, 1, 1},
  {&__pyx_n_s_init___locals_lambda, __pyx_k_init___locals_lambda, sizeof(__pyx_k_init___locals_lambda), 0, 0, 1, 1},
  {&__pyx_n_s_input_batched, __pyx_k_input_batched, sizeof(__pyx_k_input_batched), 0, 0, 1, 1},
  {&__pyx_n_u_input_batched, __pyx_k_input_batched, sizeof(__pyx_k_input_batched), 0, 1, 0, 1},
  {&__pyx_n_s_input_batched_2, __pyx_k_input_batched_2, sizeof(__pyx_k_input_batched_2), 0, 0, 1, 1},
  {&__pyx_n_s_is_empty, __pyx_k_is_empty, sizeof(__pyx_k_is_empty), 0, 0, 1, 1},
  {&__pyx_n_s_itertools, __pyx_k_itertools, sizeof(__pyx_k_itertools), 0, 0, 1, 1},
  {&__pyx_n_s_k, __pyx_k_k, sizeof(__pyx_k_k), 0, 0, 1, 1},
  {&__pyx_n_s_key, __pyx_k_key, sizeof(__pyx_k_key), 0, 0, 1, 1},
  {&__pyx_n_u_key, __pyx_k_key, sizeof(__pyx_k_key), 0, 1, 0, 1},
  {&__pyx_n_s_key_2, __pyx_k_key_2, sizeof(__pyx_k_key_2), 0, 0, 1, 1},
  {&__pyx_n_s_kwargs, __pyx_k_kwargs, sizeof(__pyx_k_kwargs), 0, 0, 1, 1},
  {&__pyx_n_s_label, __pyx_k_label, sizeof(__pyx_k_label), 0, 0, 1, 1},
  {&__pyx_n_s_level, __pyx_k_level, sizeof(__pyx_k_level), 0, 0, 1, 1},
  {&__pyx_n_s_log1p, __pyx_k_log1p, sizeof(__pyx_k_log1p), 0, 0, 1, 1},
  {&__pyx_n_s_logging, __pyx_k_logging, sizeof(__pyx_k_logging), 0, 0, 1, 1},
  {&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1},
  {&__pyx_n_s_math, __pyx_k_math, sizeof(__pyx_k_math), 0, 0, 1, 1},
  {&__pyx_n_s_max_num_elements, __pyx_k_max_num_elements, sizeof(__pyx_k_max_num_elements), 0, 0, 1, 1},
  {&__pyx_n_s_max_val, __pyx_k_max_val, sizeof(__pyx_k_max_val), 0, 0, 1, 1},
  {&__pyx_n_s_md5, __pyx_k_md5, sizeof(__pyx_k_md5), 0, 0, 1, 1},
  {&__pyx_n_u_md5, __pyx_k_md5, sizeof(__pyx_k_md5), 0, 1, 0, 1},
  {&__pyx_n_s_md5_hash, __pyx_k_md5_hash, sizeof(__pyx_k_md5_hash), 0, 0, 1, 1},
  {&__pyx_n_s_merge_accumulators, __pyx_k_merge_accumulators, sizeof(__pyx_k_merge_accumulators), 0, 0, 1, 1},
  {&__pyx_n_s_merged_accumulator, __pyx_k_merged_accumulator, sizeof(__pyx_k_merged_accumulator), 0, 0, 1, 1},
  {&__pyx_n_s_metaclass, __pyx_k_metaclass, sizeof(__pyx_k_metaclass), 0, 0, 1, 1},
  {&__pyx_n_s_min_hash, __pyx_k_min_hash, sizeof(__pyx_k_min_hash), 0, 0, 1, 1},
  {&__pyx_n_s_min_val, __pyx_k_min_val, sizeof(__pyx_k_min_val), 0, 0, 1, 1},
  {&__pyx_n_s_mmh3, __pyx_k_mmh3, sizeof(__pyx_k_mmh3), 0, 0, 1, 1},
  {&__pyx_n_u_mmh3, __pyx_k_mmh3, sizeof(__pyx_k_mmh3), 0, 1, 0, 1},
  {&__pyx_n_s_mmh3_hash, __pyx_k_mmh3_hash, sizeof(__pyx_k_mmh3_hash), 0, 0, 1, 1},
  {&__pyx_n_s_module, __pyx_k_module, sizeof(__pyx_k_module), 0, 0, 1, 1},
  {&__pyx_n_s_name, __pyx_k_name, sizeof(__pyx_k_name), 0, 0, 1, 1},
  {&__pyx_n_u_name, __pyx_k_name, sizeof(__pyx_k_name), 0, 1, 0, 1},
  {&__pyx_n_s_new, __pyx_k_new, sizeof(__pyx_k_new), 0, 0, 1, 1},
  {&__pyx_n_s_new_weight, __pyx_k_new_weight, sizeof(__pyx_k_new_weight), 0, 0, 1, 1},
  {&__pyx_n_s_num_buffers, __pyx_k_num_buffers, sizeof(__pyx_k_num_buffers), 0, 0, 1, 1},
  {&__pyx_n_s_num_quantiles, __pyx_k_num_quantiles, sizeof(__pyx_k_num_quantiles), 0, 0, 1, 1},
  {&__pyx_n_u_num_quantiles, __pyx_k_num_quantiles, sizeof(__pyx_k_num_quantiles), 0, 1, 0, 1},
  {&__pyx_n_s_num_quantiles_2, __pyx_k_num_quantiles_2, sizeof(__pyx_k_num_quantiles_2), 0, 0, 1, 1},
  {&__pyx_n_s_object, __pyx_k_object, sizeof(__pyx_k_object), 0, 0, 1, 1},
  {&__pyx_n_s_offset, __pyx_k_offset, sizeof(__pyx_k_offset), 0, 0, 1, 1},
  {&__pyx_n_s_offset_2, __pyx_k_offset_2, sizeof(__pyx_k_offset_2), 0, 0, 1, 1},
  {&__pyx_n_s_offset_fn, __pyx_k_offset_fn, sizeof(__pyx_k_offset_fn), 0, 0, 1, 1},
  {&__pyx_n_s_offset_jitter, __pyx_k_offset_jitter, sizeof(__pyx_k_offset_jitter), 0, 0, 1, 1},
  {&__pyx_n_s_parse_input_params, __pyx_k_parse_input_params, sizeof(__pyx_k_parse_input_params), 0, 0, 1, 1},
  {&__pyx_n_s_pcoll, __pyx_k_pcoll, sizeof(__pyx_k_pcoll), 0, 0, 1, 1},
  {&__pyx_n_s_pickle, __pyx_k_pickle, sizeof(__pyx_k_pickle), 0, 0, 1, 1},
  {&__pyx_n_s_pow, __pyx_k_pow, sizeof(__pyx_k_pow), 0, 0, 1, 1},
  {&__pyx_n_s_prepare, __pyx_k_prepare, sizeof(__pyx_k_prepare), 0, 0, 1, 1},
  {&__pyx_n_s_pyx_PickleError, __pyx_k_pyx_PickleError, sizeof(__pyx_k_pyx_PickleError), 0, 0, 1, 1},
  {&__pyx_n_s_pyx_checksum, __pyx_k_pyx_checksum, sizeof(__pyx_k_pyx_checksum), 0, 0, 1, 1},
  {&__pyx_n_s_pyx_result, __pyx_k_pyx_result, sizeof(__pyx_k_pyx_result), 0, 0, 1, 1},
  {&__pyx_n_s_pyx_state, __pyx_k_pyx_state, sizeof(__pyx_k_pyx_state), 0, 0, 1, 1},
  {&__pyx_n_s_pyx_type, __pyx_k_pyx_type, sizeof(__pyx_k_pyx_type), 0, 0, 1, 1},
  {&__pyx_n_s_pyx_unpickle__QuantileBuffer, __pyx_k_pyx_unpickle__QuantileBuffer, sizeof(__pyx_k_pyx_unpickle__QuantileBuffer), 0, 0, 1, 1},
  {&__pyx_n_s_pyx_vtable, __pyx_k_pyx_vtable, sizeof(__pyx_k_pyx_vtable), 0, 0, 1, 1},
  {&__pyx_n_s_qs, __pyx_k_qs, sizeof(__pyx_k_qs), 0, 0, 1, 1},
  {&__pyx_n_s_qs_2, __pyx_k_qs_2, sizeof(__pyx_k_qs_2), 0, 0, 1, 1},
  {&__pyx_n_s_qualname, __pyx_k_qualname, sizeof(__pyx_k_qualname), 0, 0, 1, 1},
  {&__pyx_n_s_quantile_state, __pyx_k_quantile_state, sizeof(__pyx_k_quantile_state), 0, 0, 1, 1},
  {&__pyx_n_s_quantiles, __pyx_k_quantiles, sizeof(__pyx_k_quantiles), 0, 0, 1, 1},
  {&__pyx_n_s_range, __pyx_k_range, sizeof(__pyx_k_range), 0, 0, 1, 1},
  {&__pyx_n_s_reduce, __pyx_k_reduce, sizeof(__pyx_k_reduce), 0, 0, 1, 1},
  {&__pyx_n_s_reduce_cython, __pyx_k_reduce_cython, sizeof(__pyx_k_reduce_cython), 0, 0, 1, 1},
  {&__pyx_n_s_reduce_ex, __pyx_k_reduce_ex, sizeof(__pyx_k_reduce_ex), 0, 0, 1, 1},
  {&__pyx_n_s_registry, __pyx_k_registry, sizeof(__pyx_k_registry), 0, 0, 1, 1},
  {&__pyx_n_s_remove, __pyx_k_remove, sizeof(__pyx_k_remove), 0, 0, 1, 1},
  {&__pyx_n_s_repeat, __pyx_k_repeat, sizeof(__pyx_k_repeat), 0, 0, 1, 1},
  {&__pyx_n_s_reverse, __pyx_k_reverse, sizeof(__pyx_k_reverse), 0, 0, 1, 1},
  {&__pyx_n_u_reverse, __pyx_k_reverse, sizeof(__pyx_k_reverse), 0, 1, 0, 1},
  {&__pyx_n_s_reverse_2, __pyx_k_reverse_2, sizeof(__pyx_k_reverse_2), 0, 0, 1, 1},
  {&__pyx_n_s_round, __pyx_k_round, sizeof(__pyx_k_round), 0, 0, 1, 1},
  {&__pyx_n_s_sample_heap, __pyx_k_sample_heap, sizeof(__pyx_k_sample_heap), 0, 0, 1, 1},
  {&__pyx_n_s_sample_set, __pyx_k_sample_set, sizeof(__pyx_k_sample_set), 0, 0, 1, 1},
  {&__pyx_n_s_sample_size, __pyx_k_sample_size, sizeof(__pyx_k_sample_size), 0, 0, 1, 1},
  {&__pyx_n_s_sample_size_2, __pyx_k_sample_size_2, sizeof(__pyx_k_sample_size_2), 0, 0, 1, 1},
  {&__pyx_n_u_sample_size_2, __pyx_k_sample_size_2, sizeof(__pyx_k_sample_size_2), 0, 1, 0, 1},
  {&__pyx_n_s_sample_space_size, __pyx_k_sample_space_size, sizeof(__pyx_k_sample_space_size), 0, 0, 1, 1},
  {&__pyx_n_s_seed, __pyx_k_seed, sizeof(__pyx_k_seed), 0, 0, 1, 1},
  {&__pyx_n_s_self, __pyx_k_self, sizeof(__pyx_k_self), 0, 0, 1, 1},
  {&__pyx_n_s_setstate, __pyx_k_setstate, sizeof(__pyx_k_setstate), 0, 0, 1, 1},
  {&__pyx_n_s_setstate_cython, __pyx_k_setstate_cython, sizeof(__pyx_k_setstate_cython), 0, 0, 1, 1},
  {&__pyx_n_s_signed, __pyx_k_signed, sizeof(__pyx_k_signed), 0, 0, 1, 1},
  {&__pyx_n_s_size, __pyx_k_size, sizeof(__pyx_k_size), 0, 0, 1, 1},
  {&__pyx_n_s_sort, __pyx_k_sort, sizeof(__pyx_k_sort), 0, 0, 1, 1},
  {&__pyx_n_s_sorted, __pyx_k_sorted, sizeof(__pyx_k_sorted), 0, 0, 1, 1},
  {&__pyx_n_s_spec, __pyx_k_spec, sizeof(__pyx_k_spec), 0, 0, 1, 1},
  {&__pyx_n_s_spec_2, __pyx_k_spec_2, sizeof(__pyx_k_spec_2), 0, 0, 1, 1},
  {&__pyx_n_s_state, __pyx_k_state, sizeof(__pyx_k_state), 0, 0, 1, 1},
  {&__pyx_n_s_staticmethod, __pyx_k_staticmethod, sizeof(__pyx_k_staticmethod), 0, 0, 1, 1},
  {&__pyx_n_s_step, __pyx_k_step, sizeof(__pyx_k_step), 0, 0, 1, 1},
  {&__pyx_kp_s_stringsource, __pyx_k_stringsource, sizeof(__pyx_k_stringsource), 0, 0, 1, 0},
  {&__pyx_n_s_sum, __pyx_k_sum, sizeof(__pyx_k_sum), 0, 0, 1, 1},
  {&__pyx_n_s_temp, __pyx_k_temp, sizeof(__pyx_k_temp), 0, 0, 1, 1},
  {&__pyx_n_s_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1},
  {&__pyx_n_s_total_weight, __pyx_k_total_weight, sizeof(__pyx_k_total_weight), 0, 0, 1, 1},
  {&__pyx_n_s_typecoders, __pyx_k_typecoders, sizeof(__pyx_k_typecoders), 0, 0, 1, 1},
  {&__pyx_n_s_typehints, __pyx_k_typehints, sizeof(__pyx_k_typehints), 0, 0, 1, 1},
  {&__pyx_n_s_typing, __pyx_k_typing, sizeof(__pyx_k_typing), 0, 0, 1, 1},
  {&__pyx_n_s_unbuffered_elements, __pyx_k_unbuffered_elements, sizeof(__pyx_k_unbuffered_elements), 0, 0, 1, 1},
  {&__pyx_n_s_unbuffered_weights, __pyx_k_unbuffered_weights, sizeof(__pyx_k_unbuffered_weights), 0, 0, 1, 1},
  {&__pyx_n_s_update, __pyx_k_update, sizeof(__pyx_k_update), 0, 0, 1, 1},
  {&__pyx_n_s_use_setstate, __pyx_k_use_setstate, sizeof(__pyx_k_use_setstate), 0, 0, 1, 1},
  {&__pyx_n_s_value, __pyx_k_value, sizeof(__pyx_k_value), 0, 0, 1, 1},
  {&__pyx_n_s_verify_deterministic, __pyx_k_verify_deterministic, sizeof(__pyx_k_verify_deterministic), 0, 0, 1, 1},
  {&__pyx_n_s_warning, __pyx_k_warning, sizeof(__pyx_k_warning), 0, 0, 1, 1},
  {&__pyx_n_s_weighted, __pyx_k_weighted, sizeof(__pyx_k_weighted), 0, 0, 1, 1},
  {&__pyx_n_u_weighted, __pyx_k_weighted, sizeof(__pyx_k_weighted), 0, 1, 0, 1},
  {&__pyx_n_s_weighted_2, __pyx_k_weighted_2, sizeof(__pyx_k_weighted_2), 0, 0, 1, 1},
  {&__pyx_n_s_weights, __pyx_k_weights, sizeof(__pyx_k_weights), 0, 0, 1, 1},
  {&__pyx_n_s_with_input_types, __pyx_k_with_input_types, sizeof(__pyx_k_with_input_types), 0, 0, 1, 1},
  {&__pyx_n_s_with_output_types, __pyx_k_with_output_types, sizeof(__pyx_k_with_output_types), 0, 0, 1, 1},
  {&__pyx_n_s_zip, __pyx_k_zip, sizeof(__pyx_k_zip), 0, 0, 1, 1},
  {0, 0, 0, 0, 0, 0, 0}
};
static CYTHON_SMALL_CODE int __Pyx_InitCachedBuiltins(void) {
  __pyx_builtin_ImportError = __Pyx_GetBuiltinName(__pyx_n_s_ImportError); if (!__pyx_builtin_ImportError) __PYX_ERR(0, 69, __pyx_L1_error)
  __pyx_builtin_object = __Pyx_GetBuiltinName(__pyx_n_s_object); if (!__pyx_builtin_object) __PYX_ERR(0, 90, __pyx_L1_error)
  __pyx_builtin_staticmethod = __Pyx_GetBuiltinName(__pyx_n_s_staticmethod); if (!__pyx_builtin_staticmethod) __PYX_ERR(0, 106, __pyx_L1_error)
  __pyx_builtin_ValueError = __Pyx_GetBuiltinName(__pyx_n_s_ValueError); if (!__pyx_builtin_ValueError) __PYX_ERR(0, 123, __pyx_L1_error)
  __pyx_builtin_round = __Pyx_GetBuiltinName(__pyx_n_s_round); if (!__pyx_builtin_round) __PYX_ERR(0, 239, __pyx_L1_error)
  __pyx_builtin_RuntimeError = __Pyx_GetBuiltinName(__pyx_n_s_RuntimeError); if (!__pyx_builtin_RuntimeError) __PYX_ERR(0, 264, __pyx_L1_error)
  __pyx_builtin_zip = __Pyx_GetBuiltinName(__pyx_n_s_zip); if (!__pyx_builtin_zip) __PYX_ERR(0, 502, __pyx_L1_error)
  __pyx_builtin_range = __Pyx_GetBuiltinName(__pyx_n_s_range); if (!__pyx_builtin_range) __PYX_ERR(0, 557, __pyx_L1_error)
  __pyx_builtin_sorted = __Pyx_GetBuiltinName(__pyx_n_s_sorted); if (!__pyx_builtin_sorted) __PYX_ERR(0, 558, __pyx_L1_error)
  __pyx_builtin_sum = __Pyx_GetBuiltinName(__pyx_n_s_sum); if (!__pyx_builtin_sum) __PYX_ERR(0, 675, __pyx_L1_error)
  __pyx_builtin_StopIteration = __Pyx_GetBuiltinName(__pyx_n_s_StopIteration); if (!__pyx_builtin_StopIteration) __PYX_ERR(0, 750, __pyx_L1_error)
  return 0;
  __pyx_L1_error:;
  return -1;
}

static CYTHON_SMALL_CODE int __Pyx_InitCachedConstants(void) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0);

  /* "apache_beam/transforms/stats.py":75
 *     # hexadecimal digits) to 16 digits and convert to int to get the 64-bit
 *     # integer fingerprint.
 *     return int(hashlib.md5(value).hexdigest()[:16], 16)             # <<<<<<<<<<<<<<
 * 
 *   _default_hash_fn = _md5_hash
 */
  __pyx_slice_ = PySlice_New(Py_None, __pyx_int_16, Py_None); if (unlikely(!__pyx_slice_)) __PYX_ERR(0, 75, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_slice_);
  __Pyx_GIVEREF(__pyx_slice_);

  /* "(tree fragment)":4
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 *     if __pyx_checksum not in (0x9fb38c7, 0x34dcb70, 0x7f9f705):             # <<<<<<<<<<<<<<
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (0x%x vs (0x9fb38c7, 0x34dcb70, 0x7f9f705) = (_iter, elements, level, max_val, min_val, weighted, weights))" % __pyx_checksum)
 */
  __pyx_tuple__2 = PyTuple_Pack(3, __pyx_int_167459015, __pyx_int_55430000, __pyx_int_133822213); if (unlikely(!__pyx_tuple__2)) __PYX_ERR(2, 4, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__2);
  __Pyx_GIVEREF(__pyx_tuple__2);

  /* "apache_beam/transforms/stats.py":56
 * 
 * # Type variables
 * T = typing.TypeVar('T')             # <<<<<<<<<<<<<<
 * K = typing.TypeVar('K')
 * V = typing.TypeVar('V')
 */
  __pyx_tuple__4 = PyTuple_Pack(1, __pyx_n_u_T); if (unlikely(!__pyx_tuple__4)) __PYX_ERR(0, 56, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__4);
  __Pyx_GIVEREF(__pyx_tuple__4);

  /* "apache_beam/transforms/stats.py":57
 * # Type variables
 * T = typing.TypeVar('T')
 * K = typing.TypeVar('K')             # <<<<<<<<<<<<<<
 * V = typing.TypeVar('V')
 * 
 */
  __pyx_tuple__5 = PyTuple_Pack(1, __pyx_n_u_K); if (unlikely(!__pyx_tuple__5)) __PYX_ERR(0, 57, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__5);
  __Pyx_GIVEREF(__pyx_tuple__5);

  /* "apache_beam/transforms/stats.py":58
 * T = typing.TypeVar('T')
 * K = typing.TypeVar('K')
 * V = typing.TypeVar('V')             # <<<<<<<<<<<<<<
 * 
 * try:
 */
  __pyx_tuple__6 = PyTuple_Pack(1, __pyx_n_u_V); if (unlikely(!__pyx_tuple__6)) __PYX_ERR(0, 58, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__6);
  __Pyx_GIVEREF(__pyx_tuple__6);

  /* "apache_beam/transforms/stats.py":63
 *   import mmh3  # pylint: disable=import-error
 * 
 *   def _mmh3_hash(value):             # <<<<<<<<<<<<<<
 *     # mmh3.hash64 returns two 64-bit unsigned integers
 *     return mmh3.hash64(value, seed=0, signed=False)[0]
 */
  __pyx_tuple__7 = PyTuple_Pack(1, __pyx_n_s_value); if (unlikely(!__pyx_tuple__7)) __PYX_ERR(0, 63, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__7);
  __Pyx_GIVEREF(__pyx_tuple__7);
  __pyx_codeobj__8 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__7, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_apache_beam_transforms_stats_py, __pyx_n_s_mmh3_hash, 63, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__8)) __PYX_ERR(0, 63, __pyx_L1_error)

  /* "apache_beam/transforms/stats.py":71
 * except ImportError:
 * 
 *   def _md5_hash(value):             # <<<<<<<<<<<<<<
 *     # md5 is a 128-bit hash, so we truncate the hexdigest (string of 32
 *     # hexadecimal digits) to 16 digits and convert to int to get the 64-bit
 */
  __pyx_tuple__9 = PyTuple_Pack(1, __pyx_n_s_value); if (unlikely(!__pyx_tuple__9)) __PYX_ERR(0, 71, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__9);
  __Pyx_GIVEREF(__pyx_tuple__9);
  __pyx_codeobj__10 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__9, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_apache_beam_transforms_stats_py, __pyx_n_s_md5_hash, 71, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__10)) __PYX_ERR(0, 71, __pyx_L1_error)

  /* "apache_beam/transforms/stats.py":81
 * 
 * 
 * def _get_default_hash_fn():             # <<<<<<<<<<<<<<
 *   """Returns either murmurhash or md5 based on installation."""
 *   if _default_hash_fn_type == 'md5':
 */
  __pyx_codeobj__11 = (PyObject*)__Pyx_PyCode_New(0, 0, 0, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_apache_beam_transforms_stats_py, __pyx_n_s_get_default_hash_fn, 81, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__11)) __PYX_ERR(0, 81, __pyx_L1_error)

  /* "apache_beam/transforms/stats.py":90
 * 
 * 
 * class ApproximateUnique(object):             # <<<<<<<<<<<<<<
 *   """
 *   Hashes input elements and uses those to extrapolate the size of the entire
 */
  __pyx_tuple__12 = PyTuple_Pack(1, __pyx_builtin_object); if (unlikely(!__pyx_tuple__12)) __PYX_ERR(0, 90, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__12);
  __Pyx_GIVEREF(__pyx_tuple__12);

  /* "apache_beam/transforms/stats.py":107
 * 
 *   @staticmethod
 *   def parse_input_params(size=None, error=None):             # <<<<<<<<<<<<<<
 *     """
 *     Check if input params are valid and return sample size.
 */
  __pyx_tuple__13 = PyTuple_Pack(2, __pyx_n_s_size, __pyx_n_s_error); if (unlikely(!__pyx_tuple__13)) __PYX_ERR(0, 107, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__13);
  __Pyx_GIVEREF(__pyx_tuple__13);
  __pyx_codeobj__14 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__13, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_apache_beam_transforms_stats_py, __pyx_n_s_parse_input_params, 107, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__14)) __PYX_ERR(0, 107, __pyx_L1_error)
  __pyx_tuple__15 = PyTuple_Pack(2, ((PyObject *)Py_None), ((PyObject *)Py_None)); if (unlikely(!__pyx_tuple__15)) __PYX_ERR(0, 107, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__15);
  __Pyx_GIVEREF(__pyx_tuple__15);

  /* "apache_beam/transforms/stats.py":138
 * 
 *   @staticmethod
 *   def _get_sample_size_from_est_error(est_err):             # <<<<<<<<<<<<<<
 *     """
 *     :return: sample size
 */
  __pyx_tuple__16 = PyTuple_Pack(1, __pyx_n_s_est_err); if (unlikely(!__pyx_tuple__16)) __PYX_ERR(0, 138, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__16);
  __Pyx_GIVEREF(__pyx_tuple__16);
  __pyx_codeobj__17 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__16, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_apache_beam_transforms_stats_py, __pyx_n_s_get_sample_size_from_est_error, 138, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__17)) __PYX_ERR(0, 138, __pyx_L1_error)

  /* "apache_beam/transforms/stats.py":150
 *   class Globally(PTransform):
 *     """ Approximate.Globally approximate number of unique values"""
 *     def __init__(self, size=None, error=None):             # <<<<<<<<<<<<<<
 *       self._sample_size = ApproximateUnique.parse_input_params(size, error)
 * 
 */
  __pyx_tuple__18 = PyTuple_Pack(3, __pyx_n_s_self, __pyx_n_s_size, __pyx_n_s_error); if (unlikely(!__pyx_tuple__18)) __PYX_ERR(0, 150, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__18);
  __Pyx_GIVEREF(__pyx_tuple__18);
  __pyx_codeobj__19 = (PyObject*)__Pyx_PyCode_New(3, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__18, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_apache_beam_transforms_stats_py, __pyx_n_s_init, 150, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__19)) __PYX_ERR(0, 150, __pyx_L1_error)
  __pyx_tuple__20 = PyTuple_Pack(2, ((PyObject *)Py_None), ((PyObject *)Py_None)); if (unlikely(!__pyx_tuple__20)) __PYX_ERR(0, 150, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__20);
  __Pyx_GIVEREF(__pyx_tuple__20);

  /* "apache_beam/transforms/stats.py":153
 *       self._sample_size = ApproximateUnique.parse_input_params(size, error)
 * 
 *     def expand(self, pcoll):             # <<<<<<<<<<<<<<
 *       coder = coders.registry.get_coder(pcoll)
 *       return pcoll \
 */
  __pyx_tuple__21 = PyTuple_Pack(3, __pyx_n_s_self, __pyx_n_s_pcoll, __pyx_n_s_coder); if (unlikely(!__pyx_tuple__21)) __PYX_ERR(0, 153, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__21);
  __Pyx_GIVEREF(__pyx_tuple__21);
  __pyx_codeobj__22 = (PyObject*)__Pyx_PyCode_New(2, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__21, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_apache_beam_transforms_stats_py, __pyx_n_s_expand, 153, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__22)) __PYX_ERR(0, 153, __pyx_L1_error)

  /* "apache_beam/transforms/stats.py":164
 *   class PerKey(PTransform):
 *     """ Approximate.PerKey approximate number of unique values per key"""
 *     def __init__(self, size=None, error=None):             # <<<<<<<<<<<<<<
 *       self._sample_size = ApproximateUnique.parse_input_params(size, error)
 * 
 */
  __pyx_tuple__23 = PyTuple_Pack(3, __pyx_n_s_self, __pyx_n_s_size, __pyx_n_s_error); if (unlikely(!__pyx_tuple__23)) __PYX_ERR(0, 164, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__23);
  __Pyx_GIVEREF(__pyx_tuple__23);
  __pyx_codeobj__24 = (PyObject*)__Pyx_PyCode_New(3, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__23, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_apache_beam_transforms_stats_py, __pyx_n_s_init, 164, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__24)) __PYX_ERR(0, 164, __pyx_L1_error)
  __pyx_tuple__25 = PyTuple_Pack(2, ((PyObject *)Py_None), ((PyObject *)Py_None)); if (unlikely(!__pyx_tuple__25)) __PYX_ERR(0, 164, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__25);
  __Pyx_GIVEREF(__pyx_tuple__25);

  /* "apache_beam/transforms/stats.py":167
 *       self._sample_size = ApproximateUnique.parse_input_params(size, error)
 * 
 *     def expand(self, pcoll):             # <<<<<<<<<<<<<<
 *       coder = coders.registry.get_coder(pcoll)
 *       return pcoll \
 */
  __pyx_tuple__26 = PyTuple_Pack(3, __pyx_n_s_self, __pyx_n_s_pcoll, __pyx_n_s_coder); if (unlikely(!__pyx_tuple__26)) __PYX_ERR(0, 167, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__26);
  __Pyx_GIVEREF(__pyx_tuple__26);
  __pyx_codeobj__27 = (PyObject*)__Pyx_PyCode_New(2, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__26, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_apache_beam_transforms_stats_py, __pyx_n_s_expand, 167, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__27)) __PYX_ERR(0, 167, __pyx_L1_error)

  /* "apache_beam/transforms/stats.py":175
 * 
 * 
 * class _LargestUnique(object):             # <<<<<<<<<<<<<<
 *   """
 *   An object to keep samples and calculate sample hash space. It is an
 */
  __pyx_tuple__28 = PyTuple_Pack(1, __pyx_builtin_object); if (unlikely(!__pyx_tuple__28)) __PYX_ERR(0, 175, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__28);
  __Pyx_GIVEREF(__pyx_tuple__28);

  /* "apache_beam/transforms/stats.py":183
 *   _HASH_SPACE_SIZE = 2.0**64
 * 
 *   def __init__(self, sample_size):             # <<<<<<<<<<<<<<
 *     self._sample_size = sample_size
 *     self._min_hash = 2.0**64
 */
  __pyx_tuple__29 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_sample_size_2); if (unlikely(!__pyx_tuple__29)) __PYX_ERR(0, 183, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__29);
  __Pyx_GIVEREF(__pyx_tuple__29);
  __pyx_codeobj__30 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__29, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_apache_beam_transforms_stats_py, __pyx_n_s_init, 183, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__30)) __PYX_ERR(0, 183, __pyx_L1_error)

  /* "apache_beam/transforms/stats.py":189
 *     self._sample_set = set()
 * 
 *   def add(self, element):             # <<<<<<<<<<<<<<
 *     """
 *     :param an element from pcoll.
 */
  __pyx_tuple__31 = PyTuple_Pack(3, __pyx_n_s_self, __pyx_n_s_element, __pyx_n_s_temp); if (unlikely(!__pyx_tuple__31)) __PYX_ERR(0, 189, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__31);
  __Pyx_GIVEREF(__pyx_tuple__31);
  __pyx_codeobj__32 = (PyObject*)__Pyx_PyCode_New(2, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__31, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_apache_beam_transforms_stats_py, __pyx_n_s_add, 189, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__32)) __PYX_ERR(0, 189, __pyx_L1_error)

  /* "apache_beam/transforms/stats.py":212
 *     return True
 * 
 *   def get_estimate(self):             # <<<<<<<<<<<<<<
 *     """
 *     :return: estimation count of unique values
 */
  __pyx_tuple__33 = PyTuple_Pack(3, __pyx_n_s_self, __pyx_n_s_sample_space_size, __pyx_n_s_est); if (unlikely(!__pyx_tuple__33)) __PYX_ERR(0, 212, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__33);
  __Pyx_GIVEREF(__pyx_tuple__33);
  __pyx_codeobj__34 = (PyObject*)__Pyx_PyCode_New(1, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__33, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_apache_beam_transforms_stats_py, __pyx_n_s_get_estimate, 212, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__34)) __PYX_ERR(0, 212, __pyx_L1_error)

  /* "apache_beam/transforms/stats.py":247
 *   unique values that were combined.
 *   """
 *   def __init__(self, sample_size, coder):             # <<<<<<<<<<<<<<
 *     self._sample_size = sample_size
 *     coder = coders.typecoders.registry.verify_deterministic(
 */
  __pyx_tuple__35 = PyTuple_Pack(3, __pyx_n_s_self, __pyx_n_s_sample_size_2, __pyx_n_s_coder); if (unlikely(!__pyx_tuple__35)) __PYX_ERR(0, 247, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__35);
  __Pyx_GIVEREF(__pyx_tuple__35);
  __pyx_codeobj__36 = (PyObject*)__Pyx_PyCode_New(3, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__35, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_apache_beam_transforms_stats_py, __pyx_n_s_init, 247, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__36)) __PYX_ERR(0, 247, __pyx_L1_error)

  /* "apache_beam/transforms/stats.py":255
 *     self._hash_fn = _get_default_hash_fn()
 * 
 *   def create_accumulator(self, *args, **kwargs):             # <<<<<<<<<<<<<<
 *     return _LargestUnique(self._sample_size)
 * 
 */
  __pyx_tuple__37 = PyTuple_Pack(3, __pyx_n_s_self, __pyx_n_s_args, __pyx_n_s_kwargs); if (unlikely(!__pyx_tuple__37)) __PYX_ERR(0, 255, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__37);
  __Pyx_GIVEREF(__pyx_tuple__37);
  __pyx_codeobj__38 = (PyObject*)__Pyx_PyCode_New(1, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS|CO_VARARGS|CO_VARKEYWORDS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__37, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_apache_beam_transforms_stats_py, __pyx_n_s_create_accumulator, 255, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__38)) __PYX_ERR(0, 255, __pyx_L1_error)

  /* "apache_beam/transforms/stats.py":258
 *     return _LargestUnique(self._sample_size)
 * 
 *   def add_input(self, accumulator, element, *args, **kwargs):             # <<<<<<<<<<<<<<
 *     try:
 *       hashed_value = self._hash_fn(self._coder.encode(element))
 */
  __pyx_tuple__39 = PyTuple_Pack(7, __pyx_n_s_self, __pyx_n_s_accumulator, __pyx_n_s_element, __pyx_n_s_args, __pyx_n_s_kwargs, __pyx_n_s_hashed_value, __pyx_n_s_e); if (unlikely(!__pyx_tuple__39)) __PYX_ERR(0, 258, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__39);
  __Pyx_GIVEREF(__pyx_tuple__39);
  __pyx_codeobj__40 = (PyObject*)__Pyx_PyCode_New(3, 0, 7, 0, CO_OPTIMIZED|CO_NEWLOCALS|CO_VARARGS|CO_VARKEYWORDS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__39, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_apache_beam_transforms_stats_py, __pyx_n_s_add_input, 258, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__40)) __PYX_ERR(0, 258, __pyx_L1_error)

  /* "apache_beam/transforms/stats.py":268
 *   # created an issue https://github.com/apache/beam/issues/19459 to speed up
 *   # merge process.
 *   def merge_accumulators(self, accumulators, *args, **kwargs):             # <<<<<<<<<<<<<<
 *     merged_accumulator = self.create_accumulator()
 *     for accumulator in accumulators:
 */
  __pyx_tuple__41 = PyTuple_Pack(7, __pyx_n_s_self, __pyx_n_s_accumulators, __pyx_n_s_args, __pyx_n_s_kwargs, __pyx_n_s_merged_accumulator, __pyx_n_s_accumulator, __pyx_n_s_i); if (unlikely(!__pyx_tuple__41)) __PYX_ERR(0, 268, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__41);
  __Pyx_GIVEREF(__pyx_tuple__41);
  __pyx_codeobj__42 = (PyObject*)__Pyx_PyCode_New(2, 0, 7, 0, CO_OPTIMIZED|CO_NEWLOCALS|CO_VARARGS|CO_VARKEYWORDS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__41, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_apache_beam_transforms_stats_py, __pyx_n_s_merge_accumulators, 268, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__42)) __PYX_ERR(0, 268, __pyx_L1_error)

  /* "apache_beam/transforms/stats.py":277
 * 
 *   @staticmethod
 *   def extract_output(accumulator):             # <<<<<<<<<<<<<<
 *     return accumulator.get_estimate()
 * 
 */
  __pyx_tuple__43 = PyTuple_Pack(1, __pyx_n_s_accumulator); if (unlikely(!__pyx_tuple__43)) __PYX_ERR(0, 277, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__43);
  __Pyx_GIVEREF(__pyx_tuple__43);
  __pyx_codeobj__44 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__43, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_apache_beam_transforms_stats_py, __pyx_n_s_extract_output, 277, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__44)) __PYX_ERR(0, 277, __pyx_L1_error)

  /* "apache_beam/transforms/stats.py":280
 *     return accumulator.get_estimate()
 * 
 *   def display_data(self):             # <<<<<<<<<<<<<<
 *     return {'sample_size': self._sample_size}
 * 
 */
  __pyx_tuple__45 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__45)) __PYX_ERR(0, 280, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__45);
  __Pyx_GIVEREF(__pyx_tuple__45);
  __pyx_codeobj__46 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__45, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_apache_beam_transforms_stats_py, __pyx_n_s_display_data_2, 280, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__46)) __PYX_ERR(0, 280, __pyx_L1_error)

  /* "apache_beam/transforms/stats.py":284
 * 
 * 
 * class ApproximateQuantiles(object):             # <<<<<<<<<<<<<<
 *   """
 *   PTransform for getting the idea of data distribution using approximate N-tile
 */
  __pyx_tuple__47 = PyTuple_Pack(1, __pyx_builtin_object); if (unlikely(!__pyx_tuple__47)) __PYX_ERR(0, 284, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__47);
  __Pyx_GIVEREF(__pyx_tuple__47);

  /* "apache_beam/transforms/stats.py":312
 *   """
 *   @staticmethod
 *   def _display_data(num_quantiles, key, reverse, weighted, input_batched):             # <<<<<<<<<<<<<<
 *     return {
 *         'num_quantiles': DisplayDataItem(num_quantiles, label='Quantile Count'),
 */
  __pyx_tuple__48 = PyTuple_Pack(5, __pyx_n_s_num_quantiles, __pyx_n_s_key, __pyx_n_s_reverse, __pyx_n_s_weighted, __pyx_n_s_input_batched); if (unlikely(!__pyx_tuple__48)) __PYX_ERR(0, 312, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__48);
  __Pyx_GIVEREF(__pyx_tuple__48);
  __pyx_codeobj__49 = (PyObject*)__Pyx_PyCode_New(5, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__48, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_apache_beam_transforms_stats_py, __pyx_n_s_display_data, 312, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__49)) __PYX_ERR(0, 312, __pyx_L1_error)

  /* "apache_beam/transforms/stats.py":348
 *         efficiently.
 *     """
 *     def __init__(             # <<<<<<<<<<<<<<
 *         self,
 *         num_quantiles,
 */
  __pyx_tuple__50 = PyTuple_Pack(6, __pyx_n_s_self, __pyx_n_s_num_quantiles, __pyx_n_s_key, __pyx_n_s_reverse, __pyx_n_s_weighted, __pyx_n_s_input_batched); if (unlikely(!__pyx_tuple__50)) __PYX_ERR(0, 348, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__50);
  __Pyx_GIVEREF(__pyx_tuple__50);
  __pyx_codeobj__51 = (PyObject*)__Pyx_PyCode_New(6, 0, 6, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__50, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_apache_beam_transforms_stats_py, __pyx_n_s_init, 348, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__51)) __PYX_ERR(0, 348, __pyx_L1_error)
  __pyx_tuple__52 = PyTuple_Pack(4, ((PyObject *)Py_None), ((PyObject *)Py_False), ((PyObject *)Py_False), ((PyObject *)Py_False)); if (unlikely(!__pyx_tuple__52)) __PYX_ERR(0, 348, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__52);
  __Pyx_GIVEREF(__pyx_tuple__52);

  /* "apache_beam/transforms/stats.py":361
 *       self._input_batched = input_batched
 * 
 *     def expand(self, pcoll):             # <<<<<<<<<<<<<<
 *       return pcoll | CombineGlobally(
 *           ApproximateQuantilesCombineFn.create(
 */
  __pyx_tuple__53 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_pcoll); if (unlikely(!__pyx_tuple__53)) __PYX_ERR(0, 361, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__53);
  __Pyx_GIVEREF(__pyx_tuple__53);
  __pyx_codeobj__54 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__53, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_apache_beam_transforms_stats_py, __pyx_n_s_expand, 361, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__54)) __PYX_ERR(0, 361, __pyx_L1_error)

  /* "apache_beam/transforms/stats.py":370
 *               input_batched=self._input_batched))
 * 
 *     def display_data(self):             # <<<<<<<<<<<<<<
 *       return ApproximateQuantiles._display_data(
 *           num_quantiles=self._num_quantiles,
 */
  __pyx_tuple__55 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__55)) __PYX_ERR(0, 370, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__55);
  __Pyx_GIVEREF(__pyx_tuple__55);
  __pyx_codeobj__56 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__55, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_apache_beam_transforms_stats_py, __pyx_n_s_display_data_2, 370, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__56)) __PYX_ERR(0, 370, __pyx_L1_error)

  /* "apache_beam/transforms/stats.py":403
 *         efficiently.
 *     """
 *     def __init__(             # <<<<<<<<<<<<<<
 *         self,
 *         num_quantiles,
 */
  __pyx_tuple__57 = PyTuple_Pack(6, __pyx_n_s_self, __pyx_n_s_num_quantiles, __pyx_n_s_key, __pyx_n_s_reverse, __pyx_n_s_weighted, __pyx_n_s_input_batched); if (unlikely(!__pyx_tuple__57)) __PYX_ERR(0, 403, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__57);
  __Pyx_GIVEREF(__pyx_tuple__57);
  __pyx_codeobj__58 = (PyObject*)__Pyx_PyCode_New(6, 0, 6, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__57, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_apache_beam_transforms_stats_py, __pyx_n_s_init, 403, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__58)) __PYX_ERR(0, 403, __pyx_L1_error)
  __pyx_tuple__59 = PyTuple_Pack(4, ((PyObject *)Py_None), ((PyObject *)Py_False), ((PyObject *)Py_False), ((PyObject *)Py_False)); if (unlikely(!__pyx_tuple__59)) __PYX_ERR(0, 403, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__59);
  __Pyx_GIVEREF(__pyx_tuple__59);

  /* "apache_beam/transforms/stats.py":416
 *       self._input_batched = input_batched
 * 
 *     def expand(self, pcoll):             # <<<<<<<<<<<<<<
 *       return pcoll | CombinePerKey(
 *           ApproximateQuantilesCombineFn.create(
 */
  __pyx_tuple__60 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_pcoll); if (unlikely(!__pyx_tuple__60)) __PYX_ERR(0, 416, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__60);
  __Pyx_GIVEREF(__pyx_tuple__60);
  __pyx_codeobj__61 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__60, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_apache_beam_transforms_stats_py, __pyx_n_s_expand, 416, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__61)) __PYX_ERR(0, 416, __pyx_L1_error)

  /* "apache_beam/transforms/stats.py":425
 *               input_batched=self._input_batched))
 * 
 *     def display_data(self):             # <<<<<<<<<<<<<<
 *       return ApproximateQuantiles._display_data(
 *           num_quantiles=self._num_quantiles,
 */
  __pyx_tuple__62 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__62)) __PYX_ERR(0, 425, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__62);
  __Pyx_GIVEREF(__pyx_tuple__62);
  __pyx_codeobj__63 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__62, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_apache_beam_transforms_stats_py, __pyx_n_s_display_data_2, 425, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__63)) __PYX_ERR(0, 425, __pyx_L1_error)

  /* "apache_beam/transforms/stats.py":457
 *       self.less_than = lambda a, b: key(a) < key(b)
 * 
 *   def get_argsort_key(self, elements):             # <<<<<<<<<<<<<<
 *     # type: (List) -> Callable[[int], Any]
 * 
 */
  __pyx_tuple__64 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_elements); if (unlikely(!__pyx_tuple__64)) __PYX_ERR(0, 457, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__64);
  __Pyx_GIVEREF(__pyx_tuple__64);
  __pyx_codeobj__65 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__64, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_apache_beam_transforms_stats_py, __pyx_n_s_get_argsort_key, 457, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__65)) __PYX_ERR(0, 457, __pyx_L1_error)

  /* "apache_beam/transforms/stats.py":466
 *       return lambda idx: self.key(elements[idx])
 * 
 *   def __reduce__(self):             # <<<<<<<<<<<<<<
 *     return (
 *         self.__class__,
 */
  __pyx_tuple__66 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__66)) __PYX_ERR(0, 466, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__66);
  __Pyx_GIVEREF(__pyx_tuple__66);
  __pyx_codeobj__67 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__66, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_apache_beam_transforms_stats_py, __pyx_n_s_reduce, 466, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__67)) __PYX_ERR(0, 466, __pyx_L1_error)

  /* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     cdef tuple state
 *     cdef object _dict
 */
  __pyx_tuple__68 = PyTuple_Pack(4, __pyx_n_s_self, __pyx_n_s_state, __pyx_n_s_dict_2, __pyx_n_s_use_setstate); if (unlikely(!__pyx_tuple__68)) __PYX_ERR(2, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__68);
  __Pyx_GIVEREF(__pyx_tuple__68);
  __pyx_codeobj__69 = (PyObject*)__Pyx_PyCode_New(1, 0, 4, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__68, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_stringsource, __pyx_n_s_reduce_cython, 1, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__69)) __PYX_ERR(2, 1, __pyx_L1_error)

  /* "(tree fragment)":16
 *     else:
 *         return __pyx_unpickle__QuantileBuffer, (type(self), 0x9fb38c7, state)
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_unpickle__QuantileBuffer__set_state(self, __pyx_state)
 */
  __pyx_tuple__70 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_pyx_state); if (unlikely(!__pyx_tuple__70)) __PYX_ERR(2, 16, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__70);
  __Pyx_GIVEREF(__pyx_tuple__70);
  __pyx_codeobj__71 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__70, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_stringsource, __pyx_n_s_setstate_cython, 16, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__71)) __PYX_ERR(2, 16, __pyx_L1_error)

  /* "apache_beam/transforms/stats.py":533
 * 
 *   # This is needed for pickling to work when Cythonization is enabled.
 *   def __reduce__(self):             # <<<<<<<<<<<<<<
 *     return (
 *         self.__class__,
 */
  __pyx_tuple__72 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__72)) __PYX_ERR(0, 533, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__72);
  __Pyx_GIVEREF(__pyx_tuple__72);
  __pyx_codeobj__73 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__72, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_apache_beam_transforms_stats_py, __pyx_n_s_reduce, 533, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__73)) __PYX_ERR(0, 533, __pyx_L1_error)

  /* "apache_beam/transforms/stats.py":542
 *             self.spec))
 * 
 *   def is_empty(self):             # <<<<<<<<<<<<<<
 *     # type: () -> bool
 * 
 */
  __pyx_tuple__74 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__74)) __PYX_ERR(0, 542, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__74);
  __Pyx_GIVEREF(__pyx_tuple__74);
  __pyx_codeobj__75 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__74, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_apache_beam_transforms_stats_py, __pyx_n_s_is_empty, 542, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__75)) __PYX_ERR(0, 542, __pyx_L1_error)

  /* "apache_beam/transforms/stats.py":548
 *     return not self.unbuffered_elements and not self.buffers
 * 
 *   def _add_unbuffered(self, elements, offset_fn):             # <<<<<<<<<<<<<<
 *     # type: (List, Any) -> None
 * 
 */
  __pyx_tuple__76 = PyTuple_Pack(3, __pyx_n_s_self, __pyx_n_s_elements, __pyx_n_s_offset_fn); if (unlikely(!__pyx_tuple__76)) __PYX_ERR(0, 548, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__76);
  __Pyx_GIVEREF(__pyx_tuple__76);
  __pyx_codeobj__77 = (PyObject*)__Pyx_PyCode_New(3, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__76, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_apache_beam_transforms_stats_py, __pyx_n_s_add_unbuffered, 548, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__77)) __PYX_ERR(0, 548, __pyx_L1_error)

  /* "apache_beam/transforms/stats.py":574
 *     self.collapse_if_needed(offset_fn)
 * 
 *   def _add_unbuffered_weighted(self, elements, offset_fn):             # <<<<<<<<<<<<<<
 *     # type: (List, Any) -> None
 * 
 */
  __pyx_tuple__78 = PyTuple_Pack(3, __pyx_n_s_self, __pyx_n_s_elements, __pyx_n_s_offset_fn); if (unlikely(!__pyx_tuple__78)) __PYX_ERR(0, 574, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__78);
  __Pyx_GIVEREF(__pyx_tuple__78);
  __pyx_codeobj__79 = (PyObject*)__Pyx_PyCode_New(3, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__78, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_apache_beam_transforms_stats_py, __pyx_n_s_add_unbuffered_weighted, 574, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__79)) __PYX_ERR(0, 574, __pyx_L1_error)

  /* "apache_beam/transforms/stats.py":612
 *     self.collapse_if_needed(offset_fn)
 * 
 *   def finalize(self):             # <<<<<<<<<<<<<<
 *     # type: () -> None
 * 
 */
  __pyx_tuple__80 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__80)) __PYX_ERR(0, 612, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__80);
  __Pyx_GIVEREF(__pyx_tuple__80);
  __pyx_codeobj__81 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__80, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_apache_beam_transforms_stats_py, __pyx_n_s_finalize, 612, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__81)) __PYX_ERR(0, 612, __pyx_L1_error)

  /* "apache_beam/transforms/stats.py":644
 *     self.unbuffered_elements = []
 * 
 *   def collapse_if_needed(self, offset_fn):             # <<<<<<<<<<<<<<
 *     # type: (Any) -> None
 * 
 */
  __pyx_tuple__82 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_offset_fn); if (unlikely(!__pyx_tuple__82)) __PYX_ERR(0, 644, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__82);
  __Pyx_GIVEREF(__pyx_tuple__82);
  __pyx_codeobj__83 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__82, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_apache_beam_transforms_stats_py, __pyx_n_s_collapse_if_needed, 644, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__83)) __PYX_ERR(0, 644, __pyx_L1_error)

  /* "apache_beam/transforms/stats.py":821
 *   _qs = None  # type: _QuantileState
 * 
 *   def __init__(             # <<<<<<<<<<<<<<
 *       self,
 *       num_quantiles,  # type: int
 */
  __pyx_tuple__84 = PyTuple_Pack(8, __pyx_n_s_self, __pyx_n_s_num_quantiles, __pyx_n_s_buffer_size, __pyx_n_s_num_buffers, __pyx_n_s_key, __pyx_n_s_reverse, __pyx_n_s_weighted, __pyx_n_s_input_batched); if (unlikely(!__pyx_tuple__84)) __PYX_ERR(0, 821, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__84);
  __Pyx_GIVEREF(__pyx_tuple__84);
  __pyx_codeobj__85 = (PyObject*)__Pyx_PyCode_New(8, 0, 8, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__84, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_apache_beam_transforms_stats_py, __pyx_n_s_init, 821, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__85)) __PYX_ERR(0, 821, __pyx_L1_error)
  __pyx_tuple__86 = PyTuple_Pack(4, ((PyObject *)Py_None), ((PyObject *)Py_False), ((PyObject *)Py_False), ((PyObject *)Py_False)); if (unlikely(!__pyx_tuple__86)) __PYX_ERR(0, 821, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__86);
  __Pyx_GIVEREF(__pyx_tuple__86);

  /* "apache_beam/transforms/stats.py":836
 *       setattr(self, 'add_input', self._add_inputs)
 * 
 *   def __reduce__(self):             # <<<<<<<<<<<<<<
 *     return (
 *         self.__class__,
 */
  __pyx_tuple__87 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__87)) __PYX_ERR(0, 836, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__87);
  __Pyx_GIVEREF(__pyx_tuple__87);
  __pyx_codeobj__88 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__87, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_apache_beam_transforms_stats_py, __pyx_n_s_reduce, 836, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__88)) __PYX_ERR(0, 836, __pyx_L1_error)

  /* "apache_beam/transforms/stats.py":849
 * 
 *   @classmethod
 *   def create(             # <<<<<<<<<<<<<<
 *       cls,
 *       num_quantiles,  # type: int
 */
  __pyx_tuple__89 = PyTuple_Pack(10, __pyx_n_s_cls, __pyx_n_s_num_quantiles, __pyx_n_s_epsilon, __pyx_n_s_max_num_elements, __pyx_n_s_key, __pyx_n_s_reverse, __pyx_n_s_weighted, __pyx_n_s_input_batched, __pyx_n_s_b, __pyx_n_s_k); if (unlikely(!__pyx_tuple__89)) __PYX_ERR(0, 849, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__89);
  __Pyx_GIVEREF(__pyx_tuple__89);
  __pyx_codeobj__90 = (PyObject*)__Pyx_PyCode_New(8, 0, 10, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__89, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_apache_beam_transforms_stats_py, __pyx_n_s_create, 849, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__90)) __PYX_ERR(0, 849, __pyx_L1_error)
  __pyx_tuple__91 = PyTuple_Pack(6, ((PyObject *)Py_None), ((PyObject *)Py_None), ((PyObject *)Py_None), ((PyObject *)Py_False), ((PyObject *)Py_False), ((PyObject *)Py_False)); if (unlikely(!__pyx_tuple__91)) __PYX_ERR(0, 849, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__91);
  __Pyx_GIVEREF(__pyx_tuple__91);

  /* "apache_beam/transforms/stats.py":909
 *         input_batched=input_batched)
 * 
 *   def _offset(self, new_weight):             # <<<<<<<<<<<<<<
 *     # type: (int) -> float
 * 
 */
  __pyx_tuple__92 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_new_weight); if (unlikely(!__pyx_tuple__92)) __PYX_ERR(0, 909, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__92);
  __Pyx_GIVEREF(__pyx_tuple__92);
  __pyx_codeobj__93 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__92, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_apache_beam_transforms_stats_py, __pyx_n_s_offset, 909, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__93)) __PYX_ERR(0, 909, __pyx_L1_error)

  /* "apache_beam/transforms/stats.py":924
 *   # TODO(https://github.com/apache/beam/issues/19737): Signature incompatible
 *   # with supertype
 *   def create_accumulator(self):  # type: ignore[override]             # <<<<<<<<<<<<<<
 *     # type: () -> _QuantileState
 *     self._qs = _QuantileState(
 */
  __pyx_tuple__94 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__94)) __PYX_ERR(0, 924, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__94);
  __Pyx_GIVEREF(__pyx_tuple__94);
  __pyx_codeobj__95 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__94, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_apache_beam_transforms_stats_py, __pyx_n_s_create_accumulator, 924, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__95)) __PYX_ERR(0, 924, __pyx_L1_error)

  /* "apache_beam/transforms/stats.py":933
 *     return self._qs
 * 
 *   def add_input(self, quantile_state, element):             # <<<<<<<<<<<<<<
 *     """
 *     Add a new element to the collection being summarized by quantile state.
 */
  __pyx_tuple__96 = PyTuple_Pack(3, __pyx_n_s_self, __pyx_n_s_quantile_state, __pyx_n_s_element); if (unlikely(!__pyx_tuple__96)) __PYX_ERR(0, 933, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__96);
  __Pyx_GIVEREF(__pyx_tuple__96);
  __pyx_codeobj__97 = (PyObject*)__Pyx_PyCode_New(3, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__96, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_apache_beam_transforms_stats_py, __pyx_n_s_add_input, 933, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__97)) __PYX_ERR(0, 933, __pyx_L1_error)

  /* "apache_beam/transforms/stats.py":940
 *     return quantile_state
 * 
 *   def _add_inputs(self, quantile_state, elements):             # <<<<<<<<<<<<<<
 *     # type: (_QuantileState, List) -> _QuantileState
 * 
 */
  __pyx_tuple__98 = PyTuple_Pack(3, __pyx_n_s_self, __pyx_n_s_quantile_state, __pyx_n_s_elements); if (unlikely(!__pyx_tuple__98)) __PYX_ERR(0, 940, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__98);
  __Pyx_GIVEREF(__pyx_tuple__98);
  __pyx_codeobj__99 = (PyObject*)__Pyx_PyCode_New(3, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__98, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_apache_beam_transforms_stats_py, __pyx_n_s_add_inputs, 940, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__99)) __PYX_ERR(0, 940, __pyx_L1_error)

  /* "apache_beam/transforms/stats.py":952
 *     return quantile_state
 * 
 *   def merge_accumulators(self, accumulators):             # <<<<<<<<<<<<<<
 *     """Merges all the accumulators (quantile state) as one."""
 *     qs = self.create_accumulator()
 */
  __pyx_tuple__100 = PyTuple_Pack(4, __pyx_n_s_self, __pyx_n_s_accumulators, __pyx_n_s_qs_2, __pyx_n_s_accumulator); if (unlikely(!__pyx_tuple__100)) __PYX_ERR(0, 952, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__100);
  __Pyx_GIVEREF(__pyx_tuple__100);
  __pyx_codeobj__101 = (PyObject*)__Pyx_PyCode_New(2, 0, 4, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__100, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_apache_beam_transforms_stats_py, __pyx_n_s_merge_accumulators, 952, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__101)) __PYX_ERR(0, 952, __pyx_L1_error)

  /* "apache_beam/transforms/stats.py":970
 *     return qs
 * 
 *   def extract_output(self, accumulator):             # <<<<<<<<<<<<<<
 *     """
 *     Outputs num_quantiles elements consisting of the minimum, maximum and
 */
  __pyx_tuple__103 = PyTuple_Pack(11, __pyx_n_s_self, __pyx_n_s_accumulator, __pyx_n_s_all_elems, __pyx_n_s_total_weight, __pyx_n_s_buffer_elem, __pyx_n_s_step, __pyx_n_s_offset_2, __pyx_n_s_quantiles, __pyx_n_s__102, __pyx_n_s_min_val, __pyx_n_s_max_val); if (unlikely(!__pyx_tuple__103)) __PYX_ERR(0, 970, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__103);
  __Pyx_GIVEREF(__pyx_tuple__103);
  __pyx_codeobj__104 = (PyObject*)__Pyx_PyCode_New(2, 0, 11, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__103, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_apache_beam_transforms_stats_py, __pyx_n_s_extract_output, 970, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__104)) __PYX_ERR(0, 970, __pyx_L1_error)

  /* "(tree fragment)":1
 * def __pyx_unpickle__QuantileBuffer(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 */
  __pyx_tuple__105 = PyTuple_Pack(5, __pyx_n_s_pyx_type, __pyx_n_s_pyx_checksum, __pyx_n_s_pyx_state, __pyx_n_s_pyx_PickleError, __pyx_n_s_pyx_result); if (unlikely(!__pyx_tuple__105)) __PYX_ERR(2, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__105);
  __Pyx_GIVEREF(__pyx_tuple__105);
  __pyx_codeobj__106 = (PyObject*)__Pyx_PyCode_New(3, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__105, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_stringsource, __pyx_n_s_pyx_unpickle__QuantileBuffer, 1, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__106)) __PYX_ERR(2, 1, __pyx_L1_error)
  __Pyx_RefNannyFinishContext();
  return 0;
  __pyx_L1_error:;
  __Pyx_RefNannyFinishContext();
  return -1;
}

static CYTHON_SMALL_CODE int __Pyx_InitGlobals(void) {
  if (__Pyx_InitStrings(__pyx_string_tab) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_float_0_5 = PyFloat_FromDouble(0.5); if (unlikely(!__pyx_float_0_5)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_float_1_0 = PyFloat_FromDouble(1.0); if (unlikely(!__pyx_float_1_0)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_float_1e9 = PyFloat_FromDouble(1e9); if (unlikely(!__pyx_float_1e9)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_float_2_0 = PyFloat_FromDouble(2.0); if (unlikely(!__pyx_float_2_0)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_float_4_0 = PyFloat_FromDouble(4.0); if (unlikely(!__pyx_float_4_0)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_float_0_01 = PyFloat_FromDouble(0.01); if (unlikely(!__pyx_float_0_01)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_0 = PyInt_FromLong(0); if (unlikely(!__pyx_int_0)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_1 = PyInt_FromLong(1); if (unlikely(!__pyx_int_1)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_2 = PyInt_FromLong(2); if (unlikely(!__pyx_int_2)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_16 = PyInt_FromLong(16); if (unlikely(!__pyx_int_16)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_55430000 = PyInt_FromLong(55430000L); if (unlikely(!__pyx_int_55430000)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_133822213 = PyInt_FromLong(133822213L); if (unlikely(!__pyx_int_133822213)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_167459015 = PyInt_FromLong(167459015L); if (unlikely(!__pyx_int_167459015)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_neg_1 = PyInt_FromLong(-1); if (unlikely(!__pyx_int_neg_1)) __PYX_ERR(0, 1, __pyx_L1_error)
  return 0;
  __pyx_L1_error:;
  return -1;
}

static CYTHON_SMALL_CODE int __Pyx_modinit_global_init_code(void); /*proto*/
static CYTHON_SMALL_CODE int __Pyx_modinit_variable_export_code(void); /*proto*/
static CYTHON_SMALL_CODE int __Pyx_modinit_function_export_code(void); /*proto*/
static CYTHON_SMALL_CODE int __Pyx_modinit_type_init_code(void); /*proto*/
static CYTHON_SMALL_CODE int __Pyx_modinit_type_import_code(void); /*proto*/
static CYTHON_SMALL_CODE int __Pyx_modinit_variable_import_code(void); /*proto*/
static CYTHON_SMALL_CODE int __Pyx_modinit_function_import_code(void); /*proto*/

static int __Pyx_modinit_global_init_code(void) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__Pyx_modinit_global_init_code", 0);
  /*--- Global init code ---*/
  __Pyx_RefNannyFinishContext();
  return 0;
}

static int __Pyx_modinit_variable_export_code(void) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__Pyx_modinit_variable_export_code", 0);
  /*--- Variable export code ---*/
  __Pyx_RefNannyFinishContext();
  return 0;
}

static int __Pyx_modinit_function_export_code(void) {
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__Pyx_modinit_function_export_code", 0);
  /*--- Function export code ---*/
  if (__Pyx_ExportFunction("_collapse", (void (*)(void))__pyx_f_11apache_beam_10transforms_5stats__collapse, "struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileBuffer *(PyObject *, PyObject *, struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileSpec *)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ExportFunction("_interpolate", (void (*)(void))__pyx_f_11apache_beam_10transforms_5stats__interpolate, "PyObject *(PyObject *, int64_t, double, double, struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileSpec *)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  __Pyx_RefNannyFinishContext();
  return 0;
  __pyx_L1_error:;
  __Pyx_RefNannyFinishContext();
  return -1;
}

static int __Pyx_modinit_type_init_code(void) {
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__Pyx_modinit_type_init_code", 0);
  /*--- Type init code ---*/
  if (PyType_Ready(&__pyx_type_11apache_beam_10transforms_5stats__QuantileSpec) < 0) __PYX_ERR(0, 434, __pyx_L1_error)
  #if PY_VERSION_HEX < 0x030800B1
  __pyx_type_11apache_beam_10transforms_5stats__QuantileSpec.tp_print = 0;
  #endif
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_11apache_beam_10transforms_5stats__QuantileSpec.tp_dictoffset && __pyx_type_11apache_beam_10transforms_5stats__QuantileSpec.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_11apache_beam_10transforms_5stats__QuantileSpec.tp_getattro = __Pyx_PyObject_GenericGetAttr;
  }
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s_QuantileSpec, (PyObject *)&__pyx_type_11apache_beam_10transforms_5stats__QuantileSpec) < 0) __PYX_ERR(0, 434, __pyx_L1_error)
  __pyx_ptype_11apache_beam_10transforms_5stats__QuantileSpec = &__pyx_type_11apache_beam_10transforms_5stats__QuantileSpec;
  if (PyType_Ready(&__pyx_type_11apache_beam_10transforms_5stats__QuantileBuffer) < 0) __PYX_ERR(0, 477, __pyx_L1_error)
  #if PY_VERSION_HEX < 0x030800B1
  __pyx_type_11apache_beam_10transforms_5stats__QuantileBuffer.tp_print = 0;
  #endif
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_11apache_beam_10transforms_5stats__QuantileBuffer.tp_dictoffset && __pyx_type_11apache_beam_10transforms_5stats__QuantileBuffer.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_11apache_beam_10transforms_5stats__QuantileBuffer.tp_getattro = __Pyx_PyObject_GenericGetAttr;
  }
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s_QuantileBuffer, (PyObject *)&__pyx_type_11apache_beam_10transforms_5stats__QuantileBuffer) < 0) __PYX_ERR(0, 477, __pyx_L1_error)
  if (__Pyx_setup_reduce((PyObject*)&__pyx_type_11apache_beam_10transforms_5stats__QuantileBuffer) < 0) __PYX_ERR(0, 477, __pyx_L1_error)
  __pyx_ptype_11apache_beam_10transforms_5stats__QuantileBuffer = &__pyx_type_11apache_beam_10transforms_5stats__QuantileBuffer;
  __pyx_vtabptr_11apache_beam_10transforms_5stats__QuantileState = &__pyx_vtable_11apache_beam_10transforms_5stats__QuantileState;
  __pyx_vtable_11apache_beam_10transforms_5stats__QuantileState.is_empty = (int (*)(struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileState *, int __pyx_skip_dispatch))__pyx_f_11apache_beam_10transforms_5stats_14_QuantileState_is_empty;
  __pyx_vtable_11apache_beam_10transforms_5stats__QuantileState._add_unbuffered = (PyObject *(*)(struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileState *, PyObject *, PyObject *, int __pyx_skip_dispatch))__pyx_f_11apache_beam_10transforms_5stats_14_QuantileState__add_unbuffered;
  __pyx_vtable_11apache_beam_10transforms_5stats__QuantileState._add_unbuffered_weighted = (PyObject *(*)(struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileState *, PyObject *, PyObject *, int __pyx_skip_dispatch))__pyx_f_11apache_beam_10transforms_5stats_14_QuantileState__add_unbuffered_weighted;
  __pyx_vtable_11apache_beam_10transforms_5stats__QuantileState.finalize = (PyObject *(*)(struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileState *, int __pyx_skip_dispatch))__pyx_f_11apache_beam_10transforms_5stats_14_QuantileState_finalize;
  __pyx_vtable_11apache_beam_10transforms_5stats__QuantileState.collapse_if_needed = (PyObject *(*)(struct __pyx_obj_11apache_beam_10transforms_5stats__QuantileState *, PyObject *, int __pyx_skip_dispatch))__pyx_f_11apache_beam_10transforms_5stats_14_QuantileState_collapse_if_needed;
  if (PyType_Ready(&__pyx_type_11apache_beam_10transforms_5stats__QuantileState) < 0) __PYX_ERR(0, 510, __pyx_L1_error)
  #if PY_VERSION_HEX < 0x030800B1
  __pyx_type_11apache_beam_10transforms_5stats__QuantileState.tp_print = 0;
  #endif
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_11apache_beam_10transforms_5stats__QuantileState.tp_dictoffset && __pyx_type_11apache_beam_10transforms_5stats__QuantileState.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_11apache_beam_10transforms_5stats__QuantileState.tp_getattro = __Pyx_PyObject_GenericGetAttr;
  }
  if (__Pyx_SetVtable(__pyx_type_11apache_beam_10transforms_5stats__QuantileState.tp_dict, __pyx_vtabptr_11apache_beam_10transforms_5stats__QuantileState) < 0) __PYX_ERR(0, 510, __pyx_L1_error)
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s_QuantileState, (PyObject *)&__pyx_type_11apache_beam_10transforms_5stats__QuantileState) < 0) __PYX_ERR(0, 510, __pyx_L1_error)
  __pyx_ptype_11apache_beam_10transforms_5stats__QuantileState = &__pyx_type_11apache_beam_10transforms_5stats__QuantileState;
  if (PyType_Ready(&__pyx_type_11apache_beam_10transforms_5stats___pyx_scope_struct____init__) < 0) __PYX_ERR(0, 436, __pyx_L1_error)
  #if PY_VERSION_HEX < 0x030800B1
  __pyx_type_11apache_beam_10transforms_5stats___pyx_scope_struct____init__.tp_print = 0;
  #endif
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_11apache_beam_10transforms_5stats___pyx_scope_struct____init__.tp_dictoffset && __pyx_type_11apache_beam_10transforms_5stats___pyx_scope_struct____init__.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_11apache_beam_10transforms_5stats___pyx_scope_struct____init__.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
  }
  __pyx_ptype_11apache_beam_10transforms_5stats___pyx_scope_struct____init__ = &__pyx_type_11apache_beam_10transforms_5stats___pyx_scope_struct____init__;
  if (PyType_Ready(&__pyx_type_11apache_beam_10transforms_5stats___pyx_scope_struct_1_get_argsort_key) < 0) __PYX_ERR(0, 457, __pyx_L1_error)
  #if PY_VERSION_HEX < 0x030800B1
  __pyx_type_11apache_beam_10transforms_5stats___pyx_scope_struct_1_get_argsort_key.tp_print = 0;
  #endif
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_11apache_beam_10transforms_5stats___pyx_scope_struct_1_get_argsort_key.tp_dictoffset && __pyx_type_11apache_beam_10transforms_5stats___pyx_scope_struct_1_get_argsort_key.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_11apache_beam_10transforms_5stats___pyx_scope_struct_1_get_argsort_key.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
  }
  __pyx_ptype_11apache_beam_10transforms_5stats___pyx_scope_struct_1_get_argsort_key = &__pyx_type_11apache_beam_10transforms_5stats___pyx_scope_struct_1_get_argsort_key;
  __Pyx_RefNannyFinishContext();
  return 0;
  __pyx_L1_error:;
  __Pyx_RefNannyFinishContext();
  return -1;
}

static int __Pyx_modinit_type_import_code(void) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__Pyx_modinit_type_import_code", 0);
  /*--- Type import code ---*/
  __Pyx_RefNannyFinishContext();
  return 0;
}

static int __Pyx_modinit_variable_import_code(void) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__Pyx_modinit_variable_import_code", 0);
  /*--- Variable import code ---*/
  __Pyx_RefNannyFinishContext();
  return 0;
}

static int __Pyx_modinit_function_import_code(void) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__Pyx_modinit_function_import_code", 0);
  /*--- Function import code ---*/
  __Pyx_RefNannyFinishContext();
  return 0;
}


#ifndef CYTHON_NO_PYINIT_EXPORT
#define __Pyx_PyMODINIT_FUNC PyMODINIT_FUNC
#elif PY_MAJOR_VERSION < 3
#ifdef __cplusplus
#define __Pyx_PyMODINIT_FUNC extern "C" void
#else
#define __Pyx_PyMODINIT_FUNC void
#endif
#else
#ifdef __cplusplus
#define __Pyx_PyMODINIT_FUNC extern "C" PyObject *
#else
#define __Pyx_PyMODINIT_FUNC PyObject *
#endif
#endif


#if PY_MAJOR_VERSION < 3
__Pyx_PyMODINIT_FUNC initstats(void) CYTHON_SMALL_CODE; /*proto*/
__Pyx_PyMODINIT_FUNC initstats(void)
#else
__Pyx_PyMODINIT_FUNC PyInit_stats(void) CYTHON_SMALL_CODE; /*proto*/
__Pyx_PyMODINIT_FUNC PyInit_stats(void)
#if CYTHON_PEP489_MULTI_PHASE_INIT
{
  return PyModuleDef_Init(&__pyx_moduledef);
}
static CYTHON_SMALL_CODE int __Pyx_check_single_interpreter(void) {
    #if PY_VERSION_HEX >= 0x030700A1
    static PY_INT64_T main_interpreter_id = -1;
    PY_INT64_T current_id = PyInterpreterState_GetID(PyThreadState_Get()->interp);
    if (main_interpreter_id == -1) {
        main_interpreter_id = current_id;
        return (unlikely(current_id == -1)) ? -1 : 0;
    } else if (unlikely(main_interpreter_id != current_id))
    #else
    static PyInterpreterState *main_interpreter = NULL;
    PyInterpreterState *current_interpreter = PyThreadState_Get()->interp;
    if (!main_interpreter) {
        main_interpreter = current_interpreter;
    } else if (unlikely(main_interpreter != current_interpreter))
    #endif
    {
        PyErr_SetString(
            PyExc_ImportError,
            "Interpreter change detected - this module can only be loaded into one interpreter per process.");
        return -1;
    }
    return 0;
}
static CYTHON_SMALL_CODE int __Pyx_copy_spec_to_module(PyObject *spec, PyObject *moddict, const char* from_name, const char* to_name, int allow_none) {
    PyObject *value = PyObject_GetAttrString(spec, from_name);
    int result = 0;
    if (likely(value)) {
        if (allow_none || value != Py_None) {
            result = PyDict_SetItemString(moddict, to_name, value);
        }
        Py_DECREF(value);
    } else if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
        PyErr_Clear();
    } else {
        result = -1;
    }
    return result;
}
static CYTHON_SMALL_CODE PyObject* __pyx_pymod_create(PyObject *spec, CYTHON_UNUSED PyModuleDef *def) {
    PyObject *module = NULL, *moddict, *modname;
    if (__Pyx_check_single_interpreter())
        return NULL;
    if (__pyx_m)
        return __Pyx_NewRef(__pyx_m);
    modname = PyObject_GetAttrString(spec, "name");
    if (unlikely(!modname)) goto bad;
    module = PyModule_NewObject(modname);
    Py_DECREF(modname);
    if (unlikely(!module)) goto bad;
    moddict = PyModule_GetDict(module);
    if (unlikely(!moddict)) goto bad;
    if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "loader", "__loader__", 1) < 0)) goto bad;
    if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "origin", "__file__", 1) < 0)) goto bad;
    if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "parent", "__package__", 1) < 0)) goto bad;
    if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "submodule_search_locations", "__path__", 0) < 0)) goto bad;
    return module;
bad:
    Py_XDECREF(module);
    return NULL;
}


static CYTHON_SMALL_CODE int __pyx_pymod_exec_stats(PyObject *__pyx_pyinit_module)
#endif
#endif
{
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  PyObject *__pyx_t_14 = NULL;
  PyObject *__pyx_t_15 = NULL;
  PyObject *__pyx_t_16 = NULL;
  PyObject *__pyx_t_17 = NULL;
  PyObject *__pyx_t_18 = NULL;
  PyObject *__pyx_t_19 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannyDeclarations
  #if CYTHON_PEP489_MULTI_PHASE_INIT
  if (__pyx_m) {
    if (__pyx_m == __pyx_pyinit_module) return 0;
    PyErr_SetString(PyExc_RuntimeError, "Module 'stats' has already been imported. Re-initialisation is not supported.");
    return -1;
  }
  #elif PY_MAJOR_VERSION >= 3
  if (__pyx_m) return __Pyx_NewRef(__pyx_m);
  #endif
  #if CYTHON_REFNANNY
__Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny");
if (!__Pyx_RefNanny) {
  PyErr_Clear();
  __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny");
  if (!__Pyx_RefNanny)
      Py_FatalError("failed to import 'refnanny' module");
}
#endif
  __Pyx_RefNannySetupContext("__Pyx_PyMODINIT_FUNC PyInit_stats(void)", 0);
  if (__Pyx_check_binary_version() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  #ifdef __Pxy_PyFrame_Initialize_Offsets
  __Pxy_PyFrame_Initialize_Offsets();
  #endif
  __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_empty_unicode = PyUnicode_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_unicode)) __PYX_ERR(0, 1, __pyx_L1_error)
  #ifdef __Pyx_CyFunction_USED
  if (__pyx_CyFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  #endif
  #ifdef __Pyx_FusedFunction_USED
  if (__pyx_FusedFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  #endif
  #ifdef __Pyx_Coroutine_USED
  if (__pyx_Coroutine_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  #endif
  #ifdef __Pyx_Generator_USED
  if (__pyx_Generator_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  #endif
  #ifdef __Pyx_AsyncGen_USED
  if (__pyx_AsyncGen_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  #endif
  #ifdef __Pyx_StopAsyncIteration_USED
  if (__pyx_StopAsyncIteration_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  #endif
  /*--- Library function declarations ---*/
  /*--- Threads initialization code ---*/
  #if defined(WITH_THREAD) && PY_VERSION_HEX < 0x030700F0 && defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS
  PyEval_InitThreads();
  #endif
  /*--- Module creation code ---*/
  #if CYTHON_PEP489_MULTI_PHASE_INIT
  __pyx_m = __pyx_pyinit_module;
  Py_INCREF(__pyx_m);
  #else
  #if PY_MAJOR_VERSION < 3
  __pyx_m = Py_InitModule4("stats", __pyx_methods, __pyx_k_This_module_has_all_statistic_re, 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m);
  #else
  __pyx_m = PyModule_Create(&__pyx_moduledef);
  #endif
  if (unlikely(!__pyx_m)) __PYX_ERR(0, 1, __pyx_L1_error)
  #endif
  __pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) __PYX_ERR(0, 1, __pyx_L1_error)
  Py_INCREF(__pyx_d);
  __pyx_b = PyImport_AddModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_b)) __PYX_ERR(0, 1, __pyx_L1_error)
  Py_INCREF(__pyx_b);
  __pyx_cython_runtime = PyImport_AddModule((char *) "cython_runtime"); if (unlikely(!__pyx_cython_runtime)) __PYX_ERR(0, 1, __pyx_L1_error)
  Py_INCREF(__pyx_cython_runtime);
  if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  /*--- Initialize various global constants etc. ---*/
  if (__Pyx_InitGlobals() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  #if PY_MAJOR_VERSION < 3 && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT)
  if (__Pyx_init_sys_getdefaultencoding_params() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  #endif
  if (__pyx_module_is_main_apache_beam__transforms__stats) {
    if (PyObject_SetAttr(__pyx_m, __pyx_n_s_name, __pyx_n_s_main) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  }
  #if PY_MAJOR_VERSION >= 3
  {
    PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) __PYX_ERR(0, 1, __pyx_L1_error)
    if (!PyDict_GetItemString(modules, "apache_beam.transforms.stats")) {
      if (unlikely(PyDict_SetItemString(modules, "apache_beam.transforms.stats", __pyx_m) < 0)) __PYX_ERR(0, 1, __pyx_L1_error)
    }
  }
  #endif
  /*--- Builtin init code ---*/
  if (__Pyx_InitCachedBuiltins() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  /*--- Constants init code ---*/
  if (__Pyx_InitCachedConstants() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  /*--- Global type/function init code ---*/
  (void)__Pyx_modinit_global_init_code();
  (void)__Pyx_modinit_variable_export_code();
  if (unlikely(__Pyx_modinit_function_export_code() < 0)) __PYX_ERR(0, 1, __pyx_L1_error)
  if (unlikely(__Pyx_modinit_type_init_code() < 0)) __PYX_ERR(0, 1, __pyx_L1_error)
  (void)__Pyx_modinit_type_import_code();
  (void)__Pyx_modinit_variable_import_code();
  (void)__Pyx_modinit_function_import_code();
  /*--- Execution code ---*/
  #if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED)
  if (__Pyx_patch_abc() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  #endif

  /* "apache_beam/transforms/stats.py":33
 * # pytype: skip-file
 * 
 * import hashlib             # <<<<<<<<<<<<<<
 * import heapq
 * import itertools
 */
  __pyx_t_1 = __Pyx_Import(__pyx_n_s_hashlib, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 33, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_hashlib, __pyx_t_1) < 0) __PYX_ERR(0, 33, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "apache_beam/transforms/stats.py":34
 * 
 * import hashlib
 * import heapq             # <<<<<<<<<<<<<<
 * import itertools
 * import logging
 */
  __pyx_t_1 = __Pyx_Import(__pyx_n_s_heapq, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 34, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_heapq, __pyx_t_1) < 0) __PYX_ERR(0, 34, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "apache_beam/transforms/stats.py":35
 * import hashlib
 * import heapq
 * import itertools             # <<<<<<<<<<<<<<
 * import logging
 * import math
 */
  __pyx_t_1 = __Pyx_Import(__pyx_n_s_itertools, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 35, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_itertools, __pyx_t_1) < 0) __PYX_ERR(0, 35, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "apache_beam/transforms/stats.py":36
 * import heapq
 * import itertools
 * import logging             # <<<<<<<<<<<<<<
 * import math
 * import typing
 */
  __pyx_t_1 = __Pyx_Import(__pyx_n_s_logging, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 36, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_logging, __pyx_t_1) < 0) __PYX_ERR(0, 36, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "apache_beam/transforms/stats.py":37
 * import itertools
 * import logging
 * import math             # <<<<<<<<<<<<<<
 * import typing
 * from typing import Any
 */
  __pyx_t_1 = __Pyx_Import(__pyx_n_s_math, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 37, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_math, __pyx_t_1) < 0) __PYX_ERR(0, 37, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "apache_beam/transforms/stats.py":38
 * import logging
 * import math
 * import typing             # <<<<<<<<<<<<<<
 * from typing import Any
 * from typing import Callable
 */
  __pyx_t_1 = __Pyx_Import(__pyx_n_s_typing, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 38, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_typing, __pyx_t_1) < 0) __PYX_ERR(0, 38, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "apache_beam/transforms/stats.py":39
 * import math
 * import typing
 * from typing import Any             # <<<<<<<<<<<<<<
 * from typing import Callable
 * from typing import List
 */
  __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 39, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_n_s_Any);
  __Pyx_GIVEREF(__pyx_n_s_Any);
  PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_Any);
  __pyx_t_2 = __Pyx_Import(__pyx_n_s_typing, __pyx_t_1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 39, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_Any); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 39, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_Any, __pyx_t_1) < 0) __PYX_ERR(0, 39, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "apache_beam/transforms/stats.py":40
 * import typing
 * from typing import Any
 * from typing import Callable             # <<<<<<<<<<<<<<
 * from typing import List
 * from typing import Tuple
 */
  __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 40, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_n_s_Callable);
  __Pyx_GIVEREF(__pyx_n_s_Callable);
  PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_Callable);
  __pyx_t_1 = __Pyx_Import(__pyx_n_s_typing, __pyx_t_2, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 40, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_Callable); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 40, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_Callable, __pyx_t_2) < 0) __PYX_ERR(0, 40, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "apache_beam/transforms/stats.py":41
 * from typing import Any
 * from typing import Callable
 * from typing import List             # <<<<<<<<<<<<<<
 * from typing import Tuple
 * 
 */
  __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 41, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_n_s_List);
  __Pyx_GIVEREF(__pyx_n_s_List);
  PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_List);
  __pyx_t_2 = __Pyx_Import(__pyx_n_s_typing, __pyx_t_1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 41, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_List); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 41, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_List, __pyx_t_1) < 0) __PYX_ERR(0, 41, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "apache_beam/transforms/stats.py":42
 * from typing import Callable
 * from typing import List
 * from typing import Tuple             # <<<<<<<<<<<<<<
 * 
 * from apache_beam import coders
 */
  __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 42, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_n_s_Tuple);
  __Pyx_GIVEREF(__pyx_n_s_Tuple);
  PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_Tuple);
  __pyx_t_1 = __Pyx_Import(__pyx_n_s_typing, __pyx_t_2, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 42, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_Tuple); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 42, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_Tuple, __pyx_t_2) < 0) __PYX_ERR(0, 42, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "apache_beam/transforms/stats.py":44
 * from typing import Tuple
 * 
 * from apache_beam import coders             # <<<<<<<<<<<<<<
 * from apache_beam import typehints
 * from apache_beam.transforms.core import *
 */
  __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 44, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_n_s_coders);
  __Pyx_GIVEREF(__pyx_n_s_coders);
  PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_coders);
  __pyx_t_2 = __Pyx_Import(__pyx_n_s_apache_beam, __pyx_t_1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 44, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_coders); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 44, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_coders, __pyx_t_1) < 0) __PYX_ERR(0, 44, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "apache_beam/transforms/stats.py":45
 * 
 * from apache_beam import coders
 * from apache_beam import typehints             # <<<<<<<<<<<<<<
 * from apache_beam.transforms.core import *
 * from apache_beam.transforms.display import DisplayDataItem
 */
  __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 45, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_n_s_typehints);
  __Pyx_GIVEREF(__pyx_n_s_typehints);
  PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_typehints);
  __pyx_t_1 = __Pyx_Import(__pyx_n_s_apache_beam, __pyx_t_2, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 45, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_typehints); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 45, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_typehints, __pyx_t_2) < 0) __PYX_ERR(0, 45, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "apache_beam/transforms/stats.py":46
 * from apache_beam import coders
 * from apache_beam import typehints
 * from apache_beam.transforms.core import *             # <<<<<<<<<<<<<<
 * from apache_beam.transforms.display import DisplayDataItem
 * from apache_beam.transforms.ptransform import PTransform
 */
  __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 46, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_n_s__3);
  __Pyx_GIVEREF(__pyx_n_s__3);
  PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s__3);
  __pyx_t_2 = __Pyx_Import(__pyx_n_s_apache_beam_transforms_core, __pyx_t_1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 46, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_import_star(__pyx_t_2) < 0) __PYX_ERR(0, 46, __pyx_L1_error);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "apache_beam/transforms/stats.py":47
 * from apache_beam import typehints
 * from apache_beam.transforms.core import *
 * from apache_beam.transforms.display import DisplayDataItem             # <<<<<<<<<<<<<<
 * from apache_beam.transforms.ptransform import PTransform
 * 
 */
  __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 47, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_n_s_DisplayDataItem);
  __Pyx_GIVEREF(__pyx_n_s_DisplayDataItem);
  PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_DisplayDataItem);
  __pyx_t_1 = __Pyx_Import(__pyx_n_s_apache_beam_transforms_display, __pyx_t_2, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 47, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_DisplayDataItem); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 47, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_DisplayDataItem, __pyx_t_2) < 0) __PYX_ERR(0, 47, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "apache_beam/transforms/stats.py":48
 * from apache_beam.transforms.core import *
 * from apache_beam.transforms.display import DisplayDataItem
 * from apache_beam.transforms.ptransform import PTransform             # <<<<<<<<<<<<<<
 * 
 * __all__ = [
 */
  __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 48, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_n_s_PTransform);
  __Pyx_GIVEREF(__pyx_n_s_PTransform);
  PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_PTransform);
  __pyx_t_2 = __Pyx_Import(__pyx_n_s_apache_beam_transforms_ptransfor, __pyx_t_1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 48, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_PTransform); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 48, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_PTransform, __pyx_t_1) < 0) __PYX_ERR(0, 48, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "apache_beam/transforms/stats.py":50
 * from apache_beam.transforms.ptransform import PTransform
 * 
 * __all__ = [             # <<<<<<<<<<<<<<
 *     'ApproximateQuantiles',
 *     'ApproximateUnique',
 */
  __pyx_t_2 = PyList_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 50, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_n_u_ApproximateQuantiles);
  __Pyx_GIVEREF(__pyx_n_u_ApproximateQuantiles);
  PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_u_ApproximateQuantiles);
  __Pyx_INCREF(__pyx_n_u_ApproximateUnique);
  __Pyx_GIVEREF(__pyx_n_u_ApproximateUnique);
  PyList_SET_ITEM(__pyx_t_2, 1, __pyx_n_u_ApproximateUnique);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_all, __pyx_t_2) < 0) __PYX_ERR(0, 50, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "apache_beam/transforms/stats.py":56
 * 
 * # Type variables
 * T = typing.TypeVar('T')             # <<<<<<<<<<<<<<
 * K = typing.TypeVar('K')
 * V = typing.TypeVar('V')
 */
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_typing); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 56, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_TypeVar); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 56, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_tuple__4, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 56, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_T, __pyx_t_2) < 0) __PYX_ERR(0, 56, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "apache_beam/transforms/stats.py":57
 * # Type variables
 * T = typing.TypeVar('T')
 * K = typing.TypeVar('K')             # <<<<<<<<<<<<<<
 * V = typing.TypeVar('V')
 * 
 */
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_typing); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 57, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_TypeVar); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 57, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_tuple__5, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 57, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_K, __pyx_t_2) < 0) __PYX_ERR(0, 57, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "apache_beam/transforms/stats.py":58
 * T = typing.TypeVar('T')
 * K = typing.TypeVar('K')
 * V = typing.TypeVar('V')             # <<<<<<<<<<<<<<
 * 
 * try:
 */
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_typing); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 58, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_TypeVar); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 58, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_tuple__6, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 58, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_V, __pyx_t_2) < 0) __PYX_ERR(0, 58, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "apache_beam/transforms/stats.py":60
 * V = typing.TypeVar('V')
 * 
 * try:             # <<<<<<<<<<<<<<
 *   import mmh3  # pylint: disable=import-error
 * 
 */
  {
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ExceptionSave(&__pyx_t_3, &__pyx_t_4, &__pyx_t_5);
    __Pyx_XGOTREF(__pyx_t_3);
    __Pyx_XGOTREF(__pyx_t_4);
    __Pyx_XGOTREF(__pyx_t_5);
    /*try:*/ {

      /* "apache_beam/transforms/stats.py":61
 * 
 * try:
 *   import mmh3  # pylint: disable=import-error             # <<<<<<<<<<<<<<
 * 
 *   def _mmh3_hash(value):
 */
      __pyx_t_2 = __Pyx_Import(__pyx_n_s_mmh3, 0, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 61, __pyx_L2_error)
      __Pyx_GOTREF(__pyx_t_2);
      if (PyDict_SetItem(__pyx_d, __pyx_n_s_mmh3, __pyx_t_2) < 0) __PYX_ERR(0, 61, __pyx_L2_error)
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

      /* "apache_beam/transforms/stats.py":63
 *   import mmh3  # pylint: disable=import-error
 * 
 *   def _mmh3_hash(value):             # <<<<<<<<<<<<<<
 *     # mmh3.hash64 returns two 64-bit unsigned integers
 *     return mmh3.hash64(value, seed=0, signed=False)[0]
 */
      __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_11apache_beam_10transforms_5stats_1_mmh3_hash, 0, __pyx_n_s_mmh3_hash, NULL, __pyx_n_s_apache_beam_transforms_stats, __pyx_d, ((PyObject *)__pyx_codeobj__8)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 63, __pyx_L2_error)
      __Pyx_GOTREF(__pyx_t_2);
      if (PyDict_SetItem(__pyx_d, __pyx_n_s_mmh3_hash, __pyx_t_2) < 0) __PYX_ERR(0, 63, __pyx_L2_error)
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

      /* "apache_beam/transforms/stats.py":67
 *     return mmh3.hash64(value, seed=0, signed=False)[0]
 * 
 *   _default_hash_fn = _mmh3_hash             # <<<<<<<<<<<<<<
 *   _default_hash_fn_type = 'mmh3'
 * except ImportError:
 */
      __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_mmh3_hash); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 67, __pyx_L2_error)
      __Pyx_GOTREF(__pyx_t_2);
      if (PyDict_SetItem(__pyx_d, __pyx_n_s_default_hash_fn, __pyx_t_2) < 0) __PYX_ERR(0, 67, __pyx_L2_error)
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

      /* "apache_beam/transforms/stats.py":68
 * 
 *   _default_hash_fn = _mmh3_hash
 *   _default_hash_fn_type = 'mmh3'             # <<<<<<<<<<<<<<
 * except ImportError:
 * 
 */
      if (PyDict_SetItem(__pyx_d, __pyx_n_s_default_hash_fn_type, __pyx_n_u_mmh3) < 0) __PYX_ERR(0, 68, __pyx_L2_error)

      /* "apache_beam/transforms/stats.py":60
 * V = typing.TypeVar('V')
 * 
 * try:             # <<<<<<<<<<<<<<
 *   import mmh3  # pylint: disable=import-error
 * 
 */
    }
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    goto __pyx_L7_try_end;
    __pyx_L2_error:;
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "apache_beam/transforms/stats.py":69
 *   _default_hash_fn = _mmh3_hash
 *   _default_hash_fn_type = 'mmh3'
 * except ImportError:             # <<<<<<<<<<<<<<
 * 
 *   def _md5_hash(value):
 */
    __pyx_t_6 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_ImportError);
    if (__pyx_t_6) {
      __Pyx_AddTraceback("apache_beam.transforms.stats", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_2, &__pyx_t_1, &__pyx_t_7) < 0) __PYX_ERR(0, 69, __pyx_L4_except_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_GOTREF(__pyx_t_7);

      /* "apache_beam/transforms/stats.py":71
 * except ImportError:
 * 
 *   def _md5_hash(value):             # <<<<<<<<<<<<<<
 *     # md5 is a 128-bit hash, so we truncate the hexdigest (string of 32
 *     # hexadecimal digits) to 16 digits and convert to int to get the 64-bit
 */
      __pyx_t_8 = __Pyx_CyFunction_New(&__pyx_mdef_11apache_beam_10transforms_5stats_3_md5_hash, 0, __pyx_n_s_md5_hash, NULL, __pyx_n_s_apache_beam_transforms_stats, __pyx_d, ((PyObject *)__pyx_codeobj__10)); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 71, __pyx_L4_except_error)
      __Pyx_GOTREF(__pyx_t_8);
      if (PyDict_SetItem(__pyx_d, __pyx_n_s_md5_hash, __pyx_t_8) < 0) __PYX_ERR(0, 71, __pyx_L4_except_error)
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

      /* "apache_beam/transforms/stats.py":77
 *     return int(hashlib.md5(value).hexdigest()[:16], 16)
 * 
 *   _default_hash_fn = _md5_hash             # <<<<<<<<<<<<<<
 *   _default_hash_fn_type = 'md5'
 * 
 */
      __Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_n_s_md5_hash); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 77, __pyx_L4_except_error)
      __Pyx_GOTREF(__pyx_t_8);
      if (PyDict_SetItem(__pyx_d, __pyx_n_s_default_hash_fn, __pyx_t_8) < 0) __PYX_ERR(0, 77, __pyx_L4_except_error)
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

      /* "apache_beam/transforms/stats.py":78
 * 
 *   _default_hash_fn = _md5_hash
 *   _default_hash_fn_type = 'md5'             # <<<<<<<<<<<<<<
 * 
 * 
 */
      if (PyDict_SetItem(__pyx_d, __pyx_n_s_default_hash_fn_type, __pyx_n_u_md5) < 0) __PYX_ERR(0, 78, __pyx_L4_except_error)
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
      goto __pyx_L3_exception_handled;
    }
    goto __pyx_L4_except_error;
    __pyx_L4_except_error:;

    /* "apache_beam/transforms/stats.py":60
 * V = typing.TypeVar('V')
 * 
 * try:             # <<<<<<<<<<<<<<
 *   import mmh3  # pylint: disable=import-error
 * 
 */
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_XGIVEREF(__pyx_t_4);
    __Pyx_XGIVEREF(__pyx_t_5);
    __Pyx_ExceptionReset(__pyx_t_3, __pyx_t_4, __pyx_t_5);
    goto __pyx_L1_error;
    __pyx_L3_exception_handled:;
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_XGIVEREF(__pyx_t_4);
    __Pyx_XGIVEREF(__pyx_t_5);
    __Pyx_ExceptionReset(__pyx_t_3, __pyx_t_4, __pyx_t_5);
    __pyx_L7_try_end:;
  }

  /* "apache_beam/transforms/stats.py":81
 * 
 * 
 * def _get_default_hash_fn():             # <<<<<<<<<<<<<<
 *   """Returns either murmurhash or md5 based on installation."""
 *   if _default_hash_fn_type == 'md5':
 */
  __pyx_t_7 = __Pyx_CyFunction_New(&__pyx_mdef_11apache_beam_10transforms_5stats_5_get_default_hash_fn, 0, __pyx_n_s_get_default_hash_fn, NULL, __pyx_n_s_apache_beam_transforms_stats, __pyx_d, ((PyObject *)__pyx_codeobj__11)); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 81, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_get_default_hash_fn, __pyx_t_7) < 0) __PYX_ERR(0, 81, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "apache_beam/transforms/stats.py":90
 * 
 * 
 * class ApproximateUnique(object):             # <<<<<<<<<<<<<<
 *   """
 *   Hashes input elements and uses those to extrapolate the size of the entire
 */
  __pyx_t_7 = __Pyx_CalculateMetaclass(NULL, __pyx_tuple__12); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 90, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_1 = __Pyx_Py3MetaclassPrepare(__pyx_t_7, __pyx_tuple__12, __pyx_n_s_ApproximateUnique, __pyx_n_s_ApproximateUnique, (PyObject *) NULL, __pyx_n_s_apache_beam_transforms_stats, __pyx_kp_s_Hashes_input_elements_and_uses); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 90, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);

  /* "apache_beam/transforms/stats.py":97
 *   """
 * 
 *   _NO_VALUE_ERR_MSG = 'Either size or error should be set. Received {}.'             # <<<<<<<<<<<<<<
 *   _MULTI_VALUE_ERR_MSG = 'Either size or error should be set. ' \
 *                          'Received {size = %s, error = %s}.'
 */
  if (__Pyx_SetNameInClass(__pyx_t_1, __pyx_n_s_NO_VALUE_ERR_MSG, __pyx_kp_u_Either_size_or_error_should_be_s) < 0) __PYX_ERR(0, 97, __pyx_L1_error)

  /* "apache_beam/transforms/stats.py":98
 * 
 *   _NO_VALUE_ERR_MSG = 'Either size or error should be set. Received {}.'
 *   _MULTI_VALUE_ERR_MSG = 'Either size or error should be set. ' \             # <<<<<<<<<<<<<<
 *                          'Received {size = %s, error = %s}.'
 *   _INPUT_SIZE_ERR_MSG = 'ApproximateUnique needs a size >= 16 for an error ' \
 */
  if (__Pyx_SetNameInClass(__pyx_t_1, __pyx_n_s_MULTI_VALUE_ERR_MSG, __pyx_kp_u_Either_size_or_error_should_be_s_2) < 0) __PYX_ERR(0, 98, __pyx_L1_error)

  /* "apache_beam/transforms/stats.py":100
 *   _MULTI_VALUE_ERR_MSG = 'Either size or error should be set. ' \
 *                          'Received {size = %s, error = %s}.'
 *   _INPUT_SIZE_ERR_MSG = 'ApproximateUnique needs a size >= 16 for an error ' \             # <<<<<<<<<<<<<<
 *                         '<= 0.50. In general, the estimation error is about ' \
 *                         '2 / sqrt(sample_size). Received {size = %s}.'
 */
  if (__Pyx_SetNameInClass(__pyx_t_1, __pyx_n_s_INPUT_SIZE_ERR_MSG, __pyx_kp_u_ApproximateUnique_needs_a_size_1) < 0) __PYX_ERR(0, 100, __pyx_L1_error)

  /* "apache_beam/transforms/stats.py":103
 *                         '<= 0.50. In general, the estimation error is about ' \
 *                         '2 / sqrt(sample_size). Received {size = %s}.'
 *   _INPUT_ERROR_ERR_MSG = 'ApproximateUnique needs an estimation error ' \             # <<<<<<<<<<<<<<
 *                          'between 0.01 and 0.50. Received {error = %s}.'
 * 
 */
  if (__Pyx_SetNameInClass(__pyx_t_1, __pyx_n_s_INPUT_ERROR_ERR_MSG, __pyx_kp_u_ApproximateUnique_needs_an_estim) < 0) __PYX_ERR(0, 103, __pyx_L1_error)

  /* "apache_beam/transforms/stats.py":107
 * 
 *   @staticmethod
 *   def parse_input_params(size=None, error=None):             # <<<<<<<<<<<<<<
 *     """
 *     Check if input params are valid and return sample size.
 */
  __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_11apache_beam_10transforms_5stats_17ApproximateUnique_1parse_input_params, __Pyx_CYFUNCTION_STATICMETHOD, __pyx_n_s_ApproximateUnique_parse_input_pa, NULL, __pyx_n_s_apache_beam_transforms_stats, __pyx_d, ((PyObject *)__pyx_codeobj__14)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 107, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_2, __pyx_tuple__15);

  /* "apache_beam/transforms/stats.py":106
 *                          'between 0.01 and 0.50. Received {error = %s}.'
 * 
 *   @staticmethod             # <<<<<<<<<<<<<<
 *   def parse_input_params(size=None, error=None):
 *     """
 */
  __pyx_t_8 = __Pyx_PyObject_CallOneArg(__pyx_builtin_staticmethod, __pyx_t_2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 106, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (__Pyx_SetNameInClass(__pyx_t_1, __pyx_n_s_parse_input_params, __pyx_t_8) < 0) __PYX_ERR(0, 107, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

  /* "apache_beam/transforms/stats.py":138
 * 
 *   @staticmethod
 *   def _get_sample_size_from_est_error(est_err):             # <<<<<<<<<<<<<<
 *     """
 *     :return: sample size
 */
  __pyx_t_8 = __Pyx_CyFunction_New(&__pyx_mdef_11apache_beam_10transforms_5stats_17ApproximateUnique_3_get_sample_size_from_est_error, __Pyx_CYFUNCTION_STATICMETHOD, __pyx_n_s_ApproximateUnique__get_sample_si, NULL, __pyx_n_s_apache_beam_transforms_stats, __pyx_d, ((PyObject *)__pyx_codeobj__17)); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 138, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);

  /* "apache_beam/transforms/stats.py":137
 *         return ApproximateUnique._get_sample_size_from_est_error(error)
 * 
 *   @staticmethod             # <<<<<<<<<<<<<<
 *   def _get_sample_size_from_est_error(est_err):
 *     """
 */
  __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_builtin_staticmethod, __pyx_t_8); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 137, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  if (__Pyx_SetNameInClass(__pyx_t_1, __pyx_n_s_get_sample_size_from_est_error, __pyx_t_2) < 0) __PYX_ERR(0, 138, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "apache_beam/transforms/stats.py":148
 *   @typehints.with_input_types(T)
 *   @typehints.with_output_types(int)
 *   class Globally(PTransform):             # <<<<<<<<<<<<<<
 *     """ Approximate.Globally approximate number of unique values"""
 *     def __init__(self, size=None, error=None):
 */
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_PTransform); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 148, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_8 = PyTuple_New(1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 148, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_2);
  __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_CalculateMetaclass(NULL, __pyx_t_8); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 148, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_9 = __Pyx_Py3MetaclassPrepare(__pyx_t_2, __pyx_t_8, __pyx_n_s_Globally, __pyx_n_s_ApproximateUnique_Globally, (PyObject *) NULL, __pyx_n_s_apache_beam_transforms_stats, __pyx_kp_s_Approximate_Globally_approximat); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 148, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);

  /* "apache_beam/transforms/stats.py":150
 *   class Globally(PTransform):
 *     """ Approximate.Globally approximate number of unique values"""
 *     def __init__(self, size=None, error=None):             # <<<<<<<<<<<<<<
 *       self._sample_size = ApproximateUnique.parse_input_params(size, error)
 * 
 */
  __pyx_t_10 = __Pyx_CyFunction_New(&__pyx_mdef_11apache_beam_10transforms_5stats_8Globally_1__init__, 0, __pyx_n_s_ApproximateUnique_Globally___ini, NULL, __pyx_n_s_apache_beam_transforms_stats, __pyx_d, ((PyObject *)__pyx_codeobj__19)); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 150, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);
  __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_10, __pyx_tuple__20);
  if (__Pyx_SetNameInClass(__pyx_t_9, __pyx_n_s_init, __pyx_t_10) < 0) __PYX_ERR(0, 150, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;

  /* "apache_beam/transforms/stats.py":153
 *       self._sample_size = ApproximateUnique.parse_input_params(size, error)
 * 
 *     def expand(self, pcoll):             # <<<<<<<<<<<<<<
 *       coder = coders.registry.get_coder(pcoll)
 *       return pcoll \
 */
  __pyx_t_10 = __Pyx_CyFunction_New(&__pyx_mdef_11apache_beam_10transforms_5stats_8Globally_3expand, 0, __pyx_n_s_ApproximateUnique_Globally_expan, NULL, __pyx_n_s_apache_beam_transforms_stats, __pyx_d, ((PyObject *)__pyx_codeobj__22)); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 153, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);
  if (__Pyx_SetNameInClass(__pyx_t_9, __pyx_n_s_expand, __pyx_t_10) < 0) __PYX_ERR(0, 153, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;

  /* "apache_beam/transforms/stats.py":146
 *     return math.ceil(4.0 / math.pow(est_err, 2.0))
 * 
 *   @typehints.with_input_types(T)             # <<<<<<<<<<<<<<
 *   @typehints.with_output_types(int)
 *   class Globally(PTransform):
 */
  __Pyx_GetModuleGlobalName(__pyx_t_12, __pyx_n_s_typehints); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 146, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_t_12, __pyx_n_s_with_input_types); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 146, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_13);
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  __Pyx_GetModuleGlobalName(__pyx_t_12, __pyx_n_s_T); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 146, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  __pyx_t_14 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_13))) {
    __pyx_t_14 = PyMethod_GET_SELF(__pyx_t_13);
    if (likely(__pyx_t_14)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_13);
      __Pyx_INCREF(__pyx_t_14);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_13, function);
    }
  }
  __pyx_t_11 = (__pyx_t_14) ? __Pyx_PyObject_Call2Args(__pyx_t_13, __pyx_t_14, __pyx_t_12) : __Pyx_PyObject_CallOneArg(__pyx_t_13, __pyx_t_12);
  __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 146, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_11);
  __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;

  /* "apache_beam/transforms/stats.py":147
 * 
 *   @typehints.with_input_types(T)
 *   @typehints.with_output_types(int)             # <<<<<<<<<<<<<<
 *   class Globally(PTransform):
 *     """ Approximate.Globally approximate number of unique values"""
 */
  __Pyx_GetModuleGlobalName(__pyx_t_14, __pyx_n_s_typehints); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 147, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_14);
  __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_t_14, __pyx_n_s_with_output_types); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 147, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
  __pyx_t_14 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_15))) {
    __pyx_t_14 = PyMethod_GET_SELF(__pyx_t_15);
    if (likely(__pyx_t_14)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_15);
      __Pyx_INCREF(__pyx_t_14);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_15, function);
    }
  }
  __pyx_t_12 = (__pyx_t_14) ? __Pyx_PyObject_Call2Args(__pyx_t_15, __pyx_t_14, ((PyObject *)(&PyInt_Type))) : __Pyx_PyObject_CallOneArg(__pyx_t_15, ((PyObject *)(&PyInt_Type)));
  __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
  if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 147, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;

  /* "apache_beam/transforms/stats.py":148
 *   @typehints.with_input_types(T)
 *   @typehints.with_output_types(int)
 *   class Globally(PTransform):             # <<<<<<<<<<<<<<
 *     """ Approximate.Globally approximate number of unique values"""
 *     def __init__(self, size=None, error=None):
 */
  __pyx_t_15 = __Pyx_Py3ClassCreate(__pyx_t_2, __pyx_n_s_Globally, __pyx_t_8, __pyx_t_9, NULL, 0, 0); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 148, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  __pyx_t_14 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_12))) {
    __pyx_t_14 = PyMethod_GET_SELF(__pyx_t_12);
    if (likely(__pyx_t_14)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_12);
      __Pyx_INCREF(__pyx_t_14);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_12, function);
    }
  }
  __pyx_t_13 = (__pyx_t_14) ? __Pyx_PyObject_Call2Args(__pyx_t_12, __pyx_t_14, __pyx_t_15) : __Pyx_PyObject_CallOneArg(__pyx_t_12, __pyx_t_15);
  __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
  if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 147, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_13);
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  __pyx_t_12 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_11))) {
    __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_11);
    if (likely(__pyx_t_12)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_11);
      __Pyx_INCREF(__pyx_t_12);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_11, function);
    }
  }
  __pyx_t_10 = (__pyx_t_12) ? __Pyx_PyObject_Call2Args(__pyx_t_11, __pyx_t_12, __pyx_t_13) : __Pyx_PyObject_CallOneArg(__pyx_t_11, __pyx_t_13);
  __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
  __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
  if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 146, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);
  __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  if (__Pyx_SetNameInClass(__pyx_t_1, __pyx_n_s_Globally, __pyx_t_10) < 0) __PYX_ERR(0, 148, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

  /* "apache_beam/transforms/stats.py":162
 *   @typehints.with_input_types(typing.Tuple[K, V])
 *   @typehints.with_output_types(typing.Tuple[K, int])
 *   class PerKey(PTransform):             # <<<<<<<<<<<<<<
 *     """ Approximate.PerKey approximate number of unique values per key"""
 *     def __init__(self, size=None, error=None):
 */
  __Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_n_s_PTransform); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 162, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 162, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_8);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_8);
  __pyx_t_8 = 0;
  __pyx_t_8 = __Pyx_CalculateMetaclass(NULL, __pyx_t_2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 162, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_9 = __Pyx_Py3MetaclassPrepare(__pyx_t_8, __pyx_t_2, __pyx_n_s_PerKey, __pyx_n_s_ApproximateUnique_PerKey, (PyObject *) NULL, __pyx_n_s_apache_beam_transforms_stats, __pyx_kp_s_Approximate_PerKey_approximate); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 162, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);

  /* "apache_beam/transforms/stats.py":164
 *   class PerKey(PTransform):
 *     """ Approximate.PerKey approximate number of unique values per key"""
 *     def __init__(self, size=None, error=None):             # <<<<<<<<<<<<<<
 *       self._sample_size = ApproximateUnique.parse_input_params(size, error)
 * 
 */
  __pyx_t_10 = __Pyx_CyFunction_New(&__pyx_mdef_11apache_beam_10transforms_5stats_6PerKey_1__init__, 0, __pyx_n_s_ApproximateUnique_PerKey___init, NULL, __pyx_n_s_apache_beam_transforms_stats, __pyx_d, ((PyObject *)__pyx_codeobj__24)); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 164, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);
  __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_10, __pyx_tuple__25);
  if (__Pyx_SetNameInClass(__pyx_t_9, __pyx_n_s_init, __pyx_t_10) < 0) __PYX_ERR(0, 164, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;

  /* "apache_beam/transforms/stats.py":167
 *       self._sample_size = ApproximateUnique.parse_input_params(size, error)
 * 
 *     def expand(self, pcoll):             # <<<<<<<<<<<<<<
 *       coder = coders.registry.get_coder(pcoll)
 *       return pcoll \
 */
  __pyx_t_10 = __Pyx_CyFunction_New(&__pyx_mdef_11apache_beam_10transforms_5stats_6PerKey_3expand, 0, __pyx_n_s_ApproximateUnique_PerKey_expand, NULL, __pyx_n_s_apache_beam_transforms_stats, __pyx_d, ((PyObject *)__pyx_codeobj__27)); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 167, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);
  if (__Pyx_SetNameInClass(__pyx_t_9, __pyx_n_s_expand, __pyx_t_10) < 0) __PYX_ERR(0, 167, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;

  /* "apache_beam/transforms/stats.py":160
 *                                                             coder)))
 * 
 *   @typehints.with_input_types(typing.Tuple[K, V])             # <<<<<<<<<<<<<<
 *   @typehints.with_output_types(typing.Tuple[K, int])
 *   class PerKey(PTransform):
 */
  __Pyx_GetModuleGlobalName(__pyx_t_13, __pyx_n_s_typehints); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 160, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_13);
  __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_13, __pyx_n_s_with_input_types); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 160, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
  __Pyx_GetModuleGlobalName(__pyx_t_13, __pyx_n_s_typing); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 160, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_13);
  __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_t_13, __pyx_n_s_Tuple); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 160, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
  __Pyx_GetModuleGlobalName(__pyx_t_13, __pyx_n_s_K); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 160, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_13);
  __Pyx_GetModuleGlobalName(__pyx_t_14, __pyx_n_s_V); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 160, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_14);
  __pyx_t_16 = PyTuple_New(2); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 160, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_16);
  __Pyx_GIVEREF(__pyx_t_13);
  PyTuple_SET_ITEM(__pyx_t_16, 0, __pyx_t_13);
  __Pyx_GIVEREF(__pyx_t_14);
  PyTuple_SET_ITEM(__pyx_t_16, 1, __pyx_t_14);
  __pyx_t_13 = 0;
  __pyx_t_14 = 0;
  __pyx_t_14 = __Pyx_PyObject_GetItem(__pyx_t_15, __pyx_t_16); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 160, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_14);
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
  __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
  __pyx_t_16 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_12))) {
    __pyx_t_16 = PyMethod_GET_SELF(__pyx_t_12);
    if (likely(__pyx_t_16)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_12);
      __Pyx_INCREF(__pyx_t_16);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_12, function);
    }
  }
  __pyx_t_11 = (__pyx_t_16) ? __Pyx_PyObject_Call2Args(__pyx_t_12, __pyx_t_16, __pyx_t_14) : __Pyx_PyObject_CallOneArg(__pyx_t_12, __pyx_t_14);
  __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
  __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
  if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 160, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_11);
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;

  /* "apache_beam/transforms/stats.py":161
 * 
 *   @typehints.with_input_types(typing.Tuple[K, V])
 *   @typehints.with_output_types(typing.Tuple[K, int])             # <<<<<<<<<<<<<<
 *   class PerKey(PTransform):
 *     """ Approximate.PerKey approximate number of unique values per key"""
 */
  __Pyx_GetModuleGlobalName(__pyx_t_16, __pyx_n_s_typehints); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 161, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_16);
  __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_t_16, __pyx_n_s_with_output_types); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 161, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
  __Pyx_GetModuleGlobalName(__pyx_t_16, __pyx_n_s_typing); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 161, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_16);
  __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_t_16, __pyx_n_s_Tuple); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 161, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_13);
  __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
  __Pyx_GetModuleGlobalName(__pyx_t_16, __pyx_n_s_K); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 161, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_16);
  __pyx_t_17 = PyTuple_New(2); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 161, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_17);
  __Pyx_GIVEREF(__pyx_t_16);
  PyTuple_SET_ITEM(__pyx_t_17, 0, __pyx_t_16);
  __Pyx_INCREF(((PyObject *)(&PyInt_Type)));
  __Pyx_GIVEREF(((PyObject *)(&PyInt_Type)));
  PyTuple_SET_ITEM(__pyx_t_17, 1, ((PyObject *)(&PyInt_Type)));
  __pyx_t_16 = 0;
  __pyx_t_16 = __Pyx_PyObject_GetItem(__pyx_t_13, __pyx_t_17); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 161, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_16);
  __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
  __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
  __pyx_t_17 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_15))) {
    __pyx_t_17 = PyMethod_GET_SELF(__pyx_t_15);
    if (likely(__pyx_t_17)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_15);
      __Pyx_INCREF(__pyx_t_17);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_15, function);
    }
  }
  __pyx_t_14 = (__pyx_t_17) ? __Pyx_PyObject_Call2Args(__pyx_t_15, __pyx_t_17, __pyx_t_16) : __Pyx_PyObject_CallOneArg(__pyx_t_15, __pyx_t_16);
  __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
  __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
  if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 161, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_14);
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;

  /* "apache_beam/transforms/stats.py":162
 *   @typehints.with_input_types(typing.Tuple[K, V])
 *   @typehints.with_output_types(typing.Tuple[K, int])
 *   class PerKey(PTransform):             # <<<<<<<<<<<<<<
 *     """ Approximate.PerKey approximate number of unique values per key"""
 *     def __init__(self, size=None, error=None):
 */
  __pyx_t_15 = __Pyx_Py3ClassCreate(__pyx_t_8, __pyx_n_s_PerKey, __pyx_t_2, __pyx_t_9, NULL, 0, 0); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 162, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  __pyx_t_16 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_14))) {
    __pyx_t_16 = PyMethod_GET_SELF(__pyx_t_14);
    if (likely(__pyx_t_16)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_14);
      __Pyx_INCREF(__pyx_t_16);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_14, function);
    }
  }
  __pyx_t_12 = (__pyx_t_16) ? __Pyx_PyObject_Call2Args(__pyx_t_14, __pyx_t_16, __pyx_t_15) : __Pyx_PyObject_CallOneArg(__pyx_t_14, __pyx_t_15);
  __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
  if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 161, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
  __pyx_t_14 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_11))) {
    __pyx_t_14 = PyMethod_GET_SELF(__pyx_t_11);
    if (likely(__pyx_t_14)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_11);
      __Pyx_INCREF(__pyx_t_14);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_11, function);
    }
  }
  __pyx_t_10 = (__pyx_t_14) ? __Pyx_PyObject_Call2Args(__pyx_t_11, __pyx_t_14, __pyx_t_12) : __Pyx_PyObject_CallOneArg(__pyx_t_11, __pyx_t_12);
  __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 160, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);
  __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  if (__Pyx_SetNameInClass(__pyx_t_1, __pyx_n_s_PerKey, __pyx_t_10) < 0) __PYX_ERR(0, 162, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "apache_beam/transforms/stats.py":90
 * 
 * 
 * class ApproximateUnique(object):             # <<<<<<<<<<<<<<
 *   """
 *   Hashes input elements and uses those to extrapolate the size of the entire
 */
  __pyx_t_2 = __Pyx_Py3ClassCreate(__pyx_t_7, __pyx_n_s_ApproximateUnique, __pyx_tuple__12, __pyx_t_1, NULL, 0, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 90, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_ApproximateUnique, __pyx_t_2) < 0) __PYX_ERR(0, 90, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "apache_beam/transforms/stats.py":175
 * 
 * 
 * class _LargestUnique(object):             # <<<<<<<<<<<<<<
 *   """
 *   An object to keep samples and calculate sample hash space. It is an
 */
  __pyx_t_7 = __Pyx_CalculateMetaclass(NULL, __pyx_tuple__28); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 175, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_1 = __Pyx_Py3MetaclassPrepare(__pyx_t_7, __pyx_tuple__28, __pyx_n_s_LargestUnique, __pyx_n_s_LargestUnique, (PyObject *) NULL, __pyx_n_s_apache_beam_transforms_stats, __pyx_kp_s_An_object_to_keep_samples_and_c); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 175, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);

  /* "apache_beam/transforms/stats.py":181
 *   """
 *   # We use unsigned 64-bit integer hashes.
 *   _HASH_SPACE_SIZE = 2.0**64             # <<<<<<<<<<<<<<
 * 
 *   def __init__(self, sample_size):
 */
  __pyx_t_2 = PyFloat_FromDouble(pow(2.0, 64.0)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 181, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (__Pyx_SetNameInClass(__pyx_t_1, __pyx_n_s_HASH_SPACE_SIZE, __pyx_t_2) < 0) __PYX_ERR(0, 181, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "apache_beam/transforms/stats.py":183
 *   _HASH_SPACE_SIZE = 2.0**64
 * 
 *   def __init__(self, sample_size):             # <<<<<<<<<<<<<<
 *     self._sample_size = sample_size
 *     self._min_hash = 2.0**64
 */
  __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_11apache_beam_10transforms_5stats_14_LargestUnique_1__init__, 0, __pyx_n_s_LargestUnique___init, NULL, __pyx_n_s_apache_beam_transforms_stats, __pyx_d, ((PyObject *)__pyx_codeobj__30)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 183, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (__Pyx_SetNameInClass(__pyx_t_1, __pyx_n_s_init, __pyx_t_2) < 0) __PYX_ERR(0, 183, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "apache_beam/transforms/stats.py":189
 *     self._sample_set = set()
 * 
 *   def add(self, element):             # <<<<<<<<<<<<<<
 *     """
 *     :param an element from pcoll.
 */
  __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_11apache_beam_10transforms_5stats_14_LargestUnique_3add, 0, __pyx_n_s_LargestUnique_add, NULL, __pyx_n_s_apache_beam_transforms_stats, __pyx_d, ((PyObject *)__pyx_codeobj__32)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 189, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (__Pyx_SetNameInClass(__pyx_t_1, __pyx_n_s_add, __pyx_t_2) < 0) __PYX_ERR(0, 189, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "apache_beam/transforms/stats.py":212
 *     return True
 * 
 *   def get_estimate(self):             # <<<<<<<<<<<<<<
 *     """
 *     :return: estimation count of unique values
 */
  __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_11apache_beam_10transforms_5stats_14_LargestUnique_5get_estimate, 0, __pyx_n_s_LargestUnique_get_estimate, NULL, __pyx_n_s_apache_beam_transforms_stats, __pyx_d, ((PyObject *)__pyx_codeobj__34)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 212, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (__Pyx_SetNameInClass(__pyx_t_1, __pyx_n_s_get_estimate, __pyx_t_2) < 0) __PYX_ERR(0, 212, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "apache_beam/transforms/stats.py":175
 * 
 * 
 * class _LargestUnique(object):             # <<<<<<<<<<<<<<
 *   """
 *   An object to keep samples and calculate sample hash space. It is an
 */
  __pyx_t_2 = __Pyx_Py3ClassCreate(__pyx_t_7, __pyx_n_s_LargestUnique, __pyx_tuple__28, __pyx_t_1, NULL, 0, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 175, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_LargestUnique, __pyx_t_2) < 0) __PYX_ERR(0, 175, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "apache_beam/transforms/stats.py":242
 * 
 * 
 * class ApproximateUniqueCombineFn(CombineFn):             # <<<<<<<<<<<<<<
 *   """
 *   ApproximateUniqueCombineFn computes an estimate of the number of
 */
  __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_n_s_CombineFn); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 242, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 242, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_7);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_7);
  __pyx_t_7 = 0;
  __pyx_t_7 = __Pyx_CalculateMetaclass(NULL, __pyx_t_1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 242, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_2 = __Pyx_Py3MetaclassPrepare(__pyx_t_7, __pyx_t_1, __pyx_n_s_ApproximateUniqueCombineFn, __pyx_n_s_ApproximateUniqueCombineFn, (PyObject *) NULL, __pyx_n_s_apache_beam_transforms_stats, __pyx_kp_s_ApproximateUniqueCombineFn_comp); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 242, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);

  /* "apache_beam/transforms/stats.py":247
 *   unique values that were combined.
 *   """
 *   def __init__(self, sample_size, coder):             # <<<<<<<<<<<<<<
 *     self._sample_size = sample_size
 *     coder = coders.typecoders.registry.verify_deterministic(
 */
  __pyx_t_8 = __Pyx_CyFunction_New(&__pyx_mdef_11apache_beam_10transforms_5stats_26ApproximateUniqueCombineFn_1__init__, 0, __pyx_n_s_ApproximateUniqueCombineFn___ini, NULL, __pyx_n_s_apache_beam_transforms_stats, __pyx_d, ((PyObject *)__pyx_codeobj__36)); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 247, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  if (__Pyx_SetNameInClass(__pyx_t_2, __pyx_n_s_init, __pyx_t_8) < 0) __PYX_ERR(0, 247, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

  /* "apache_beam/transforms/stats.py":255
 *     self._hash_fn = _get_default_hash_fn()
 * 
 *   def create_accumulator(self, *args, **kwargs):             # <<<<<<<<<<<<<<
 *     return _LargestUnique(self._sample_size)
 * 
 */
  __pyx_t_8 = __Pyx_CyFunction_New(&__pyx_mdef_11apache_beam_10transforms_5stats_26ApproximateUniqueCombineFn_3create_accumulator, 0, __pyx_n_s_ApproximateUniqueCombineFn_creat, NULL, __pyx_n_s_apache_beam_transforms_stats, __pyx_d, ((PyObject *)__pyx_codeobj__38)); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 255, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  if (__Pyx_SetNameInClass(__pyx_t_2, __pyx_n_s_create_accumulator, __pyx_t_8) < 0) __PYX_ERR(0, 255, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

  /* "apache_beam/transforms/stats.py":258
 *     return _LargestUnique(self._sample_size)
 * 
 *   def add_input(self, accumulator, element, *args, **kwargs):             # <<<<<<<<<<<<<<
 *     try:
 *       hashed_value = self._hash_fn(self._coder.encode(element))
 */
  __pyx_t_8 = __Pyx_CyFunction_New(&__pyx_mdef_11apache_beam_10transforms_5stats_26ApproximateUniqueCombineFn_5add_input, 0, __pyx_n_s_ApproximateUniqueCombineFn_add_i, NULL, __pyx_n_s_apache_beam_transforms_stats, __pyx_d, ((PyObject *)__pyx_codeobj__40)); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 258, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  if (__Pyx_SetNameInClass(__pyx_t_2, __pyx_n_s_add_input, __pyx_t_8) < 0) __PYX_ERR(0, 258, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

  /* "apache_beam/transforms/stats.py":268
 *   # created an issue https://github.com/apache/beam/issues/19459 to speed up
 *   # merge process.
 *   def merge_accumulators(self, accumulators, *args, **kwargs):             # <<<<<<<<<<<<<<
 *     merged_accumulator = self.create_accumulator()
 *     for accumulator in accumulators:
 */
  __pyx_t_8 = __Pyx_CyFunction_New(&__pyx_mdef_11apache_beam_10transforms_5stats_26ApproximateUniqueCombineFn_7merge_accumulators, 0, __pyx_n_s_ApproximateUniqueCombineFn_merge, NULL, __pyx_n_s_apache_beam_transforms_stats, __pyx_d, ((PyObject *)__pyx_codeobj__42)); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 268, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  if (__Pyx_SetNameInClass(__pyx_t_2, __pyx_n_s_merge_accumulators, __pyx_t_8) < 0) __PYX_ERR(0, 268, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

  /* "apache_beam/transforms/stats.py":277
 * 
 *   @staticmethod
 *   def extract_output(accumulator):             # <<<<<<<<<<<<<<
 *     return accumulator.get_estimate()
 * 
 */
  __pyx_t_8 = __Pyx_CyFunction_New(&__pyx_mdef_11apache_beam_10transforms_5stats_26ApproximateUniqueCombineFn_9extract_output, __Pyx_CYFUNCTION_STATICMETHOD, __pyx_n_s_ApproximateUniqueCombineFn_extra, NULL, __pyx_n_s_apache_beam_transforms_stats, __pyx_d, ((PyObject *)__pyx_codeobj__44)); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 277, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);

  /* "apache_beam/transforms/stats.py":276
 *     return merged_accumulator
 * 
 *   @staticmethod             # <<<<<<<<<<<<<<
 *   def extract_output(accumulator):
 *     return accumulator.get_estimate()
 */
  __pyx_t_9 = __Pyx_PyObject_CallOneArg(__pyx_builtin_staticmethod, __pyx_t_8); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 276, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  if (__Pyx_SetNameInClass(__pyx_t_2, __pyx_n_s_extract_output, __pyx_t_9) < 0) __PYX_ERR(0, 277, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;

  /* "apache_beam/transforms/stats.py":280
 *     return accumulator.get_estimate()
 * 
 *   def display_data(self):             # <<<<<<<<<<<<<<
 *     return {'sample_size': self._sample_size}
 * 
 */
  __pyx_t_9 = __Pyx_CyFunction_New(&__pyx_mdef_11apache_beam_10transforms_5stats_26ApproximateUniqueCombineFn_11display_data, 0, __pyx_n_s_ApproximateUniqueCombineFn_displ, NULL, __pyx_n_s_apache_beam_transforms_stats, __pyx_d, ((PyObject *)__pyx_codeobj__46)); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 280, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  if (__Pyx_SetNameInClass(__pyx_t_2, __pyx_n_s_display_data_2, __pyx_t_9) < 0) __PYX_ERR(0, 280, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;

  /* "apache_beam/transforms/stats.py":242
 * 
 * 
 * class ApproximateUniqueCombineFn(CombineFn):             # <<<<<<<<<<<<<<
 *   """
 *   ApproximateUniqueCombineFn computes an estimate of the number of
 */
  __pyx_t_9 = __Pyx_Py3ClassCreate(__pyx_t_7, __pyx_n_s_ApproximateUniqueCombineFn, __pyx_t_1, __pyx_t_2, NULL, 0, 0); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 242, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_ApproximateUniqueCombineFn, __pyx_t_9) < 0) __PYX_ERR(0, 242, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "apache_beam/transforms/stats.py":284
 * 
 * 
 * class ApproximateQuantiles(object):             # <<<<<<<<<<<<<<
 *   """
 *   PTransform for getting the idea of data distribution using approximate N-tile
 */
  __pyx_t_1 = __Pyx_CalculateMetaclass(NULL, __pyx_tuple__47); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 284, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_7 = __Pyx_Py3MetaclassPrepare(__pyx_t_1, __pyx_tuple__47, __pyx_n_s_ApproximateQuantiles, __pyx_n_s_ApproximateQuantiles, (PyObject *) NULL, __pyx_n_s_apache_beam_transforms_stats, __pyx_kp_s_PTransform_for_getting_the_idea); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 284, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);

  /* "apache_beam/transforms/stats.py":312
 *   """
 *   @staticmethod
 *   def _display_data(num_quantiles, key, reverse, weighted, input_batched):             # <<<<<<<<<<<<<<
 *     return {
 *         'num_quantiles': DisplayDataItem(num_quantiles, label='Quantile Count'),
 */
  __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_11apache_beam_10transforms_5stats_20ApproximateQuantiles_1_display_data, __Pyx_CYFUNCTION_STATICMETHOD, __pyx_n_s_ApproximateQuantiles__display_da, NULL, __pyx_n_s_apache_beam_transforms_stats, __pyx_d, ((PyObject *)__pyx_codeobj__49)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 312, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);

  /* "apache_beam/transforms/stats.py":311
 *     out: [0, 2, 5, 7, 100]
 *   """
 *   @staticmethod             # <<<<<<<<<<<<<<
 *   def _display_data(num_quantiles, key, reverse, weighted, input_batched):
 *     return {
 */
  __pyx_t_9 = __Pyx_PyObject_CallOneArg(__pyx_builtin_staticmethod, __pyx_t_2); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 311, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (__Pyx_SetNameInClass(__pyx_t_7, __pyx_n_s_display_data, __pyx_t_9) < 0) __PYX_ERR(0, 312, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;

  /* "apache_beam/transforms/stats.py":328
 *       typehints.Union[typing.Sequence[T], typing.Tuple[T, float]])
 *   @typehints.with_output_types(typing.List[T])
 *   class Globally(PTransform):             # <<<<<<<<<<<<<<
 *     """
 *     PTransform takes PCollection and returns a list whose single value is
 */
  __Pyx_GetModuleGlobalName(__pyx_t_9, __pyx_n_s_PTransform); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 328, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 328, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_9);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_9);
  __pyx_t_9 = 0;
  __pyx_t_9 = __Pyx_CalculateMetaclass(NULL, __pyx_t_2); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 328, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __pyx_t_8 = __Pyx_Py3MetaclassPrepare(__pyx_t_9, __pyx_t_2, __pyx_n_s_Globally, __pyx_n_s_ApproximateQuantiles_Globally, (PyObject *) NULL, __pyx_n_s_apache_beam_transforms_stats, __pyx_kp_s_PTransform_takes_PCollection_an); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 328, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);

  /* "apache_beam/transforms/stats.py":348
 *         efficiently.
 *     """
 *     def __init__(             # <<<<<<<<<<<<<<
 *         self,
 *         num_quantiles,
 */
  __pyx_t_10 = __Pyx_CyFunction_New(&__pyx_mdef_11apache_beam_10transforms_5stats_8Globally_5__init__, 0, __pyx_n_s_ApproximateQuantiles_Globally_2, NULL, __pyx_n_s_apache_beam_transforms_stats, __pyx_d, ((PyObject *)__pyx_codeobj__51)); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 348, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);
  __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_10, __pyx_tuple__52);
  if (__Pyx_SetNameInClass(__pyx_t_8, __pyx_n_s_init, __pyx_t_10) < 0) __PYX_ERR(0, 348, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;

  /* "apache_beam/transforms/stats.py":361
 *       self._input_batched = input_batched
 * 
 *     def expand(self, pcoll):             # <<<<<<<<<<<<<<
 *       return pcoll | CombineGlobally(
 *           ApproximateQuantilesCombineFn.create(
 */
  __pyx_t_10 = __Pyx_CyFunction_New(&__pyx_mdef_11apache_beam_10transforms_5stats_8Globally_7expand, 0, __pyx_n_s_ApproximateQuantiles_Globally_ex, NULL, __pyx_n_s_apache_beam_transforms_stats, __pyx_d, ((PyObject *)__pyx_codeobj__54)); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 361, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);
  if (__Pyx_SetNameInClass(__pyx_t_8, __pyx_n_s_expand, __pyx_t_10) < 0) __PYX_ERR(0, 361, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;

  /* "apache_beam/transforms/stats.py":370
 *               input_batched=self._input_batched))
 * 
 *     def display_data(self):             # <<<<<<<<<<<<<<
 *       return ApproximateQuantiles._display_data(
 *           num_quantiles=self._num_quantiles,
 */
  __pyx_t_10 = __Pyx_CyFunction_New(&__pyx_mdef_11apache_beam_10transforms_5stats_8Globally_9display_data, 0, __pyx_n_s_ApproximateQuantiles_Globally_di, NULL, __pyx_n_s_apache_beam_transforms_stats, __pyx_d, ((PyObject *)__pyx_codeobj__56)); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 370, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);
  if (__Pyx_SetNameInClass(__pyx_t_8, __pyx_n_s_display_data_2, __pyx_t_10) < 0) __PYX_ERR(0, 370, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;

  /* "apache_beam/transforms/stats.py":325
 *     }
 * 
 *   @typehints.with_input_types(             # <<<<<<<<<<<<<<
 *       typehints.Union[typing.Sequence[T], typing.Tuple[T, float]])
 *   @typehints.with_output_types(typing.List[T])
 */
  __Pyx_GetModuleGlobalName(__pyx_t_12, __pyx_n_s_typehints); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 325, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  __pyx_t_14 = __Pyx_PyObject_GetAttrStr(__pyx_t_12, __pyx_n_s_with_input_types); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 325, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_14);
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;

  /* "apache_beam/transforms/stats.py":326
 * 
 *   @typehints.with_input_types(
 *       typehints.Union[typing.Sequence[T], typing.Tuple[T, float]])             # <<<<<<<<<<<<<<
 *   @typehints.with_output_types(typing.List[T])
 *   class Globally(PTransform):
 */
  __Pyx_GetModuleGlobalName(__pyx_t_12, __pyx_n_s_typehints); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 326, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_t_12, __pyx_n_s_Union); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 326, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  __Pyx_GetModuleGlobalName(__pyx_t_12, __pyx_n_s_typing); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 326, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  __pyx_t_16 = __Pyx_PyObject_GetAttrStr(__pyx_t_12, __pyx_n_s_Sequence); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 326, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_16);
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  __Pyx_GetModuleGlobalName(__pyx_t_12, __pyx_n_s_T); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 326, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  __pyx_t_17 = __Pyx_PyObject_GetItem(__pyx_t_16, __pyx_t_12); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 326, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_17);
  __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  __Pyx_GetModuleGlobalName(__pyx_t_12, __pyx_n_s_typing); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 326, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  __pyx_t_16 = __Pyx_PyObject_GetAttrStr(__pyx_t_12, __pyx_n_s_Tuple); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 326, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_16);
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  __Pyx_GetModuleGlobalName(__pyx_t_12, __pyx_n_s_T); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 326, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  __pyx_t_13 = PyTuple_New(2); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 326, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_13);
  __Pyx_GIVEREF(__pyx_t_12);
  PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_t_12);
  __Pyx_INCREF(((PyObject *)(&PyFloat_Type)));
  __Pyx_GIVEREF(((PyObject *)(&PyFloat_Type)));
  PyTuple_SET_ITEM(__pyx_t_13, 1, ((PyObject *)(&PyFloat_Type)));
  __pyx_t_12 = 0;
  __pyx_t_12 = __Pyx_PyObject_GetItem(__pyx_t_16, __pyx_t_13); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 326, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
  __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
  __pyx_t_13 = PyTuple_New(2); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 326, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_13);
  __Pyx_GIVEREF(__pyx_t_17);
  PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_t_17);
  __Pyx_GIVEREF(__pyx_t_12);
  PyTuple_SET_ITEM(__pyx_t_13, 1, __pyx_t_12);
  __pyx_t_17 = 0;
  __pyx_t_12 = 0;
  __pyx_t_12 = __Pyx_PyObject_GetItem(__pyx_t_15, __pyx_t_13); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 326, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
  __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
  __pyx_t_13 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_14))) {
    __pyx_t_13 = PyMethod_GET_SELF(__pyx_t_14);
    if (likely(__pyx_t_13)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_14);
      __Pyx_INCREF(__pyx_t_13);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_14, function);
    }
  }
  __pyx_t_11 = (__pyx_t_13) ? __Pyx_PyObject_Call2Args(__pyx_t_14, __pyx_t_13, __pyx_t_12) : __Pyx_PyObject_CallOneArg(__pyx_t_14, __pyx_t_12);
  __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 325, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_11);
  __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;

  /* "apache_beam/transforms/stats.py":327
 *   @typehints.with_input_types(
 *       typehints.Union[typing.Sequence[T], typing.Tuple[T, float]])
 *   @typehints.with_output_types(typing.List[T])             # <<<<<<<<<<<<<<
 *   class Globally(PTransform):
 *     """
 */
  __Pyx_GetModuleGlobalName(__pyx_t_13, __pyx_n_s_typehints); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 327, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_13);
  __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_t_13, __pyx_n_s_with_output_types); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 327, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
  __Pyx_GetModuleGlobalName(__pyx_t_13, __pyx_n_s_typing); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 327, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_13);
  __pyx_t_17 = __Pyx_PyObject_GetAttrStr(__pyx_t_13, __pyx_n_s_List); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 327, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_17);
  __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
  __Pyx_GetModuleGlobalName(__pyx_t_13, __pyx_n_s_T); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 327, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_13);
  __pyx_t_16 = __Pyx_PyObject_GetItem(__pyx_t_17, __pyx_t_13); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 327, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_16);
  __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
  __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
  __pyx_t_13 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_15))) {
    __pyx_t_13 = PyMethod_GET_SELF(__pyx_t_15);
    if (likely(__pyx_t_13)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_15);
      __Pyx_INCREF(__pyx_t_13);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_15, function);
    }
  }
  __pyx_t_12 = (__pyx_t_13) ? __Pyx_PyObject_Call2Args(__pyx_t_15, __pyx_t_13, __pyx_t_16) : __Pyx_PyObject_CallOneArg(__pyx_t_15, __pyx_t_16);
  __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
  __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
  if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 327, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;

  /* "apache_beam/transforms/stats.py":328
 *       typehints.Union[typing.Sequence[T], typing.Tuple[T, float]])
 *   @typehints.with_output_types(typing.List[T])
 *   class Globally(PTransform):             # <<<<<<<<<<<<<<
 *     """
 *     PTransform takes PCollection and returns a list whose single value is
 */
  __pyx_t_15 = __Pyx_Py3ClassCreate(__pyx_t_9, __pyx_n_s_Globally, __pyx_t_2, __pyx_t_8, NULL, 0, 0); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 328, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  __pyx_t_16 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_12))) {
    __pyx_t_16 = PyMethod_GET_SELF(__pyx_t_12);
    if (likely(__pyx_t_16)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_12);
      __Pyx_INCREF(__pyx_t_16);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_12, function);
    }
  }
  __pyx_t_14 = (__pyx_t_16) ? __Pyx_PyObject_Call2Args(__pyx_t_12, __pyx_t_16, __pyx_t_15) : __Pyx_PyObject_CallOneArg(__pyx_t_12, __pyx_t_15);
  __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
  if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 327, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_14);
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  __pyx_t_12 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_11))) {
    __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_11);
    if (likely(__pyx_t_12)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_11);
      __Pyx_INCREF(__pyx_t_12);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_11, function);
    }
  }
  __pyx_t_10 = (__pyx_t_12) ? __Pyx_PyObject_Call2Args(__pyx_t_11, __pyx_t_12, __pyx_t_14) : __Pyx_PyObject_CallOneArg(__pyx_t_11, __pyx_t_14);
  __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
  __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
  if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 325, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);
  __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  if (__Pyx_SetNameInClass(__pyx_t_7, __pyx_n_s_Globally, __pyx_t_10) < 0) __PYX_ERR(0, 328, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "apache_beam/transforms/stats.py":382
 *                       typing.Tuple[K, typing.Tuple[V, float]]])
 *   @typehints.with_output_types(typing.Tuple[K, typing.List[V]])
 *   class PerKey(PTransform):             # <<<<<<<<<<<<<<
 *     """
 *     PTransform takes PCollection of KV and returns a list based on each key
 */
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_PTransform); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 382, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_9 = PyTuple_New(1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 382, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_2);
  __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_CalculateMetaclass(NULL, __pyx_t_9); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 382, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_8 = __Pyx_Py3MetaclassPrepare(__pyx_t_2, __pyx_t_9, __pyx_n_s_PerKey, __pyx_n_s_ApproximateQuantiles_PerKey, (PyObject *) NULL, __pyx_n_s_apache_beam_transforms_stats, __pyx_kp_s_PTransform_takes_PCollection_of); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 382, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);

  /* "apache_beam/transforms/stats.py":403
 *         efficiently.
 *     """
 *     def __init__(             # <<<<<<<<<<<<<<
 *         self,
 *         num_quantiles,
 */
  __pyx_t_10 = __Pyx_CyFunction_New(&__pyx_mdef_11apache_beam_10transforms_5stats_6PerKey_5__init__, 0, __pyx_n_s_ApproximateQuantiles_PerKey___in, NULL, __pyx_n_s_apache_beam_transforms_stats, __pyx_d, ((PyObject *)__pyx_codeobj__58)); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 403, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);
  __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_10, __pyx_tuple__59);
  if (__Pyx_SetNameInClass(__pyx_t_8, __pyx_n_s_init, __pyx_t_10) < 0) __PYX_ERR(0, 403, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;

  /* "apache_beam/transforms/stats.py":416
 *       self._input_batched = input_batched
 * 
 *     def expand(self, pcoll):             # <<<<<<<<<<<<<<
 *       return pcoll | CombinePerKey(
 *           ApproximateQuantilesCombineFn.create(
 */
  __pyx_t_10 = __Pyx_CyFunction_New(&__pyx_mdef_11apache_beam_10transforms_5stats_6PerKey_7expand, 0, __pyx_n_s_ApproximateQuantiles_PerKey_expa, NULL, __pyx_n_s_apache_beam_transforms_stats, __pyx_d, ((PyObject *)__pyx_codeobj__61)); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 416, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);
  if (__Pyx_SetNameInClass(__pyx_t_8, __pyx_n_s_expand, __pyx_t_10) < 0) __PYX_ERR(0, 416, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;

  /* "apache_beam/transforms/stats.py":425
 *               input_batched=self._input_batched))
 * 
 *     def display_data(self):             # <<<<<<<<<<<<<<
 *       return ApproximateQuantiles._display_data(
 *           num_quantiles=self._num_quantiles,
 */
  __pyx_t_10 = __Pyx_CyFunction_New(&__pyx_mdef_11apache_beam_10transforms_5stats_6PerKey_9display_data, 0, __pyx_n_s_ApproximateQuantiles_PerKey_disp, NULL, __pyx_n_s_apache_beam_transforms_stats, __pyx_d, ((PyObject *)__pyx_codeobj__63)); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 425, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);
  if (__Pyx_SetNameInClass(__pyx_t_8, __pyx_n_s_display_data_2, __pyx_t_10) < 0) __PYX_ERR(0, 425, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;

  /* "apache_beam/transforms/stats.py":378
 *           input_batched=self._input_batched)
 * 
 *   @typehints.with_input_types(             # <<<<<<<<<<<<<<
 *       typehints.Union[typing.Tuple[K, V],
 *                       typing.Tuple[K, typing.Tuple[V, float]]])
 */
  __Pyx_GetModuleGlobalName(__pyx_t_14, __pyx_n_s_typehints); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 378, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_14);
  __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_14, __pyx_n_s_with_input_types); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 378, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;

  /* "apache_beam/transforms/stats.py":379
 * 
 *   @typehints.with_input_types(
 *       typehints.Union[typing.Tuple[K, V],             # <<<<<<<<<<<<<<
 *                       typing.Tuple[K, typing.Tuple[V, float]]])
 *   @typehints.with_output_types(typing.Tuple[K, typing.List[V]])
 */
  __Pyx_GetModuleGlobalName(__pyx_t_14, __pyx_n_s_typehints); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 379, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_14);
  __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_t_14, __pyx_n_s_Union); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 379, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
  __Pyx_GetModuleGlobalName(__pyx_t_14, __pyx_n_s_typing); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 379, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_14);
  __pyx_t_16 = __Pyx_PyObject_GetAttrStr(__pyx_t_14, __pyx_n_s_Tuple); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 379, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_16);
  __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
  __Pyx_GetModuleGlobalName(__pyx_t_14, __pyx_n_s_K); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 379, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_14);
  __Pyx_GetModuleGlobalName(__pyx_t_13, __pyx_n_s_V); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 379, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_13);
  __pyx_t_17 = PyTuple_New(2); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 379, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_17);
  __Pyx_GIVEREF(__pyx_t_14);
  PyTuple_SET_ITEM(__pyx_t_17, 0, __pyx_t_14);
  __Pyx_GIVEREF(__pyx_t_13);
  PyTuple_SET_ITEM(__pyx_t_17, 1, __pyx_t_13);
  __pyx_t_14 = 0;
  __pyx_t_13 = 0;
  __pyx_t_13 = __Pyx_PyObject_GetItem(__pyx_t_16, __pyx_t_17); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 379, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_13);
  __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
  __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;

  /* "apache_beam/transforms/stats.py":380
 *   @typehints.with_input_types(
 *       typehints.Union[typing.Tuple[K, V],
 *                       typing.Tuple[K, typing.Tuple[V, float]]])             # <<<<<<<<<<<<<<
 *   @typehints.with_output_types(typing.Tuple[K, typing.List[V]])
 *   class PerKey(PTransform):
 */
  __Pyx_GetModuleGlobalName(__pyx_t_17, __pyx_n_s_typing); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 380, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_17);
  __pyx_t_16 = __Pyx_PyObject_GetAttrStr(__pyx_t_17, __pyx_n_s_Tuple); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 380, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_16);
  __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
  __Pyx_GetModuleGlobalName(__pyx_t_17, __pyx_n_s_K); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 380, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_17);
  __Pyx_GetModuleGlobalName(__pyx_t_14, __pyx_n_s_typing); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 380, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_14);
  __pyx_t_18 = __Pyx_PyObject_GetAttrStr(__pyx_t_14, __pyx_n_s_Tuple); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 380, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_18);
  __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
  __Pyx_GetModuleGlobalName(__pyx_t_14, __pyx_n_s_V); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 380, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_14);
  __pyx_t_19 = PyTuple_New(2); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 380, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_19);
  __Pyx_GIVEREF(__pyx_t_14);
  PyTuple_SET_ITEM(__pyx_t_19, 0, __pyx_t_14);
  __Pyx_INCREF(((PyObject *)(&PyFloat_Type)));
  __Pyx_GIVEREF(((PyObject *)(&PyFloat_Type)));
  PyTuple_SET_ITEM(__pyx_t_19, 1, ((PyObject *)(&PyFloat_Type)));
  __pyx_t_14 = 0;
  __pyx_t_14 = __Pyx_PyObject_GetItem(__pyx_t_18, __pyx_t_19); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 380, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_14);
  __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
  __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
  __pyx_t_19 = PyTuple_New(2); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 380, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_19);
  __Pyx_GIVEREF(__pyx_t_17);
  PyTuple_SET_ITEM(__pyx_t_19, 0, __pyx_t_17);
  __Pyx_GIVEREF(__pyx_t_14);
  PyTuple_SET_ITEM(__pyx_t_19, 1, __pyx_t_14);
  __pyx_t_17 = 0;
  __pyx_t_14 = 0;
  __pyx_t_14 = __Pyx_PyObject_GetItem(__pyx_t_16, __pyx_t_19); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 380, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_14);
  __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
  __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;

  /* "apache_beam/transforms/stats.py":379
 * 
 *   @typehints.with_input_types(
 *       typehints.Union[typing.Tuple[K, V],             # <<<<<<<<<<<<<<
 *                       typing.Tuple[K, typing.Tuple[V, float]]])
 *   @typehints.with_output_types(typing.Tuple[K, typing.List[V]])
 */
  __pyx_t_19 = PyTuple_New(2); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 379, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_19);
  __Pyx_GIVEREF(__pyx_t_13);
  PyTuple_SET_ITEM(__pyx_t_19, 0, __pyx_t_13);
  __Pyx_GIVEREF(__pyx_t_14);
  PyTuple_SET_ITEM(__pyx_t_19, 1, __pyx_t_14);
  __pyx_t_13 = 0;
  __pyx_t_14 = 0;
  __pyx_t_14 = __Pyx_PyObject_GetItem(__pyx_t_15, __pyx_t_19); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 379, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_14);
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
  __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
  __pyx_t_19 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_12))) {
    __pyx_t_19 = PyMethod_GET_SELF(__pyx_t_12);
    if (likely(__pyx_t_19)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_12);
      __Pyx_INCREF(__pyx_t_19);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_12, function);
    }
  }
  __pyx_t_11 = (__pyx_t_19) ? __Pyx_PyObject_Call2Args(__pyx_t_12, __pyx_t_19, __pyx_t_14) : __Pyx_PyObject_CallOneArg(__pyx_t_12, __pyx_t_14);
  __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0;
  __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
  if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 378, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_11);
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;

  /* "apache_beam/transforms/stats.py":381
 *       typehints.Union[typing.Tuple[K, V],
 *                       typing.Tuple[K, typing.Tuple[V, float]]])
 *   @typehints.with_output_types(typing.Tuple[K, typing.List[V]])             # <<<<<<<<<<<<<<
 *   class PerKey(PTransform):
 *     """
 */
  __Pyx_GetModuleGlobalName(__pyx_t_19, __pyx_n_s_typehints); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 381, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_19);
  __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_t_19, __pyx_n_s_with_output_types); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 381, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
  __Pyx_GetModuleGlobalName(__pyx_t_19, __pyx_n_s_typing); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 381, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_19);
  __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_t_19, __pyx_n_s_Tuple); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 381, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_13);
  __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
  __Pyx_GetModuleGlobalName(__pyx_t_19, __pyx_n_s_K); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 381, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_19);
  __Pyx_GetModuleGlobalName(__pyx_t_16, __pyx_n_s_typing); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 381, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_16);
  __pyx_t_17 = __Pyx_PyObject_GetAttrStr(__pyx_t_16, __pyx_n_s_List); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 381, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_17);
  __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
  __Pyx_GetModuleGlobalName(__pyx_t_16, __pyx_n_s_V); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 381, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_16);
  __pyx_t_18 = __Pyx_PyObject_GetItem(__pyx_t_17, __pyx_t_16); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 381, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_18);
  __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
  __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
  __pyx_t_16 = PyTuple_New(2); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 381, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_16);
  __Pyx_GIVEREF(__pyx_t_19);
  PyTuple_SET_ITEM(__pyx_t_16, 0, __pyx_t_19);
  __Pyx_GIVEREF(__pyx_t_18);
  PyTuple_SET_ITEM(__pyx_t_16, 1, __pyx_t_18);
  __pyx_t_19 = 0;
  __pyx_t_18 = 0;
  __pyx_t_18 = __Pyx_PyObject_GetItem(__pyx_t_13, __pyx_t_16); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 381, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_18);
  __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
  __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
  __pyx_t_16 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_15))) {
    __pyx_t_16 = PyMethod_GET_SELF(__pyx_t_15);
    if (likely(__pyx_t_16)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_15);
      __Pyx_INCREF(__pyx_t_16);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_15, function);
    }
  }
  __pyx_t_14 = (__pyx_t_16) ? __Pyx_PyObject_Call2Args(__pyx_t_15, __pyx_t_16, __pyx_t_18) : __Pyx_PyObject_CallOneArg(__pyx_t_15, __pyx_t_18);
  __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
  __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
  if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 381, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_14);
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;

  /* "apache_beam/transforms/stats.py":382
 *                       typing.Tuple[K, typing.Tuple[V, float]]])
 *   @typehints.with_output_types(typing.Tuple[K, typing.List[V]])
 *   class PerKey(PTransform):             # <<<<<<<<<<<<<<
 *     """
 *     PTransform takes PCollection of KV and returns a list based on each key
 */
  __pyx_t_15 = __Pyx_Py3ClassCreate(__pyx_t_2, __pyx_n_s_PerKey, __pyx_t_9, __pyx_t_8, NULL, 0, 0); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 382, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  __pyx_t_18 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_14))) {
    __pyx_t_18 = PyMethod_GET_SELF(__pyx_t_14);
    if (likely(__pyx_t_18)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_14);
      __Pyx_INCREF(__pyx_t_18);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_14, function);
    }
  }
  __pyx_t_12 = (__pyx_t_18) ? __Pyx_PyObject_Call2Args(__pyx_t_14, __pyx_t_18, __pyx_t_15) : __Pyx_PyObject_CallOneArg(__pyx_t_14, __pyx_t_15);
  __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
  if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 381, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
  __pyx_t_14 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_11))) {
    __pyx_t_14 = PyMethod_GET_SELF(__pyx_t_11);
    if (likely(__pyx_t_14)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_11);
      __Pyx_INCREF(__pyx_t_14);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_11, function);
    }
  }
  __pyx_t_10 = (__pyx_t_14) ? __Pyx_PyObject_Call2Args(__pyx_t_11, __pyx_t_14, __pyx_t_12) : __Pyx_PyObject_CallOneArg(__pyx_t_11, __pyx_t_12);
  __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 378, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);
  __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  if (__Pyx_SetNameInClass(__pyx_t_7, __pyx_n_s_PerKey, __pyx_t_10) < 0) __PYX_ERR(0, 382, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;

  /* "apache_beam/transforms/stats.py":284
 * 
 * 
 * class ApproximateQuantiles(object):             # <<<<<<<<<<<<<<
 *   """
 *   PTransform for getting the idea of data distribution using approximate N-tile
 */
  __pyx_t_9 = __Pyx_Py3ClassCreate(__pyx_t_1, __pyx_n_s_ApproximateQuantiles, __pyx_tuple__47, __pyx_t_7, NULL, 0, 0); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 284, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_ApproximateQuantiles, __pyx_t_9) < 0) __PYX_ERR(0, 284, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "apache_beam/transforms/stats.py":457
 *       self.less_than = lambda a, b: key(a) < key(b)
 * 
 *   def get_argsort_key(self, elements):             # <<<<<<<<<<<<<<
 *     # type: (List) -> Callable[[int], Any]
 * 
 */
  __pyx_t_1 = __Pyx_CyFunction_New(&__pyx_mdef_11apache_beam_10transforms_5stats_13_QuantileSpec_3get_argsort_key, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_QuantileSpec_get_argsort_key, NULL, __pyx_n_s_apache_beam_transforms_stats, __pyx_d, ((PyObject *)__pyx_codeobj__65)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 457, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem((PyObject *)__pyx_ptype_11apache_beam_10transforms_5stats__QuantileSpec->tp_dict, __pyx_n_s_get_argsort_key, __pyx_t_1) < 0) __PYX_ERR(0, 457, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  PyType_Modified(__pyx_ptype_11apache_beam_10transforms_5stats__QuantileSpec);

  /* "apache_beam/transforms/stats.py":466
 *       return lambda idx: self.key(elements[idx])
 * 
 *   def __reduce__(self):             # <<<<<<<<<<<<<<
 *     return (
 *         self.__class__,
 */
  __pyx_t_1 = __Pyx_CyFunction_New(&__pyx_mdef_11apache_beam_10transforms_5stats_13_QuantileSpec_5__reduce__, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_QuantileSpec___reduce, NULL, __pyx_n_s_apache_beam_transforms_stats, __pyx_d, ((PyObject *)__pyx_codeobj__67)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 466, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem((PyObject *)__pyx_ptype_11apache_beam_10transforms_5stats__QuantileSpec->tp_dict, __pyx_n_s_reduce, __pyx_t_1) < 0) __PYX_ERR(0, 466, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  PyType_Modified(__pyx_ptype_11apache_beam_10transforms_5stats__QuantileSpec);

  /* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     cdef tuple state
 *     cdef object _dict
 */
  __pyx_t_1 = __Pyx_CyFunction_New(&__pyx_mdef_11apache_beam_10transforms_5stats_15_QuantileBuffer_7__reduce_cython__, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_QuantileBuffer___reduce_cython, NULL, __pyx_n_s_apache_beam_transforms_stats, __pyx_d, ((PyObject *)__pyx_codeobj__69)); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem((PyObject *)__pyx_ptype_11apache_beam_10transforms_5stats__QuantileBuffer->tp_dict, __pyx_n_s_reduce_cython, __pyx_t_1) < 0) __PYX_ERR(2, 1, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  PyType_Modified(__pyx_ptype_11apache_beam_10transforms_5stats__QuantileBuffer);

  /* "(tree fragment)":16
 *     else:
 *         return __pyx_unpickle__QuantileBuffer, (type(self), 0x9fb38c7, state)
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_unpickle__QuantileBuffer__set_state(self, __pyx_state)
 */
  __pyx_t_1 = __Pyx_CyFunction_New(&__pyx_mdef_11apache_beam_10transforms_5stats_15_QuantileBuffer_9__setstate_cython__, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_QuantileBuffer___setstate_cytho, NULL, __pyx_n_s_apache_beam_transforms_stats, __pyx_d, ((PyObject *)__pyx_codeobj__71)); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 16, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem((PyObject *)__pyx_ptype_11apache_beam_10transforms_5stats__QuantileBuffer->tp_dict, __pyx_n_s_setstate_cython, __pyx_t_1) < 0) __PYX_ERR(2, 16, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  PyType_Modified(__pyx_ptype_11apache_beam_10transforms_5stats__QuantileBuffer);

  /* "apache_beam/transforms/stats.py":533
 * 
 *   # This is needed for pickling to work when Cythonization is enabled.
 *   def __reduce__(self):             # <<<<<<<<<<<<<<
 *     return (
 *         self.__class__,
 */
  __pyx_t_1 = __Pyx_CyFunction_New(&__pyx_mdef_11apache_beam_10transforms_5stats_14_QuantileState_3__reduce__, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_QuantileState___reduce, NULL, __pyx_n_s_apache_beam_transforms_stats, __pyx_d, ((PyObject *)__pyx_codeobj__73)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 533, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem((PyObject *)__pyx_ptype_11apache_beam_10transforms_5stats__QuantileState->tp_dict, __pyx_n_s_reduce, __pyx_t_1) < 0) __PYX_ERR(0, 533, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  PyType_Modified(__pyx_ptype_11apache_beam_10transforms_5stats__QuantileState);

  /* "apache_beam/transforms/stats.py":542
 *             self.spec))
 * 
 *   def is_empty(self):             # <<<<<<<<<<<<<<
 *     # type: () -> bool
 * 
 */
  __pyx_t_1 = __Pyx_CyFunction_New(&__pyx_mdef_11apache_beam_10transforms_5stats_14_QuantileState_5is_empty, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_QuantileState_is_empty, NULL, __pyx_n_s_apache_beam_transforms_stats, __pyx_d, ((PyObject *)__pyx_codeobj__75)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 542, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem((PyObject *)__pyx_ptype_11apache_beam_10transforms_5stats__QuantileState->tp_dict, __pyx_n_s_is_empty, __pyx_t_1) < 0) __PYX_ERR(0, 542, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  PyType_Modified(__pyx_ptype_11apache_beam_10transforms_5stats__QuantileState);

  /* "apache_beam/transforms/stats.py":548
 *     return not self.unbuffered_elements and not self.buffers
 * 
 *   def _add_unbuffered(self, elements, offset_fn):             # <<<<<<<<<<<<<<
 *     # type: (List, Any) -> None
 * 
 */
  __pyx_t_1 = __Pyx_CyFunction_New(&__pyx_mdef_11apache_beam_10transforms_5stats_14_QuantileState_7_add_unbuffered, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_QuantileState__add_unbuffered, NULL, __pyx_n_s_apache_beam_transforms_stats, __pyx_d, ((PyObject *)__pyx_codeobj__77)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 548, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem((PyObject *)__pyx_ptype_11apache_beam_10transforms_5stats__QuantileState->tp_dict, __pyx_n_s_add_unbuffered, __pyx_t_1) < 0) __PYX_ERR(0, 548, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  PyType_Modified(__pyx_ptype_11apache_beam_10transforms_5stats__QuantileState);

  /* "apache_beam/transforms/stats.py":574
 *     self.collapse_if_needed(offset_fn)
 * 
 *   def _add_unbuffered_weighted(self, elements, offset_fn):             # <<<<<<<<<<<<<<
 *     # type: (List, Any) -> None
 * 
 */
  __pyx_t_1 = __Pyx_CyFunction_New(&__pyx_mdef_11apache_beam_10transforms_5stats_14_QuantileState_9_add_unbuffered_weighted, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_QuantileState__add_unbuffered_w, NULL, __pyx_n_s_apache_beam_transforms_stats, __pyx_d, ((PyObject *)__pyx_codeobj__79)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 574, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem((PyObject *)__pyx_ptype_11apache_beam_10transforms_5stats__QuantileState->tp_dict, __pyx_n_s_add_unbuffered_weighted, __pyx_t_1) < 0) __PYX_ERR(0, 574, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  PyType_Modified(__pyx_ptype_11apache_beam_10transforms_5stats__QuantileState);

  /* "apache_beam/transforms/stats.py":612
 *     self.collapse_if_needed(offset_fn)
 * 
 *   def finalize(self):             # <<<<<<<<<<<<<<
 *     # type: () -> None
 * 
 */
  __pyx_t_1 = __Pyx_CyFunction_New(&__pyx_mdef_11apache_beam_10transforms_5stats_14_QuantileState_11finalize, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_QuantileState_finalize, NULL, __pyx_n_s_apache_beam_transforms_stats, __pyx_d, ((PyObject *)__pyx_codeobj__81)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 612, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem((PyObject *)__pyx_ptype_11apache_beam_10transforms_5stats__QuantileState->tp_dict, __pyx_n_s_finalize, __pyx_t_1) < 0) __PYX_ERR(0, 612, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  PyType_Modified(__pyx_ptype_11apache_beam_10transforms_5stats__QuantileState);

  /* "apache_beam/transforms/stats.py":644
 *     self.unbuffered_elements = []
 * 
 *   def collapse_if_needed(self, offset_fn):             # <<<<<<<<<<<<<<
 *     # type: (Any) -> None
 * 
 */
  __pyx_t_1 = __Pyx_CyFunction_New(&__pyx_mdef_11apache_beam_10transforms_5stats_14_QuantileState_13collapse_if_needed, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_QuantileState_collapse_if_neede, NULL, __pyx_n_s_apache_beam_transforms_stats, __pyx_d, ((PyObject *)__pyx_codeobj__83)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 644, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem((PyObject *)__pyx_ptype_11apache_beam_10transforms_5stats__QuantileState->tp_dict, __pyx_n_s_collapse_if_needed, __pyx_t_1) < 0) __PYX_ERR(0, 644, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  PyType_Modified(__pyx_ptype_11apache_beam_10transforms_5stats__QuantileState);

  /* "apache_beam/transforms/stats.py":760
 * 
 * 
 * class ApproximateQuantilesCombineFn(CombineFn):             # <<<<<<<<<<<<<<
 *   """
 *   This combiner gives an idea of the distribution of a collection of values
 */
  __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_CombineFn); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 760, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 760, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_1);
  __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_CalculateMetaclass(NULL, __pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 760, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_9 = __Pyx_Py3MetaclassPrepare(__pyx_t_1, __pyx_t_7, __pyx_n_s_ApproximateQuantilesCombineFn, __pyx_n_s_ApproximateQuantilesCombineFn, (PyObject *) NULL, __pyx_n_s_apache_beam_transforms_stats, __pyx_kp_s_This_combiner_gives_an_idea_of); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 760, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);

  /* "apache_beam/transforms/stats.py":810
 *   # For alternating between biasing up and down in the above even weight
 *   # collapse operation.
 *   _offset_jitter = 0             # <<<<<<<<<<<<<<
 * 
 *   # The cost (in time and space) to compute quantiles to a given accuracy is a
 */
  if (__Pyx_SetNameInClass(__pyx_t_9, __pyx_n_s_offset_jitter, __pyx_int_0) < 0) __PYX_ERR(0, 810, __pyx_L1_error)

  /* "apache_beam/transforms/stats.py":818
 *   # non-optimal. The impact is logarithmic with respect to this value, so this
 *   # default should be fine for most uses.
 *   _MAX_NUM_ELEMENTS = 1e9             # <<<<<<<<<<<<<<
 *   _qs = None  # type: _QuantileState
 * 
 */
  if (__Pyx_SetNameInClass(__pyx_t_9, __pyx_n_s_MAX_NUM_ELEMENTS, __pyx_float_1e9) < 0) __PYX_ERR(0, 818, __pyx_L1_error)

  /* "apache_beam/transforms/stats.py":819
 *   # default should be fine for most uses.
 *   _MAX_NUM_ELEMENTS = 1e9
 *   _qs = None  # type: _QuantileState             # <<<<<<<<<<<<<<
 * 
 *   def __init__(
 */
  if (__Pyx_SetNameInClass(__pyx_t_9, __pyx_n_s_qs, Py_None) < 0) __PYX_ERR(0, 819, __pyx_L1_error)

  /* "apache_beam/transforms/stats.py":821
 *   _qs = None  # type: _QuantileState
 * 
 *   def __init__(             # <<<<<<<<<<<<<<
 *       self,
 *       num_quantiles,  # type: int
 */
  __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_11apache_beam_10transforms_5stats_29ApproximateQuantilesCombineFn_1__init__, 0, __pyx_n_s_ApproximateQuantilesCombineFn_2, NULL, __pyx_n_s_apache_beam_transforms_stats, __pyx_d, ((PyObject *)__pyx_codeobj__85)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 821, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_2, __pyx_tuple__86);
  if (__Pyx_SetNameInClass(__pyx_t_9, __pyx_n_s_init, __pyx_t_2) < 0) __PYX_ERR(0, 821, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "apache_beam/transforms/stats.py":836
 *       setattr(self, 'add_input', self._add_inputs)
 * 
 *   def __reduce__(self):             # <<<<<<<<<<<<<<
 *     return (
 *         self.__class__,
 */
  __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_11apache_beam_10transforms_5stats_29ApproximateQuantilesCombineFn_3__reduce__, 0, __pyx_n_s_ApproximateQuantilesCombineFn_3, NULL, __pyx_n_s_apache_beam_transforms_stats, __pyx_d, ((PyObject *)__pyx_codeobj__88)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 836, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (__Pyx_SetNameInClass(__pyx_t_9, __pyx_n_s_reduce, __pyx_t_2) < 0) __PYX_ERR(0, 836, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "apache_beam/transforms/stats.py":849
 * 
 *   @classmethod
 *   def create(             # <<<<<<<<<<<<<<
 *       cls,
 *       num_quantiles,  # type: int
 */
  __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_11apache_beam_10transforms_5stats_29ApproximateQuantilesCombineFn_5create, __Pyx_CYFUNCTION_CLASSMETHOD, __pyx_n_s_ApproximateQuantilesCombineFn_cr, NULL, __pyx_n_s_apache_beam_transforms_stats, __pyx_d, ((PyObject *)__pyx_codeobj__90)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 849, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_2, __pyx_tuple__91);

  /* "apache_beam/transforms/stats.py":848
 *             self._input_batched))
 * 
 *   @classmethod             # <<<<<<<<<<<<<<
 *   def create(
 *       cls,
 */
  __pyx_t_8 = __Pyx_Method_ClassMethod(__pyx_t_2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 848, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (__Pyx_SetNameInClass(__pyx_t_9, __pyx_n_s_create, __pyx_t_8) < 0) __PYX_ERR(0, 849, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

  /* "apache_beam/transforms/stats.py":909
 *         input_batched=input_batched)
 * 
 *   def _offset(self, new_weight):             # <<<<<<<<<<<<<<
 *     # type: (int) -> float
 * 
 */
  __pyx_t_8 = __Pyx_CyFunction_New(&__pyx_mdef_11apache_beam_10transforms_5stats_29ApproximateQuantilesCombineFn_7_offset, 0, __pyx_n_s_ApproximateQuantilesCombineFn__o, NULL, __pyx_n_s_apache_beam_transforms_stats, __pyx_d, ((PyObject *)__pyx_codeobj__93)); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 909, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  if (__Pyx_SetNameInClass(__pyx_t_9, __pyx_n_s_offset, __pyx_t_8) < 0) __PYX_ERR(0, 909, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

  /* "apache_beam/transforms/stats.py":924
 *   # TODO(https://github.com/apache/beam/issues/19737): Signature incompatible
 *   # with supertype
 *   def create_accumulator(self):  # type: ignore[override]             # <<<<<<<<<<<<<<
 *     # type: () -> _QuantileState
 *     self._qs = _QuantileState(
 */
  __pyx_t_8 = __Pyx_CyFunction_New(&__pyx_mdef_11apache_beam_10transforms_5stats_29ApproximateQuantilesCombineFn_9create_accumulator, 0, __pyx_n_s_ApproximateQuantilesCombineFn_cr_2, NULL, __pyx_n_s_apache_beam_transforms_stats, __pyx_d, ((PyObject *)__pyx_codeobj__95)); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 924, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  if (__Pyx_SetNameInClass(__pyx_t_9, __pyx_n_s_create_accumulator, __pyx_t_8) < 0) __PYX_ERR(0, 924, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

  /* "apache_beam/transforms/stats.py":933
 *     return self._qs
 * 
 *   def add_input(self, quantile_state, element):             # <<<<<<<<<<<<<<
 *     """
 *     Add a new element to the collection being summarized by quantile state.
 */
  __pyx_t_8 = __Pyx_CyFunction_New(&__pyx_mdef_11apache_beam_10transforms_5stats_29ApproximateQuantilesCombineFn_11add_input, 0, __pyx_n_s_ApproximateQuantilesCombineFn_ad, NULL, __pyx_n_s_apache_beam_transforms_stats, __pyx_d, ((PyObject *)__pyx_codeobj__97)); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 933, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  if (__Pyx_SetNameInClass(__pyx_t_9, __pyx_n_s_add_input, __pyx_t_8) < 0) __PYX_ERR(0, 933, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

  /* "apache_beam/transforms/stats.py":940
 *     return quantile_state
 * 
 *   def _add_inputs(self, quantile_state, elements):             # <<<<<<<<<<<<<<
 *     # type: (_QuantileState, List) -> _QuantileState
 * 
 */
  __pyx_t_8 = __Pyx_CyFunction_New(&__pyx_mdef_11apache_beam_10transforms_5stats_29ApproximateQuantilesCombineFn_13_add_inputs, 0, __pyx_n_s_ApproximateQuantilesCombineFn__a, NULL, __pyx_n_s_apache_beam_transforms_stats, __pyx_d, ((PyObject *)__pyx_codeobj__99)); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 940, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  if (__Pyx_SetNameInClass(__pyx_t_9, __pyx_n_s_add_inputs, __pyx_t_8) < 0) __PYX_ERR(0, 940, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

  /* "apache_beam/transforms/stats.py":952
 *     return quantile_state
 * 
 *   def merge_accumulators(self, accumulators):             # <<<<<<<<<<<<<<
 *     """Merges all the accumulators (quantile state) as one."""
 *     qs = self.create_accumulator()
 */
  __pyx_t_8 = __Pyx_CyFunction_New(&__pyx_mdef_11apache_beam_10transforms_5stats_29ApproximateQuantilesCombineFn_15merge_accumulators, 0, __pyx_n_s_ApproximateQuantilesCombineFn_me, NULL, __pyx_n_s_apache_beam_transforms_stats, __pyx_d, ((PyObject *)__pyx_codeobj__101)); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 952, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  if (__Pyx_SetNameInClass(__pyx_t_9, __pyx_n_s_merge_accumulators, __pyx_t_8) < 0) __PYX_ERR(0, 952, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

  /* "apache_beam/transforms/stats.py":970
 *     return qs
 * 
 *   def extract_output(self, accumulator):             # <<<<<<<<<<<<<<
 *     """
 *     Outputs num_quantiles elements consisting of the minimum, maximum and
 */
  __pyx_t_8 = __Pyx_CyFunction_New(&__pyx_mdef_11apache_beam_10transforms_5stats_29ApproximateQuantilesCombineFn_17extract_output, 0, __pyx_n_s_ApproximateQuantilesCombineFn_ex, NULL, __pyx_n_s_apache_beam_transforms_stats, __pyx_d, ((PyObject *)__pyx_codeobj__104)); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 970, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  if (__Pyx_SetNameInClass(__pyx_t_9, __pyx_n_s_extract_output, __pyx_t_8) < 0) __PYX_ERR(0, 970, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

  /* "apache_beam/transforms/stats.py":760
 * 
 * 
 * class ApproximateQuantilesCombineFn(CombineFn):             # <<<<<<<<<<<<<<
 *   """
 *   This combiner gives an idea of the distribution of a collection of values
 */
  __pyx_t_8 = __Pyx_Py3ClassCreate(__pyx_t_1, __pyx_n_s_ApproximateQuantilesCombineFn, __pyx_t_7, __pyx_t_9, NULL, 0, 0); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 760, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_ApproximateQuantilesCombineFn, __pyx_t_8) < 0) __PYX_ERR(0, 760, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "(tree fragment)":1
 * def __pyx_unpickle__QuantileBuffer(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 */
  __pyx_t_7 = __Pyx_CyFunction_New(&__pyx_mdef_11apache_beam_10transforms_5stats_7__pyx_unpickle__QuantileBuffer, 0, __pyx_n_s_pyx_unpickle__QuantileBuffer, NULL, __pyx_n_s_apache_beam_transforms_stats, __pyx_d, ((PyObject *)__pyx_codeobj__106)); if (unlikely(!__pyx_t_7)) __PYX_ERR(2, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_pyx_unpickle__QuantileBuffer, __pyx_t_7) < 0) __PYX_ERR(2, 1, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "apache_beam/transforms/stats.py":1
 * #             # <<<<<<<<<<<<<<
 * # Licensed to the Apache Software Foundation (ASF) under one or more
 * # contributor license agreements.  See the NOTICE file distributed with
 */
  __pyx_t_7 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_7) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /*--- Wrapped vars code ---*/

  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_XDECREF(__pyx_t_13);
  __Pyx_XDECREF(__pyx_t_14);
  __Pyx_XDECREF(__pyx_t_15);
  __Pyx_XDECREF(__pyx_t_16);
  __Pyx_XDECREF(__pyx_t_17);
  __Pyx_XDECREF(__pyx_t_18);
  __Pyx_XDECREF(__pyx_t_19);
  if (__pyx_m) {
    if (__pyx_d) {
      __Pyx_AddTraceback("init apache_beam.transforms.stats", __pyx_clineno, __pyx_lineno, __pyx_filename);
    }
    Py_CLEAR(__pyx_m);
  } else if (!PyErr_Occurred()) {
    PyErr_SetString(PyExc_ImportError, "init apache_beam.transforms.stats");
  }
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  #if CYTHON_PEP489_MULTI_PHASE_INIT
  return (__pyx_m != NULL) ? 0 : -1;
  #elif PY_MAJOR_VERSION >= 3
  return __pyx_m;
  #else
  return;
  #endif
}

/* --- Runtime support code --- */
/* Refnanny */
#if CYTHON_REFNANNY
static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) {
    PyObject *m = NULL, *p = NULL;
    void *r = NULL;
    m = PyImport_ImportModule(modname);
    if (!m) goto end;
    p = PyObject_GetAttrString(m, "RefNannyAPI");
    if (!p) goto end;
    r = PyLong_AsVoidPtr(p);
end:
    Py_XDECREF(p);
    Py_XDECREF(m);
    return (__Pyx_RefNannyAPIStruct *)r;
}
#endif

/* PyObjectGetAttrStr */
#if CYTHON_USE_TYPE_SLOTS
static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name) {
    PyTypeObject* tp = Py_TYPE(obj);
    if (likely(tp->tp_getattro))
        return tp->tp_getattro(obj, attr_name);
#if PY_MAJOR_VERSION < 3
    if (likely(tp->tp_getattr))
        return tp->tp_getattr(obj, PyString_AS_STRING(attr_name));
#endif
    return PyObject_GetAttr(obj, attr_name);
}
#endif

/* GetBuiltinName */
static PyObject *__Pyx_GetBuiltinName(PyObject *name) {
    PyObject* result = __Pyx_PyObject_GetAttrStr(__pyx_b, name);
    if (unlikely(!result)) {
        PyErr_Format(PyExc_NameError,
#if PY_MAJOR_VERSION >= 3
            "name '%U' is not defined", name);
#else
            "name '%.200s' is not defined", PyString_AS_STRING(name));
#endif
    }
    return result;
}

/* PyDictVersioning */
#if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_TYPE_SLOTS
static CYTHON_INLINE PY_UINT64_T __Pyx_get_tp_dict_version(PyObject *obj) {
    PyObject *dict = Py_TYPE(obj)->tp_dict;
    return likely(dict) ? __PYX_GET_DICT_VERSION(dict) : 0;
}
static CYTHON_INLINE PY_UINT64_T __Pyx_get_object_dict_version(PyObject *obj) {
    PyObject **dictptr = NULL;
    Py_ssize_t offset = Py_TYPE(obj)->tp_dictoffset;
    if (offset) {
#if CYTHON_COMPILING_IN_CPYTHON
        dictptr = (likely(offset > 0)) ? (PyObject **) ((char *)obj + offset) : _PyObject_GetDictPtr(obj);
#else
        dictptr = _PyObject_GetDictPtr(obj);
#endif
    }
    return (dictptr && *dictptr) ? __PYX_GET_DICT_VERSION(*dictptr) : 0;
}
static CYTHON_INLINE int __Pyx_object_dict_version_matches(PyObject* obj, PY_UINT64_T tp_dict_version, PY_UINT64_T obj_dict_version) {
    PyObject *dict = Py_TYPE(obj)->tp_dict;
    if (unlikely(!dict) || unlikely(tp_dict_version != __PYX_GET_DICT_VERSION(dict)))
        return 0;
    return obj_dict_version == __Pyx_get_object_dict_version(obj);
}
#endif

/* GetModuleGlobalName */
#if CYTHON_USE_DICT_VERSIONS
static PyObject *__Pyx__GetModuleGlobalName(PyObject *name, PY_UINT64_T *dict_version, PyObject **dict_cached_value)
#else
static CYTHON_INLINE PyObject *__Pyx__GetModuleGlobalName(PyObject *name)
#endif
{
    PyObject *result;
#if !CYTHON_AVOID_BORROWED_REFS
#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1
    result = _PyDict_GetItem_KnownHash(__pyx_d, name, ((PyASCIIObject *) name)->hash);
    __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version)
    if (likely(result)) {
        return __Pyx_NewRef(result);
    } else if (unlikely(PyErr_Occurred())) {
        return NULL;
    }
#else
    result = PyDict_GetItem(__pyx_d, name);
    __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version)
    if (likely(result)) {
        return __Pyx_NewRef(result);
    }
#endif
#else
    result = PyObject_GetItem(__pyx_d, name);
    __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version)
    if (likely(result)) {
        return __Pyx_NewRef(result);
    }
    PyErr_Clear();
#endif
    return __Pyx_GetBuiltinName(name);
}

/* PyObjectCall */
#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw) {
    PyObject *result;
    ternaryfunc call = Py_TYPE(func)->tp_call;
    if (unlikely(!call))
        return PyObject_Call(func, arg, kw);
    if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
        return NULL;
    result = (*call)(func, arg, kw);
    Py_LeaveRecursiveCall();
    if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
        PyErr_SetString(
            PyExc_SystemError,
            "NULL result without error in PyObject_Call");
    }
    return result;
}
#endif

/* GetItemInt */
static PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j) {
    PyObject *r;
    if (!j) return NULL;
    r = PyObject_GetItem(o, j);
    Py_DECREF(j);
    return r;
}
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i,
                                                              CYTHON_NCP_UNUSED int wraparound,
                                                              CYTHON_NCP_UNUSED int boundscheck) {
#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    Py_ssize_t wrapped_i = i;
    if (wraparound & unlikely(i < 0)) {
        wrapped_i += PyList_GET_SIZE(o);
    }
    if ((!boundscheck) || likely(__Pyx_is_valid_index(wrapped_i, PyList_GET_SIZE(o)))) {
        PyObject *r = PyList_GET_ITEM(o, wrapped_i);
        Py_INCREF(r);
        return r;
    }
    return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
#else
    return PySequence_GetItem(o, i);
#endif
}
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i,
                                                              CYTHON_NCP_UNUSED int wraparound,
                                                              CYTHON_NCP_UNUSED int boundscheck) {
#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    Py_ssize_t wrapped_i = i;
    if (wraparound & unlikely(i < 0)) {
        wrapped_i += PyTuple_GET_SIZE(o);
    }
    if ((!boundscheck) || likely(__Pyx_is_valid_index(wrapped_i, PyTuple_GET_SIZE(o)))) {
        PyObject *r = PyTuple_GET_ITEM(o, wrapped_i);
        Py_INCREF(r);
        return r;
    }
    return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
#else
    return PySequence_GetItem(o, i);
#endif
}
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i, int is_list,
                                                     CYTHON_NCP_UNUSED int wraparound,
                                                     CYTHON_NCP_UNUSED int boundscheck) {
#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS && CYTHON_USE_TYPE_SLOTS
    if (is_list || PyList_CheckExact(o)) {
        Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyList_GET_SIZE(o);
        if ((!boundscheck) || (likely(__Pyx_is_valid_index(n, PyList_GET_SIZE(o))))) {
            PyObject *r = PyList_GET_ITEM(o, n);
            Py_INCREF(r);
            return r;
        }
    }
    else if (PyTuple_CheckExact(o)) {
        Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyTuple_GET_SIZE(o);
        if ((!boundscheck) || likely(__Pyx_is_valid_index(n, PyTuple_GET_SIZE(o)))) {
            PyObject *r = PyTuple_GET_ITEM(o, n);
            Py_INCREF(r);
            return r;
        }
    } else {
        PySequenceMethods *m = Py_TYPE(o)->tp_as_sequence;
        if (likely(m && m->sq_item)) {
            if (wraparound && unlikely(i < 0) && likely(m->sq_length)) {
                Py_ssize_t l = m->sq_length(o);
                if (likely(l >= 0)) {
                    i += l;
                } else {
                    if (!PyErr_ExceptionMatches(PyExc_OverflowError))
                        return NULL;
                    PyErr_Clear();
                }
            }
            return m->sq_item(o, i);
        }
    }
#else
    if (is_list || PySequence_Check(o)) {
        return PySequence_GetItem(o, i);
    }
#endif
    return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
}

/* PyCFunctionFastCall */
#if CYTHON_FAST_PYCCALL
static CYTHON_INLINE PyObject * __Pyx_PyCFunction_FastCall(PyObject *func_obj, PyObject **args, Py_ssize_t nargs) {
    PyCFunctionObject *func = (PyCFunctionObject*)func_obj;
    PyCFunction meth = PyCFunction_GET_FUNCTION(func);
    PyObject *self = PyCFunction_GET_SELF(func);
    int flags = PyCFunction_GET_FLAGS(func);
    assert(PyCFunction_Check(func));
    assert(METH_FASTCALL == (flags & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS | METH_STACKLESS)));
    assert(nargs >= 0);
    assert(nargs == 0 || args != NULL);
    /* _PyCFunction_FastCallDict() must not be called with an exception set,
       because it may clear it (directly or indirectly) and so the
       caller loses its exception */
    assert(!PyErr_Occurred());
    if ((PY_VERSION_HEX < 0x030700A0) || unlikely(flags & METH_KEYWORDS)) {
        return (*((__Pyx_PyCFunctionFastWithKeywords)(void*)meth)) (self, args, nargs, NULL);
    } else {
        return (*((__Pyx_PyCFunctionFast)(void*)meth)) (self, args, nargs);
    }
}
#endif

/* PyFunctionFastCall */
#if CYTHON_FAST_PYCALL
static PyObject* __Pyx_PyFunction_FastCallNoKw(PyCodeObject *co, PyObject **args, Py_ssize_t na,
                                               PyObject *globals) {
    PyFrameObject *f;
    PyThreadState *tstate = __Pyx_PyThreadState_Current;
    PyObject **fastlocals;
    Py_ssize_t i;
    PyObject *result;
    assert(globals != NULL);
    /* XXX Perhaps we should create a specialized
       PyFrame_New() that doesn't take locals, but does
       take builtins without sanity checking them.
       */
    assert(tstate != NULL);
    f = PyFrame_New(tstate, co, globals, NULL);
    if (f == NULL) {
        return NULL;
    }
    fastlocals = __Pyx_PyFrame_GetLocalsplus(f);
    for (i = 0; i < na; i++) {
        Py_INCREF(*args);
        fastlocals[i] = *args++;
    }
    result = PyEval_EvalFrameEx(f,0);
    ++tstate->recursion_depth;
    Py_DECREF(f);
    --tstate->recursion_depth;
    return result;
}
#if 1 || PY_VERSION_HEX < 0x030600B1
static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, Py_ssize_t nargs, PyObject *kwargs) {
    PyCodeObject *co = (PyCodeObject *)PyFunction_GET_CODE(func);
    PyObject *globals = PyFunction_GET_GLOBALS(func);
    PyObject *argdefs = PyFunction_GET_DEFAULTS(func);
    PyObject *closure;
#if PY_MAJOR_VERSION >= 3
    PyObject *kwdefs;
#endif
    PyObject *kwtuple, **k;
    PyObject **d;
    Py_ssize_t nd;
    Py_ssize_t nk;
    PyObject *result;
    assert(kwargs == NULL || PyDict_Check(kwargs));
    nk = kwargs ? PyDict_Size(kwargs) : 0;
    if (Py_EnterRecursiveCall((char*)" while calling a Python object")) {
        return NULL;
    }
    if (
#if PY_MAJOR_VERSION >= 3
            co->co_kwonlyargcount == 0 &&
#endif
            likely(kwargs == NULL || nk == 0) &&
            co->co_flags == (CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE)) {
        if (argdefs == NULL && co->co_argcount == nargs) {
            result = __Pyx_PyFunction_FastCallNoKw(co, args, nargs, globals);
            goto done;
        }
        else if (nargs == 0 && argdefs != NULL
                 && co->co_argcount == Py_SIZE(argdefs)) {
            /* function called with no arguments, but all parameters have
               a default value: use default values as arguments .*/
            args = &PyTuple_GET_ITEM(argdefs, 0);
            result =__Pyx_PyFunction_FastCallNoKw(co, args, Py_SIZE(argdefs), globals);
            goto done;
        }
    }
    if (kwargs != NULL) {
        Py_ssize_t pos, i;
        kwtuple = PyTuple_New(2 * nk);
        if (kwtuple == NULL) {
            result = NULL;
            goto done;
        }
        k = &PyTuple_GET_ITEM(kwtuple, 0);
        pos = i = 0;
        while (PyDict_Next(kwargs, &pos, &k[i], &k[i+1])) {
            Py_INCREF(k[i]);
            Py_INCREF(k[i+1]);
            i += 2;
        }
        nk = i / 2;
    }
    else {
        kwtuple = NULL;
        k = NULL;
    }
    closure = PyFunction_GET_CLOSURE(func);
#if PY_MAJOR_VERSION >= 3
    kwdefs = PyFunction_GET_KW_DEFAULTS(func);
#endif
    if (argdefs != NULL) {
        d = &PyTuple_GET_ITEM(argdefs, 0);
        nd = Py_SIZE(argdefs);
    }
    else {
        d = NULL;
        nd = 0;
    }
#if PY_MAJOR_VERSION >= 3
    result = PyEval_EvalCodeEx((PyObject*)co, globals, (PyObject *)NULL,
                               args, (int)nargs,
                               k, (int)nk,
                               d, (int)nd, kwdefs, closure);
#else
    result = PyEval_EvalCodeEx(co, globals, (PyObject *)NULL,
                               args, (int)nargs,
                               k, (int)nk,
                               d, (int)nd, closure);
#endif
    Py_XDECREF(kwtuple);
done:
    Py_LeaveRecursiveCall();
    return result;
}
#endif
#endif

/* PyObjectCall2Args */
static CYTHON_UNUSED PyObject* __Pyx_PyObject_Call2Args(PyObject* function, PyObject* arg1, PyObject* arg2) {
    PyObject *args, *result = NULL;
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(function)) {
        PyObject *args[2] = {arg1, arg2};
        return __Pyx_PyFunction_FastCall(function, args, 2);
    }
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(function)) {
        PyObject *args[2] = {arg1, arg2};
        return __Pyx_PyCFunction_FastCall(function, args, 2);
    }
    #endif
    args = PyTuple_New(2);
    if (unlikely(!args)) goto done;
    Py_INCREF(arg1);
    PyTuple_SET_ITEM(args, 0, arg1);
    Py_INCREF(arg2);
    PyTuple_SET_ITEM(args, 1, arg2);
    Py_INCREF(function);
    result = __Pyx_PyObject_Call(function, args, NULL);
    Py_DECREF(args);
    Py_DECREF(function);
done:
    return result;
}

/* PyObjectCallMethO */
#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg) {
    PyObject *self, *result;
    PyCFunction cfunc;
    cfunc = PyCFunction_GET_FUNCTION(func);
    self = PyCFunction_GET_SELF(func);
    if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
        return NULL;
    result = cfunc(self, arg);
    Py_LeaveRecursiveCall();
    if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
        PyErr_SetString(
            PyExc_SystemError,
            "NULL result without error in PyObject_Call");
    }
    return result;
}
#endif

/* PyObjectCallOneArg */
#if CYTHON_COMPILING_IN_CPYTHON
static PyObject* __Pyx__PyObject_CallOneArg(PyObject *func, PyObject *arg) {
    PyObject *result;
    PyObject *args = PyTuple_New(1);
    if (unlikely(!args)) return NULL;
    Py_INCREF(arg);
    PyTuple_SET_ITEM(args, 0, arg);
    result = __Pyx_PyObject_Call(func, args, NULL);
    Py_DECREF(args);
    return result;
}
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
#if CYTHON_FAST_PYCALL
    if (PyFunction_Check(func)) {
        return __Pyx_PyFunction_FastCall(func, &arg, 1);
    }
#endif
    if (likely(PyCFunction_Check(func))) {
        if (likely(PyCFunction_GET_FLAGS(func) & METH_O)) {
            return __Pyx_PyObject_CallMethO(func, arg);
#if CYTHON_FAST_PYCCALL
        } else if (__Pyx_PyFastCFunction_Check(func)) {
            return __Pyx_PyCFunction_FastCall(func, &arg, 1);
#endif
        }
    }
    return __Pyx__PyObject_CallOneArg(func, arg);
}
#else
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
    PyObject *result;
    PyObject *args = PyTuple_Pack(1, arg);
    if (unlikely(!args)) return NULL;
    result = __Pyx_PyObject_Call(func, args, NULL);
    Py_DECREF(args);
    return result;
}
#endif

/* PyObjectCallNoArg */
#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func) {
#if CYTHON_FAST_PYCALL
    if (PyFunction_Check(func)) {
        return __Pyx_PyFunction_FastCall(func, NULL, 0);
    }
#endif
#if defined(__Pyx_CyFunction_USED) && defined(NDEBUG)
    if (likely(PyCFunction_Check(func) || __Pyx_CyFunction_Check(func)))
#else
    if (likely(PyCFunction_Check(func)))
#endif
    {
        if (likely(PyCFunction_GET_FLAGS(func) & METH_NOARGS)) {
            return __Pyx_PyObject_CallMethO(func, NULL);
        }
    }
    return __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL);
}
#endif

/* SliceObject */
static CYTHON_INLINE PyObject* __Pyx_PyObject_GetSlice(PyObject* obj,
        Py_ssize_t cstart, Py_ssize_t cstop,
        PyObject** _py_start, PyObject** _py_stop, PyObject** _py_slice,
        int has_cstart, int has_cstop, CYTHON_UNUSED int wraparound) {
#if CYTHON_USE_TYPE_SLOTS
    PyMappingMethods* mp;
#if PY_MAJOR_VERSION < 3
    PySequenceMethods* ms = Py_TYPE(obj)->tp_as_sequence;
    if (likely(ms && ms->sq_slice)) {
        if (!has_cstart) {
            if (_py_start && (*_py_start != Py_None)) {
                cstart = __Pyx_PyIndex_AsSsize_t(*_py_start);
                if ((cstart == (Py_ssize_t)-1) && PyErr_Occurred()) goto bad;
            } else
                cstart = 0;
        }
        if (!has_cstop) {
            if (_py_stop && (*_py_stop != Py_None)) {
                cstop = __Pyx_PyIndex_AsSsize_t(*_py_stop);
                if ((cstop == (Py_ssize_t)-1) && PyErr_Occurred()) goto bad;
            } else
                cstop = PY_SSIZE_T_MAX;
        }
        if (wraparound && unlikely((cstart < 0) | (cstop < 0)) && likely(ms->sq_length)) {
            Py_ssize_t l = ms->sq_length(obj);
            if (likely(l >= 0)) {
                if (cstop < 0) {
                    cstop += l;
                    if (cstop < 0) cstop = 0;
                }
                if (cstart < 0) {
                    cstart += l;
                    if (cstart < 0) cstart = 0;
                }
            } else {
                if (!PyErr_ExceptionMatches(PyExc_OverflowError))
                    goto bad;
                PyErr_Clear();
            }
        }
        return ms->sq_slice(obj, cstart, cstop);
    }
#endif
    mp = Py_TYPE(obj)->tp_as_mapping;
    if (likely(mp && mp->mp_subscript))
#endif
    {
        PyObject* result;
        PyObject *py_slice, *py_start, *py_stop;
        if (_py_slice) {
            py_slice = *_py_slice;
        } else {
            PyObject* owned_start = NULL;
            PyObject* owned_stop = NULL;
            if (_py_start) {
                py_start = *_py_start;
            } else {
                if (has_cstart) {
                    owned_start = py_start = PyInt_FromSsize_t(cstart);
                    if (unlikely(!py_start)) goto bad;
                } else
                    py_start = Py_None;
            }
            if (_py_stop) {
                py_stop = *_py_stop;
            } else {
                if (has_cstop) {
                    owned_stop = py_stop = PyInt_FromSsize_t(cstop);
                    if (unlikely(!py_stop)) {
                        Py_XDECREF(owned_start);
                        goto bad;
                    }
                } else
                    py_stop = Py_None;
            }
            py_slice = PySlice_New(py_start, py_stop, Py_None);
            Py_XDECREF(owned_start);
            Py_XDECREF(owned_stop);
            if (unlikely(!py_slice)) goto bad;
        }
#if CYTHON_USE_TYPE_SLOTS
        result = mp->mp_subscript(obj, py_slice);
#else
        result = PyObject_GetItem(obj, py_slice);
#endif
        if (!_py_slice) {
            Py_DECREF(py_slice);
        }
        return result;
    }
    PyErr_Format(PyExc_TypeError,
        "'%.200s' object is unsliceable", Py_TYPE(obj)->tp_name);
bad:
    return NULL;
}

/* BytesEquals */
static CYTHON_INLINE int __Pyx_PyBytes_Equals(PyObject* s1, PyObject* s2, int equals) {
#if CYTHON_COMPILING_IN_PYPY
    return PyObject_RichCompareBool(s1, s2, equals);
#else
    if (s1 == s2) {
        return (equals == Py_EQ);
    } else if (PyBytes_CheckExact(s1) & PyBytes_CheckExact(s2)) {
        const char *ps1, *ps2;
        Py_ssize_t length = PyBytes_GET_SIZE(s1);
        if (length != PyBytes_GET_SIZE(s2))
            return (equals == Py_NE);
        ps1 = PyBytes_AS_STRING(s1);
        ps2 = PyBytes_AS_STRING(s2);
        if (ps1[0] != ps2[0]) {
            return (equals == Py_NE);
        } else if (length == 1) {
            return (equals == Py_EQ);
        } else {
            int result;
#if CYTHON_USE_UNICODE_INTERNALS && (PY_VERSION_HEX < 0x030B0000)
            Py_hash_t hash1, hash2;
            hash1 = ((PyBytesObject*)s1)->ob_shash;
            hash2 = ((PyBytesObject*)s2)->ob_shash;
            if (hash1 != hash2 && hash1 != -1 && hash2 != -1) {
                return (equals == Py_NE);
            }
#endif
            result = memcmp(ps1, ps2, (size_t)length);
            return (equals == Py_EQ) ? (result == 0) : (result != 0);
        }
    } else if ((s1 == Py_None) & PyBytes_CheckExact(s2)) {
        return (equals == Py_NE);
    } else if ((s2 == Py_None) & PyBytes_CheckExact(s1)) {
        return (equals == Py_NE);
    } else {
        int result;
        PyObject* py_result = PyObject_RichCompare(s1, s2, equals);
        if (!py_result)
            return -1;
        result = __Pyx_PyObject_IsTrue(py_result);
        Py_DECREF(py_result);
        return result;
    }
#endif
}

/* UnicodeEquals */
static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int equals) {
#if CYTHON_COMPILING_IN_PYPY
    return PyObject_RichCompareBool(s1, s2, equals);
#else
#if PY_MAJOR_VERSION < 3
    PyObject* owned_ref = NULL;
#endif
    int s1_is_unicode, s2_is_unicode;
    if (s1 == s2) {
        goto return_eq;
    }
    s1_is_unicode = PyUnicode_CheckExact(s1);
    s2_is_unicode = PyUnicode_CheckExact(s2);
#if PY_MAJOR_VERSION < 3
    if ((s1_is_unicode & (!s2_is_unicode)) && PyString_CheckExact(s2)) {
        owned_ref = PyUnicode_FromObject(s2);
        if (unlikely(!owned_ref))
            return -1;
        s2 = owned_ref;
        s2_is_unicode = 1;
    } else if ((s2_is_unicode & (!s1_is_unicode)) && PyString_CheckExact(s1)) {
        owned_ref = PyUnicode_FromObject(s1);
        if (unlikely(!owned_ref))
            return -1;
        s1 = owned_ref;
        s1_is_unicode = 1;
    } else if (((!s2_is_unicode) & (!s1_is_unicode))) {
        return __Pyx_PyBytes_Equals(s1, s2, equals);
    }
#endif
    if (s1_is_unicode & s2_is_unicode) {
        Py_ssize_t length;
        int kind;
        void *data1, *data2;
        if (unlikely(__Pyx_PyUnicode_READY(s1) < 0) || unlikely(__Pyx_PyUnicode_READY(s2) < 0))
            return -1;
        length = __Pyx_PyUnicode_GET_LENGTH(s1);
        if (length != __Pyx_PyUnicode_GET_LENGTH(s2)) {
            goto return_ne;
        }
#if CYTHON_USE_UNICODE_INTERNALS
        {
            Py_hash_t hash1, hash2;
        #if CYTHON_PEP393_ENABLED
            hash1 = ((PyASCIIObject*)s1)->hash;
            hash2 = ((PyASCIIObject*)s2)->hash;
        #else
            hash1 = ((PyUnicodeObject*)s1)->hash;
            hash2 = ((PyUnicodeObject*)s2)->hash;
        #endif
            if (hash1 != hash2 && hash1 != -1 && hash2 != -1) {
                goto return_ne;
            }
        }
#endif
        kind = __Pyx_PyUnicode_KIND(s1);
        if (kind != __Pyx_PyUnicode_KIND(s2)) {
            goto return_ne;
        }
        data1 = __Pyx_PyUnicode_DATA(s1);
        data2 = __Pyx_PyUnicode_DATA(s2);
        if (__Pyx_PyUnicode_READ(kind, data1, 0) != __Pyx_PyUnicode_READ(kind, data2, 0)) {
            goto return_ne;
        } else if (length == 1) {
            goto return_eq;
        } else {
            int result = memcmp(data1, data2, (size_t)(length * kind));
            #if PY_MAJOR_VERSION < 3
            Py_XDECREF(owned_ref);
            #endif
            return (equals == Py_EQ) ? (result == 0) : (result != 0);
        }
    } else if ((s1 == Py_None) & s2_is_unicode) {
        goto return_ne;
    } else if ((s2 == Py_None) & s1_is_unicode) {
        goto return_ne;
    } else {
        int result;
        PyObject* py_result = PyObject_RichCompare(s1, s2, equals);
        #if PY_MAJOR_VERSION < 3
        Py_XDECREF(owned_ref);
        #endif
        if (!py_result)
            return -1;
        result = __Pyx_PyObject_IsTrue(py_result);
        Py_DECREF(py_result);
        return result;
    }
return_eq:
    #if PY_MAJOR_VERSION < 3
    Py_XDECREF(owned_ref);
    #endif
    return (equals == Py_EQ);
return_ne:
    #if PY_MAJOR_VERSION < 3
    Py_XDECREF(owned_ref);
    #endif
    return (equals == Py_NE);
#endif
}

/* RaiseDoubleKeywords */
static void __Pyx_RaiseDoubleKeywordsError(
    const char* func_name,
    PyObject* kw_name)
{
    PyErr_Format(PyExc_TypeError,
        #if PY_MAJOR_VERSION >= 3
        "%s() got multiple values for keyword argument '%U'", func_name, kw_name);
        #else
        "%s() got multiple values for keyword argument '%s'", func_name,
        PyString_AsString(kw_name));
        #endif
}

/* ParseKeywords */
static int __Pyx_ParseOptionalKeywords(
    PyObject *kwds,
    PyObject **argnames[],
    PyObject *kwds2,
    PyObject *values[],
    Py_ssize_t num_pos_args,
    const char* function_name)
{
    PyObject *key = 0, *value = 0;
    Py_ssize_t pos = 0;
    PyObject*** name;
    PyObject*** first_kw_arg = argnames + num_pos_args;
    while (PyDict_Next(kwds, &pos, &key, &value)) {
        name = first_kw_arg;
        while (*name && (**name != key)) name++;
        if (*name) {
            values[name-argnames] = value;
            continue;
        }
        name = first_kw_arg;
        #if PY_MAJOR_VERSION < 3
        if (likely(PyString_Check(key))) {
            while (*name) {
                if ((CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**name) == PyString_GET_SIZE(key))
                        && _PyString_Eq(**name, key)) {
                    values[name-argnames] = value;
                    break;
                }
                name++;
            }
            if (*name) continue;
            else {
                PyObject*** argname = argnames;
                while (argname != first_kw_arg) {
                    if ((**argname == key) || (
                            (CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**argname) == PyString_GET_SIZE(key))
                             && _PyString_Eq(**argname, key))) {
                        goto arg_passed_twice;
                    }
                    argname++;
                }
            }
        } else
        #endif
        if (likely(PyUnicode_Check(key))) {
            while (*name) {
                int cmp = (**name == key) ? 0 :
                #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
                    (__Pyx_PyUnicode_GET_LENGTH(**name) != __Pyx_PyUnicode_GET_LENGTH(key)) ? 1 :
                #endif
                    PyUnicode_Compare(**name, key);
                if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
                if (cmp == 0) {
                    values[name-argnames] = value;
                    break;
                }
                name++;
            }
            if (*name) continue;
            else {
                PyObject*** argname = argnames;
                while (argname != first_kw_arg) {
                    int cmp = (**argname == key) ? 0 :
                    #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
                        (__Pyx_PyUnicode_GET_LENGTH(**argname) != __Pyx_PyUnicode_GET_LENGTH(key)) ? 1 :
                    #endif
                        PyUnicode_Compare(**argname, key);
                    if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
                    if (cmp == 0) goto arg_passed_twice;
                    argname++;
                }
            }
        } else
            goto invalid_keyword_type;
        if (kwds2) {
            if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad;
        } else {
            goto invalid_keyword;
        }
    }
    return 0;
arg_passed_twice:
    __Pyx_RaiseDoubleKeywordsError(function_name, key);
    goto bad;
invalid_keyword_type:
    PyErr_Format(PyExc_TypeError,
        "%.200s() keywords must be strings", function_name);
    goto bad;
invalid_keyword:
    PyErr_Format(PyExc_TypeError,
    #if PY_MAJOR_VERSION < 3
        "%.200s() got an unexpected keyword argument '%.200s'",
        function_name, PyString_AsString(key));
    #else
        "%s() got an unexpected keyword argument '%U'",
        function_name, key);
    #endif
bad:
    return -1;
}

/* RaiseArgTupleInvalid */
static void __Pyx_RaiseArgtupleInvalid(
    const char* func_name,
    int exact,
    Py_ssize_t num_min,
    Py_ssize_t num_max,
    Py_ssize_t num_found)
{
    Py_ssize_t num_expected;
    const char *more_or_less;
    if (num_found < num_min) {
        num_expected = num_min;
        more_or_less = "at least";
    } else {
        num_expected = num_max;
        more_or_less = "at most";
    }
    if (exact) {
        more_or_less = "exactly";
    }
    PyErr_Format(PyExc_TypeError,
                 "%.200s() takes %.8s %" CYTHON_FORMAT_SSIZE_T "d positional argument%.1s (%" CYTHON_FORMAT_SSIZE_T "d given)",
                 func_name, more_or_less, num_expected,
                 (num_expected == 1) ? "" : "s", num_found);
}

/* PyErrFetchRestore */
#if CYTHON_FAST_THREAD_STATE
static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) {
    PyObject *tmp_type, *tmp_value, *tmp_tb;
    tmp_type = tstate->curexc_type;
    tmp_value = tstate->curexc_value;
    tmp_tb = tstate->curexc_traceback;
    tstate->curexc_type = type;
    tstate->curexc_value = value;
    tstate->curexc_traceback = tb;
    Py_XDECREF(tmp_type);
    Py_XDECREF(tmp_value);
    Py_XDECREF(tmp_tb);
}
static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
    *type = tstate->curexc_type;
    *value = tstate->curexc_value;
    *tb = tstate->curexc_traceback;
    tstate->curexc_type = 0;
    tstate->curexc_value = 0;
    tstate->curexc_traceback = 0;
}
#endif

/* RaiseException */
#if PY_MAJOR_VERSION < 3
static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb,
                        CYTHON_UNUSED PyObject *cause) {
    __Pyx_PyThreadState_declare
    Py_XINCREF(type);
    if (!value || value == Py_None)
        value = NULL;
    else
        Py_INCREF(value);
    if (!tb || tb == Py_None)
        tb = NULL;
    else {
        Py_INCREF(tb);
        if (!PyTraceBack_Check(tb)) {
            PyErr_SetString(PyExc_TypeError,
                "raise: arg 3 must be a traceback or None");
            goto raise_error;
        }
    }
    if (PyType_Check(type)) {
#if CYTHON_COMPILING_IN_PYPY
        if (!value) {
            Py_INCREF(Py_None);
            value = Py_None;
        }
#endif
        PyErr_NormalizeException(&type, &value, &tb);
    } else {
        if (value) {
            PyErr_SetString(PyExc_TypeError,
                "instance exception may not have a separate value");
            goto raise_error;
        }
        value = type;
        type = (PyObject*) Py_TYPE(type);
        Py_INCREF(type);
        if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) {
            PyErr_SetString(PyExc_TypeError,
                "raise: exception class must be a subclass of BaseException");
            goto raise_error;
        }
    }
    __Pyx_PyThreadState_assign
    __Pyx_ErrRestore(type, value, tb);
    return;
raise_error:
    Py_XDECREF(value);
    Py_XDECREF(type);
    Py_XDECREF(tb);
    return;
}
#else
static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause) {
    PyObject* owned_instance = NULL;
    if (tb == Py_None) {
        tb = 0;
    } else if (tb && !PyTraceBack_Check(tb)) {
        PyErr_SetString(PyExc_TypeError,
            "raise: arg 3 must be a traceback or None");
        goto bad;
    }
    if (value == Py_None)
        value = 0;
    if (PyExceptionInstance_Check(type)) {
        if (value) {
            PyErr_SetString(PyExc_TypeError,
                "instance exception may not have a separate value");
            goto bad;
        }
        value = type;
        type = (PyObject*) Py_TYPE(value);
    } else if (PyExceptionClass_Check(type)) {
        PyObject *instance_class = NULL;
        if (value && PyExceptionInstance_Check(value)) {
            instance_class = (PyObject*) Py_TYPE(value);
            if (instance_class != type) {
                int is_subclass = PyObject_IsSubclass(instance_class, type);
                if (!is_subclass) {
                    instance_class = NULL;
                } else if (unlikely(is_subclass == -1)) {
                    goto bad;
                } else {
                    type = instance_class;
                }
            }
        }
        if (!instance_class) {
            PyObject *args;
            if (!value)
                args = PyTuple_New(0);
            else if (PyTuple_Check(value)) {
                Py_INCREF(value);
                args = value;
            } else
                args = PyTuple_Pack(1, value);
            if (!args)
                goto bad;
            owned_instance = PyObject_Call(type, args, NULL);
            Py_DECREF(args);
            if (!owned_instance)
                goto bad;
            value = owned_instance;
            if (!PyExceptionInstance_Check(value)) {
                PyErr_Format(PyExc_TypeError,
                             "calling %R should have returned an instance of "
                             "BaseException, not %R",
                             type, Py_TYPE(value));
                goto bad;
            }
        }
    } else {
        PyErr_SetString(PyExc_TypeError,
            "raise: exception class must be a subclass of BaseException");
        goto bad;
    }
    if (cause) {
        PyObject *fixed_cause;
        if (cause == Py_None) {
            fixed_cause = NULL;
        } else if (PyExceptionClass_Check(cause)) {
            fixed_cause = PyObject_CallObject(cause, NULL);
            if (fixed_cause == NULL)
                goto bad;
        } else if (PyExceptionInstance_Check(cause)) {
            fixed_cause = cause;
            Py_INCREF(fixed_cause);
        } else {
            PyErr_SetString(PyExc_TypeError,
                            "exception causes must derive from "
                            "BaseException");
            goto bad;
        }
        PyException_SetCause(value, fixed_cause);
    }
    PyErr_SetObject(type, value);
    if (tb) {
#if CYTHON_FAST_THREAD_STATE
        PyThreadState *tstate = __Pyx_PyThreadState_Current;
        PyObject* tmp_tb = tstate->curexc_traceback;
        if (tb != tmp_tb) {
            Py_INCREF(tb);
            tstate->curexc_traceback = tb;
            Py_XDECREF(tmp_tb);
        }
#else
        PyObject *tmp_type, *tmp_value, *tmp_tb;
        PyErr_Fetch(&tmp_type, &tmp_value, &tmp_tb);
        Py_INCREF(tb);
        PyErr_Restore(tmp_type, tmp_value, tb);
        Py_XDECREF(tmp_tb);
#endif
    }
bad:
    Py_XDECREF(owned_instance);
    return;
}
#endif

/* PyFloatBinop */
#if !CYTHON_COMPILING_IN_PYPY
#define __Pyx_PyFloat_TrueDivideCObj_ZeroDivisionError(operand) if (unlikely(zerodivision_check && ((operand) == 0))) {\
    PyErr_SetString(PyExc_ZeroDivisionError, "float division by zero");\
    return NULL;\
}
static PyObject* __Pyx_PyFloat_TrueDivideCObj(PyObject *op1, PyObject *op2, double floatval, int inplace, int zerodivision_check) {
    const double a = floatval;
    double b, result;
    (void)inplace;
    (void)zerodivision_check;
    if (likely(PyFloat_CheckExact(op2))) {
        b = PyFloat_AS_DOUBLE(op2);
        __Pyx_PyFloat_TrueDivideCObj_ZeroDivisionError(b)
    } else
    #if PY_MAJOR_VERSION < 3
    if (likely(PyInt_CheckExact(op2))) {
        b = (double) PyInt_AS_LONG(op2);
        __Pyx_PyFloat_TrueDivideCObj_ZeroDivisionError(b)
    } else
    #endif
    if (likely(PyLong_CheckExact(op2))) {
        #if CYTHON_USE_PYLONG_INTERNALS
        const digit* digits = ((PyLongObject*)op2)->ob_digit;
        const Py_ssize_t size = Py_SIZE(op2);
        switch (size) {
            case  0: __Pyx_PyFloat_TrueDivideCObj_ZeroDivisionError(0) break;
            case -1: b = -(double) digits[0]; break;
            case  1: b = (double) digits[0]; break;
            case -2:
            case 2:
                if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT && ((8 * sizeof(unsigned long) < 53) || (1 * PyLong_SHIFT < 53))) {
                    b = (double) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                    if ((8 * sizeof(unsigned long) < 53) || (2 * PyLong_SHIFT < 53) || (b < (double) ((PY_LONG_LONG)1 << 53))) {
                        if (size == -2)
                            b = -b;
                        break;
                    }
                }
                CYTHON_FALLTHROUGH;
            case -3:
            case 3:
                if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT && ((8 * sizeof(unsigned long) < 53) || (2 * PyLong_SHIFT < 53))) {
                    b = (double) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                    if ((8 * sizeof(unsigned long) < 53) || (3 * PyLong_SHIFT < 53) || (b < (double) ((PY_LONG_LONG)1 << 53))) {
                        if (size == -3)
                            b = -b;
                        break;
                    }
                }
                CYTHON_FALLTHROUGH;
            case -4:
            case 4:
                if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT && ((8 * sizeof(unsigned long) < 53) || (3 * PyLong_SHIFT < 53))) {
                    b = (double) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                    if ((8 * sizeof(unsigned long) < 53) || (4 * PyLong_SHIFT < 53) || (b < (double) ((PY_LONG_LONG)1 << 53))) {
                        if (size == -4)
                            b = -b;
                        break;
                    }
                }
                CYTHON_FALLTHROUGH;
            default:
        #else
        {
        #endif
            b = PyLong_AsDouble(op2);
            if (unlikely(b == -1.0 && PyErr_Occurred())) return NULL;
            __Pyx_PyFloat_TrueDivideCObj_ZeroDivisionError(b)
        }
    } else {
        return (inplace ? PyNumber_InPlaceTrueDivide : PyNumber_TrueDivide)(op1, op2);
    }
        __Pyx_PyFloat_TrueDivideCObj_ZeroDivisionError(b)
        PyFPE_START_PROTECT("divide", return NULL)
        result = a / b;
        PyFPE_END_PROTECT(result)
        return PyFloat_FromDouble(result);
}
#endif

/* PyObjectSetAttrStr */
  #if CYTHON_USE_TYPE_SLOTS
static CYTHON_INLINE int __Pyx_PyObject_SetAttrStr(PyObject* obj, PyObject* attr_name, PyObject* value) {
    PyTypeObject* tp = Py_TYPE(obj);
    if (likely(tp->tp_setattro))
        return tp->tp_setattro(obj, attr_name, value);
#if PY_MAJOR_VERSION < 3
    if (likely(tp->tp_setattr))
        return tp->tp_setattr(obj, PyString_AS_STRING(attr_name), value);
#endif
    return PyObject_SetAttr(obj, attr_name, value);
}
#endif

/* GetTopmostException */
  #if CYTHON_USE_EXC_INFO_STACK
static _PyErr_StackItem *
__Pyx_PyErr_GetTopmostException(PyThreadState *tstate)
{
    _PyErr_StackItem *exc_info = tstate->exc_info;
    while ((exc_info->exc_type == NULL || exc_info->exc_type == Py_None) &&
           exc_info->previous_item != NULL)
    {
        exc_info = exc_info->previous_item;
    }
    return exc_info;
}
#endif

/* SaveResetException */
  #if CYTHON_FAST_THREAD_STATE
static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
    #if CYTHON_USE_EXC_INFO_STACK
    _PyErr_StackItem *exc_info = __Pyx_PyErr_GetTopmostException(tstate);
    *type = exc_info->exc_type;
    *value = exc_info->exc_value;
    *tb = exc_info->exc_traceback;
    #else
    *type = tstate->exc_type;
    *value = tstate->exc_value;
    *tb = tstate->exc_traceback;
    #endif
    Py_XINCREF(*type);
    Py_XINCREF(*value);
    Py_XINCREF(*tb);
}
static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) {
    PyObject *tmp_type, *tmp_value, *tmp_tb;
    #if CYTHON_USE_EXC_INFO_STACK
    _PyErr_StackItem *exc_info = tstate->exc_info;
    tmp_type = exc_info->exc_type;
    tmp_value = exc_info->exc_value;
    tmp_tb = exc_info->exc_traceback;
    exc_info->exc_type = type;
    exc_info->exc_value = value;
    exc_info->exc_traceback = tb;
    #else
    tmp_type = tstate->exc_type;
    tmp_value = tstate->exc_value;
    tmp_tb = tstate->exc_traceback;
    tstate->exc_type = type;
    tstate->exc_value = value;
    tstate->exc_traceback = tb;
    #endif
    Py_XDECREF(tmp_type);
    Py_XDECREF(tmp_value);
    Py_XDECREF(tmp_tb);
}
#endif

/* PyErrExceptionMatches */
  #if CYTHON_FAST_THREAD_STATE
static int __Pyx_PyErr_ExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) {
    Py_ssize_t i, n;
    n = PyTuple_GET_SIZE(tuple);
#if PY_MAJOR_VERSION >= 3
    for (i=0; i<n; i++) {
        if (exc_type == PyTuple_GET_ITEM(tuple, i)) return 1;
    }
#endif
    for (i=0; i<n; i++) {
        if (__Pyx_PyErr_GivenExceptionMatches(exc_type, PyTuple_GET_ITEM(tuple, i))) return 1;
    }
    return 0;
}
static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err) {
    PyObject *exc_type = tstate->curexc_type;
    if (exc_type == err) return 1;
    if (unlikely(!exc_type)) return 0;
    if (unlikely(PyTuple_Check(err)))
        return __Pyx_PyErr_ExceptionMatchesTuple(exc_type, err);
    return __Pyx_PyErr_GivenExceptionMatches(exc_type, err);
}
#endif

/* GetException */
  #if CYTHON_FAST_THREAD_STATE
static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb)
#else
static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb)
#endif
{
    PyObject *local_type, *local_value, *local_tb;
#if CYTHON_FAST_THREAD_STATE
    PyObject *tmp_type, *tmp_value, *tmp_tb;
    local_type = tstate->curexc_type;
    local_value = tstate->curexc_value;
    local_tb = tstate->curexc_traceback;
    tstate->curexc_type = 0;
    tstate->curexc_value = 0;
    tstate->curexc_traceback = 0;
#else
    PyErr_Fetch(&local_type, &local_value, &local_tb);
#endif
    PyErr_NormalizeException(&local_type, &local_value, &local_tb);
#if CYTHON_FAST_THREAD_STATE
    if (unlikely(tstate->curexc_type))
#else
    if (unlikely(PyErr_Occurred()))
#endif
        goto bad;
    #if PY_MAJOR_VERSION >= 3
    if (local_tb) {
        if (unlikely(PyException_SetTraceback(local_value, local_tb) < 0))
            goto bad;
    }
    #endif
    Py_XINCREF(local_tb);
    Py_XINCREF(local_type);
    Py_XINCREF(local_value);
    *type = local_type;
    *value = local_value;
    *tb = local_tb;
#if CYTHON_FAST_THREAD_STATE
    #if CYTHON_USE_EXC_INFO_STACK
    {
        _PyErr_StackItem *exc_info = tstate->exc_info;
        tmp_type = exc_info->exc_type;
        tmp_value = exc_info->exc_value;
        tmp_tb = exc_info->exc_traceback;
        exc_info->exc_type = local_type;
        exc_info->exc_value = local_value;
        exc_info->exc_traceback = local_tb;
    }
    #else
    tmp_type = tstate->exc_type;
    tmp_value = tstate->exc_value;
    tmp_tb = tstate->exc_traceback;
    tstate->exc_type = local_type;
    tstate->exc_value = local_value;
    tstate->exc_traceback = local_tb;
    #endif
    Py_XDECREF(tmp_type);
    Py_XDECREF(tmp_value);
    Py_XDECREF(tmp_tb);
#else
    PyErr_SetExcInfo(local_type, local_value, local_tb);
#endif
    return 0;
bad:
    *type = 0;
    *value = 0;
    *tb = 0;
    Py_XDECREF(local_type);
    Py_XDECREF(local_value);
    Py_XDECREF(local_tb);
    return -1;
}

/* SwapException */
  #if CYTHON_FAST_THREAD_STATE
static CYTHON_INLINE void __Pyx__ExceptionSwap(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
    PyObject *tmp_type, *tmp_value, *tmp_tb;
    #if CYTHON_USE_EXC_INFO_STACK
    _PyErr_StackItem *exc_info = tstate->exc_info;
    tmp_type = exc_info->exc_type;
    tmp_value = exc_info->exc_value;
    tmp_tb = exc_info->exc_traceback;
    exc_info->exc_type = *type;
    exc_info->exc_value = *value;
    exc_info->exc_traceback = *tb;
    #else
    tmp_type = tstate->exc_type;
    tmp_value = tstate->exc_value;
    tmp_tb = tstate->exc_traceback;
    tstate->exc_type = *type;
    tstate->exc_value = *value;
    tstate->exc_traceback = *tb;
    #endif
    *type = tmp_type;
    *value = tmp_value;
    *tb = tmp_tb;
}
#else
static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb) {
    PyObject *tmp_type, *tmp_value, *tmp_tb;
    PyErr_GetExcInfo(&tmp_type, &tmp_value, &tmp_tb);
    PyErr_SetExcInfo(*type, *value, *tb);
    *type = tmp_type;
    *value = tmp_value;
    *tb = tmp_tb;
}
#endif

/* GetAttr */
  static CYTHON_INLINE PyObject *__Pyx_GetAttr(PyObject *o, PyObject *n) {
#if CYTHON_USE_TYPE_SLOTS
#if PY_MAJOR_VERSION >= 3
    if (likely(PyUnicode_Check(n)))
#else
    if (likely(PyString_Check(n)))
#endif
        return __Pyx_PyObject_GetAttrStr(o, n);
#endif
    return PyObject_GetAttr(o, n);
}

/* HasAttr */
  static CYTHON_INLINE int __Pyx_HasAttr(PyObject *o, PyObject *n) {
    PyObject *r;
    if (unlikely(!__Pyx_PyBaseString_Check(n))) {
        PyErr_SetString(PyExc_TypeError,
                        "hasattr(): attribute name must be string");
        return -1;
    }
    r = __Pyx_GetAttr(o, n);
    if (unlikely(!r)) {
        PyErr_Clear();
        return 0;
    } else {
        Py_DECREF(r);
        return 1;
    }
}

/* None */
  static CYTHON_INLINE void __Pyx_RaiseClosureNameError(const char *varname) {
    PyErr_Format(PyExc_NameError, "free variable '%s' referenced before assignment in enclosing scope", varname);
}

/* FetchCommonType */
  static PyTypeObject* __Pyx_FetchCommonType(PyTypeObject* type) {
    PyObject* fake_module;
    PyTypeObject* cached_type = NULL;
    fake_module = PyImport_AddModule((char*) "_cython_" CYTHON_ABI);
    if (!fake_module) return NULL;
    Py_INCREF(fake_module);
    cached_type = (PyTypeObject*) PyObject_GetAttrString(fake_module, type->tp_name);
    if (cached_type) {
        if (!PyType_Check((PyObject*)cached_type)) {
            PyErr_Format(PyExc_TypeError,
                "Shared Cython type %.200s is not a type object",
                type->tp_name);
            goto bad;
        }
        if (cached_type->tp_basicsize != type->tp_basicsize) {
            PyErr_Format(PyExc_TypeError,
                "Shared Cython type %.200s has the wrong size, try recompiling",
                type->tp_name);
            goto bad;
        }
    } else {
        if (!PyErr_ExceptionMatches(PyExc_AttributeError)) goto bad;
        PyErr_Clear();
        if (PyType_Ready(type) < 0) goto bad;
        if (PyObject_SetAttrString(fake_module, type->tp_name, (PyObject*) type) < 0)
            goto bad;
        Py_INCREF(type);
        cached_type = type;
    }
done:
    Py_DECREF(fake_module);
    return cached_type;
bad:
    Py_XDECREF(cached_type);
    cached_type = NULL;
    goto done;
}

/* CythonFunctionShared */
  #include <structmember.h>
static PyObject *
__Pyx_CyFunction_get_doc(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *closure)
{
    if (unlikely(op->func_doc == NULL)) {
        if (op->func.m_ml->ml_doc) {
#if PY_MAJOR_VERSION >= 3
            op->func_doc = PyUnicode_FromString(op->func.m_ml->ml_doc);
#else
            op->func_doc = PyString_FromString(op->func.m_ml->ml_doc);
#endif
            if (unlikely(op->func_doc == NULL))
                return NULL;
        } else {
            Py_INCREF(Py_None);
            return Py_None;
        }
    }
    Py_INCREF(op->func_doc);
    return op->func_doc;
}
static int
__Pyx_CyFunction_set_doc(__pyx_CyFunctionObject *op, PyObject *value, CYTHON_UNUSED void *context)
{
    PyObject *tmp = op->func_doc;
    if (value == NULL) {
        value = Py_None;
    }
    Py_INCREF(value);
    op->func_doc = value;
    Py_XDECREF(tmp);
    return 0;
}
static PyObject *
__Pyx_CyFunction_get_name(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *context)
{
    if (unlikely(op->func_name == NULL)) {
#if PY_MAJOR_VERSION >= 3
        op->func_name = PyUnicode_InternFromString(op->func.m_ml->ml_name);
#else
        op->func_name = PyString_InternFromString(op->func.m_ml->ml_name);
#endif
        if (unlikely(op->func_name == NULL))
            return NULL;
    }
    Py_INCREF(op->func_name);
    return op->func_name;
}
static int
__Pyx_CyFunction_set_name(__pyx_CyFunctionObject *op, PyObject *value, CYTHON_UNUSED void *context)
{
    PyObject *tmp;
#if PY_MAJOR_VERSION >= 3
    if (unlikely(value == NULL || !PyUnicode_Check(value)))
#else
    if (unlikely(value == NULL || !PyString_Check(value)))
#endif
    {
        PyErr_SetString(PyExc_TypeError,
                        "__name__ must be set to a string object");
        return -1;
    }
    tmp = op->func_name;
    Py_INCREF(value);
    op->func_name = value;
    Py_XDECREF(tmp);
    return 0;
}
static PyObject *
__Pyx_CyFunction_get_qualname(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *context)
{
    Py_INCREF(op->func_qualname);
    return op->func_qualname;
}
static int
__Pyx_CyFunction_set_qualname(__pyx_CyFunctionObject *op, PyObject *value, CYTHON_UNUSED void *context)
{
    PyObject *tmp;
#if PY_MAJOR_VERSION >= 3
    if (unlikely(value == NULL || !PyUnicode_Check(value)))
#else
    if (unlikely(value == NULL || !PyString_Check(value)))
#endif
    {
        PyErr_SetString(PyExc_TypeError,
                        "__qualname__ must be set to a string object");
        return -1;
    }
    tmp = op->func_qualname;
    Py_INCREF(value);
    op->func_qualname = value;
    Py_XDECREF(tmp);
    return 0;
}
static PyObject *
__Pyx_CyFunction_get_self(__pyx_CyFunctionObject *m, CYTHON_UNUSED void *closure)
{
    PyObject *self;
    self = m->func_closure;
    if (self == NULL)
        self = Py_None;
    Py_INCREF(self);
    return self;
}
static PyObject *
__Pyx_CyFunction_get_dict(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *context)
{
    if (unlikely(op->func_dict == NULL)) {
        op->func_dict = PyDict_New();
        if (unlikely(op->func_dict == NULL))
            return NULL;
    }
    Py_INCREF(op->func_dict);
    return op->func_dict;
}
static int
__Pyx_CyFunction_set_dict(__pyx_CyFunctionObject *op, PyObject *value, CYTHON_UNUSED void *context)
{
    PyObject *tmp;
    if (unlikely(value == NULL)) {
        PyErr_SetString(PyExc_TypeError,
               "function's dictionary may not be deleted");
        return -1;
    }
    if (unlikely(!PyDict_Check(value))) {
        PyErr_SetString(PyExc_TypeError,
               "setting function's dictionary to a non-dict");
        return -1;
    }
    tmp = op->func_dict;
    Py_INCREF(value);
    op->func_dict = value;
    Py_XDECREF(tmp);
    return 0;
}
static PyObject *
__Pyx_CyFunction_get_globals(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *context)
{
    Py_INCREF(op->func_globals);
    return op->func_globals;
}
static PyObject *
__Pyx_CyFunction_get_closure(CYTHON_UNUSED __pyx_CyFunctionObject *op, CYTHON_UNUSED void *context)
{
    Py_INCREF(Py_None);
    return Py_None;
}
static PyObject *
__Pyx_CyFunction_get_code(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *context)
{
    PyObject* result = (op->func_code) ? op->func_code : Py_None;
    Py_INCREF(result);
    return result;
}
static int
__Pyx_CyFunction_init_defaults(__pyx_CyFunctionObject *op) {
    int result = 0;
    PyObject *res = op->defaults_getter((PyObject *) op);
    if (unlikely(!res))
        return -1;
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    op->defaults_tuple = PyTuple_GET_ITEM(res, 0);
    Py_INCREF(op->defaults_tuple);
    op->defaults_kwdict = PyTuple_GET_ITEM(res, 1);
    Py_INCREF(op->defaults_kwdict);
    #else
    op->defaults_tuple = PySequence_ITEM(res, 0);
    if (unlikely(!op->defaults_tuple)) result = -1;
    else {
        op->defaults_kwdict = PySequence_ITEM(res, 1);
        if (unlikely(!op->defaults_kwdict)) result = -1;
    }
    #endif
    Py_DECREF(res);
    return result;
}
static int
__Pyx_CyFunction_set_defaults(__pyx_CyFunctionObject *op, PyObject* value, CYTHON_UNUSED void *context) {
    PyObject* tmp;
    if (!value) {
        value = Py_None;
    } else if (value != Py_None && !PyTuple_Check(value)) {
        PyErr_SetString(PyExc_TypeError,
                        "__defaults__ must be set to a tuple object");
        return -1;
    }
    Py_INCREF(value);
    tmp = op->defaults_tuple;
    op->defaults_tuple = value;
    Py_XDECREF(tmp);
    return 0;
}
static PyObject *
__Pyx_CyFunction_get_defaults(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *context) {
    PyObject* result = op->defaults_tuple;
    if (unlikely(!result)) {
        if (op->defaults_getter) {
            if (__Pyx_CyFunction_init_defaults(op) < 0) return NULL;
            result = op->defaults_tuple;
        } else {
            result = Py_None;
        }
    }
    Py_INCREF(result);
    return result;
}
static int
__Pyx_CyFunction_set_kwdefaults(__pyx_CyFunctionObject *op, PyObject* value, CYTHON_UNUSED void *context) {
    PyObject* tmp;
    if (!value) {
        value = Py_None;
    } else if (value != Py_None && !PyDict_Check(value)) {
        PyErr_SetString(PyExc_TypeError,
                        "__kwdefaults__ must be set to a dict object");
        return -1;
    }
    Py_INCREF(value);
    tmp = op->defaults_kwdict;
    op->defaults_kwdict = value;
    Py_XDECREF(tmp);
    return 0;
}
static PyObject *
__Pyx_CyFunction_get_kwdefaults(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *context) {
    PyObject* result = op->defaults_kwdict;
    if (unlikely(!result)) {
        if (op->defaults_getter) {
            if (__Pyx_CyFunction_init_defaults(op) < 0) return NULL;
            result = op->defaults_kwdict;
        } else {
            result = Py_None;
        }
    }
    Py_INCREF(result);
    return result;
}
static int
__Pyx_CyFunction_set_annotations(__pyx_CyFunctionObject *op, PyObject* value, CYTHON_UNUSED void *context) {
    PyObject* tmp;
    if (!value || value == Py_None) {
        value = NULL;
    } else if (!PyDict_Check(value)) {
        PyErr_SetString(PyExc_TypeError,
                        "__annotations__ must be set to a dict object");
        return -1;
    }
    Py_XINCREF(value);
    tmp = op->func_annotations;
    op->func_annotations = value;
    Py_XDECREF(tmp);
    return 0;
}
static PyObject *
__Pyx_CyFunction_get_annotations(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *context) {
    PyObject* result = op->func_annotations;
    if (unlikely(!result)) {
        result = PyDict_New();
        if (unlikely(!result)) return NULL;
        op->func_annotations = result;
    }
    Py_INCREF(result);
    return result;
}
static PyGetSetDef __pyx_CyFunction_getsets[] = {
    {(char *) "func_doc", (getter)__Pyx_CyFunction_get_doc, (setter)__Pyx_CyFunction_set_doc, 0, 0},
    {(char *) "__doc__",  (getter)__Pyx_CyFunction_get_doc, (setter)__Pyx_CyFunction_set_doc, 0, 0},
    {(char *) "func_name", (getter)__Pyx_CyFunction_get_name, (setter)__Pyx_CyFunction_set_name, 0, 0},
    {(char *) "__name__", (getter)__Pyx_CyFunction_get_name, (setter)__Pyx_CyFunction_set_name, 0, 0},
    {(char *) "__qualname__", (getter)__Pyx_CyFunction_get_qualname, (setter)__Pyx_CyFunction_set_qualname, 0, 0},
    {(char *) "__self__", (getter)__Pyx_CyFunction_get_self, 0, 0, 0},
    {(char *) "func_dict", (getter)__Pyx_CyFunction_get_dict, (setter)__Pyx_CyFunction_set_dict, 0, 0},
    {(char *) "__dict__", (getter)__Pyx_CyFunction_get_dict, (setter)__Pyx_CyFunction_set_dict, 0, 0},
    {(char *) "func_globals", (getter)__Pyx_CyFunction_get_globals, 0, 0, 0},
    {(char *) "__globals__", (getter)__Pyx_CyFunction_get_globals, 0, 0, 0},
    {(char *) "func_closure", (getter)__Pyx_CyFunction_get_closure, 0, 0, 0},
    {(char *) "__closure__", (getter)__Pyx_CyFunction_get_closure, 0, 0, 0},
    {(char *) "func_code", (getter)__Pyx_CyFunction_get_code, 0, 0, 0},
    {(char *) "__code__", (getter)__Pyx_CyFunction_get_code, 0, 0, 0},
    {(char *) "func_defaults", (getter)__Pyx_CyFunction_get_defaults, (setter)__Pyx_CyFunction_set_defaults, 0, 0},
    {(char *) "__defaults__", (getter)__Pyx_CyFunction_get_defaults, (setter)__Pyx_CyFunction_set_defaults, 0, 0},
    {(char *) "__kwdefaults__", (getter)__Pyx_CyFunction_get_kwdefaults, (setter)__Pyx_CyFunction_set_kwdefaults, 0, 0},
    {(char *) "__annotations__", (getter)__Pyx_CyFunction_get_annotations, (setter)__Pyx_CyFunction_set_annotations, 0, 0},
    {0, 0, 0, 0, 0}
};
static PyMemberDef __pyx_CyFunction_members[] = {
    {(char *) "__module__", T_OBJECT, offsetof(PyCFunctionObject, m_module), PY_WRITE_RESTRICTED, 0},
    {0, 0, 0,  0, 0}
};
static PyObject *
__Pyx_CyFunction_reduce(__pyx_CyFunctionObject *m, CYTHON_UNUSED PyObject *args)
{
#if PY_MAJOR_VERSION >= 3
    Py_INCREF(m->func_qualname);
    return m->func_qualname;
#else
    return PyString_FromString(m->func.m_ml->ml_name);
#endif
}
static PyMethodDef __pyx_CyFunction_methods[] = {
    {"__reduce__", (PyCFunction)__Pyx_CyFunction_reduce, METH_VARARGS, 0},
    {0, 0, 0, 0}
};
#if PY_VERSION_HEX < 0x030500A0
#define __Pyx_CyFunction_weakreflist(cyfunc) ((cyfunc)->func_weakreflist)
#else
#define __Pyx_CyFunction_weakreflist(cyfunc) ((cyfunc)->func.m_weakreflist)
#endif
static PyObject *__Pyx_CyFunction_Init(__pyx_CyFunctionObject *op, PyMethodDef *ml, int flags, PyObject* qualname,
                                       PyObject *closure, PyObject *module, PyObject* globals, PyObject* code) {
    if (unlikely(op == NULL))
        return NULL;
    op->flags = flags;
    __Pyx_CyFunction_weakreflist(op) = NULL;
    op->func.m_ml = ml;
    op->func.m_self = (PyObject *) op;
    Py_XINCREF(closure);
    op->func_closure = closure;
    Py_XINCREF(module);
    op->func.m_module = module;
    op->func_dict = NULL;
    op->func_name = NULL;
    Py_INCREF(qualname);
    op->func_qualname = qualname;
    op->func_doc = NULL;
    op->func_classobj = NULL;
    op->func_globals = globals;
    Py_INCREF(op->func_globals);
    Py_XINCREF(code);
    op->func_code = code;
    op->defaults_pyobjects = 0;
    op->defaults_size = 0;
    op->defaults = NULL;
    op->defaults_tuple = NULL;
    op->defaults_kwdict = NULL;
    op->defaults_getter = NULL;
    op->func_annotations = NULL;
    return (PyObject *) op;
}
static int
__Pyx_CyFunction_clear(__pyx_CyFunctionObject *m)
{
    Py_CLEAR(m->func_closure);
    Py_CLEAR(m->func.m_module);
    Py_CLEAR(m->func_dict);
    Py_CLEAR(m->func_name);
    Py_CLEAR(m->func_qualname);
    Py_CLEAR(m->func_doc);
    Py_CLEAR(m->func_globals);
    Py_CLEAR(m->func_code);
    Py_CLEAR(m->func_classobj);
    Py_CLEAR(m->defaults_tuple);
    Py_CLEAR(m->defaults_kwdict);
    Py_CLEAR(m->func_annotations);
    if (m->defaults) {
        PyObject **pydefaults = __Pyx_CyFunction_Defaults(PyObject *, m);
        int i;
        for (i = 0; i < m->defaults_pyobjects; i++)
            Py_XDECREF(pydefaults[i]);
        PyObject_Free(m->defaults);
        m->defaults = NULL;
    }
    return 0;
}
static void __Pyx__CyFunction_dealloc(__pyx_CyFunctionObject *m)
{
    if (__Pyx_CyFunction_weakreflist(m) != NULL)
        PyObject_ClearWeakRefs((PyObject *) m);
    __Pyx_CyFunction_clear(m);
    PyObject_GC_Del(m);
}
static void __Pyx_CyFunction_dealloc(__pyx_CyFunctionObject *m)
{
    PyObject_GC_UnTrack(m);
    __Pyx__CyFunction_dealloc(m);
}
static int __Pyx_CyFunction_traverse(__pyx_CyFunctionObject *m, visitproc visit, void *arg)
{
    Py_VISIT(m->func_closure);
    Py_VISIT(m->func.m_module);
    Py_VISIT(m->func_dict);
    Py_VISIT(m->func_name);
    Py_VISIT(m->func_qualname);
    Py_VISIT(m->func_doc);
    Py_VISIT(m->func_globals);
    Py_VISIT(m->func_code);
    Py_VISIT(m->func_classobj);
    Py_VISIT(m->defaults_tuple);
    Py_VISIT(m->defaults_kwdict);
    if (m->defaults) {
        PyObject **pydefaults = __Pyx_CyFunction_Defaults(PyObject *, m);
        int i;
        for (i = 0; i < m->defaults_pyobjects; i++)
            Py_VISIT(pydefaults[i]);
    }
    return 0;
}
static PyObject *__Pyx_CyFunction_descr_get(PyObject *func, PyObject *obj, PyObject *type)
{
#if PY_MAJOR_VERSION < 3
    __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
    if (m->flags & __Pyx_CYFUNCTION_STATICMETHOD) {
        Py_INCREF(func);
        return func;
    }
    if (m->flags & __Pyx_CYFUNCTION_CLASSMETHOD) {
        if (type == NULL)
            type = (PyObject *)(Py_TYPE(obj));
        return __Pyx_PyMethod_New(func, type, (PyObject *)(Py_TYPE(type)));
    }
    if (obj == Py_None)
        obj = NULL;
#endif
    return __Pyx_PyMethod_New(func, obj, type);
}
static PyObject*
__Pyx_CyFunction_repr(__pyx_CyFunctionObject *op)
{
#if PY_MAJOR_VERSION >= 3
    return PyUnicode_FromFormat("<cyfunction %U at %p>",
                                op->func_qualname, (void *)op);
#else
    return PyString_FromFormat("<cyfunction %s at %p>",
                               PyString_AsString(op->func_qualname), (void *)op);
#endif
}
static PyObject * __Pyx_CyFunction_CallMethod(PyObject *func, PyObject *self, PyObject *arg, PyObject *kw) {
    PyCFunctionObject* f = (PyCFunctionObject*)func;
    PyCFunction meth = f->m_ml->ml_meth;
    Py_ssize_t size;
    switch (f->m_ml->ml_flags & (METH_VARARGS | METH_KEYWORDS | METH_NOARGS | METH_O)) {
    case METH_VARARGS:
        if (likely(kw == NULL || PyDict_Size(kw) == 0))
            return (*meth)(self, arg);
        break;
    case METH_VARARGS | METH_KEYWORDS:
        return (*(PyCFunctionWithKeywords)(void*)meth)(self, arg, kw);
    case METH_NOARGS:
        if (likely(kw == NULL || PyDict_Size(kw) == 0)) {
            size = PyTuple_GET_SIZE(arg);
            if (likely(size == 0))
                return (*meth)(self, NULL);
            PyErr_Format(PyExc_TypeError,
                "%.200s() takes no arguments (%" CYTHON_FORMAT_SSIZE_T "d given)",
                f->m_ml->ml_name, size);
            return NULL;
        }
        break;
    case METH_O:
        if (likely(kw == NULL || PyDict_Size(kw) == 0)) {
            size = PyTuple_GET_SIZE(arg);
            if (likely(size == 1)) {
                PyObject *result, *arg0;
                #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
                arg0 = PyTuple_GET_ITEM(arg, 0);
                #else
                arg0 = PySequence_ITEM(arg, 0); if (unlikely(!arg0)) return NULL;
                #endif
                result = (*meth)(self, arg0);
                #if !(CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS)
                Py_DECREF(arg0);
                #endif
                return result;
            }
            PyErr_Format(PyExc_TypeError,
                "%.200s() takes exactly one argument (%" CYTHON_FORMAT_SSIZE_T "d given)",
                f->m_ml->ml_name, size);
            return NULL;
        }
        break;
    default:
        PyErr_SetString(PyExc_SystemError, "Bad call flags in "
                        "__Pyx_CyFunction_Call. METH_OLDARGS is no "
                        "longer supported!");
        return NULL;
    }
    PyErr_Format(PyExc_TypeError, "%.200s() takes no keyword arguments",
                 f->m_ml->ml_name);
    return NULL;
}
static CYTHON_INLINE PyObject *__Pyx_CyFunction_Call(PyObject *func, PyObject *arg, PyObject *kw) {
    return __Pyx_CyFunction_CallMethod(func, ((PyCFunctionObject*)func)->m_self, arg, kw);
}
static PyObject *__Pyx_CyFunction_CallAsMethod(PyObject *func, PyObject *args, PyObject *kw) {
    PyObject *result;
    __pyx_CyFunctionObject *cyfunc = (__pyx_CyFunctionObject *) func;
    if ((cyfunc->flags & __Pyx_CYFUNCTION_CCLASS) && !(cyfunc->flags & __Pyx_CYFUNCTION_STATICMETHOD)) {
        Py_ssize_t argc;
        PyObject *new_args;
        PyObject *self;
        argc = PyTuple_GET_SIZE(args);
        new_args = PyTuple_GetSlice(args, 1, argc);
        if (unlikely(!new_args))
            return NULL;
        self = PyTuple_GetItem(args, 0);
        if (unlikely(!self)) {
            Py_DECREF(new_args);
#if PY_MAJOR_VERSION > 2
            PyErr_Format(PyExc_TypeError,
                         "unbound method %.200S() needs an argument",
                         cyfunc->func_qualname);
#else
            PyErr_SetString(PyExc_TypeError,
                            "unbound method needs an argument");
#endif
            return NULL;
        }
        result = __Pyx_CyFunction_CallMethod(func, self, new_args, kw);
        Py_DECREF(new_args);
    } else {
        result = __Pyx_CyFunction_Call(func, args, kw);
    }
    return result;
}
static PyTypeObject __pyx_CyFunctionType_type = {
    PyVarObject_HEAD_INIT(0, 0)
    "cython_function_or_method",
    sizeof(__pyx_CyFunctionObject),
    0,
    (destructor) __Pyx_CyFunction_dealloc,
    0,
    0,
    0,
#if PY_MAJOR_VERSION < 3
    0,
#else
    0,
#endif
    (reprfunc) __Pyx_CyFunction_repr,
    0,
    0,
    0,
    0,
    __Pyx_CyFunction_CallAsMethod,
    0,
    0,
    0,
    0,
    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,
    0,
    (traverseproc) __Pyx_CyFunction_traverse,
    (inquiry) __Pyx_CyFunction_clear,
    0,
#if PY_VERSION_HEX < 0x030500A0
    offsetof(__pyx_CyFunctionObject, func_weakreflist),
#else
    offsetof(PyCFunctionObject, m_weakreflist),
#endif
    0,
    0,
    __pyx_CyFunction_methods,
    __pyx_CyFunction_members,
    __pyx_CyFunction_getsets,
    0,
    0,
    __Pyx_CyFunction_descr_get,
    0,
    offsetof(__pyx_CyFunctionObject, func_dict),
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
#if PY_VERSION_HEX >= 0x030400a1
    0,
#endif
#if PY_VERSION_HEX >= 0x030800b1 && (!CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800)
    0,
#endif
#if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
    0,
#endif
#if PY_VERSION_HEX >= 0x030C0000
    0,
#endif
#if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000 && PY_VERSION_HEX < 0x030a0000
    0,
#endif
};
static int __pyx_CyFunction_init(void) {
    __pyx_CyFunctionType = __Pyx_FetchCommonType(&__pyx_CyFunctionType_type);
    if (unlikely(__pyx_CyFunctionType == NULL)) {
        return -1;
    }
    return 0;
}
static CYTHON_INLINE void *__Pyx_CyFunction_InitDefaults(PyObject *func, size_t size, int pyobjects) {
    __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
    m->defaults = PyObject_Malloc(size);
    if (unlikely(!m->defaults))
        return PyErr_NoMemory();
    memset(m->defaults, 0, size);
    m->defaults_pyobjects = pyobjects;
    m->defaults_size = size;
    return m->defaults;
}
static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsTuple(PyObject *func, PyObject *tuple) {
    __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
    m->defaults_tuple = tuple;
    Py_INCREF(tuple);
}
static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsKwDict(PyObject *func, PyObject *dict) {
    __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
    m->defaults_kwdict = dict;
    Py_INCREF(dict);
}
static CYTHON_INLINE void __Pyx_CyFunction_SetAnnotationsDict(PyObject *func, PyObject *dict) {
    __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
    m->func_annotations = dict;
    Py_INCREF(dict);
}

/* CythonFunction */
  static PyObject *__Pyx_CyFunction_New(PyMethodDef *ml, int flags, PyObject* qualname,
                                      PyObject *closure, PyObject *module, PyObject* globals, PyObject* code) {
    PyObject *op = __Pyx_CyFunction_Init(
        PyObject_GC_New(__pyx_CyFunctionObject, __pyx_CyFunctionType),
        ml, flags, qualname, closure, module, globals, code
    );
    if (likely(op)) {
        PyObject_GC_Track(op);
    }
    return op;
}

/* ObjectGetItem */
  #if CYTHON_USE_TYPE_SLOTS
static PyObject *__Pyx_PyObject_GetIndex(PyObject *obj, PyObject* index) {
    PyObject *runerr = NULL;
    Py_ssize_t key_value;
    PySequenceMethods *m = Py_TYPE(obj)->tp_as_sequence;
    if (unlikely(!(m && m->sq_item))) {
        PyErr_Format(PyExc_TypeError, "'%.200s' object is not subscriptable", Py_TYPE(obj)->tp_name);
        return NULL;
    }
    key_value = __Pyx_PyIndex_AsSsize_t(index);
    if (likely(key_value != -1 || !(runerr = PyErr_Occurred()))) {
        return __Pyx_GetItemInt_Fast(obj, key_value, 0, 1, 1);
    }
    if (PyErr_GivenExceptionMatches(runerr, PyExc_OverflowError)) {
        PyErr_Clear();
        PyErr_Format(PyExc_IndexError, "cannot fit '%.200s' into an index-sized integer", Py_TYPE(index)->tp_name);
    }
    return NULL;
}
static PyObject *__Pyx_PyObject_GetItem(PyObject *obj, PyObject* key) {
    PyMappingMethods *m = Py_TYPE(obj)->tp_as_mapping;
    if (likely(m && m->mp_subscript)) {
        return m->mp_subscript(obj, key);
    }
    return __Pyx_PyObject_GetIndex(obj, key);
}
#endif

/* GetAttr3 */
  static PyObject *__Pyx_GetAttr3Default(PyObject *d) {
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    if (unlikely(!__Pyx_PyErr_ExceptionMatches(PyExc_AttributeError)))
        return NULL;
    __Pyx_PyErr_Clear();
    Py_INCREF(d);
    return d;
}
static CYTHON_INLINE PyObject *__Pyx_GetAttr3(PyObject *o, PyObject *n, PyObject *d) {
    PyObject *r = __Pyx_GetAttr(o, n);
    return (likely(r)) ? r : __Pyx_GetAttr3Default(d);
}

/* ExtTypeTest */
  static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type) {
    if (unlikely(!type)) {
        PyErr_SetString(PyExc_SystemError, "Missing type object");
        return 0;
    }
    if (likely(__Pyx_TypeCheck(obj, type)))
        return 1;
    PyErr_Format(PyExc_TypeError, "Cannot convert %.200s to %.200s",
                 Py_TYPE(obj)->tp_name, type->tp_name);
    return 0;
}

/* WriteUnraisableException */
  static void __Pyx_WriteUnraisable(const char *name, CYTHON_UNUSED int clineno,
                                  CYTHON_UNUSED int lineno, CYTHON_UNUSED const char *filename,
                                  int full_traceback, CYTHON_UNUSED int nogil) {
    PyObject *old_exc, *old_val, *old_tb;
    PyObject *ctx;
    __Pyx_PyThreadState_declare
#ifdef WITH_THREAD
    PyGILState_STATE state;
    if (nogil)
        state = PyGILState_Ensure();
    else state = (PyGILState_STATE)0;
#endif
    __Pyx_PyThreadState_assign
    __Pyx_ErrFetch(&old_exc, &old_val, &old_tb);
    if (full_traceback) {
        Py_XINCREF(old_exc);
        Py_XINCREF(old_val);
        Py_XINCREF(old_tb);
        __Pyx_ErrRestore(old_exc, old_val, old_tb);
        PyErr_PrintEx(1);
    }
    #if PY_MAJOR_VERSION < 3
    ctx = PyString_FromString(name);
    #else
    ctx = PyUnicode_FromString(name);
    #endif
    __Pyx_ErrRestore(old_exc, old_val, old_tb);
    if (!ctx) {
        PyErr_WriteUnraisable(Py_None);
    } else {
        PyErr_WriteUnraisable(ctx);
        Py_DECREF(ctx);
    }
#ifdef WITH_THREAD
    if (nogil)
        PyGILState_Release(state);
#endif
}

/* DivInt[Py_ssize_t] */
  static CYTHON_INLINE Py_ssize_t __Pyx_div_Py_ssize_t(Py_ssize_t a, Py_ssize_t b) {
    Py_ssize_t q = a / b;
    Py_ssize_t r = a - q*b;
    q -= ((r != 0) & ((r ^ b) < 0));
    return q;
}

/* PyObjectGetMethod */
  static int __Pyx_PyObject_GetMethod(PyObject *obj, PyObject *name, PyObject **method) {
    PyObject *attr;
#if CYTHON_UNPACK_METHODS && CYTHON_COMPILING_IN_CPYTHON && CYTHON_USE_PYTYPE_LOOKUP
    PyTypeObject *tp = Py_TYPE(obj);
    PyObject *descr;
    descrgetfunc f = NULL;
    PyObject **dictptr, *dict;
    int meth_found = 0;
    assert (*method == NULL);
    if (unlikely(tp->tp_getattro != PyObject_GenericGetAttr)) {
        attr = __Pyx_PyObject_GetAttrStr(obj, name);
        goto try_unpack;
    }
    if (unlikely(tp->tp_dict == NULL) && unlikely(PyType_Ready(tp) < 0)) {
        return 0;
    }
    descr = _PyType_Lookup(tp, name);
    if (likely(descr != NULL)) {
        Py_INCREF(descr);
#if PY_MAJOR_VERSION >= 3
        #ifdef __Pyx_CyFunction_USED
        if (likely(PyFunction_Check(descr) || (Py_TYPE(descr) == &PyMethodDescr_Type) || __Pyx_CyFunction_Check(descr)))
        #else
        if (likely(PyFunction_Check(descr) || (Py_TYPE(descr) == &PyMethodDescr_Type)))
        #endif
#else
        #ifdef __Pyx_CyFunction_USED
        if (likely(PyFunction_Check(descr) || __Pyx_CyFunction_Check(descr)))
        #else
        if (likely(PyFunction_Check(descr)))
        #endif
#endif
        {
            meth_found = 1;
        } else {
            f = Py_TYPE(descr)->tp_descr_get;
            if (f != NULL && PyDescr_IsData(descr)) {
                attr = f(descr, obj, (PyObject *)Py_TYPE(obj));
                Py_DECREF(descr);
                goto try_unpack;
            }
        }
    }
    dictptr = _PyObject_GetDictPtr(obj);
    if (dictptr != NULL && (dict = *dictptr) != NULL) {
        Py_INCREF(dict);
        attr = __Pyx_PyDict_GetItemStr(dict, name);
        if (attr != NULL) {
            Py_INCREF(attr);
            Py_DECREF(dict);
            Py_XDECREF(descr);
            goto try_unpack;
        }
        Py_DECREF(dict);
    }
    if (meth_found) {
        *method = descr;
        return 1;
    }
    if (f != NULL) {
        attr = f(descr, obj, (PyObject *)Py_TYPE(obj));
        Py_DECREF(descr);
        goto try_unpack;
    }
    if (descr != NULL) {
        *method = descr;
        return 0;
    }
    PyErr_Format(PyExc_AttributeError,
#if PY_MAJOR_VERSION >= 3
                 "'%.50s' object has no attribute '%U'",
                 tp->tp_name, name);
#else
                 "'%.50s' object has no attribute '%.400s'",
                 tp->tp_name, PyString_AS_STRING(name));
#endif
    return 0;
#else
    attr = __Pyx_PyObject_GetAttrStr(obj, name);
    goto try_unpack;
#endif
try_unpack:
#if CYTHON_UNPACK_METHODS
    if (likely(attr) && PyMethod_Check(attr) && likely(PyMethod_GET_SELF(attr) == obj)) {
        PyObject *function = PyMethod_GET_FUNCTION(attr);
        Py_INCREF(function);
        Py_DECREF(attr);
        *method = function;
        return 1;
    }
#endif
    *method = attr;
    return 0;
}

/* PyObjectCallMethod1 */
  static PyObject* __Pyx__PyObject_CallMethod1(PyObject* method, PyObject* arg) {
    PyObject *result = __Pyx_PyObject_CallOneArg(method, arg);
    Py_DECREF(method);
    return result;
}
static PyObject* __Pyx_PyObject_CallMethod1(PyObject* obj, PyObject* method_name, PyObject* arg) {
    PyObject *method = NULL, *result;
    int is_method = __Pyx_PyObject_GetMethod(obj, method_name, &method);
    if (likely(is_method)) {
        result = __Pyx_PyObject_Call2Args(method, obj, arg);
        Py_DECREF(method);
        return result;
    }
    if (unlikely(!method)) return NULL;
    return __Pyx__PyObject_CallMethod1(method, arg);
}

/* append */
  static CYTHON_INLINE int __Pyx_PyObject_Append(PyObject* L, PyObject* x) {
    if (likely(PyList_CheckExact(L))) {
        if (unlikely(__Pyx_PyList_Append(L, x) < 0)) return -1;
    } else {
        PyObject* retval = __Pyx_PyObject_CallMethod1(L, __pyx_n_s_append, x);
        if (unlikely(!retval))
            return -1;
        Py_DECREF(retval);
    }
    return 0;
}

/* PyIntBinop */
  #if !CYTHON_COMPILING_IN_PYPY
static PyObject* __Pyx_PyInt_AddObjC(PyObject *op1, PyObject *op2, CYTHON_UNUSED long intval, int inplace, int zerodivision_check) {
    (void)inplace;
    (void)zerodivision_check;
    #if PY_MAJOR_VERSION < 3
    if (likely(PyInt_CheckExact(op1))) {
        const long b = intval;
        long x;
        long a = PyInt_AS_LONG(op1);
            x = (long)((unsigned long)a + b);
            if (likely((x^a) >= 0 || (x^b) >= 0))
                return PyInt_FromLong(x);
            return PyLong_Type.tp_as_number->nb_add(op1, op2);
    }
    #endif
    #if CYTHON_USE_PYLONG_INTERNALS
    if (likely(PyLong_CheckExact(op1))) {
        const long b = intval;
        long a, x;
#ifdef HAVE_LONG_LONG
        const PY_LONG_LONG llb = intval;
        PY_LONG_LONG lla, llx;
#endif
        const digit* digits = ((PyLongObject*)op1)->ob_digit;
        const Py_ssize_t size = Py_SIZE(op1);
        if (likely(__Pyx_sst_abs(size) <= 1)) {
            a = likely(size) ? digits[0] : 0;
            if (size == -1) a = -a;
        } else {
            switch (size) {
                case -2:
                    if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
                        a = -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
#ifdef HAVE_LONG_LONG
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) {
                        lla = -(PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
#endif
                    }
                    CYTHON_FALLTHROUGH;
                case 2:
                    if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
                        a = (long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
#ifdef HAVE_LONG_LONG
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) {
                        lla = (PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
#endif
                    }
                    CYTHON_FALLTHROUGH;
                case -3:
                    if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
                        a = -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
#ifdef HAVE_LONG_LONG
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) {
                        lla = -(PY_LONG_LONG) (((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
#endif
                    }
                    CYTHON_FALLTHROUGH;
                case 3:
                    if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
                        a = (long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
#ifdef HAVE_LONG_LONG
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) {
                        lla = (PY_LONG_LONG) (((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
#endif
                    }
                    CYTHON_FALLTHROUGH;
                case -4:
                    if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
                        a = -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
#ifdef HAVE_LONG_LONG
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) {
                        lla = -(PY_LONG_LONG) (((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
#endif
                    }
                    CYTHON_FALLTHROUGH;
                case 4:
                    if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
                        a = (long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
#ifdef HAVE_LONG_LONG
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) {
                        lla = (PY_LONG_LONG) (((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
#endif
                    }
                    CYTHON_FALLTHROUGH;
                default: return PyLong_Type.tp_as_number->nb_add(op1, op2);
            }
        }
                x = a + b;
            return PyLong_FromLong(x);
#ifdef HAVE_LONG_LONG
        long_long:
                llx = lla + llb;
            return PyLong_FromLongLong(llx);
#endif
        
        
    }
    #endif
    if (PyFloat_CheckExact(op1)) {
        const long b = intval;
        double a = PyFloat_AS_DOUBLE(op1);
            double result;
            PyFPE_START_PROTECT("add", return NULL)
            result = ((double)a) + (double)b;
            PyFPE_END_PROTECT(result)
            return PyFloat_FromDouble(result);
    }
    return (inplace ? PyNumber_InPlaceAdd : PyNumber_Add)(op1, op2);
}
#endif

/* RaiseTooManyValuesToUnpack */
  static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected) {
    PyErr_Format(PyExc_ValueError,
                 "too many values to unpack (expected %" CYTHON_FORMAT_SSIZE_T "d)", expected);
}

/* RaiseNeedMoreValuesToUnpack */
  static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index) {
    PyErr_Format(PyExc_ValueError,
                 "need more than %" CYTHON_FORMAT_SSIZE_T "d value%.1s to unpack",
                 index, (index == 1) ? "" : "s");
}

/* IterFinish */
  static CYTHON_INLINE int __Pyx_IterFinish(void) {
#if CYTHON_FAST_THREAD_STATE
    PyThreadState *tstate = __Pyx_PyThreadState_Current;
    PyObject* exc_type = tstate->curexc_type;
    if (unlikely(exc_type)) {
        if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) {
            PyObject *exc_value, *exc_tb;
            exc_value = tstate->curexc_value;
            exc_tb = tstate->curexc_traceback;
            tstate->curexc_type = 0;
            tstate->curexc_value = 0;
            tstate->curexc_traceback = 0;
            Py_DECREF(exc_type);
            Py_XDECREF(exc_value);
            Py_XDECREF(exc_tb);
            return 0;
        } else {
            return -1;
        }
    }
    return 0;
#else
    if (unlikely(PyErr_Occurred())) {
        if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) {
            PyErr_Clear();
            return 0;
        } else {
            return -1;
        }
    }
    return 0;
#endif
}

/* UnpackItemEndCheck */
  static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected) {
    if (unlikely(retval)) {
        Py_DECREF(retval);
        __Pyx_RaiseTooManyValuesError(expected);
        return -1;
    }
    return __Pyx_IterFinish();
}

/* PyIntFromDouble */
  #if PY_MAJOR_VERSION < 3
static CYTHON_INLINE PyObject* __Pyx_PyInt_FromDouble(double value) {
    if (value >= (double)LONG_MIN && value <= (double)LONG_MAX) {
        return PyInt_FromLong((long)value);
    }
    return PyLong_FromDouble(value);
}
#endif

/* IterNext */
  static PyObject *__Pyx_PyIter_Next2Default(PyObject* defval) {
    PyObject* exc_type;
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    exc_type = __Pyx_PyErr_Occurred();
    if (unlikely(exc_type)) {
        if (!defval || unlikely(!__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration)))
            return NULL;
        __Pyx_PyErr_Clear();
        Py_INCREF(defval);
        return defval;
    }
    if (defval) {
        Py_INCREF(defval);
        return defval;
    }
    __Pyx_PyErr_SetNone(PyExc_StopIteration);
    return NULL;
}
static void __Pyx_PyIter_Next_ErrorNoIterator(PyObject *iterator) {
    PyErr_Format(PyExc_TypeError,
        "%.200s object is not an iterator", Py_TYPE(iterator)->tp_name);
}
static CYTHON_INLINE PyObject *__Pyx_PyIter_Next2(PyObject* iterator, PyObject* defval) {
    PyObject* next;
    iternextfunc iternext = Py_TYPE(iterator)->tp_iternext;
    if (likely(iternext)) {
#if CYTHON_USE_TYPE_SLOTS || CYTHON_COMPILING_IN_PYPY
        next = iternext(iterator);
        if (likely(next))
            return next;
        #if PY_VERSION_HEX >= 0x02070000 && CYTHON_COMPILING_IN_CPYTHON
        if (unlikely(iternext == &_PyObject_NextNotImplemented))
            return NULL;
        #endif
#else
        next = PyIter_Next(iterator);
        if (likely(next))
            return next;
#endif
    } else if (CYTHON_USE_TYPE_SLOTS || unlikely(!PyIter_Check(iterator))) {
        __Pyx_PyIter_Next_ErrorNoIterator(iterator);
        return NULL;
    }
#if !CYTHON_USE_TYPE_SLOTS
    else {
        next = PyIter_Next(iterator);
        if (likely(next))
            return next;
    }
#endif
    return __Pyx_PyIter_Next2Default(defval);
}

/* PyIntBinop */
  #if !CYTHON_COMPILING_IN_PYPY
static PyObject* __Pyx_PyInt_SubtractObjC(PyObject *op1, PyObject *op2, CYTHON_UNUSED long intval, int inplace, int zerodivision_check) {
    (void)inplace;
    (void)zerodivision_check;
    #if PY_MAJOR_VERSION < 3
    if (likely(PyInt_CheckExact(op1))) {
        const long b = intval;
        long x;
        long a = PyInt_AS_LONG(op1);
            x = (long)((unsigned long)a - b);
            if (likely((x^a) >= 0 || (x^~b) >= 0))
                return PyInt_FromLong(x);
            return PyLong_Type.tp_as_number->nb_subtract(op1, op2);
    }
    #endif
    #if CYTHON_USE_PYLONG_INTERNALS
    if (likely(PyLong_CheckExact(op1))) {
        const long b = intval;
        long a, x;
#ifdef HAVE_LONG_LONG
        const PY_LONG_LONG llb = intval;
        PY_LONG_LONG lla, llx;
#endif
        const digit* digits = ((PyLongObject*)op1)->ob_digit;
        const Py_ssize_t size = Py_SIZE(op1);
        if (likely(__Pyx_sst_abs(size) <= 1)) {
            a = likely(size) ? digits[0] : 0;
            if (size == -1) a = -a;
        } else {
            switch (size) {
                case -2:
                    if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
                        a = -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
#ifdef HAVE_LONG_LONG
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) {
                        lla = -(PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
#endif
                    }
                    CYTHON_FALLTHROUGH;
                case 2:
                    if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
                        a = (long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
#ifdef HAVE_LONG_LONG
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) {
                        lla = (PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
#endif
                    }
                    CYTHON_FALLTHROUGH;
                case -3:
                    if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
                        a = -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
#ifdef HAVE_LONG_LONG
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) {
                        lla = -(PY_LONG_LONG) (((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
#endif
                    }
                    CYTHON_FALLTHROUGH;
                case 3:
                    if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
                        a = (long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
#ifdef HAVE_LONG_LONG
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) {
                        lla = (PY_LONG_LONG) (((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
#endif
                    }
                    CYTHON_FALLTHROUGH;
                case -4:
                    if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
                        a = -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
#ifdef HAVE_LONG_LONG
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) {
                        lla = -(PY_LONG_LONG) (((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
#endif
                    }
                    CYTHON_FALLTHROUGH;
                case 4:
                    if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
                        a = (long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
#ifdef HAVE_LONG_LONG
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) {
                        lla = (PY_LONG_LONG) (((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
#endif
                    }
                    CYTHON_FALLTHROUGH;
                default: return PyLong_Type.tp_as_number->nb_subtract(op1, op2);
            }
        }
                x = a - b;
            return PyLong_FromLong(x);
#ifdef HAVE_LONG_LONG
        long_long:
                llx = lla - llb;
            return PyLong_FromLongLong(llx);
#endif
        
        
    }
    #endif
    if (PyFloat_CheckExact(op1)) {
        const long b = intval;
        double a = PyFloat_AS_DOUBLE(op1);
            double result;
            PyFPE_START_PROTECT("subtract", return NULL)
            result = ((double)a) - (double)b;
            PyFPE_END_PROTECT(result)
            return PyFloat_FromDouble(result);
    }
    return (inplace ? PyNumber_InPlaceSubtract : PyNumber_Subtract)(op1, op2);
}
#endif

/* PyIntCompare */
  static CYTHON_INLINE PyObject* __Pyx_PyInt_EqObjC(PyObject *op1, PyObject *op2, CYTHON_UNUSED long intval, CYTHON_UNUSED long inplace) {
    if (op1 == op2) {
        Py_RETURN_TRUE;
    }
    #if PY_MAJOR_VERSION < 3
    if (likely(PyInt_CheckExact(op1))) {
        const long b = intval;
        long a = PyInt_AS_LONG(op1);
        if (a == b) Py_RETURN_TRUE; else Py_RETURN_FALSE;
    }
    #endif
    #if CYTHON_USE_PYLONG_INTERNALS
    if (likely(PyLong_CheckExact(op1))) {
        int unequal;
        unsigned long uintval;
        Py_ssize_t size = Py_SIZE(op1);
        const digit* digits = ((PyLongObject*)op1)->ob_digit;
        if (intval == 0) {
            if (size == 0) Py_RETURN_TRUE; else Py_RETURN_FALSE;
        } else if (intval < 0) {
            if (size >= 0)
                Py_RETURN_FALSE;
            intval = -intval;
            size = -size;
        } else {
            if (size <= 0)
                Py_RETURN_FALSE;
        }
        uintval = (unsigned long) intval;
#if PyLong_SHIFT * 4 < SIZEOF_LONG*8
        if (uintval >> (PyLong_SHIFT * 4)) {
            unequal = (size != 5) || (digits[0] != (uintval & (unsigned long) PyLong_MASK))
                 | (digits[1] != ((uintval >> (1 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[2] != ((uintval >> (2 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[3] != ((uintval >> (3 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[4] != ((uintval >> (4 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK));
        } else
#endif
#if PyLong_SHIFT * 3 < SIZEOF_LONG*8
        if (uintval >> (PyLong_SHIFT * 3)) {
            unequal = (size != 4) || (digits[0] != (uintval & (unsigned long) PyLong_MASK))
                 | (digits[1] != ((uintval >> (1 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[2] != ((uintval >> (2 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[3] != ((uintval >> (3 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK));
        } else
#endif
#if PyLong_SHIFT * 2 < SIZEOF_LONG*8
        if (uintval >> (PyLong_SHIFT * 2)) {
            unequal = (size != 3) || (digits[0] != (uintval & (unsigned long) PyLong_MASK))
                 | (digits[1] != ((uintval >> (1 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[2] != ((uintval >> (2 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK));
        } else
#endif
#if PyLong_SHIFT * 1 < SIZEOF_LONG*8
        if (uintval >> (PyLong_SHIFT * 1)) {
            unequal = (size != 2) || (digits[0] != (uintval & (unsigned long) PyLong_MASK))
                 | (digits[1] != ((uintval >> (1 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK));
        } else
#endif
            unequal = (size != 1) || (((unsigned long) digits[0]) != (uintval & (unsigned long) PyLong_MASK));
        if (unequal == 0) Py_RETURN_TRUE; else Py_RETURN_FALSE;
    }
    #endif
    if (PyFloat_CheckExact(op1)) {
        const long b = intval;
        double a = PyFloat_AS_DOUBLE(op1);
        if ((double)a == (double)b) Py_RETURN_TRUE; else Py_RETURN_FALSE;
    }
    return (
        PyObject_RichCompare(op1, op2, Py_EQ));
}

/* PyIntBinop */
  #if !CYTHON_COMPILING_IN_PYPY
#if PY_MAJOR_VERSION < 3 || CYTHON_USE_PYLONG_INTERNALS
#define __Pyx_PyInt_RemainderObjC_ZeroDivisionError(operand)\
    if (unlikely(zerodivision_check && ((operand) == 0))) {\
        PyErr_SetString(PyExc_ZeroDivisionError, "integer division or modulo by zero");\
        return NULL;\
    }
#endif
static PyObject* __Pyx_PyInt_RemainderObjC(PyObject *op1, PyObject *op2, CYTHON_UNUSED long intval, int inplace, int zerodivision_check) {
    (void)inplace;
    (void)zerodivision_check;
    #if PY_MAJOR_VERSION < 3
    if (likely(PyInt_CheckExact(op1))) {
        const long b = intval;
        long x;
        long a = PyInt_AS_LONG(op1);
            __Pyx_PyInt_RemainderObjC_ZeroDivisionError(b)
            x = a % b;
            x += ((x != 0) & ((x ^ b) < 0)) * b;
            return PyInt_FromLong(x);
    }
    #endif
    #if CYTHON_USE_PYLONG_INTERNALS
    if (likely(PyLong_CheckExact(op1))) {
        const long b = intval;
        long a, x;
#ifdef HAVE_LONG_LONG
        const PY_LONG_LONG llb = intval;
        PY_LONG_LONG lla, llx;
#endif
        const digit* digits = ((PyLongObject*)op1)->ob_digit;
        const Py_ssize_t size = Py_SIZE(op1);
        if (likely(__Pyx_sst_abs(size) <= 1)) {
            a = likely(size) ? digits[0] : 0;
            if (size == -1) a = -a;
        } else {
            switch (size) {
                case -2:
                    if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
                        a = -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
#ifdef HAVE_LONG_LONG
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) {
                        lla = -(PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
#endif
                    }
                    CYTHON_FALLTHROUGH;
                case 2:
                    if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
                        a = (long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
#ifdef HAVE_LONG_LONG
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) {
                        lla = (PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
#endif
                    }
                    CYTHON_FALLTHROUGH;
                case -3:
                    if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
                        a = -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
#ifdef HAVE_LONG_LONG
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) {
                        lla = -(PY_LONG_LONG) (((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
#endif
                    }
                    CYTHON_FALLTHROUGH;
                case 3:
                    if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
                        a = (long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
#ifdef HAVE_LONG_LONG
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) {
                        lla = (PY_LONG_LONG) (((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
#endif
                    }
                    CYTHON_FALLTHROUGH;
                case -4:
                    if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
                        a = -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
#ifdef HAVE_LONG_LONG
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) {
                        lla = -(PY_LONG_LONG) (((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
#endif
                    }
                    CYTHON_FALLTHROUGH;
                case 4:
                    if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
                        a = (long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
#ifdef HAVE_LONG_LONG
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) {
                        lla = (PY_LONG_LONG) (((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
#endif
                    }
                    CYTHON_FALLTHROUGH;
                default: return PyLong_Type.tp_as_number->nb_remainder(op1, op2);
            }
        }
                __Pyx_PyInt_RemainderObjC_ZeroDivisionError(b)
                x = a % b;
                x += ((x != 0) & ((x ^ b) < 0)) * b;
            return PyLong_FromLong(x);
#ifdef HAVE_LONG_LONG
        long_long:
                llx = lla % llb;
                llx += ((llx != 0) & ((llx ^ llb) < 0)) * llb;
            return PyLong_FromLongLong(llx);
#endif
        
        
    }
    #endif
    return (inplace ? PyNumber_InPlaceRemainder : PyNumber_Remainder)(op1, op2);
}
#endif

/* PyIntBinop */
  #if !CYTHON_COMPILING_IN_PYPY
#if PY_MAJOR_VERSION < 3 || CYTHON_USE_PYLONG_INTERNALS
#define __Pyx_PyInt_TrueDivideObjC_ZeroDivisionError(operand)\
    if (unlikely(zerodivision_check && ((operand) == 0))) {\
        PyErr_SetString(PyExc_ZeroDivisionError, "integer division by zero");\
        return NULL;\
    }
#endif
static PyObject* __Pyx_PyInt_TrueDivideObjC(PyObject *op1, PyObject *op2, CYTHON_UNUSED long intval, int inplace, int zerodivision_check) {
    (void)inplace;
    (void)zerodivision_check;
    #if PY_MAJOR_VERSION < 3
    if (likely(PyInt_CheckExact(op1))) {
        const long b = intval;
        long a = PyInt_AS_LONG(op1);
            __Pyx_PyInt_TrueDivideObjC_ZeroDivisionError(b)
            if (8 * sizeof(long) <= 53 || likely(labs(a) <= ((PY_LONG_LONG)1 << 53))) {
                return PyFloat_FromDouble((double)a / (double)b);
            }
            return PyInt_Type.tp_as_number->nb_true_divide(op1, op2);
    }
    #endif
    #if CYTHON_USE_PYLONG_INTERNALS
    if (likely(PyLong_CheckExact(op1))) {
        const long b = intval;
        long a, x;
        const digit* digits = ((PyLongObject*)op1)->ob_digit;
        const Py_ssize_t size = Py_SIZE(op1);
        if (likely(__Pyx_sst_abs(size) <= 1)) {
            a = likely(size) ? digits[0] : 0;
            if (size == -1) a = -a;
        } else {
            switch (size) {
                case -2:
                    if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT && 1 * PyLong_SHIFT < 53) {
                        a = -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
                    }
                    CYTHON_FALLTHROUGH;
                case 2:
                    if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT && 1 * PyLong_SHIFT < 53) {
                        a = (long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
                    }
                    CYTHON_FALLTHROUGH;
                case -3:
                    if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT && 2 * PyLong_SHIFT < 53) {
                        a = -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
                    }
                    CYTHON_FALLTHROUGH;
                case 3:
                    if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT && 2 * PyLong_SHIFT < 53) {
                        a = (long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
                    }
                    CYTHON_FALLTHROUGH;
                case -4:
                    if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT && 3 * PyLong_SHIFT < 53) {
                        a = -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
                    }
                    CYTHON_FALLTHROUGH;
                case 4:
                    if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT && 3 * PyLong_SHIFT < 53) {
                        a = (long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
                    }
                    CYTHON_FALLTHROUGH;
                default: return PyLong_Type.tp_as_number->nb_true_divide(op1, op2);
            }
        }
                __Pyx_PyInt_TrueDivideObjC_ZeroDivisionError(b)
                if ((8 * sizeof(long) <= 53 || likely(labs(a) <= ((PY_LONG_LONG)1 << 53)))
                        || __Pyx_sst_abs(size) <= 52 / PyLong_SHIFT) {
                    return PyFloat_FromDouble((double)a / (double)b);
                }
                return PyLong_Type.tp_as_number->nb_true_divide(op1, op2);
            return PyLong_FromLong(x);
        
    }
    #endif
    if (PyFloat_CheckExact(op1)) {
        const long b = intval;
        double a = PyFloat_AS_DOUBLE(op1);
            double result;
            if (unlikely(zerodivision_check && b == 0)) {
                PyErr_SetString(PyExc_ZeroDivisionError, "float division by zero");
                return NULL;
            }
            PyFPE_START_PROTECT("divide", return NULL)
            result = ((double)a) / (double)b;
            PyFPE_END_PROTECT(result)
            return PyFloat_FromDouble(result);
    }
    return (inplace ? PyNumber_InPlaceTrueDivide : PyNumber_TrueDivide)(op1, op2);
}
#endif

/* PyIntBinop */
  #if !CYTHON_COMPILING_IN_PYPY
static PyObject* __Pyx_PyInt_SubtractCObj(PyObject *op1, PyObject *op2, CYTHON_UNUSED long intval, int inplace, int zerodivision_check) {
    (void)inplace;
    (void)zerodivision_check;
    #if PY_MAJOR_VERSION < 3
    if (likely(PyInt_CheckExact(op2))) {
        const long a = intval;
        long x;
        long b = PyInt_AS_LONG(op2);
            x = (long)((unsigned long)a - b);
            if (likely((x^a) >= 0 || (x^~b) >= 0))
                return PyInt_FromLong(x);
            return PyLong_Type.tp_as_number->nb_subtract(op1, op2);
    }
    #endif
    #if CYTHON_USE_PYLONG_INTERNALS
    if (likely(PyLong_CheckExact(op2))) {
        const long a = intval;
        long b, x;
#ifdef HAVE_LONG_LONG
        const PY_LONG_LONG lla = intval;
        PY_LONG_LONG llb, llx;
#endif
        const digit* digits = ((PyLongObject*)op2)->ob_digit;
        const Py_ssize_t size = Py_SIZE(op2);
        if (likely(__Pyx_sst_abs(size) <= 1)) {
            b = likely(size) ? digits[0] : 0;
            if (size == -1) b = -b;
        } else {
            switch (size) {
                case -2:
                    if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
                        b = -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
#ifdef HAVE_LONG_LONG
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) {
                        llb = -(PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
#endif
                    }
                    CYTHON_FALLTHROUGH;
                case 2:
                    if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
                        b = (long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
#ifdef HAVE_LONG_LONG
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) {
                        llb = (PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
#endif
                    }
                    CYTHON_FALLTHROUGH;
                case -3:
                    if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
                        b = -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
#ifdef HAVE_LONG_LONG
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) {
                        llb = -(PY_LONG_LONG) (((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
#endif
                    }
                    CYTHON_FALLTHROUGH;
                case 3:
                    if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
                        b = (long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
#ifdef HAVE_LONG_LONG
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) {
                        llb = (PY_LONG_LONG) (((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
#endif
                    }
                    CYTHON_FALLTHROUGH;
                case -4:
                    if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
                        b = -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
#ifdef HAVE_LONG_LONG
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) {
                        llb = -(PY_LONG_LONG) (((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
#endif
                    }
                    CYTHON_FALLTHROUGH;
                case 4:
                    if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
                        b = (long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
#ifdef HAVE_LONG_LONG
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) {
                        llb = (PY_LONG_LONG) (((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
#endif
                    }
                    CYTHON_FALLTHROUGH;
                default: return PyLong_Type.tp_as_number->nb_subtract(op1, op2);
            }
        }
                x = a - b;
            return PyLong_FromLong(x);
#ifdef HAVE_LONG_LONG
        long_long:
                llx = lla - llb;
            return PyLong_FromLongLong(llx);
#endif
        
        
    }
    #endif
    if (PyFloat_CheckExact(op2)) {
        const long a = intval;
        double b = PyFloat_AS_DOUBLE(op2);
            double result;
            PyFPE_START_PROTECT("subtract", return NULL)
            result = ((double)a) - (double)b;
            PyFPE_END_PROTECT(result)
            return PyFloat_FromDouble(result);
    }
    return (inplace ? PyNumber_InPlaceSubtract : PyNumber_Subtract)(op1, op2);
}
#endif

/* Import */
  static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level) {
    PyObject *empty_list = 0;
    PyObject *module = 0;
    PyObject *global_dict = 0;
    PyObject *empty_dict = 0;
    PyObject *list;
    #if PY_MAJOR_VERSION < 3
    PyObject *py_import;
    py_import = __Pyx_PyObject_GetAttrStr(__pyx_b, __pyx_n_s_import);
    if (!py_import)
        goto bad;
    #endif
    if (from_list)
        list = from_list;
    else {
        empty_list = PyList_New(0);
        if (!empty_list)
            goto bad;
        list = empty_list;
    }
    global_dict = PyModule_GetDict(__pyx_m);
    if (!global_dict)
        goto bad;
    empty_dict = PyDict_New();
    if (!empty_dict)
        goto bad;
    {
        #if PY_MAJOR_VERSION >= 3
        if (level == -1) {
            if ((1) && (strchr(__Pyx_MODULE_NAME, '.'))) {
                module = PyImport_ImportModuleLevelObject(
                    name, global_dict, empty_dict, list, 1);
                if (!module) {
                    if (!PyErr_ExceptionMatches(PyExc_ImportError))
                        goto bad;
                    PyErr_Clear();
                }
            }
            level = 0;
        }
        #endif
        if (!module) {
            #if PY_MAJOR_VERSION < 3
            PyObject *py_level = PyInt_FromLong(level);
            if (!py_level)
                goto bad;
            module = PyObject_CallFunctionObjArgs(py_import,
                name, global_dict, empty_dict, list, py_level, (PyObject *)NULL);
            Py_DECREF(py_level);
            #else
            module = PyImport_ImportModuleLevelObject(
                name, global_dict, empty_dict, list, level);
            #endif
        }
    }
bad:
    #if PY_MAJOR_VERSION < 3
    Py_XDECREF(py_import);
    #endif
    Py_XDECREF(empty_list);
    Py_XDECREF(empty_dict);
    return module;
}

/* ImportFrom */
  static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name) {
    PyObject* value = __Pyx_PyObject_GetAttrStr(module, name);
    if (unlikely(!value) && PyErr_ExceptionMatches(PyExc_AttributeError)) {
        PyErr_Format(PyExc_ImportError,
        #if PY_MAJOR_VERSION < 3
            "cannot import name %.230s", PyString_AS_STRING(name));
        #else
            "cannot import name %S", name);
        #endif
    }
    return value;
}

/* PyObject_GenericGetAttrNoDict */
  #if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
static PyObject *__Pyx_RaiseGenericGetAttributeError(PyTypeObject *tp, PyObject *attr_name) {
    PyErr_Format(PyExc_AttributeError,
#if PY_MAJOR_VERSION >= 3
                 "'%.50s' object has no attribute '%U'",
                 tp->tp_name, attr_name);
#else
                 "'%.50s' object has no attribute '%.400s'",
                 tp->tp_name, PyString_AS_STRING(attr_name));
#endif
    return NULL;
}
static CYTHON_INLINE PyObject* __Pyx_PyObject_GenericGetAttrNoDict(PyObject* obj, PyObject* attr_name) {
    PyObject *descr;
    PyTypeObject *tp = Py_TYPE(obj);
    if (unlikely(!PyString_Check(attr_name))) {
        return PyObject_GenericGetAttr(obj, attr_name);
    }
    assert(!tp->tp_dictoffset);
    descr = _PyType_Lookup(tp, attr_name);
    if (unlikely(!descr)) {
        return __Pyx_RaiseGenericGetAttributeError(tp, attr_name);
    }
    Py_INCREF(descr);
    #if PY_MAJOR_VERSION < 3
    if (likely(PyType_HasFeature(Py_TYPE(descr), Py_TPFLAGS_HAVE_CLASS)))
    #endif
    {
        descrgetfunc f = Py_TYPE(descr)->tp_descr_get;
        if (unlikely(f)) {
            PyObject *res = f(descr, obj, (PyObject *)tp);
            Py_DECREF(descr);
            return res;
        }
    }
    return descr;
}
#endif

/* PyObject_GenericGetAttr */
  #if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
static PyObject* __Pyx_PyObject_GenericGetAttr(PyObject* obj, PyObject* attr_name) {
    if (unlikely(Py_TYPE(obj)->tp_dictoffset)) {
        return PyObject_GenericGetAttr(obj, attr_name);
    }
    return __Pyx_PyObject_GenericGetAttrNoDict(obj, attr_name);
}
#endif

/* PyObjectGetAttrStrNoError */
  static void __Pyx_PyObject_GetAttrStr_ClearAttributeError(void) {
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    if (likely(__Pyx_PyErr_ExceptionMatches(PyExc_AttributeError)))
        __Pyx_PyErr_Clear();
}
static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStrNoError(PyObject* obj, PyObject* attr_name) {
    PyObject *result;
#if CYTHON_COMPILING_IN_CPYTHON && CYTHON_USE_TYPE_SLOTS && PY_VERSION_HEX >= 0x030700B1
    PyTypeObject* tp = Py_TYPE(obj);
    if (likely(tp->tp_getattro == PyObject_GenericGetAttr)) {
        return _PyObject_GenericGetAttrWithDict(obj, attr_name, NULL, 1);
    }
#endif
    result = __Pyx_PyObject_GetAttrStr(obj, attr_name);
    if (unlikely(!result)) {
        __Pyx_PyObject_GetAttrStr_ClearAttributeError();
    }
    return result;
}

/* SetupReduce */
  static int __Pyx_setup_reduce_is_named(PyObject* meth, PyObject* name) {
  int ret;
  PyObject *name_attr;
  name_attr = __Pyx_PyObject_GetAttrStr(meth, __pyx_n_s_name);
  if (likely(name_attr)) {
      ret = PyObject_RichCompareBool(name_attr, name, Py_EQ);
  } else {
      ret = -1;
  }
  if (unlikely(ret < 0)) {
      PyErr_Clear();
      ret = 0;
  }
  Py_XDECREF(name_attr);
  return ret;
}
static int __Pyx_setup_reduce(PyObject* type_obj) {
    int ret = 0;
    PyObject *object_reduce = NULL;
    PyObject *object_getstate = NULL;
    PyObject *object_reduce_ex = NULL;
    PyObject *reduce = NULL;
    PyObject *reduce_ex = NULL;
    PyObject *reduce_cython = NULL;
    PyObject *setstate = NULL;
    PyObject *setstate_cython = NULL;
    PyObject *getstate = NULL;
#if CYTHON_USE_PYTYPE_LOOKUP
    getstate = _PyType_Lookup((PyTypeObject*)type_obj, __pyx_n_s_getstate);
#else
    getstate = __Pyx_PyObject_GetAttrStrNoError(type_obj, __pyx_n_s_getstate);
    if (!getstate && PyErr_Occurred()) {
        goto __PYX_BAD;
    }
#endif
    if (getstate) {
#if CYTHON_USE_PYTYPE_LOOKUP
        object_getstate = _PyType_Lookup(&PyBaseObject_Type, __pyx_n_s_getstate);
#else
        object_getstate = __Pyx_PyObject_GetAttrStrNoError((PyObject*)&PyBaseObject_Type, __pyx_n_s_getstate);
        if (!object_getstate && PyErr_Occurred()) {
            goto __PYX_BAD;
        }
#endif
        if (object_getstate != getstate) {
            goto __PYX_GOOD;
        }
    }
#if CYTHON_USE_PYTYPE_LOOKUP
    object_reduce_ex = _PyType_Lookup(&PyBaseObject_Type, __pyx_n_s_reduce_ex); if (!object_reduce_ex) goto __PYX_BAD;
#else
    object_reduce_ex = __Pyx_PyObject_GetAttrStr((PyObject*)&PyBaseObject_Type, __pyx_n_s_reduce_ex); if (!object_reduce_ex) goto __PYX_BAD;
#endif
    reduce_ex = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_reduce_ex); if (unlikely(!reduce_ex)) goto __PYX_BAD;
    if (reduce_ex == object_reduce_ex) {
#if CYTHON_USE_PYTYPE_LOOKUP
        object_reduce = _PyType_Lookup(&PyBaseObject_Type, __pyx_n_s_reduce); if (!object_reduce) goto __PYX_BAD;
#else
        object_reduce = __Pyx_PyObject_GetAttrStr((PyObject*)&PyBaseObject_Type, __pyx_n_s_reduce); if (!object_reduce) goto __PYX_BAD;
#endif
        reduce = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_reduce); if (unlikely(!reduce)) goto __PYX_BAD;
        if (reduce == object_reduce || __Pyx_setup_reduce_is_named(reduce, __pyx_n_s_reduce_cython)) {
            reduce_cython = __Pyx_PyObject_GetAttrStrNoError(type_obj, __pyx_n_s_reduce_cython);
            if (likely(reduce_cython)) {
                ret = PyDict_SetItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_reduce, reduce_cython); if (unlikely(ret < 0)) goto __PYX_BAD;
                ret = PyDict_DelItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_reduce_cython); if (unlikely(ret < 0)) goto __PYX_BAD;
            } else if (reduce == object_reduce || PyErr_Occurred()) {
                goto __PYX_BAD;
            }
            setstate = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_setstate);
            if (!setstate) PyErr_Clear();
            if (!setstate || __Pyx_setup_reduce_is_named(setstate, __pyx_n_s_setstate_cython)) {
                setstate_cython = __Pyx_PyObject_GetAttrStrNoError(type_obj, __pyx_n_s_setstate_cython);
                if (likely(setstate_cython)) {
                    ret = PyDict_SetItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_setstate, setstate_cython); if (unlikely(ret < 0)) goto __PYX_BAD;
                    ret = PyDict_DelItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_setstate_cython); if (unlikely(ret < 0)) goto __PYX_BAD;
                } else if (!setstate || PyErr_Occurred()) {
                    goto __PYX_BAD;
                }
            }
            PyType_Modified((PyTypeObject*)type_obj);
        }
    }
    goto __PYX_GOOD;
__PYX_BAD:
    if (!PyErr_Occurred())
        PyErr_Format(PyExc_RuntimeError, "Unable to initialize pickling for %s", ((PyTypeObject*)type_obj)->tp_name);
    ret = -1;
__PYX_GOOD:
#if !CYTHON_USE_PYTYPE_LOOKUP
    Py_XDECREF(object_reduce);
    Py_XDECREF(object_reduce_ex);
    Py_XDECREF(object_getstate);
    Py_XDECREF(getstate);
#endif
    Py_XDECREF(reduce);
    Py_XDECREF(reduce_ex);
    Py_XDECREF(reduce_cython);
    Py_XDECREF(setstate);
    Py_XDECREF(setstate_cython);
    return ret;
}

/* SetVTable */
  static int __Pyx_SetVtable(PyObject *dict, void *vtable) {
#if PY_VERSION_HEX >= 0x02070000
    PyObject *ob = PyCapsule_New(vtable, 0, 0);
#else
    PyObject *ob = PyCObject_FromVoidPtr(vtable, 0);
#endif
    if (!ob)
        goto bad;
    if (PyDict_SetItem(dict, __pyx_n_s_pyx_vtable, ob) < 0)
        goto bad;
    Py_DECREF(ob);
    return 0;
bad:
    Py_XDECREF(ob);
    return -1;
}

/* CalculateMetaclass */
  static PyObject *__Pyx_CalculateMetaclass(PyTypeObject *metaclass, PyObject *bases) {
    Py_ssize_t i, nbases = PyTuple_GET_SIZE(bases);
    for (i=0; i < nbases; i++) {
        PyTypeObject *tmptype;
        PyObject *tmp = PyTuple_GET_ITEM(bases, i);
        tmptype = Py_TYPE(tmp);
#if PY_MAJOR_VERSION < 3
        if (tmptype == &PyClass_Type)
            continue;
#endif
        if (!metaclass) {
            metaclass = tmptype;
            continue;
        }
        if (PyType_IsSubtype(metaclass, tmptype))
            continue;
        if (PyType_IsSubtype(tmptype, metaclass)) {
            metaclass = tmptype;
            continue;
        }
        PyErr_SetString(PyExc_TypeError,
                        "metaclass conflict: "
                        "the metaclass of a derived class "
                        "must be a (non-strict) subclass "
                        "of the metaclasses of all its bases");
        return NULL;
    }
    if (!metaclass) {
#if PY_MAJOR_VERSION < 3
        metaclass = &PyClass_Type;
#else
        metaclass = &PyType_Type;
#endif
    }
    Py_INCREF((PyObject*) metaclass);
    return (PyObject*) metaclass;
}

/* Py3ClassCreate */
  static PyObject *__Pyx_Py3MetaclassPrepare(PyObject *metaclass, PyObject *bases, PyObject *name,
                                           PyObject *qualname, PyObject *mkw, PyObject *modname, PyObject *doc) {
    PyObject *ns;
    if (metaclass) {
        PyObject *prep = __Pyx_PyObject_GetAttrStr(metaclass, __pyx_n_s_prepare);
        if (prep) {
            PyObject *pargs = PyTuple_Pack(2, name, bases);
            if (unlikely(!pargs)) {
                Py_DECREF(prep);
                return NULL;
            }
            ns = PyObject_Call(prep, pargs, mkw);
            Py_DECREF(prep);
            Py_DECREF(pargs);
        } else {
            if (unlikely(!PyErr_ExceptionMatches(PyExc_AttributeError)))
                return NULL;
            PyErr_Clear();
            ns = PyDict_New();
        }
    } else {
        ns = PyDict_New();
    }
    if (unlikely(!ns))
        return NULL;
    if (unlikely(PyObject_SetItem(ns, __pyx_n_s_module, modname) < 0)) goto bad;
    if (unlikely(PyObject_SetItem(ns, __pyx_n_s_qualname, qualname) < 0)) goto bad;
    if (unlikely(doc && PyObject_SetItem(ns, __pyx_n_s_doc, doc) < 0)) goto bad;
    return ns;
bad:
    Py_DECREF(ns);
    return NULL;
}
static PyObject *__Pyx_Py3ClassCreate(PyObject *metaclass, PyObject *name, PyObject *bases,
                                      PyObject *dict, PyObject *mkw,
                                      int calculate_metaclass, int allow_py2_metaclass) {
    PyObject *result, *margs;
    PyObject *owned_metaclass = NULL;
    if (allow_py2_metaclass) {
        owned_metaclass = PyObject_GetItem(dict, __pyx_n_s_metaclass);
        if (owned_metaclass) {
            metaclass = owned_metaclass;
        } else if (likely(PyErr_ExceptionMatches(PyExc_KeyError))) {
            PyErr_Clear();
        } else {
            return NULL;
        }
    }
    if (calculate_metaclass && (!metaclass || PyType_Check(metaclass))) {
        metaclass = __Pyx_CalculateMetaclass((PyTypeObject*) metaclass, bases);
        Py_XDECREF(owned_metaclass);
        if (unlikely(!metaclass))
            return NULL;
        owned_metaclass = metaclass;
    }
    margs = PyTuple_Pack(3, name, bases, dict);
    if (unlikely(!margs)) {
        result = NULL;
    } else {
        result = PyObject_Call(metaclass, margs, mkw);
        Py_DECREF(margs);
    }
    Py_XDECREF(owned_metaclass);
    return result;
}

/* ClassMethod */
  static PyObject* __Pyx_Method_ClassMethod(PyObject *method) {
#if CYTHON_COMPILING_IN_PYPY && PYPY_VERSION_NUM <= 0x05080000
    if (PyObject_TypeCheck(method, &PyWrapperDescr_Type)) {
        return PyClassMethod_New(method);
    }
#else
#if CYTHON_COMPILING_IN_PYSTON || CYTHON_COMPILING_IN_PYPY
    if (PyMethodDescr_Check(method))
#else
    #if PY_MAJOR_VERSION == 2
    static PyTypeObject *methoddescr_type = NULL;
    if (methoddescr_type == NULL) {
       PyObject *meth = PyObject_GetAttrString((PyObject*)&PyList_Type, "append");
       if (!meth) return NULL;
       methoddescr_type = Py_TYPE(meth);
       Py_DECREF(meth);
    }
    #else
    PyTypeObject *methoddescr_type = &PyMethodDescr_Type;
    #endif
    if (__Pyx_TypeCheck(method, methoddescr_type))
#endif
    {
        PyMethodDescrObject *descr = (PyMethodDescrObject *)method;
        #if PY_VERSION_HEX < 0x03020000
        PyTypeObject *d_type = descr->d_type;
        #else
        PyTypeObject *d_type = descr->d_common.d_type;
        #endif
        return PyDescr_NewClassMethod(d_type, descr->d_method);
    }
#endif
    else if (PyMethod_Check(method)) {
        return PyClassMethod_New(PyMethod_GET_FUNCTION(method));
    }
    else {
        return PyClassMethod_New(method);
    }
}

/* CLineInTraceback */
  #ifndef CYTHON_CLINE_IN_TRACEBACK
static int __Pyx_CLineForTraceback(CYTHON_UNUSED PyThreadState *tstate, int c_line) {
    PyObject *use_cline;
    PyObject *ptype, *pvalue, *ptraceback;
#if CYTHON_COMPILING_IN_CPYTHON
    PyObject **cython_runtime_dict;
#endif
    if (unlikely(!__pyx_cython_runtime)) {
        return c_line;
    }
    __Pyx_ErrFetchInState(tstate, &ptype, &pvalue, &ptraceback);
#if CYTHON_COMPILING_IN_CPYTHON
    cython_runtime_dict = _PyObject_GetDictPtr(__pyx_cython_runtime);
    if (likely(cython_runtime_dict)) {
        __PYX_PY_DICT_LOOKUP_IF_MODIFIED(
            use_cline, *cython_runtime_dict,
            __Pyx_PyDict_GetItemStr(*cython_runtime_dict, __pyx_n_s_cline_in_traceback))
    } else
#endif
    {
      PyObject *use_cline_obj = __Pyx_PyObject_GetAttrStr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback);
      if (use_cline_obj) {
        use_cline = PyObject_Not(use_cline_obj) ? Py_False : Py_True;
        Py_DECREF(use_cline_obj);
      } else {
        PyErr_Clear();
        use_cline = NULL;
      }
    }
    if (!use_cline) {
        c_line = 0;
        (void) PyObject_SetAttr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback, Py_False);
    }
    else if (use_cline == Py_False || (use_cline != Py_True && PyObject_Not(use_cline) != 0)) {
        c_line = 0;
    }
    __Pyx_ErrRestoreInState(tstate, ptype, pvalue, ptraceback);
    return c_line;
}
#endif

/* CodeObjectCache */
  static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) {
    int start = 0, mid = 0, end = count - 1;
    if (end >= 0 && code_line > entries[end].code_line) {
        return count;
    }
    while (start < end) {
        mid = start + (end - start) / 2;
        if (code_line < entries[mid].code_line) {
            end = mid;
        } else if (code_line > entries[mid].code_line) {
             start = mid + 1;
        } else {
            return mid;
        }
    }
    if (code_line <= entries[mid].code_line) {
        return mid;
    } else {
        return mid + 1;
    }
}
static PyCodeObject *__pyx_find_code_object(int code_line) {
    PyCodeObject* code_object;
    int pos;
    if (unlikely(!code_line) || unlikely(!__pyx_code_cache.entries)) {
        return NULL;
    }
    pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
    if (unlikely(pos >= __pyx_code_cache.count) || unlikely(__pyx_code_cache.entries[pos].code_line != code_line)) {
        return NULL;
    }
    code_object = __pyx_code_cache.entries[pos].code_object;
    Py_INCREF(code_object);
    return code_object;
}
static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) {
    int pos, i;
    __Pyx_CodeObjectCacheEntry* entries = __pyx_code_cache.entries;
    if (unlikely(!code_line)) {
        return;
    }
    if (unlikely(!entries)) {
        entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Malloc(64*sizeof(__Pyx_CodeObjectCacheEntry));
        if (likely(entries)) {
            __pyx_code_cache.entries = entries;
            __pyx_code_cache.max_count = 64;
            __pyx_code_cache.count = 1;
            entries[0].code_line = code_line;
            entries[0].code_object = code_object;
            Py_INCREF(code_object);
        }
        return;
    }
    pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
    if ((pos < __pyx_code_cache.count) && unlikely(__pyx_code_cache.entries[pos].code_line == code_line)) {
        PyCodeObject* tmp = entries[pos].code_object;
        entries[pos].code_object = code_object;
        Py_DECREF(tmp);
        return;
    }
    if (__pyx_code_cache.count == __pyx_code_cache.max_count) {
        int new_max = __pyx_code_cache.max_count + 64;
        entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Realloc(
            __pyx_code_cache.entries, ((size_t)new_max) * sizeof(__Pyx_CodeObjectCacheEntry));
        if (unlikely(!entries)) {
            return;
        }
        __pyx_code_cache.entries = entries;
        __pyx_code_cache.max_count = new_max;
    }
    for (i=__pyx_code_cache.count; i>pos; i--) {
        entries[i] = entries[i-1];
    }
    entries[pos].code_line = code_line;
    entries[pos].code_object = code_object;
    __pyx_code_cache.count++;
    Py_INCREF(code_object);
}

/* AddTraceback */
  #include "compile.h"
#include "frameobject.h"
#include "traceback.h"
#if PY_VERSION_HEX >= 0x030b00a6
  #ifndef Py_BUILD_CORE
    #define Py_BUILD_CORE 1
  #endif
  #include "internal/pycore_frame.h"
#endif
static PyCodeObject* __Pyx_CreateCodeObjectForTraceback(
            const char *funcname, int c_line,
            int py_line, const char *filename) {
    PyCodeObject *py_code = NULL;
    PyObject *py_funcname = NULL;
    #if PY_MAJOR_VERSION < 3
    PyObject *py_srcfile = NULL;
    py_srcfile = PyString_FromString(filename);
    if (!py_srcfile) goto bad;
    #endif
    if (c_line) {
        #if PY_MAJOR_VERSION < 3
        py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
        if (!py_funcname) goto bad;
        #else
        py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
        if (!py_funcname) goto bad;
        funcname = PyUnicode_AsUTF8(py_funcname);
        if (!funcname) goto bad;
        #endif
    }
    else {
        #if PY_MAJOR_VERSION < 3
        py_funcname = PyString_FromString(funcname);
        if (!py_funcname) goto bad;
        #endif
    }
    #if PY_MAJOR_VERSION < 3
    py_code = __Pyx_PyCode_New(
        0,
        0,
        0,
        0,
        0,
        __pyx_empty_bytes, /*PyObject *code,*/
        __pyx_empty_tuple, /*PyObject *consts,*/
        __pyx_empty_tuple, /*PyObject *names,*/
        __pyx_empty_tuple, /*PyObject *varnames,*/
        __pyx_empty_tuple, /*PyObject *freevars,*/
        __pyx_empty_tuple, /*PyObject *cellvars,*/
        py_srcfile,   /*PyObject *filename,*/
        py_funcname,  /*PyObject *name,*/
        py_line,
        __pyx_empty_bytes  /*PyObject *lnotab*/
    );
    Py_DECREF(py_srcfile);
    #else
    py_code = PyCode_NewEmpty(filename, funcname, py_line);
    #endif
    Py_XDECREF(py_funcname);  // XDECREF since it's only set on Py3 if cline
    return py_code;
bad:
    Py_XDECREF(py_funcname);
    #if PY_MAJOR_VERSION < 3
    Py_XDECREF(py_srcfile);
    #endif
    return NULL;
}
static void __Pyx_AddTraceback(const char *funcname, int c_line,
                               int py_line, const char *filename) {
    PyCodeObject *py_code = 0;
    PyFrameObject *py_frame = 0;
    PyThreadState *tstate = __Pyx_PyThreadState_Current;
    PyObject *ptype, *pvalue, *ptraceback;
    if (c_line) {
        c_line = __Pyx_CLineForTraceback(tstate, c_line);
    }
    py_code = __pyx_find_code_object(c_line ? -c_line : py_line);
    if (!py_code) {
        __Pyx_ErrFetchInState(tstate, &ptype, &pvalue, &ptraceback);
        py_code = __Pyx_CreateCodeObjectForTraceback(
            funcname, c_line, py_line, filename);
        if (!py_code) {
            /* If the code object creation fails, then we should clear the
               fetched exception references and propagate the new exception */
            Py_XDECREF(ptype);
            Py_XDECREF(pvalue);
            Py_XDECREF(ptraceback);
            goto bad;
        }
        __Pyx_ErrRestoreInState(tstate, ptype, pvalue, ptraceback);
        __pyx_insert_code_object(c_line ? -c_line : py_line, py_code);
    }
    py_frame = PyFrame_New(
        tstate,            /*PyThreadState *tstate,*/
        py_code,           /*PyCodeObject *code,*/
        __pyx_d,    /*PyObject *globals,*/
        0                  /*PyObject *locals*/
    );
    if (!py_frame) goto bad;
    __Pyx_PyFrame_SetLineNumber(py_frame, py_line);
    PyTraceBack_Here(py_frame);
bad:
    Py_XDECREF(py_code);
    Py_XDECREF(py_frame);
}

/* CIntFromPyVerify */
  #define __PYX_VERIFY_RETURN_INT(target_type, func_type, func_value)\
    __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 0)
#define __PYX_VERIFY_RETURN_INT_EXC(target_type, func_type, func_value)\
    __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 1)
#define __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, exc)\
    {\
        func_type value = func_value;\
        if (sizeof(target_type) < sizeof(func_type)) {\
            if (unlikely(value != (func_type) (target_type) value)) {\
                func_type zero = 0;\
                if (exc && unlikely(value == (func_type)-1 && PyErr_Occurred()))\
                    return (target_type) -1;\
                if (is_unsigned && unlikely(value < zero))\
                    goto raise_neg_overflow;\
                else\
                    goto raise_overflow;\
            }\
        }\
        return (target_type) value;\
    }

/* CIntToPy */
  static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int64_t(int64_t value) {
#ifdef __Pyx_HAS_GCC_DIAGNOSTIC
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wconversion"
#endif
    const int64_t neg_one = (int64_t) -1, const_zero = (int64_t) 0;
#ifdef __Pyx_HAS_GCC_DIAGNOSTIC
#pragma GCC diagnostic pop
#endif
    const int is_unsigned = neg_one > const_zero;
    if (is_unsigned) {
        if (sizeof(int64_t) < sizeof(long)) {
            return PyInt_FromLong((long) value);
        } else if (sizeof(int64_t) <= sizeof(unsigned long)) {
            return PyLong_FromUnsignedLong((unsigned long) value);
#ifdef HAVE_LONG_LONG
        } else if (sizeof(int64_t) <= sizeof(unsigned PY_LONG_LONG)) {
            return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
#endif
        }
    } else {
        if (sizeof(int64_t) <= sizeof(long)) {
            return PyInt_FromLong((long) value);
#ifdef HAVE_LONG_LONG
        } else if (sizeof(int64_t) <= sizeof(PY_LONG_LONG)) {
            return PyLong_FromLongLong((PY_LONG_LONG) value);
#endif
        }
    }
    {
        int one = 1; int little = (int)*(unsigned char *)&one;
        unsigned char *bytes = (unsigned char *)&value;
        return _PyLong_FromByteArray(bytes, sizeof(int64_t),
                                     little, !is_unsigned);
    }
}

/* CIntFromPy */
  static CYTHON_INLINE int64_t __Pyx_PyInt_As_int64_t(PyObject *x) {
#ifdef __Pyx_HAS_GCC_DIAGNOSTIC
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wconversion"
#endif
    const int64_t neg_one = (int64_t) -1, const_zero = (int64_t) 0;
#ifdef __Pyx_HAS_GCC_DIAGNOSTIC
#pragma GCC diagnostic pop
#endif
    const int is_unsigned = neg_one > const_zero;
#if PY_MAJOR_VERSION < 3
    if (likely(PyInt_Check(x))) {
        if (sizeof(int64_t) < sizeof(long)) {
            __PYX_VERIFY_RETURN_INT(int64_t, long, PyInt_AS_LONG(x))
        } else {
            long val = PyInt_AS_LONG(x);
            if (is_unsigned && unlikely(val < 0)) {
                goto raise_neg_overflow;
            }
            return (int64_t) val;
        }
    } else
#endif
    if (likely(PyLong_Check(x))) {
        if (is_unsigned) {
#if CYTHON_USE_PYLONG_INTERNALS
            const digit* digits = ((PyLongObject*)x)->ob_digit;
            switch (Py_SIZE(x)) {
                case  0: return (int64_t) 0;
                case  1: __PYX_VERIFY_RETURN_INT(int64_t, digit, digits[0])
                case 2:
                    if (8 * sizeof(int64_t) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int64_t, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int64_t) >= 2 * PyLong_SHIFT) {
                            return (int64_t) (((((int64_t)digits[1]) << PyLong_SHIFT) | (int64_t)digits[0]));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(int64_t) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int64_t, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int64_t) >= 3 * PyLong_SHIFT) {
                            return (int64_t) (((((((int64_t)digits[2]) << PyLong_SHIFT) | (int64_t)digits[1]) << PyLong_SHIFT) | (int64_t)digits[0]));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(int64_t) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int64_t, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int64_t) >= 4 * PyLong_SHIFT) {
                            return (int64_t) (((((((((int64_t)digits[3]) << PyLong_SHIFT) | (int64_t)digits[2]) << PyLong_SHIFT) | (int64_t)digits[1]) << PyLong_SHIFT) | (int64_t)digits[0]));
                        }
                    }
                    break;
            }
#endif
#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX < 0x030C00A7
            if (unlikely(Py_SIZE(x) < 0)) {
                goto raise_neg_overflow;
            }
#else
            {
                int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
                if (unlikely(result < 0))
                    return (int64_t) -1;
                if (unlikely(result == 1))
                    goto raise_neg_overflow;
            }
#endif
            if (sizeof(int64_t) <= sizeof(unsigned long)) {
                __PYX_VERIFY_RETURN_INT_EXC(int64_t, unsigned long, PyLong_AsUnsignedLong(x))
#ifdef HAVE_LONG_LONG
            } else if (sizeof(int64_t) <= sizeof(unsigned PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(int64_t, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
#endif
            }
        } else {
#if CYTHON_USE_PYLONG_INTERNALS
            const digit* digits = ((PyLongObject*)x)->ob_digit;
            switch (Py_SIZE(x)) {
                case  0: return (int64_t) 0;
                case -1: __PYX_VERIFY_RETURN_INT(int64_t, sdigit, (sdigit) (-(sdigit)digits[0]))
                case  1: __PYX_VERIFY_RETURN_INT(int64_t,  digit, +digits[0])
                case -2:
                    if (8 * sizeof(int64_t) - 1 > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int64_t, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int64_t) - 1 > 2 * PyLong_SHIFT) {
                            return (int64_t) (((int64_t)-1)*(((((int64_t)digits[1]) << PyLong_SHIFT) | (int64_t)digits[0])));
                        }
                    }
                    break;
                case 2:
                    if (8 * sizeof(int64_t) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int64_t, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int64_t) - 1 > 2 * PyLong_SHIFT) {
                            return (int64_t) ((((((int64_t)digits[1]) << PyLong_SHIFT) | (int64_t)digits[0])));
                        }
                    }
                    break;
                case -3:
                    if (8 * sizeof(int64_t) - 1 > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int64_t, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int64_t) - 1 > 3 * PyLong_SHIFT) {
                            return (int64_t) (((int64_t)-1)*(((((((int64_t)digits[2]) << PyLong_SHIFT) | (int64_t)digits[1]) << PyLong_SHIFT) | (int64_t)digits[0])));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(int64_t) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int64_t, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int64_t) - 1 > 3 * PyLong_SHIFT) {
                            return (int64_t) ((((((((int64_t)digits[2]) << PyLong_SHIFT) | (int64_t)digits[1]) << PyLong_SHIFT) | (int64_t)digits[0])));
                        }
                    }
                    break;
                case -4:
                    if (8 * sizeof(int64_t) - 1 > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int64_t, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int64_t) - 1 > 4 * PyLong_SHIFT) {
                            return (int64_t) (((int64_t)-1)*(((((((((int64_t)digits[3]) << PyLong_SHIFT) | (int64_t)digits[2]) << PyLong_SHIFT) | (int64_t)digits[1]) << PyLong_SHIFT) | (int64_t)digits[0])));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(int64_t) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int64_t, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int64_t) - 1 > 4 * PyLong_SHIFT) {
                            return (int64_t) ((((((((((int64_t)digits[3]) << PyLong_SHIFT) | (int64_t)digits[2]) << PyLong_SHIFT) | (int64_t)digits[1]) << PyLong_SHIFT) | (int64_t)digits[0])));
                        }
                    }
                    break;
            }
#endif
            if (sizeof(int64_t) <= sizeof(long)) {
                __PYX_VERIFY_RETURN_INT_EXC(int64_t, long, PyLong_AsLong(x))
#ifdef HAVE_LONG_LONG
            } else if (sizeof(int64_t) <= sizeof(PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(int64_t, PY_LONG_LONG, PyLong_AsLongLong(x))
#endif
            }
        }
        {
#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
            PyErr_SetString(PyExc_RuntimeError,
                            "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
#else
            int64_t val;
            PyObject *v = __Pyx_PyNumber_IntOrLong(x);
 #if PY_MAJOR_VERSION < 3
            if (likely(v) && !PyLong_Check(v)) {
                PyObject *tmp = v;
                v = PyNumber_Long(tmp);
                Py_DECREF(tmp);
            }
 #endif
            if (likely(v)) {
                int one = 1; int is_little = (int)*(unsigned char *)&one;
                unsigned char *bytes = (unsigned char *)&val;
                int ret = _PyLong_AsByteArray((PyLongObject *)v,
                                              bytes, sizeof(val),
                                              is_little, !is_unsigned);
                Py_DECREF(v);
                if (likely(!ret))
                    return val;
            }
#endif
            return (int64_t) -1;
        }
    } else {
        int64_t val;
        PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
        if (!tmp) return (int64_t) -1;
        val = __Pyx_PyInt_As_int64_t(tmp);
        Py_DECREF(tmp);
        return val;
    }
raise_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "value too large to convert to int64_t");
    return (int64_t) -1;
raise_neg_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "can't convert negative value to int64_t");
    return (int64_t) -1;
}

/* CIntFromPy */
  static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) {
#ifdef __Pyx_HAS_GCC_DIAGNOSTIC
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wconversion"
#endif
    const long neg_one = (long) -1, const_zero = (long) 0;
#ifdef __Pyx_HAS_GCC_DIAGNOSTIC
#pragma GCC diagnostic pop
#endif
    const int is_unsigned = neg_one > const_zero;
#if PY_MAJOR_VERSION < 3
    if (likely(PyInt_Check(x))) {
        if (sizeof(long) < sizeof(long)) {
            __PYX_VERIFY_RETURN_INT(long, long, PyInt_AS_LONG(x))
        } else {
            long val = PyInt_AS_LONG(x);
            if (is_unsigned && unlikely(val < 0)) {
                goto raise_neg_overflow;
            }
            return (long) val;
        }
    } else
#endif
    if (likely(PyLong_Check(x))) {
        if (is_unsigned) {
#if CYTHON_USE_PYLONG_INTERNALS
            const digit* digits = ((PyLongObject*)x)->ob_digit;
            switch (Py_SIZE(x)) {
                case  0: return (long) 0;
                case  1: __PYX_VERIFY_RETURN_INT(long, digit, digits[0])
                case 2:
                    if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(long) >= 2 * PyLong_SHIFT) {
                            return (long) (((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(long) >= 3 * PyLong_SHIFT) {
                            return (long) (((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(long) >= 4 * PyLong_SHIFT) {
                            return (long) (((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
                        }
                    }
                    break;
            }
#endif
#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX < 0x030C00A7
            if (unlikely(Py_SIZE(x) < 0)) {
                goto raise_neg_overflow;
            }
#else
            {
                int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
                if (unlikely(result < 0))
                    return (long) -1;
                if (unlikely(result == 1))
                    goto raise_neg_overflow;
            }
#endif
            if (sizeof(long) <= sizeof(unsigned long)) {
                __PYX_VERIFY_RETURN_INT_EXC(long, unsigned long, PyLong_AsUnsignedLong(x))
#ifdef HAVE_LONG_LONG
            } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(long, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
#endif
            }
        } else {
#if CYTHON_USE_PYLONG_INTERNALS
            const digit* digits = ((PyLongObject*)x)->ob_digit;
            switch (Py_SIZE(x)) {
                case  0: return (long) 0;
                case -1: __PYX_VERIFY_RETURN_INT(long, sdigit, (sdigit) (-(sdigit)digits[0]))
                case  1: __PYX_VERIFY_RETURN_INT(long,  digit, +digits[0])
                case -2:
                    if (8 * sizeof(long) - 1 > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
                            return (long) (((long)-1)*(((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
                        }
                    }
                    break;
                case 2:
                    if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
                            return (long) ((((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
                        }
                    }
                    break;
                case -3:
                    if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
                            return (long) (((long)-1)*(((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
                            return (long) ((((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
                        }
                    }
                    break;
                case -4:
                    if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
                            return (long) (((long)-1)*(((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
                            return (long) ((((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
                        }
                    }
                    break;
            }
#endif
            if (sizeof(long) <= sizeof(long)) {
                __PYX_VERIFY_RETURN_INT_EXC(long, long, PyLong_AsLong(x))
#ifdef HAVE_LONG_LONG
            } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(long, PY_LONG_LONG, PyLong_AsLongLong(x))
#endif
            }
        }
        {
#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
            PyErr_SetString(PyExc_RuntimeError,
                            "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
#else
            long val;
            PyObject *v = __Pyx_PyNumber_IntOrLong(x);
 #if PY_MAJOR_VERSION < 3
            if (likely(v) && !PyLong_Check(v)) {
                PyObject *tmp = v;
                v = PyNumber_Long(tmp);
                Py_DECREF(tmp);
            }
 #endif
            if (likely(v)) {
                int one = 1; int is_little = (int)*(unsigned char *)&one;
                unsigned char *bytes = (unsigned char *)&val;
                int ret = _PyLong_AsByteArray((PyLongObject *)v,
                                              bytes, sizeof(val),
                                              is_little, !is_unsigned);
                Py_DECREF(v);
                if (likely(!ret))
                    return val;
            }
#endif
            return (long) -1;
        }
    } else {
        long val;
        PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
        if (!tmp) return (long) -1;
        val = __Pyx_PyInt_As_long(tmp);
        Py_DECREF(tmp);
        return val;
    }
raise_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "value too large to convert to long");
    return (long) -1;
raise_neg_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "can't convert negative value to long");
    return (long) -1;
}

/* CIntToPy */
  static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) {
#ifdef __Pyx_HAS_GCC_DIAGNOSTIC
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wconversion"
#endif
    const long neg_one = (long) -1, const_zero = (long) 0;
#ifdef __Pyx_HAS_GCC_DIAGNOSTIC
#pragma GCC diagnostic pop
#endif
    const int is_unsigned = neg_one > const_zero;
    if (is_unsigned) {
        if (sizeof(long) < sizeof(long)) {
            return PyInt_FromLong((long) value);
        } else if (sizeof(long) <= sizeof(unsigned long)) {
            return PyLong_FromUnsignedLong((unsigned long) value);
#ifdef HAVE_LONG_LONG
        } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
            return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
#endif
        }
    } else {
        if (sizeof(long) <= sizeof(long)) {
            return PyInt_FromLong((long) value);
#ifdef HAVE_LONG_LONG
        } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
            return PyLong_FromLongLong((PY_LONG_LONG) value);
#endif
        }
    }
    {
        int one = 1; int little = (int)*(unsigned char *)&one;
        unsigned char *bytes = (unsigned char *)&value;
        return _PyLong_FromByteArray(bytes, sizeof(long),
                                     little, !is_unsigned);
    }
}

/* CIntFromPy */
  static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) {
#ifdef __Pyx_HAS_GCC_DIAGNOSTIC
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wconversion"
#endif
    const int neg_one = (int) -1, const_zero = (int) 0;
#ifdef __Pyx_HAS_GCC_DIAGNOSTIC
#pragma GCC diagnostic pop
#endif
    const int is_unsigned = neg_one > const_zero;
#if PY_MAJOR_VERSION < 3
    if (likely(PyInt_Check(x))) {
        if (sizeof(int) < sizeof(long)) {
            __PYX_VERIFY_RETURN_INT(int, long, PyInt_AS_LONG(x))
        } else {
            long val = PyInt_AS_LONG(x);
            if (is_unsigned && unlikely(val < 0)) {
                goto raise_neg_overflow;
            }
            return (int) val;
        }
    } else
#endif
    if (likely(PyLong_Check(x))) {
        if (is_unsigned) {
#if CYTHON_USE_PYLONG_INTERNALS
            const digit* digits = ((PyLongObject*)x)->ob_digit;
            switch (Py_SIZE(x)) {
                case  0: return (int) 0;
                case  1: __PYX_VERIFY_RETURN_INT(int, digit, digits[0])
                case 2:
                    if (8 * sizeof(int) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int) >= 2 * PyLong_SHIFT) {
                            return (int) (((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(int) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int) >= 3 * PyLong_SHIFT) {
                            return (int) (((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(int) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int) >= 4 * PyLong_SHIFT) {
                            return (int) (((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
                        }
                    }
                    break;
            }
#endif
#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX < 0x030C00A7
            if (unlikely(Py_SIZE(x) < 0)) {
                goto raise_neg_overflow;
            }
#else
            {
                int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
                if (unlikely(result < 0))
                    return (int) -1;
                if (unlikely(result == 1))
                    goto raise_neg_overflow;
            }
#endif
            if (sizeof(int) <= sizeof(unsigned long)) {
                __PYX_VERIFY_RETURN_INT_EXC(int, unsigned long, PyLong_AsUnsignedLong(x))
#ifdef HAVE_LONG_LONG
            } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
#endif
            }
        } else {
#if CYTHON_USE_PYLONG_INTERNALS
            const digit* digits = ((PyLongObject*)x)->ob_digit;
            switch (Py_SIZE(x)) {
                case  0: return (int) 0;
                case -1: __PYX_VERIFY_RETURN_INT(int, sdigit, (sdigit) (-(sdigit)digits[0]))
                case  1: __PYX_VERIFY_RETURN_INT(int,  digit, +digits[0])
                case -2:
                    if (8 * sizeof(int) - 1 > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
                            return (int) (((int)-1)*(((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
                        }
                    }
                    break;
                case 2:
                    if (8 * sizeof(int) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
                            return (int) ((((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
                        }
                    }
                    break;
                case -3:
                    if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
                            return (int) (((int)-1)*(((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(int) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
                            return (int) ((((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
                        }
                    }
                    break;
                case -4:
                    if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) {
                            return (int) (((int)-1)*(((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(int) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) {
                            return (int) ((((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
                        }
                    }
                    break;
            }
#endif
            if (sizeof(int) <= sizeof(long)) {
                __PYX_VERIFY_RETURN_INT_EXC(int, long, PyLong_AsLong(x))
#ifdef HAVE_LONG_LONG
            } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(int, PY_LONG_LONG, PyLong_AsLongLong(x))
#endif
            }
        }
        {
#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
            PyErr_SetString(PyExc_RuntimeError,
                            "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
#else
            int val;
            PyObject *v = __Pyx_PyNumber_IntOrLong(x);
 #if PY_MAJOR_VERSION < 3
            if (likely(v) && !PyLong_Check(v)) {
                PyObject *tmp = v;
                v = PyNumber_Long(tmp);
                Py_DECREF(tmp);
            }
 #endif
            if (likely(v)) {
                int one = 1; int is_little = (int)*(unsigned char *)&one;
                unsigned char *bytes = (unsigned char *)&val;
                int ret = _PyLong_AsByteArray((PyLongObject *)v,
                                              bytes, sizeof(val),
                                              is_little, !is_unsigned);
                Py_DECREF(v);
                if (likely(!ret))
                    return val;
            }
#endif
            return (int) -1;
        }
    } else {
        int val;
        PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
        if (!tmp) return (int) -1;
        val = __Pyx_PyInt_As_int(tmp);
        Py_DECREF(tmp);
        return val;
    }
raise_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "value too large to convert to int");
    return (int) -1;
raise_neg_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "can't convert negative value to int");
    return (int) -1;
}

/* FastTypeChecks */
  #if CYTHON_COMPILING_IN_CPYTHON
static int __Pyx_InBases(PyTypeObject *a, PyTypeObject *b) {
    while (a) {
        a = a->tp_base;
        if (a == b)
            return 1;
    }
    return b == &PyBaseObject_Type;
}
static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b) {
    PyObject *mro;
    if (a == b) return 1;
    mro = a->tp_mro;
    if (likely(mro)) {
        Py_ssize_t i, n;
        n = PyTuple_GET_SIZE(mro);
        for (i = 0; i < n; i++) {
            if (PyTuple_GET_ITEM(mro, i) == (PyObject *)b)
                return 1;
        }
        return 0;
    }
    return __Pyx_InBases(a, b);
}
#if PY_MAJOR_VERSION == 2
static int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject* exc_type2) {
    PyObject *exception, *value, *tb;
    int res;
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ErrFetch(&exception, &value, &tb);
    res = exc_type1 ? PyObject_IsSubclass(err, exc_type1) : 0;
    if (unlikely(res == -1)) {
        PyErr_WriteUnraisable(err);
        res = 0;
    }
    if (!res) {
        res = PyObject_IsSubclass(err, exc_type2);
        if (unlikely(res == -1)) {
            PyErr_WriteUnraisable(err);
            res = 0;
        }
    }
    __Pyx_ErrRestore(exception, value, tb);
    return res;
}
#else
static CYTHON_INLINE int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject *exc_type2) {
    int res = exc_type1 ? __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type1) : 0;
    if (!res) {
        res = __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type2);
    }
    return res;
}
#endif
static int __Pyx_PyErr_GivenExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) {
    Py_ssize_t i, n;
    assert(PyExceptionClass_Check(exc_type));
    n = PyTuple_GET_SIZE(tuple);
#if PY_MAJOR_VERSION >= 3
    for (i=0; i<n; i++) {
        if (exc_type == PyTuple_GET_ITEM(tuple, i)) return 1;
    }
#endif
    for (i=0; i<n; i++) {
        PyObject *t = PyTuple_GET_ITEM(tuple, i);
        #if PY_MAJOR_VERSION < 3
        if (likely(exc_type == t)) return 1;
        #endif
        if (likely(PyExceptionClass_Check(t))) {
            if (__Pyx_inner_PyErr_GivenExceptionMatches2(exc_type, NULL, t)) return 1;
        } else {
        }
    }
    return 0;
}
static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject* exc_type) {
    if (likely(err == exc_type)) return 1;
    if (likely(PyExceptionClass_Check(err))) {
        if (likely(PyExceptionClass_Check(exc_type))) {
            return __Pyx_inner_PyErr_GivenExceptionMatches2(err, NULL, exc_type);
        } else if (likely(PyTuple_Check(exc_type))) {
            return __Pyx_PyErr_GivenExceptionMatchesTuple(err, exc_type);
        } else {
        }
    }
    return PyErr_GivenExceptionMatches(err, exc_type);
}
static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *exc_type1, PyObject *exc_type2) {
    assert(PyExceptionClass_Check(exc_type1));
    assert(PyExceptionClass_Check(exc_type2));
    if (likely(err == exc_type1 || err == exc_type2)) return 1;
    if (likely(PyExceptionClass_Check(err))) {
        return __Pyx_inner_PyErr_GivenExceptionMatches2(err, exc_type1, exc_type2);
    }
    return (PyErr_GivenExceptionMatches(err, exc_type1) || PyErr_GivenExceptionMatches(err, exc_type2));
}
#endif

/* CStringEquals */
  static CYTHON_INLINE int __Pyx_StrEq(const char *s1, const char *s2) {
    while (*s1 != '\0' && *s1 == *s2) { s1++; s2++; }
    return *s1 == *s2;
}

/* CheckBinaryVersion */
  static int __Pyx_check_binary_version(void) {
    char ctversion[5];
    int same=1, i, found_dot;
    const char* rt_from_call = Py_GetVersion();
    PyOS_snprintf(ctversion, 5, "%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION);
    found_dot = 0;
    for (i = 0; i < 4; i++) {
        if (!ctversion[i]) {
            same = (rt_from_call[i] < '0' || rt_from_call[i] > '9');
            break;
        }
        if (rt_from_call[i] != ctversion[i]) {
            same = 0;
            break;
        }
    }
    if (!same) {
        char rtversion[5] = {'\0'};
        char message[200];
        for (i=0; i<4; ++i) {
            if (rt_from_call[i] == '.') {
                if (found_dot) break;
                found_dot = 1;
            } else if (rt_from_call[i] < '0' || rt_from_call[i] > '9') {
                break;
            }
            rtversion[i] = rt_from_call[i];
        }
        PyOS_snprintf(message, sizeof(message),
                      "compiletime version %s of module '%.100s' "
                      "does not match runtime version %s",
                      ctversion, __Pyx_MODULE_NAME, rtversion);
        return PyErr_WarnEx(NULL, message, 1);
    }
    return 0;
}

/* FunctionExport */
  static int __Pyx_ExportFunction(const char *name, void (*f)(void), const char *sig) {
    PyObject *d = 0;
    PyObject *cobj = 0;
    union {
        void (*fp)(void);
        void *p;
    } tmp;
    d = PyObject_GetAttrString(__pyx_m, (char *)"__pyx_capi__");
    if (!d) {
        PyErr_Clear();
        d = PyDict_New();
        if (!d)
            goto bad;
        Py_INCREF(d);
        if (PyModule_AddObject(__pyx_m, (char *)"__pyx_capi__", d) < 0)
            goto bad;
    }
    tmp.fp = f;
#if PY_VERSION_HEX >= 0x02070000
    cobj = PyCapsule_New(tmp.p, sig, 0);
#else
    cobj = PyCObject_FromVoidPtrAndDesc(tmp.p, (void *)sig, 0);
#endif
    if (!cobj)
        goto bad;
    if (PyDict_SetItemString(d, name, cobj) < 0)
        goto bad;
    Py_DECREF(cobj);
    Py_DECREF(d);
    return 0;
bad:
    Py_XDECREF(cobj);
    Py_XDECREF(d);
    return -1;
}

/* InitStrings */
  static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
    while (t->p) {
        #if PY_MAJOR_VERSION < 3
        if (t->is_unicode) {
            *t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL);
        } else if (t->intern) {
            *t->p = PyString_InternFromString(t->s);
        } else {
            *t->p = PyString_FromStringAndSize(t->s, t->n - 1);
        }
        #else
        if (t->is_unicode | t->is_str) {
            if (t->intern) {
                *t->p = PyUnicode_InternFromString(t->s);
            } else if (t->encoding) {
                *t->p = PyUnicode_Decode(t->s, t->n - 1, t->encoding, NULL);
            } else {
                *t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1);
            }
        } else {
            *t->p = PyBytes_FromStringAndSize(t->s, t->n - 1);
        }
        #endif
        if (!*t->p)
            return -1;
        if (PyObject_Hash(*t->p) == -1)
            return -1;
        ++t;
    }
    return 0;
}

static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char* c_str) {
    return __Pyx_PyUnicode_FromStringAndSize(c_str, (Py_ssize_t)strlen(c_str));
}
static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject* o) {
    Py_ssize_t ignore;
    return __Pyx_PyObject_AsStringAndSize(o, &ignore);
}
#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
#if !CYTHON_PEP393_ENABLED
static const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
    char* defenc_c;
    PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL);
    if (!defenc) return NULL;
    defenc_c = PyBytes_AS_STRING(defenc);
#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
    {
        char* end = defenc_c + PyBytes_GET_SIZE(defenc);
        char* c;
        for (c = defenc_c; c < end; c++) {
            if ((unsigned char) (*c) >= 128) {
                PyUnicode_AsASCIIString(o);
                return NULL;
            }
        }
    }
#endif
    *length = PyBytes_GET_SIZE(defenc);
    return defenc_c;
}
#else
static CYTHON_INLINE const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
    if (unlikely(__Pyx_PyUnicode_READY(o) == -1)) return NULL;
#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
    if (likely(PyUnicode_IS_ASCII(o))) {
        *length = PyUnicode_GET_LENGTH(o);
        return PyUnicode_AsUTF8(o);
    } else {
        PyUnicode_AsASCIIString(o);
        return NULL;
    }
#else
    return PyUnicode_AsUTF8AndSize(o, length);
#endif
}
#endif
#endif
static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
    if (
#if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
            __Pyx_sys_getdefaultencoding_not_ascii &&
#endif
            PyUnicode_Check(o)) {
        return __Pyx_PyUnicode_AsStringAndSize(o, length);
    } else
#endif
#if (!CYTHON_COMPILING_IN_PYPY) || (defined(PyByteArray_AS_STRING) && defined(PyByteArray_GET_SIZE))
    if (PyByteArray_Check(o)) {
        *length = PyByteArray_GET_SIZE(o);
        return PyByteArray_AS_STRING(o);
    } else
#endif
    {
        char* result;
        int r = PyBytes_AsStringAndSize(o, &result, length);
        if (unlikely(r < 0)) {
            return NULL;
        } else {
            return result;
        }
    }
}
static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) {
   int is_true = x == Py_True;
   if (is_true | (x == Py_False) | (x == Py_None)) return is_true;
   else return PyObject_IsTrue(x);
}
static CYTHON_INLINE int __Pyx_PyObject_IsTrueAndDecref(PyObject* x) {
    int retval;
    if (unlikely(!x)) return -1;
    retval = __Pyx_PyObject_IsTrue(x);
    Py_DECREF(x);
    return retval;
}
static PyObject* __Pyx_PyNumber_IntOrLongWrongResultType(PyObject* result, const char* type_name) {
#if PY_MAJOR_VERSION >= 3
    if (PyLong_Check(result)) {
        if (PyErr_WarnFormat(PyExc_DeprecationWarning, 1,
                "__int__ returned non-int (type %.200s).  "
                "The ability to return an instance of a strict subclass of int "
                "is deprecated, and may be removed in a future version of Python.",
                Py_TYPE(result)->tp_name)) {
            Py_DECREF(result);
            return NULL;
        }
        return result;
    }
#endif
    PyErr_Format(PyExc_TypeError,
                 "__%.4s__ returned non-%.4s (type %.200s)",
                 type_name, type_name, Py_TYPE(result)->tp_name);
    Py_DECREF(result);
    return NULL;
}
static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) {
#if CYTHON_USE_TYPE_SLOTS
  PyNumberMethods *m;
#endif
  const char *name = NULL;
  PyObject *res = NULL;
#if PY_MAJOR_VERSION < 3
  if (likely(PyInt_Check(x) || PyLong_Check(x)))
#else
  if (likely(PyLong_Check(x)))
#endif
    return __Pyx_NewRef(x);
#if CYTHON_USE_TYPE_SLOTS
  m = Py_TYPE(x)->tp_as_number;
  #if PY_MAJOR_VERSION < 3
  if (m && m->nb_int) {
    name = "int";
    res = m->nb_int(x);
  }
  else if (m && m->nb_long) {
    name = "long";
    res = m->nb_long(x);
  }
  #else
  if (likely(m && m->nb_int)) {
    name = "int";
    res = m->nb_int(x);
  }
  #endif
#else
  if (!PyBytes_CheckExact(x) && !PyUnicode_CheckExact(x)) {
    res = PyNumber_Int(x);
  }
#endif
  if (likely(res)) {
#if PY_MAJOR_VERSION < 3
    if (unlikely(!PyInt_Check(res) && !PyLong_Check(res))) {
#else
    if (unlikely(!PyLong_CheckExact(res))) {
#endif
        return __Pyx_PyNumber_IntOrLongWrongResultType(res, name);
    }
  }
  else if (!PyErr_Occurred()) {
    PyErr_SetString(PyExc_TypeError,
                    "an integer is required");
  }
  return res;
}
static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) {
  Py_ssize_t ival;
  PyObject *x;
#if PY_MAJOR_VERSION < 3
  if (likely(PyInt_CheckExact(b))) {
    if (sizeof(Py_ssize_t) >= sizeof(long))
        return PyInt_AS_LONG(b);
    else
        return PyInt_AsSsize_t(b);
  }
#endif
  if (likely(PyLong_CheckExact(b))) {
    #if CYTHON_USE_PYLONG_INTERNALS
    const digit* digits = ((PyLongObject*)b)->ob_digit;
    const Py_ssize_t size = Py_SIZE(b);
    if (likely(__Pyx_sst_abs(size) <= 1)) {
        ival = likely(size) ? digits[0] : 0;
        if (size == -1) ival = -ival;
        return ival;
    } else {
      switch (size) {
         case 2:
           if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
             return (Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
           }
           break;
         case -2:
           if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
             return -(Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
           }
           break;
         case 3:
           if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
             return (Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
           }
           break;
         case -3:
           if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
             return -(Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
           }
           break;
         case 4:
           if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
             return (Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
           }
           break;
         case -4:
           if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
             return -(Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
           }
           break;
      }
    }
    #endif
    return PyLong_AsSsize_t(b);
  }
  x = PyNumber_Index(b);
  if (!x) return -1;
  ival = PyInt_AsSsize_t(x);
  Py_DECREF(x);
  return ival;
}
static CYTHON_INLINE Py_hash_t __Pyx_PyIndex_AsHash_t(PyObject* o) {
  if (sizeof(Py_hash_t) == sizeof(Py_ssize_t)) {
    return (Py_hash_t) __Pyx_PyIndex_AsSsize_t(o);
#if PY_MAJOR_VERSION < 3
  } else if (likely(PyInt_CheckExact(o))) {
    return PyInt_AS_LONG(o);
#endif
  } else {
    Py_ssize_t ival;
    PyObject *x;
    x = PyNumber_Index(o);
    if (!x) return -1;
    ival = PyInt_AsLong(x);
    Py_DECREF(x);
    return ival;
  }
}
static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b) {
  return b ? __Pyx_NewRef(Py_True) : __Pyx_NewRef(Py_False);
}
static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) {
    return PyInt_FromSize_t(ival);
}


#endif /* Py_PYTHON_H */
