
     Ti$                       S SK Jr  S SKJrJrJrJr  S SKJrJ	r	J
r
  S SKJr  S SKJr  S SKJr  S SKJrJrJrJrJrJrJrJrJrJrJrJrJrJrJ r J!r!J"r"J#r#J$r$J%r%  S SK&J'r'J(r(   " S	 S
\5      r)g)    )annotations)OptionalSequenceTypeVarUnion)
GraphProtoSparseTensorProtoTensorProto)
get_schema)	TypeAlias)Opset18)BFLOAT16BOOL	COMPLEX64
COMPLEX128DOUBLEFLOATFLOAT8E4M3FNFLOAT8E4M3FNUZ
FLOAT8E5M2FLOAT8E5M2FNUZFLOAT16INT8INT16INT32INT64STRINGUINT8UINT16UINT32UINT64)OpOpsetc                     \ rS rSr% S r\" S\\\5      r	SSSSSSS.                 SIS jjr
\" S	\\\\\\\\\\\\\\\\\\5      r\\\\\\\\\\\\\\\\\\\4   rS
\S'   SS.SJS jjr\" S\\\\\\\\\\\\\\\\\\5      r\" S\\\\\\\\\\\\\\\\\\5      r SS.       SKS jjr!\\\\"\#\\\\\\\\\\\\\\\\4   r$S
\S'   SSSSSSSSS.                 SLS jjr%\" S\\\5      r&  SMSSSSSSS.                       SNS jjjr'\" S\\\\\\\5      r(\" S\\\5      r) SOSS.         SPS jjjr*\" S\\\\\\\\\\\\\\5      r+\r,S
\S'   SQS jr-\" / SP\.\/\      P\.\/\"      P\.\/\#      P\.\/\      P\.\/\      P\.\/\      P\.\/\      P\.\/\      P\.\/\      P\.\/\      P\.\/\      P\.\/\      P\.\/\      P\.\/\      P\.\/\      P\.\   P\.\"   P\.\#   P\.\   P\.\   P\.\   P\.\   P\.\   P\.\   P\.\   P\.\   P\.\   P\.\   P\.\   P\.\   P\/\   P\/\"   P\/\#   P\/\   P\/\   P\/\   P\/\   P\/\   P\/\   P\/\   P\/\   P\/\   P\/\   P\/\   P\/\   P\P\P\"P\#P\P\P\P\P\P\P\P\P\P\P\P\P\P\P\P\P76 r0SRS  jr1\r2S
\S!'   \/ SP\/\   P\/\   P\/\"   P\/\#   P\/\   P\/\   P\/\   P\/\   P\/\   P\/\   P\/\   P\/\   P\/\   P\/\   P\/\   P\/\   P\P\P\"P\#P\P\P\P\P\P\P\P\P\P\P\P\P\P\P\P\P\/\   P\/\   P\/\   P\/\   P7   r3S
\S"'   SSS# jr4\r5S
\S$'   \r6S
\S%'   \" / S&P\.\/\      P\.\/\      P\.\/\"      P\.\/\#      P\.\/\      P\.\/\      P\.\/\      P\.\/\      P\.\/\      P\.\/\      P\.\/\      P\.\/\      P\.\/\      P\.\/\      P\.\/\      P\.\/\      P\.\   P\.\   P\.\"   P\.\#   P\.\   P\.\   P\.\   P\.\   P\.\   P\.\   P\.\   P\.\   P\.\   P\.\   P\.\   P\.\   P\.\   P\.\   P\.\   P\.\   P\/\   P\/\   P\/\"   P\/\#   P\/\   P\/\   P\/\   P\/\   P\/\   P\/\   P\/\   P\/\   P\/\   P\/\   P\/\   P\/\   P\/\   P\/\   P\/\   P\/\   P\P\P\"P\#P\P\P\P\P\P\P\P\P\P\P\P\P\P\P\P\P76 r7          STS' jr8\" S(\\\"\#\\\\\\\\\\\\5      r9\" S)\\5      r:  SMS*S+.           SUS, jjjr;\" S-\\\\5      r<\" S.\\\\\\5      r= SOSSS/.           SVS0 jjjr>\" S1\\\"\#\\\\\\\\\\\\\\\\5      r?SS2.SWS3 jjr@\" S4\\\"\#\\\\\\\\\\\\5      rA\" S5\\\5      rB   SXSSS6S7SS8S9S:S;S<.	                           SYS= jjjrC\" S>\\\"\#\\\\\\\\\\\\\\\\5      rDSSSSS?.               SZS@ jjrE\" SA\\\"\#\\\\\\\\\\\\\\\\5      rF\rGS
\SB'   SSSC.S[SD jjrH\" SE\\\"\#\\\\\\\\\\\\\\\\5      rI\rJS
\SF'   S\SG jrKSHrLg)]Opset19/   c                2    [         R                  " U SS5      $ )N    )r#   __new__)clss    b/var/www/html/ai-image-ml/venv/lib/python3.13/site-packages/onnxscript/onnx_opset/_impl/opset19.pyr*   Opset19.__new__0   s    }}S"b))    T_AveragePoolNOTSETr   N)auto_pad	ceil_modecount_include_pad	dilationspadsstridesc               p    [        SSS5      n	[        U SU	5      n
U
" U R                  X5      UUUUUUUS.6$ )uV  [🌐 AveragePool(19)](https://onnx.ai/onnx/operators/onnx__AveragePool.html#averagepool-19 "Online Documentation")


 AveragePool consumes an input tensor X and applies average pooling across
 the tensor according to kernel sizes, stride sizes, and pad lengths.
 average pooling consisting of computing the average on all values of a
 subset of the input tensor according to the kernel size and downsampling the
 data into the output tensor Y for further processing. The output spatial shape is calculated differently
 depending on whether explicit padding is used, where pads is employed, or auto padding is used, where auto_pad is utilized.
 With explicit padding (https://pytorch.org/docs/stable/generated/torch.nn.MaxPool2d.html?highlight=maxpool#torch.nn.MaxPool2d):
 ```
 output_spatial_shape[i] = floor((input_spatial_shape[i] + pad_shape[i] - dilation[i] * (kernel_shape[i] - 1) - 1) / strides_spatial_shape[i] + 1)
 ```
 or
 ```
 output_spatial_shape[i] = ceil((input_spatial_shape[i] + pad_shape[i] - dilation[i] * (kernel_shape[i] - 1) - 1) / strides_spatial_shape[i] + 1)
 ```
 if ceil_mode is enabled. `pad_shape[i]` is the sum of pads along axis `i`.

 `auto_pad` is a DEPRECATED attribute. If you are using them currently, the output spatial shape will be following when ceil_mode is enabled:
 ```
 VALID: output_spatial_shape[i] = ceil((input_spatial_shape[i] - ((kernel_spatial_shape[i] - 1) * dilations[i] + 1) + 1) / strides_spatial_shape[i])
 SAME_UPPER or SAME_LOWER: output_spatial_shape[i] = ceil(input_spatial_shape[i] / strides_spatial_shape[i])
 ```
 or when ceil_mode is disabled (https://www.tensorflow.org/api_docs/python/tf/keras/layers/AveragePooling2D):
 ```
 VALID: output_spatial_shape[i] = floor((input_spatial_shape[i] - ((kernel_spatial_shape[i] - 1) * dilations[i] + 1)) / strides_spatial_shape[i]) + 1
 SAME_UPPER or SAME_LOWER: output_spatial_shape[i] = floor((input_spatial_shape[i] - 1) / strides_spatial_shape[i]) + 1
 ```
 And pad shape will be following if `SAME_UPPER` or `SAME_LOWER`:
 ```
 pad_shape[i] = (output_spatial_shape[i] - 1) * strides_spatial_shape[i] + ((kernel_spatial_shape[i] - 1) * dilations[i] + 1) - input_spatial_shape[i]
 ```
 The output of each pooling window is divided by the number of elements (exclude pad when attribute count_include_pad is zero).


Args:
    X: (differentiable) Input data tensor from the previous operator; dimensions
        for image case are (N x C x H x W), where N is the batch size, C is the
        number of channels, and H and W are the height and the width of the
        data. For non image case, the dimensions are in the form of (N x C x D1
        x D2 ... Dn), where N is the batch size. Optionally, if dimension
        denotation is in effect, the operation expects the input data tensor to
        arrive with the dimension denotation of [DATA_BATCH, DATA_CHANNEL,
        DATA_FEATURE, DATA_FEATURE ...].

    auto_pad: auto_pad must be either NOTSET, SAME_UPPER, SAME_LOWER or VALID.
        Where default value is NOTSET, which means explicit padding is used.
        SAME_UPPER or SAME_LOWER mean pad the input so that `output_shape[i] =
        ceil(input_shape[i] / strides[i])` for each axis `i`. The padding is
        split between the two sides equally or almost equally (depending on
        whether it is even or odd). In case the padding is an odd number, the
        extra padding is added at the end for SAME_UPPER and at the beginning
        for SAME_LOWER.

    ceil_mode: Whether to use ceil or floor (default) to compute the output
        shape.

    count_include_pad: Whether include pad pixels when calculating values for
        the edges. Default is 0, doesn't count include pad.

    dilations: Dilation value along each spatial axis of filter. If not present,
        the dilation defaults to 1 along each spatial axis.

    kernel_shape: The size of the kernel along each axis.

    pads: Padding for the beginning and ending along each spatial axis, it can
        take any value greater than or equal to 0. The value represent the
        number of pixels added to the beginning and end part of the
        corresponding axis. `pads` format should be as follow [x1_begin,
        x2_begin...x1_end, x2_end,...], where xi_begin the number of pixels
        added at the beginning of axis `i` and xi_end, the number of pixels
        added at the end of axis `i`. This attribute cannot be used
        simultaneously with auto_pad attribute. If not present, the padding
        defaults to 0 along start and end of each spatial axis.

    strides: Stride along each spatial axis. If not present, the stride defaults
        to 1 along each spatial axis.
AveragePoolr)   r(   )r1   r2   r3   r4   kernel_shaper5   r6   r   r"   _prepare_inputs)selfXr1   r2   r3   r4   r9   r5   r6   schemaops              r,   r8   Opset19.AveragePool5   sQ    x M2r2mV,!!&,/%	
 		
r.   T1_Castr   T2_Cast   )saturatec               d    [        SSS5      n[        U SU5      nU" U R                  XA5      X#S.6$ )u  [🌐 Cast(19)](https://onnx.ai/onnx/operators/onnx__Cast.html#cast-19 "Online Documentation")


The operator casts the elements of a given input tensor to a data type
specified by the 'to' argument and returns an output tensor of the same size in
the converted type. The 'to' argument must be one of the data types specified
in the 'DataType' enum field in the TensorProto message.

Casting from string tensor in plain (e.g., "3.14" and "1000") and scientific numeric representations
(e.g., "1e-5" and "1E8") to float types is supported. For example, converting string "100.5" to an integer may
yield result 100. There are some string literals reserved for special floating-point values;
"+INF" (and "INF"), "-INF", and "NaN" are positive infinity, negative infinity, and not-a-number, respectively.
Any string which can exactly match "+INF" in a case-insensitive way would be mapped to positive infinite. Similarly,
this case-insensitive rule is applied to "INF" and "NaN". When casting from numeric tensors
to string tensors, plain floating-point representation (such as "314.15926") would be used.
Converting non-numerical-literal string such as "Hello World!" is an undefined behavior. Cases
of converting string representing floating-point arithmetic value, such as "2.718", to INT is an undefined behavior.

Conversion from a numerical type to any numerical type is always allowed.
User must be aware of precision loss and value change caused by range difference between two types.
For example, a 64-bit float 3.1415926459 may be round to a 32-bit float 3.141592. Similarly, converting
an integer 36 to Boolean may produce 1 because we truncate bits which can't be stored in the targeted type.

In more detail, the conversion among numerical types should follow these rules
if the destination type is not a float 8 type.

* Casting from floating point to:
  * floating point: +/- infinity if OOR (out of range).
  * fixed point: undefined if OOR.
  * bool: +/- 0.0 to False; all else to True.
* Casting from fixed point to:
  * floating point: +/- infinity if OOR. (+ infinity in the case of uint)
  * fixed point: when OOR, discard higher bits and reinterpret (with respect to two's complement representation for
    signed types). For example, 200 (int16) -> -56 (int8).
  * bool: zero to False; nonzero to True.
* Casting from bool to:
  * floating point: `{1.0, 0.0}`.
  * fixed point: `{1, 0}`.
  * bool: no change.

Float 8 type were introduced to speed up the training of
deep models. By default the conversion of a float *x* obeys
to the following rules. `[x]` means the value rounded to
the target mantissa width.

| x                 | E4M3FN   | E4M3FNUZ | E5M2     | E5M2FNUZ |
| ----------------- | -------- | -------- | -------- | -------- |
| 0                 | 0        | 0        | 0        | 0        |
| -0                | -0       | 0        | -0       | 0        |
| NaN               | NaN      | NaN      | NaN      | NaN      |
| Inf               | FLT_MAX  | NaN      | FLT_MAX  | NaN      |
| -Inf              | -FLT_MAX | NaN      | -FLT_MAX | NaN      |
| \[x\] > FLT_MAX   | FLT_MAX  | FLT_MAX  | FLT_MAX  | FLT_MAX  |
| \[x\] \< -FLT_MAX | -FLT_MAX | -FLT_MAX | -FLT_MAX | -FLT_MAX |
| else              | RNE      | RNE      | RNE      | RNE      |

The behavior changes if the parameter 'saturate' is set to False.
The rules then become:

| x                 | E4M3FN | E4M3FNUZ | E5M2 | E5M2FNUZ |
| ----------------- | ------ | -------- | ---- | -------- |
| 0                 | 0      | 0        | 0    | 0        |
| -0                | -0     | 0        | -0   | 0        |
| NaN               | NaN    | NaN      | NaN  | NaN      |
| -NaN              | -NaN   | NaN      | -NaN | NaN      |
| Inf               | NaN    | NaN      | Inf  | NaN      |
| -Inf              | -NaN   | NaN      | -Inf | NaN      |
| \[x\] > FLT_MAX   | NaN    | NaN      | Inf  | NaN      |
| \[x\] \< -FLT_MAX | NaN    | NaN      | -Inf | NaN      |
| else              | RNE    | RNE      | RNE  | RNE      |


Args:
    input: (differentiable) Input tensor to be cast.

    saturate: The parameter defines how the conversion behaves if an input value
        is out of range of the destination type. It only applies for float 8
        conversion (float8e4m3fn, float8e4m3fnuz, float8e5m2, float8e5m2fnuz).
        It is true by default. All cases are fully described in two tables
        inserted in the operator description.

    to: The data type to which the elements of the input tensor are cast.
        Strictly must be one of the types from DataType enum in TensorProto
Castr)   r(   )rD   tor:   )r<   inputrD   rG   r>   r?   s         r,   rF   Opset19.Cast   s9    l FB+ff%4''6QQr.   T1_CastLikeT2_CastLikec               f    [        SSS5      n[        U SU5      nU" U R                  XAU5      SU06$ )u_  [🌐 CastLike(19)](https://onnx.ai/onnx/operators/onnx__CastLike.html#castlike-19 "Online Documentation")


The operator casts the elements of a given input tensor (the first input) to
the same data type as the elements of the second input tensor.
See documentation of the Cast operator for further details.


Args:
    input: (differentiable) Input tensor to be cast.

    target_type: (non-differentiable) The (first) input tensor will be cast to
        produce a tensor of the same type as this (second input) tensor.

    saturate: The parameter defines how the conversion behaves if an input value
        is out of range of the destination type. It only applies for float 8
        conversion (float8e4m3fn, float8e4m3fnuz, float8e5m2, float8e5m2fnuz).
        It is true by default. Please refer to operator Cast description for
        further details.
CastLiker)   r(   rD   r:   )r<   rH   target_typerD   r>   r?   s         r,   rM   Opset19.CastLikeO  s=    0 JB/j&)4''{CWhWWr.   
T_Constantsparse_valuevaluevalue_floatvalue_floats	value_int
value_intsvalue_stringvalue_stringsc               P    [        SSS5      n	[        U SU	5      n
U
" UUUUUUUUS9$ )u  [🌐 Constant(19)](https://onnx.ai/onnx/operators/onnx__Constant.html#constant-19 "Online Documentation")


This operator produces a constant tensor. Exactly one of the provided attributes, either value, sparse_value,
or value_* must be specified.


Args:
    sparse_value: The value for the elements of the output tensor in sparse
        format.

    value: The value for the elements of the output tensor.

    value_float: The value for the sole element for the scalar, float32, output
        tensor.

    value_floats: The values for the elements for the 1D, float32, output
        tensor.

    value_int: The value for the sole element for the scalar, int64, output
        tensor.

    value_ints: The values for the elements for the 1D, int64, output tensor.

    value_string: The value for the sole element for the scalar, UTF-8 string,
        output tensor.

    value_strings: The values for the elements for the 1D, UTF-8 string, output
        tensor.
Constantr)   r(   rQ   )r   r"   )r<   rR   rS   rT   rU   rV   rW   rX   rY   r>   r?   s              r,   r[   Opset19.Constant  sF    V JB/j&)%#%!%'	
 		
r.   T_DeformConvr4   groupr9   offset_groupr5   r6   c          
     r    [        SSS5      n[        U SU5      nU" U R                  XX#XE5      UUUU	U
US.6$ )u1  [🌐 DeformConv(19)](https://onnx.ai/onnx/operators/onnx__DeformConv.html#deformconv-19 "Online Documentation")


Performs deformable convolution as described in https://arxiv.org/abs/1703.06211 and https://arxiv.org/abs/1811.11168.
This operator specification supports the general N-D case. Note that most common use cases have 2D or 3D data.


Args:
    X: Input data tensor. For 2D image data, it has shape (N, C, H, W) where N
        is the batch size, C is the number of input channels, and H and W are
        the height and width. In general, the shape is (N, C, D1, D2, ... , Dn)
        for n-dimensional data, where D1 to Dn are the spatial dimension sizes.
        Most common use cases have n = 2 or 3.

    W: Weight tensor that will be used in the convolutions. It has shape (oC,
        C/group, kH, kW), where oC is the number of output channels and kH and
        kW are the kernel height and width. For more than 2 dimensions, it has
        shape (oC, C/group, k1, k2, ... , kn).

    offset: Offset tensor denoting the offset for the sampling locations in the
        convolution kernel. It has shape (N, offset_group * kH * kW * 2, oH, oW)
        for 2D data or (N, offset_group * k1 * k2 * ... * kn * n, o1, o2, ... ,
        on) for nD data. Use linear interpolationfor fractional offset values.
        Sampling locations outside of the padded input tensor gives zero.

    B: (optional) Optional 1D bias of length oC to be added to the convolution.
        Default is a tensor of zeros.

    mask: (optional) The mask tensor to be applied to each position in the
        convolution kernel. It has shape (N, offset_group * kH * kW, oH, oW) for
        2D data or (N, offset_group * k1 * k2 * ... * kn * n, o1, o2, ... , on)
        for nD data. Default is a tensor of ones.

    dilations: Dilation value along each spatial axis of the kernel. Default is
        1 along each axis.

    group: Number of groups the input and output channels, C and oC, are divided
        into. C and oC must both be divisible by group. Default is 1.

    kernel_shape: Shape of the convolution kernel. If not present, it is
        inferred from the shape of input W.

    offset_group: Number of groups of offset. C must be divisible by
        offset_group. Default is 1.

    pads: Padding for the beginning and end along each spatial axis. The values
        represent the number of pixels added to the beginning and end of the
        corresponding axis and can take any nonnegative value. The format should
        be as follows: [x1_begin, x2_begin, ..., x1_end, x2_end, ...], where
        xi_begin is the number of pixels added at the beginning of axis `i` and
        xi_end is the number of pixels added at the end of axis `i`. Default is
        0 along each axis.

    strides: Stride along each spatial axis. Default is 1 along each axis.

DeformConvr)   r(   r^   r:   )r<   r=   WoffsetBmaskr4   r_   r9   r`   r5   r6   r>   r?   s                 r,   rb   Opset19.DeformConv  sR    N L"b1lF+!!&Q@%%
 	
r.   T1_DequantizeLinearT2_DequantizeLinear)axisc               f    [        SSS5      n[        U SU5      nU" U R                  XQX#5      SU06$ )ul  [🌐 DequantizeLinear(19)](https://onnx.ai/onnx/operators/onnx__DequantizeLinear.html#dequantizelinear-19 "Online Documentation")


The linear dequantization operator. It consumes a quantized tensor, a scale, and a zero point to compute the full precision tensor.
The dequantization formula is `y = (x - x_zero_point) * x_scale`. `x_scale` and `x_zero_point` must have same shape, and can be either a scalar
for per-tensor / per layer quantization, or a 1-D tensor for per-axis quantization.
`x_zero_point` and `x` must have same type. `x` and `y` must have same shape. In the case of dequantizing int32,
there's no zero point (zero point is supposed to be 0).
`zero-point` is usually not used in the case of float8e4m3fn, float8e4m3fnuz, float8e5m2, float8e5m2fnuz quantization,
but the dequantization formula remains the same for consistency and 'x_scale' still determines the output type.


Args:
    x: N-D quantized input tensor to be de-quantized.

    x_scale: Scale for input 'x'. It can be a scalar, which means a
        per-tensor/layer dequantization, or a 1-D tensor for per-axis
        dequantization.

    x_zero_point: (optional) Zero point for input 'x'. Shape must match x_scale.
        It's optional. Zero point is 0 when it's not specified.

    axis: (Optional) The axis of the dequantizing dimension of the input tensor.
        Used only for per-axis quantization. Negative value means counting
        dimensions from the back. Accepted range is `[-r, r-1]` where `r =
        rank(input)`. When the rank of the input is 1, per-tensor quantization
        is applied, rendering the axis unnecessary in this scenario.
DequantizeLinearr)   r(   rj   r:   )r<   xx_scalex_zero_pointrj   r>   r?   s          r,   rl   Opset19.DequantizeLinear  sA    J .B7(&14''7IUPTUUr.   T_EqualT1_Equalc                `    [        SSS5      n[        U SU5      nU" U R                  X1U5      6 $ )uh  [🌐 Equal(19)](https://onnx.ai/onnx/operators/onnx__Equal.html#equal-19 "Online Documentation")


Returns the tensor resulted from performing the `equal` logical operation
elementwise on the input tensors `A` and `B` (with Numpy-style broadcasting support).

This operator supports **multidirectional (i.e., Numpy-style) broadcasting**; for more details please check `Broadcasting in ONNX <https://github.com/onnx/onnx/blob/master/docs/Broadcasting.md>`_.


Args:
    A: (non-differentiable) First input operand for the logical operator.

    B: (non-differentiable) Second input operand for the logical operator.
Equalr)   r(   r:   )r<   Are   r>   r?   s        r,   rt   Opset19.EqualY  s8      GR,gv&4''1566r.   
V_Identityc                ^    [        SSS5      n[        U SU5      nU" U R                  X!5      6 $ )u   [🌐 Identity(19)](https://onnx.ai/onnx/operators/onnx__Identity.html#identity-19 "Online Documentation")

Identity operator

Args:
    input: (differentiable) Input tensor
Identityr)   r(   r:   )r<   rH   r>   r?   s       r,   ry   Opset19.Identity  s6     JB/j&)4''677r.   B_IfV_Ifc               f    [        SSS5      n[        U SU5      nU" U R                  XA5      UUS.6$ )ug  [🌐 If(19)](https://onnx.ai/onnx/operators/onnx__If.html#if-19 "Online Documentation")

If conditional

Args:
    cond: Condition for the if. The tensor must contain a single element.

    else_branch: Graph to run if condition is false. Has N outputs: values you
        wish to be live-out to the enclosing scope. The number of outputs must
        match the number of outputs in the then_branch.

    then_branch: Graph to run if condition is true. Has N outputs: values you
        wish to be live-out to the enclosing scope. The number of outputs must
        match the number of outputs in the else_branch.
Ifr)   r(   )else_branchthen_branchr:   )r<   condr   r   r>   r?   s         r,   r~   
Opset19.If  sA    " D"b)dF#!!&/##
 	
r.   I_LoopB_LoopV_Loopc               j    [        SSS5      n[        U SU5      nU" U R                  " XQU/UQ76 SU06$ )u3  [🌐 Loop(19)](https://onnx.ai/onnx/operators/onnx__Loop.html#loop-19 "Online Documentation")


Generic Looping construct. This loop has multiple termination conditions:

1) Trip count. Iteration count specified at runtime. Set by
   specifying the input M. Optional. Set to empty string to omit.
   Note that a static trip count (specified at graph construction time) can be
   specified by passing in a constant node for input M.
2) Loop termination condition. This is an input to the op that determines
   whether to run the first iteration and also a loop-carried dependency for
   the body graph. The body graph must yield a value for the condition variable,
   whether this input is provided or not.

This table summarizes the operating modes of this operator with equivalent
C-style code:

Operator inputs defined as (max_trip_count, condition_var).

* input ("", ""):
        for (int i=0; ; ++i) {
          cond = ... // Note this value is ignored, but is required in the body
        }

* input ("", cond) // Note this is analogous to a while loop
        bool cond = ...;
        for (int i=0; cond; ++i) {
          cond = ...;
        }

* input ("", 1) // Note this is analogous to a do-while loop
        bool cond = true
        for (int i=0; cond; ++i) {
          cond = ...;
        }

* input (trip_count, "") // Note this is analogous to a for loop
        int trip_count = ...
        for (int i=0; i < trip_count; ++i) {
          cond = ...; // ignored
        }

* input (trip_count, cond)
        int trip_count = ...;
        bool cond = ...;
        for (int i=0; i < trip_count && cond; ++i) {
          cond = ...;
        }


*Sample usage - cond as well as trip count*

    graph predict-net {
      %a = Constant[value = <Scalar Tensor [3]>]()
      %b = Constant[value = <Scalar Tensor [6]>]()
      %keepgoing = Constant[value = <Scalar Tensor [1]>]()
      %max_trip_count = Constant[value = <Scalar Tensor [10]>]()
      %keepgoing_out, %b_out, %user_defined_vals = Loop[body = <graph body-net>](%max_trip_count, %keepgoing, %b)
      return
    }

    graph body-net (
      %i[INT32, scalar]           // iteration number
      %keepgoing_in[BOOL, scalar] // incoming loop-termination-condition; not used
      %b_in[INT32, scalar]        // incoming value of loop-carried-dependency b
    ) {
      %my_local = Add(%a, %b_in)
      %b_out = Sub(%a, %b_in) // outgoing value of loop-carried-dependency b
      %keepgoing_out = Greater(%my_local, %b_out) // outgoing loop-termination-condition
      %user_defined_val = Add(%b_in, %b_in) // scan-output value to be accumulated
      return %keepgoing_out, %b_out, %user_defined_val
    }

*Sample equivalent C code*

    {
      /* User-defined code (enclosing scope) */
      int a = 3, b = 6;
      bool keepgoing = true; // Analogous to input cond
      /* End user-defined code */

      /* Implicitly-defined code */
      const int max_trip_count = 10; // Analogous to input M
      int user_defined_vals[]; // Imagine this is resizable
      /* End implicitly-defined code */
      /* initialize loop-carried variables and scan-output variables */
      bool keepgoing_out = keepgoing
      int b_out = b

      for (int i=0; i < max_trip_count && keepgoing_out; ++i) {
        /* Implicitly-defined code: bind actual parameter values
           to formal parameter variables of loop-body */
        bool keepgoing_in = keepgoing_out;
        bool b_in = b_out;

        /* User-defined code (loop body) */
        int my_local = a + b_in; // Reading value "a" from the enclosing scope is fine
        b_out = a - b_in;
        keepgoing_out = my_local > b_out;
        user_defined_val = b_in + b_in; // b_in and b_out are different variables
        /* End user-defined code */

        /* Implicitly defined-code */
        user_defined_vals[i] = user_defined_val // accumulate scan-output values
      }
      // int t = my_local; // Can't do this. my_local is not accessible here.

      // The values below are bound to the output variables of the loop and therefore accessible
      // b_out; user_defined_vals; keepgoing_out;
    }

There are several things of note in this code snippet:

1) Values from the enclosing scope (i.e. variable "a" here) are in scope and can
   be referenced in the inputs of the loop.
2) Any values computed in the loop body that needs to be used in a subsequent
   iteration or after the loop are modelled using a pair of variables in the loop-body,
   consisting of an input variable (eg., b_in) and an output variable (eg., b_out).
   These are referred to as loop-carried dependences. The loop operation node
   supplies the input value of the input variable for the first iteration, and
   returns the output value of the output variable produced by the final
   iteration.
3) Scan_output variables are used to implicitly concatenate values computed across
   all the iterations. In the above example, the value of user_defined_val computed
   over all iterations are concatenated and returned as the value of user_defined_vals
   after the loop.
4) Values created in the body cannot be accessed in the enclosing scope,
   except using the mechanism described above.

Note that the semantics of this op support "diagonal" or "wavefront" execution.
(See Step 3 here for an example:
https://devblogs.nvidia.com/optimizing-recurrent-neural-networks-cudnn-5/).
Frontends should emit multi-layer RNNs as a series of While operators (with
time being the inner looping dimension), with each successive layer consuming
the scan_outputs from the previous layer, possibly going through several
point-wise operators (e.g. dropout, residual connections, linear layer).

The input/output of subgraph (produced by loop node) matching is based on order instead of name. The implementation will figure out the names based on this order.


Args:
    M: (optional) A maximum trip-count for the loop specified at runtime.
        Optional. Pass empty string to skip.

    cond: (optional) A boolean termination condition. Optional. Pass empty
        string to skip.

    v_initial: (variadic, heterogeneous) The initial values of any loop-carried
        dependencies (values that change across loop iterations)

    body: The graph run each iteration. It has 2+N inputs: (iteration_num,
        condition, loop carried dependencies...). It has 1+N+K outputs:
        (condition, loop carried dependencies..., scan_outputs...). Each
        scan_output is created by concatenating the value of the specified
        output value at the end of each iteration of the loop. It is an error if
        the dimensions or data type of these scan_outputs change across loop
        iterations.
Loopr)   r(   bodyr:   )r<   Mr   r   	v_initialr>   r?   s          r,   r   Opset19.LoopZ  sC    L FB+ff%4''4D)DP4PPr.   T_PadTind_Padconstant)modec          	     h    [        SSS5      n[        U SU5      nU" U R                  XaX#U5      SU06$ )u;  [🌐 Pad(19)](https://onnx.ai/onnx/operators/onnx__Pad.html#pad-19 "Online Documentation")


Given a tensor containing the data to be padded (`data`), a tensor containing the number of start and end pad values for axis (`pads`), (optionally) a `mode`, and (optionally) `constant_value`,
a padded tensor (`output`) is generated.

The three supported `modes` are (similar to corresponding modes supported by `numpy.pad`):

1) `constant`(default) - pads with a given constant value as specified by `constant_value` (which defaults to 0, empty string, or False)

2) `reflect` - pads with the reflection of the vector mirrored on the first and last values of the vector along each axis

3) `edge` - pads with the edge values of array

4) `wrap` - wrap-around padding as if the data tensor forms a torus


Example 1 (`constant` mode):

Insert 0 pads to the beginning of the second dimension.

::

    data = [
        [1.0, 1.2],
        [2.3, 3.4],
        [4.5, 5.7],
    ]

    pads = [0, 2, 0, 0]

    mode = 'constant'

    constant_value = 0.0

    output = [
        [0.0, 0.0, 1.0, 1.2],
        [0.0, 0.0, 2.3, 3.4],
        [0.0, 0.0, 4.5, 5.7],
    ]



Example 2 (`reflect` mode):

::

    data = [
        [1.0, 1.2],
        [2.3, 3.4],
        [4.5, 5.7],
    ]

    pads = [0, 2, 0, 0]

    mode = 'reflect'

    output = [
        [1.0, 1.2, 1.0, 1.2],
        [2.3, 3.4, 2.3, 3.4],
        [4.5, 5.7, 4.5, 5.7],
    ]



Example 3 (`edge` mode):

::

    data = [
        [1.0, 1.2],
        [2.3, 3.4],
        [4.5, 5.7],
    ]

    pads = [0, 2, 0, 0]

    mode = 'edge'

    output = [
        [1.0, 1.0, 1.0, 1.2],
        [2.3, 2.3, 2.3, 3.4],
        [4.5, 4.5, 4.5, 5.7],
    ]



Example 4 (`wrap` mode):

::

    data = [
        [1.0, 1.2],
        [2.3, 3.4],
        [4.5, 5.7],
    ]

    pads = [2, 1, 1, 1]

    mode = 'wrap'

    output = [
        [3.4, 2.3, 3.4, 2.3],
        [5.7, 4.5, 5.7, 4.5],
        [1.2, 1.0, 1.2, 1.0],
        [3.4, 2.3, 3.4, 2.3],
        [5.7, 4.5, 5.7, 4.5],
        [1.2, 1.0, 1.2, 1.0],
    ]




Args:
    data: (differentiable) Input tensor.

    pads: (non-differentiable) Tensor of integers indicating the number of
        padding elements to add or remove (if negative) at the beginning and end
        of each axis. For 2D input tensor, it is the number of pixels. `pads`
        should be a 1D tensor of shape [2 * num_axes] where `num_axes` refers to
        the number of elements in the `axes` input or the input rank if `axes`
        are not provided explicitly. `pads` format should be: [x1_begin,
        x2_begin, ..., x1_end, x2_end,...], where xi_begin is the number of pad
        values added at the beginning of axis `axes[i]` and xi_end, the number
        of pad values added at the end of axis `axes[i]`.

    constant_value: (optional, non-differentiable) (Optional) A scalar value to
        be used if the mode chosen is `constant` (by default it is 0, empty
        string or False).

    axes: (optional, non-differentiable) 1-D tensor of axes that `pads` apply
        to. Negative value means counting dimensions from the back. Accepted
        range is [-r, r-1] where r = rank(data). Behavior is undefined if an
        axis is repeated. If not provided, all axes are assumed (`[0, 1, ...,
        input_rank-1]`).

    mode: Supported modes: `constant`(default), `reflect`, `edge`, `wrap`
Padr)   r(   r   r:   )r<   datar5   constant_valueaxesr   r>   r?   s           r,   r   Opset19.Pad  sA    h E2r*eV$4''dDQ]X\]]r.   T1_QuantizeLinearT2_QuantizeLinearrj   rD   c               h    [        SSS5      n[        U SU5      nU" U R                  XaX#5      UUS.6$ )u   [🌐 QuantizeLinear(19)](https://onnx.ai/onnx/operators/onnx__QuantizeLinear.html#quantizelinear-19 "Online Documentation")


The linear quantization operator. It consumes a high precision tensor, a scale, and a zero point to compute the low precision / quantized tensor.
The scale factor and zero point must have same shape, and can be either a scalar for per-tensor / per layer quantization, or a 1-D tensor for per-axis quantization.
The quantization formula is `y = saturate ((x / y_scale) + y_zero_point)`.
For saturation, it saturates to [0, 255] if it's uint8, or [-128, 127] if it's int8.
For (x / y_scale), it's rounding to the nearest even. Refer to https://en.wikipedia.org/wiki/Rounding for details.
'y_zero_point' and 'y' must have same type.
'y_zero_point' is usually not used for quantization to float8e4m3fn, float8e4m3fnuz, float8e5m2, float8e5m2fnuz,
but the quantization formula remains the same for consistency and
the type of the attribute 'y_zero_point' still determines the quantization type.


Args:
    x: N-D full precision Input tensor to be quantized.

    y_scale: Scale for doing quantization to get 'y'. It can be a scalar, which
        means per-tensor/layer quantization, or a 1-D Tensor for per-axis
        quantization.

    y_zero_point: (optional) Zero point for doing quantization to get 'y'. Shape
        must match y_scale. Default is uint8 with zero point of 0 if it's not
        specified.

    axis: (Optional) The axis of the quantization dimension of the input tensor.
        Ignored for per-tensor quantization. Negative value means counting
        dimensions from the back. Accepted range is [-r, r-1] where r =
        rank(input).

    saturate: The parameter defines how the conversion behaves if an input value
        is out of range of the destination type. It only applies for float 8
        quantization (float8e4m3fn, float8e4m3fnuz, float8e5m2, float8e5m2fnuz).
        It is true by default. All cases are fully described in two tables
        inserted in the operator description.
QuantizeLinearr)   r(   r   r:   )r<   rm   y_scaley_zero_pointrj   rD   r>   r?   s           r,   r   Opset19.QuantizeLinear  sF    \ ,b"5&/!!&WC
 	
r.   	T_Reshape)	allowzeroc               f    [        SSS5      n[        U SU5      nU" U R                  XAU5      SU06$ )u  [🌐 Reshape(19)](https://onnx.ai/onnx/operators/onnx__Reshape.html#reshape-19 "Online Documentation")


Reshape the input tensor similar to numpy.reshape.
First input is the data tensor, second input is a shape tensor which specifies the output shape. It outputs the reshaped tensor.
At most one dimension of the new shape can be -1. In this case, the value is
inferred from the size of the tensor and the remaining dimensions. A dimension
could also be 0, in which case the actual dimension value is unchanged (i.e. taken
from the input tensor). If 'allowzero' is set, and the new shape includes 0, the
dimension will be set explicitly to zero (i.e. not taken from input tensor).
Shape (second input) could be an empty shape, which means converting to a scalar.
The input tensor's shape and the output tensor's shape are required to have the same number of elements.

If the attribute 'allowzero' is set, it is invalid for the specified shape to
contain both a zero value and -1, as the value of the dimension corresponding
to -1 cannot be determined uniquely.


Args:
    data: (differentiable) An input tensor.

    shape: (non-differentiable) Specified shape for output.

    allowzero: (Optional) By default, when any value in the 'shape' input is
        equal to zero the corresponding dimension value is copied from the input
        tensor dynamically. allowzero=1 indicates that if any value in the
        'shape' input is set to zero, the zero value is honored, similar to
        NumPy.
Reshaper)   r(   r   r:   )r<   r   shaper   r>   r?   s         r,   r   Opset19.Reshape  s=    > Ir2.i(4''e<R	RRr.   	T1_Resize	T2_Resize
half_pixelg      g        stretchnearestround_prefer_floor		antialiasr   coordinate_transformation_modecubic_coeff_aexclude_outsideextrapolation_valuekeep_aspect_ratio_policyr   nearest_modec       	        x    [        SSS5      n[        U SU5      nU" U R                  XX#U5      UUUUU	U
UUUS.	6$ )u  [🌐 Resize(19)](https://onnx.ai/onnx/operators/onnx__Resize.html#resize-19 "Online Documentation")


Resize the input tensor. In general, it calculates every value in the output tensor as a weighted average of neighborhood (a.k.a. sampling locations) in the input tensor.
Each dimension value of the output tensor is:
::

    output_dimension = floor(input_dimension * (roi_end - roi_start) * scale)


if input \"sizes\" is not specified.


Args:
    X: (differentiable) N-D tensor

    roi: (optional, non-differentiable) 1-D tensor given as [start1, ...,
        startN, end1, ..., endN], where N is the rank of X or the length of
        axes, if provided. The RoIs' coordinates are normalized in the
        coordinate system of the input image. It only takes effect when
        coordinate_transformation_mode is "tf_crop_and_resize"

    scales: (optional, non-differentiable) The scale array along each dimension.
        It takes value greater than 0. If it's less than 1, it's sampling down,
        otherwise, it's upsampling. The number of elements of 'scales' should be
        the same as the rank of input 'X' or the length of 'axes', if provided.
        One of 'scales' and 'sizes' MUST be specified and it is an error if both
        are specified. If 'sizes' is needed, the user can use an empty string as
        the name of 'scales' in this operator's input list.

    sizes: (optional, non-differentiable) Target size of the output tensor. Its
        interpretation depends on the 'keep_aspect_ratio_policy' value.The
        number of elements of 'sizes' should be the same as the rank of input
        'X', or the length of 'axes', if provided. Only one of 'scales' and
        'sizes' can be specified.

    antialias: If set to 1, "linear" and "cubic" interpolation modes will use an
        antialiasing filter when downscaling. Antialiasing is achieved by
        stretching the resampling filter by a factor max(1, 1 / scale), which
        means that when downsampling, more input pixels contribute to an output
        pixel.

    axes: If provided, it specifies a subset of axes that 'roi', 'scales' and
        'sizes' refer to. If not provided, all axes are assumed [0, 1, ...,
        r-1], where r = rank(data). Non-specified dimensions are interpreted as
        non-resizable. Negative value means counting dimensions from the back.
        Accepted range is [-r, r-1], where r = rank(data). Behavior is undefined
        if an axis is repeated.

    coordinate_transformation_mode:
This attribute describes how to transform
        the coordinate in the resized tensor to the coordinate in the original
        tensor.

The coordinate of each dimension is transformed individually.
        Let's describe a case using axis x as an example.
Denote `x_resized` as
        the coordinate of axis x in the resized tensor,
 `x_original` as the
        coordinate of axis x in the original tensor,
 `length_original` as the
        length of the original tensor in axis x,
 `length_resized` as the length
        of the resized tensor in axis x,
 `scale = length_resized /
        length_original`,
 `output_width` the target length on the axis x which
        can be a fractional number when it is calculated out of a scale factor,
        and `output_width_int` the effective output width as an integer.

if
        coordinate_transformation_mode is `"half_pixel"`,
```
x_original =
        (x_resized + 0.5) / scale - 0.5
```

if coordinate_transformation_mode
        is `"half_pixel_symmetric"`,
```
adjustment = output_width_int /
        output_width
center = input_width / 2
offset = center * (1 - adjustment)
        x_ori = offset + (x + 0.5) / scale - 0.5
```

if
        coordinate_transformation_mode is `"pytorch_half_pixel"`,
```
x_original
        = length_resized > 1 ? (x_resized + 0.5) / scale - 0.5 : 0
```

if
        coordinate_transformation_mode is `"align_corners"`,
```
x_original =
        x_resized * (length_original - 1) / (length_resized - 1)
```

if
        coordinate_transformation_mode is `"asymmetric"`,
```
x_original =
        x_resized / scale
```

if coordinate_transformation_mode is
        `"tf_crop_and_resize"`,
```
x_original = length_resized > 1 ? start_x *
        (length_original - 1) + x_resized * (end_x - start_x) * (length_original
        - 1) / (length_resized - 1) : 0.5 * (start_x + end_x) * (length_original
        - 1)
```
.

    cubic_coeff_a: The coefficient 'a' used in cubic interpolation. Two common
        choice are -0.5 (in some cases of TensorFlow) and -0.75 (in PyTorch).
        Check out Equation (4) in https://ieeexplore.ieee.org/document/1163711
        for the details. This attribute is valid only if mode is "cubic".

    exclude_outside: If set to 1, the weight of sampling locations outside the
        tensor will be set to 0 and the weight will be renormalized so that
        their sum is 1.0. The default value is 0.

    extrapolation_value: When coordinate_transformation_mode is
        "tf_crop_and_resize" and x_original is outside the range [0,
        length_original - 1], this value is used as the corresponding output
        value. Default is 0.0f.

    keep_aspect_ratio_policy:
This attribute describes how to interpret the
        `sizes` input with regard to keeping the original aspect ratio of the
        input, and it is not applicable when
the `scales` input is used.

Given
        a set of `sizes`, associated with a subset of `axes` (explicitly
        provided or default), and assuming `d = axes[i]`, with `i` being the
        index of the provided `sizes`.

If `keep_aspect_ratio_policy` is
        `"stretch"`, the original aspect ratio is disregarded, and the input is
        resized to the specified size:
`out_size[d] = sizes[i]`

If
        `keep_aspect_ratio_policy` is `"not_larger"`, the sizes are adjusted so
        that no extent of the output is larger than the specified size, while
        keeping the original aspect ratio:
```
scale = Min(sizes[i] /
        in_size[d])
out_size[d] = round_int(scale * in_size[d])
```

If
        `keep_aspect_ratio_policy` is `"not_smaller"`, the sizes are adjusted so
        that no extent of the output is smaller than the specified size, while
        keeping the original aspect ratio:
```
scale = Max(sizes[i] /
        in_size[d])
out_size[d] = round_int(scale * in_size[d])
```

For
        non-resizable axes (those not specified in `axes`), the output size will
        be equal to the input size.

Note: `round_int` stands for computing the
        nearest integer value, rounding halfway cases up.

    mode: Three interpolation modes: "nearest" (default), "linear" and "cubic".
        The "linear" mode includes linear interpolation for 1D tensor and
        N-linear interpolation for N-D tensor (for example, bilinear
        interpolation for 2D tensor). The "cubic" mode includes cubic
        interpolation for 1D tensor and N-cubic interpolation for N-D tensor
        (for example, bicubic interpolation for 2D tensor).

    nearest_mode: Four modes: "round_prefer_floor" (default, as known as round
        half down), "round_prefer_ceil" (as known as round half up), "floor",
        "ceil". Only used by nearest interpolation. It indicates how to get
        "nearest" pixel in input tensor from x_original, so this attribute is
        valid only if "mode" is "nearest".
Resizer)   r(   r   r:   )r<   r=   roiscalessizesr   r   r   r   r   r   r   r   r   r>   r?   s                   r,   r   Opset19.ResizeE  s[    \ Hb"-h'!!&S%@+I'+ 3%=%
 	
r.   V_Scan)scan_input_axesscan_input_directionsscan_output_axesscan_output_directionsc          
     r    [        SSS5      n[        U SU5      n	U	" U R                  " U/UQ76 UUUUUUS.6$ )u  [🌐 Scan(19)](https://onnx.ai/onnx/operators/onnx__Scan.html#scan-19 "Online Documentation")


Scan can be used to iterate over one or more scan_input tensors,
constructing zero or more scan_output tensors. It combines ideas from general recurrences,
functional programming constructs such as scan, fold, map, and zip, and is intended to enable
generalizations of RNN-like constructs for sequence-to-sequence processing.
Other tensors (referred to as state_variables here) can be used to carry a state
when iterating from one element to another (similar to hidden-state in RNNs, also referred
to as loop-carried dependences in the context of loops).
Many common usages involve a single scan_input tensor (where functionality
similar to scan, fold and map can be obtained). When more than one scan_input is used,
a behavior similar to zip is obtained.

The attribute body must be a graph, specifying the computation to be performed in
every iteration. It takes as input the current values of the state_variables and
the current iterated element of the scan_inputs. It must return the (updated) values
of the state_variables and zero or more scan_output_element tensors. The values of the
scan_output_element tensors are concatenated over all the iterations to produce the
scan_output values of the scan construct (similar to the concatenated intermediate
hidden-state values of RNN-like constructs). All the output tensors (state_variables as
well as scan_output_element tensors) are required to have the same shape in each iteration
of the loop (a restriction imposed to enable efficient memory allocation).

Note that the iterated element passed to the body subgraph does not have a sequence
axis. It will have a rank one less than the rank of the corresponding scan_input.

The scan operation returns the final values of the state_variables as well as the
scan_outputs.

The optional attribute scan_input_directions specifies the direction (forward or backward)
for each scan input. If this attribute is omitted, all sequences are scanned in the forward
direction. A bidirectional scan may be performed by specifying the same tensor input twice
in the scan_inputs, once with a forward direction, and once with a backward direction.

The scan_output of the operation is produced by concatenating the scan_output_element
values produced by the body in each iteration.  The optional attribute scan_output_directions
specifies the direction in which scan_output is constructed (by appending or prepending the
scan_output_element to scan_output in each iteration) for each scan_output. If this attribute
is omitted, the scan_output_element is appended to the scan_output in each iteration.

The optional attribute scan_input_axes specifies the axis to be scanned for each scan_input.
If omitted, every scan_input will be scanned in axis 0. For example, if axis 0 is the
batch axis and axis 1 is the time axis (to be scanned), specify an axis value of 1.
Note that scanning a non-zero axis may be less efficient than scanning axis zero.

The optional attribute scan_output_axes specifies the axis along which the scan_outputs
are accumulated for each scan_output. For example, if axis 1 is the time axis (to be
scanned) for both inputs and outputs, specify a scan_input axis and scan_output axis
value of 1.

Note that because of the ONNX restriction that only the last parameter of an operator can
be variadic, the initial-states and scan-inputs are listed together as one input parameter.
Similarly, the final-states and scan-outputs are listed together as one output parameter.
The attribute num_scan_inputs indicates the number M of scan-inputs.

The behavior of

    Scan <
        num_scan_inputs = m,
        body = loop-body,
        scan_input_axes = [axis_1, ..., axis_m]
    > (init_1, ..., init_n, scan_1, ..., scan_m)

is equivalent to the following pseudo-code:

    // scan_i.shape[axis_i] denotes the (max) sequence-length of scan_i
    // scan_i.shape[axis_i] is required to be equal to scan_j.shape[axis_j] for all i,j.
    sequence_length = scan_1.shape[axis_1];

    // initialize state-variables
    st_1 = init_1; ... st_n = init_n;
    // initialize scan-output variables: [] denotes an empty tensor
    scan_out_1 = []; ...; scan_out_k = [];
    // identify number of iterations:

    // execute loop
    for (int t = 0; t < sequence_length; ++t) {
        // generate the scan-input elements: the notation T<axis=k>[t] indicates the sub-tensor
        // of rank one less than T obtained by indexing T at position t along axis k.
        si_1 = scan_1<axis=axis_1>[t];
        ... ;
        si_m = scan_m<axis=axis_m>[t];
        // execute loop-body
        st_1, ..., st_n, so_1, ..., so_k = loop-body(st_1, ..., st_n, si_1, ..., si_m)
        // accumulate the scan-output elements
        scan_out_1 = Concat<axis=0>(scan_out_1, so_1); ... ; scan_out_k = Concat<axis=0>(scan_out_k, so_k);
    }

    return st_1, ..., st_n, scan_out_1, ..., scan_out_k;

*Sample usage: Encoding RNN using a Scan*

The following example shows how a simple RNN over an input tensor %X, with weight tensor %Wi,
recurrence weight tensor %Ri, bias tensors %Wbi and %Rbi, and initial hidden-state %H_0 can
be encoded as a ScanLoop. Note that the loop-body is a nested graph, and it directly computes
%Wi, %Ri, %Wbi, and %Rbi (typically constants or initializers in the body graph). If these
values are computed in the outer graph, they need to be passed in as extra state_variables.

    graph rnn-encoding {
      %H_0 = ...
      %X = ...
      %Y_h, %Y = Scan[body = <graph rnn-cell-1>, num_scan_inputs=1](%H_0, %X)
      return %Y, %Y_h
    }

    graph rnn-cell-1 (
      %H_tminus1[FLOAT, tensor]
      %X_t[FLOAT, tensor]
    ) {
      %Wi = ...
      %Ri = ...
      %Wbi = ...
      %Rbi = ...
      %t1 = X_t * (Wi^T)
      %t2 = H_tminus1*(Ri^T)
      %t3 = Add(%t1, %t2)
      %t4 = Add(%t3, %Wbi)
      %t5 = Add(%t4, %Rbi)
      %Ht = Tanh(%t5)
      %Accumulate = Identity(%Ht)
      return %Ht, %Accumulate
    }



Args:
    initial_state_and_scan_inputs: (variadic, heterogeneous) Initial values of
        the loop's N state variables followed by M scan_inputs

    body: The graph run each iteration. It has N+M inputs: (loop state
        variables..., scan_input_elts...). It has N+K outputs: (loop state
        variables..., scan_output_elts...). Each scan_output is created by
        concatenating the value of the specified scan_output_elt value at the
        end of each iteration of the loop. It is an error if the dimensions of
        these values change across loop iterations.

    num_scan_inputs: An attribute specifying the number of scan_inputs M.

    scan_input_axes: An optional list of M flags. The i-th element of the list
        specifies the axis to be scanned (the sequence axis) for the i-th
        scan_input. If omitted, 0 will be used as the scan axis for every
        scan_input. Negative value for an axis means counting dimensions from
        the back. Accepted range is [-r, r-1] where r = rank(input).

    scan_input_directions: An optional list of M flags. The i-th element of the
        list specifies the direction to be scanned for the i-th scan_input
        tensor: 0 indicates forward direction and 1 indicates reverse direction.
        If omitted, all scan_input tensors will be scanned in the forward
        direction.

    scan_output_axes: An optional list of K flags. The i-th element of the list
        specifies the axis for the i-th scan_output. The scan outputs are
        accumulated along the specified axis. If omitted, 0 will be used as the
        scan axis for every scan_output. Negative value for an axis means
        counting dimensions from the back. Accepted range is [-r, r-1].

    scan_output_directions: An optional list of K flags, one for each
        scan_output. The i-th element of the list specifies whether the i-th
        scan_output should be constructed by appending or prepending a new value
        in each iteration: 0 indicates appending and 1 indicates prepending. If
        omitted, all scan_output tensors will be produced by appending a value
        in each iteration.
Scanr)   r(   )r   num_scan_inputsr   r   r   r   r:   )
r<   r   r   r   r   r   r   initial_state_and_scan_inputsr>   r?   s
             r,   r   Opset19.Scan:  sT    ^ FB+ff%!!&I+HI++"7-#9
 	
r.   T_ShapeT1_Shapeendstartc               d    [        SSS5      n[        U SU5      nU" U R                  XA5      X#S.6$ )u  [🌐 Shape(19)](https://onnx.ai/onnx/operators/onnx__Shape.html#shape-19 "Online Documentation")


Takes a tensor as input and outputs an 1D int64 tensor containing the shape of the input tensor.
Optional attributes start and end can be used to compute a slice of the input tensor's shape.
If start axis is omitted, the slice starts from axis 0.
The end axis, if specified, is exclusive (and the returned value will not include the size of that axis).
If the end axis is omitted, the axes upto the last one will be included.
Negative axes indicate counting back from the last axis.
Note that axes will be clamped to the range [0, r], where r is the
rank of the input tensor if they are out-of-range (after adding r in the case of
negative axis). Thus, specifying any end value > r is equivalent to specifying an end
value of r, and specifying any start value < -r is equivalent to specifying a start
value of 0. If start > end, the result will be an empty shape.

Examples:

::

    Input tensor with shape: [2, 3, 4]
    No attributes specified.
    Output: [2, 3, 4]



::

    Input tensor with shape: [2, 3, 4]
    start: -1
    Output: [4]



::

    Input tensor with shape: [2, 3, 4]
    end: -1
    Output: [2, 3]



::

    Input tensor with shape: [2, 3, 4]
    start: 1
    end: 2
    Output: [3]




Args:
    data: (non-differentiable) An input tensor.

    end: (Optional) Ending axis for slicing the shape. Negative value means
        counting dimensions from the back. If omitted, sizes of all axes upto
        (including) the last one will be included.

    start: (Optional) Starting axis for slicing the shape. Default value is
        0.Negative value means counting dimensions from the back.
Shaper)   r(   r   r:   )r<   r   r   r   r>   r?   s         r,   r   Opset19.Shape  s9    ~ GR,gv&4''53LLr.   T_SizeT1_Sizec                ^    [        SSS5      n[        U SU5      nU" U R                  X!5      6 $ )u  [🌐 Size(19)](https://onnx.ai/onnx/operators/onnx__Size.html#size-19 "Online Documentation")


Takes a tensor as input and outputs a int64 scalar that equals to the total number of elements of the input tensor.


Args:
    data: (non-differentiable) An input tensor.
Sizer)   r(   r:   )r<   r   r>   r?   s       r,   r   Opset19.Sizel  s6     FB+ff%4''566r.    )r=   r/   r1   strr2   intr3   r   r4   Optional[Sequence[int]]r9   zSequence[int]r5   r   r6   r   returnr/   )rH   rA   rD   r   rG   r   r   rB   )rH   rJ   rN   rK   rD   r   r   rK   )rR   zOptional[SparseTensorProto]rS   zOptional[TensorProto]rT   zOptional[float]rU   zOptional[Sequence[float]]rV   Optional[int]rW   r   rX   zOptional[str]rY   zOptional[Sequence[str]]r   rP   )NN)r=   r]   rc   r]   rd   r]   re   Optional[T_DeformConv]rf   r   r4   r   r_   r   r9   r   r`   r   r5   r   r6   r   r   r]   )N)
rm   rh   rn   ri   ro   zOptional[T1_DequantizeLinear]rj   r   r   ri   )ru   rq   re   rq   r   rr   )rH   rw   r   rw   )r   r{   r   r   r   r   r   r|   )
r   zOptional[I_Loop]r   zOptional[B_Loop]r   r   r   r   r   r   )r   r   r5   r   r   zOptional[T_Pad]r   zOptional[Tind_Pad]r   r   r   r   )rm   r   r   r   r   zOptional[T2_QuantizeLinear]rj   r   rD   r   r   r   )r   r   r   r   r   r   r   r   )NNN)r=   r   r   zOptional[T2_Resize]r   zOptional[FLOAT]r   zOptional[INT64]r   r   r   r   r   r   r   floatr   r   r   r   r   r   r   r   r   r   r   r   )r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   )r   r   r   r   r   r   r   r   )r   r   r   r   )M__name__
__module____qualname____firstlineno__r*   r   r   r   r   r/   r8   r   r   r   r   r   r   r   r   r   r   r   r   r    r!   r   rA   r   rB   __annotations__rF   rJ   rK   rM   r   r   rP   r[   r]   rb   rh   ri   rl   rq   rr   rt   r   r   rw   ry   r{   r|   r~   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   __static_attributes__r   r.   r,   r%   r%   /   s:   * OVUGDM !!"-1(,+/g
g
 	g

 g
 g
 +g
 $g
 &g
 )g
 
g
R 'G, #	GY * 78 XRt 'K, 'K. PQX X/:XILX	X8 "'	J	 4 59'+'+26#'.2&*156
 26
 %	6

 %6
 06
 !6
 ,6
 $6
 /6
 
6
p >65'BL %)'+Q
 .204(,+/Q
Q
 Q
 	Q

 "Q
 %Q
 +Q
 Q
 .Q
 Q
 &Q
 )Q
 
Q
f "	 ""75'R 7;	'V 'V'V %'V 4	'V 'V 
'VR G$ Hi7(  CC$ C 	*%&C 	)$%	C
 	&!"C 	%!C 	'"#C 	%!C 	%!C 	%!C 	$ C 	&!"C 	&!"C 	&!"C 	&!"C  	%!!C" 	#C$ 	%C& 	'C( 	)C* 	+C, 	-C. 	/C0 	1C2 	3C4 	5C6 	7C8 	9C: 	;C< 	=C> 	?C@ 	ACB 	CCD 	ECF 	GCH 	ICJ 	KCL 	MCN 	OCP 	QCR 	SCT 	UCV 	WCX 	YCZ 	[C\ 	]C^ 	_C` 	aCb 	cCd 	eCf 	gCh 	iCj 	kCl 	mCn 	oCp 	qCr 	sCt 	uCv 	wCx 	yCz 	{C| 	}C~ 	C@ 	ACB 	CCD 	ECJJ8 D)(	" (	"(	"(	" 	(	" 		(	"
 	(	" 	(	" 	(	" 	(	" 	(	" 	(	" 	(	" 	(	" 	(	" 	(	" 	(	"  	!(	"" 	#(	"$ 	%(	"& 	'(	"( 	)(	"* 	+(	", 	-(	". 	/(	"0 	1(	"2 	3(	"4 	5(	"6 	7(	"8 	9(	": 	;(	"< 	=(	"> 	?(	"@ 	A(	"B 	C(	"D 	E(	"F 	G(	"H 	I(	"J 	K(	"L 	 M(	"N 	O(	"P 	 Q(	"*D) *X
2 FIFI NN(#$N 	$ N 	*%&	N
 	)$%N 	&!"N 	%!N 	'"#N 	%!N 	%!N 	%!N 	$ N 	&!"N 	&!"N 	&!"N  	&!"!N" 	%!#N$ 	%N& 	'N( 	)N* 	+N, 	-N. 	/N0 	1N2 	3N4 	 5N6 	7N8 	 9N: 	;N< 	=N> 	?N@ 	ANB 	CND 	ENF 	GNH 	INJ 	KNL 	MNN 	ONP 	QNR 	SNT 	UNV 	WNX 	YNZ 	[N\ 	 ]N^ 	_N` 	 aNb 	cNd 	eNf 	gNh 	iNj 	kNl 	mNn 	oNp 	qNr 	sNt 	uNv 	wNx 	yNz 	{N| 	}N~ 	N@ 	ANB 	CND 	ENF 	GNH 	INJ 	KNL 	MNN 	ONP 	QNR 	SNT 	UNV 	WNX 	YNZ 	[NF`hQhQ hQ 	hQ
 hQ 
hQT #E( z5%0H +/#'V^ V^V^ V^ (	V^
 !V^ V^ 
V^p   3XuguU 59	4
 4
4
 #4
 2	4
 4
 4
 
4
l +I0 JK !SF #I( VUG<I
 $("&!%[
 (,.:$ %((10[
[
 ![
  	[

 [
 [
 &[
 ),[
 [
 [
 #[
 #&[
 [
 [
  
![
z +F: 489=48:>y
(.y
 y
 	y

 1y
  7y
 2y
 !8y
 
y
v +G0  Hi;?a AMF +F0 GY7r.   r%   N)*
__future__r   typingr   r   r   r   onnxr   r	   r
   	onnx.defsr   typing_extensionsr   #onnxscript.onnx_opset._impl.opset18r   onnxscript.onnx_typesr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r    r!   onnxscript.valuesr"   r#   r%   r   r.   r,   <module>r      sP    # 5 5 ; ;   ' 7     , (J7g J7r.   