@triton.jit
def _AvgPoolCeilStats_cl3d_backward_impl(Inpgrad_ptr, Outgrad_ptr,
    Output_ptr, Meangrad_ptr, Sqmeangrad_ptr, h_outgrad, w_outgrad,
    d_outgrad, d_inpgrad, batch_stride_outgrad, H_stride_outgrad,
    W_stride_outgrad, batch_stride_inpgrad, H_stride_inpgrad,
    W_stride_inpgrad, numel_no_channels_inpgrad, num_channels: tl.constexpr,
    almost_half_d: tl.constexpr):
    batch = tl.program_id(0)
    H = tl.program_id(1)
    W = tl.program_id(2)
    Inpgrad_ptr += (batch * batch_stride_inpgrad + H * H_stride_inpgrad + W *
        W_stride_inpgrad)
    Output_ptr += (batch * batch_stride_inpgrad + H * H_stride_inpgrad + W *
        W_stride_inpgrad)
    pair_offset = tl.arange(0, 2)
    channels_offset = tl.arange(0, num_channels)
    d_offset = tl.arange(0, almost_half_d)
    inpgrad_offset = d_offset[:, None, None] * num_channels + channels_offset[
        None, :, None]
    outgrad_offset = d_offset[:, None, None] * (2 * num_channels
        ) + channels_offset[None, :, None] + pair_offset[None, None, :
        ] * num_channels
    inpgrad_mask = d_offset[:, None, None] < d_inpgrad
    outgrad_mask = d_offset[:, None, None] * 2 + pair_offset[None, None, :
        ] < d_outgrad
    inpgrad = tl.load(Inpgrad_ptr + inpgrad_offset, mask=inpgrad_mask,
        other=0.0)
    output = tl.load(Output_ptr + inpgrad_offset, mask=inpgrad_mask, other=0.0)
    meangrad = tl.load(Meangrad_ptr + channels_offset)[None, :, None]
    sqmeangrad = tl.load(Sqmeangrad_ptr + channels_offset)[None, :, None]
    normalizer = tl.sum(outgrad_mask.to(tl.float16), axis=2)[:, :, None].to(tl
        .float16)
    W_skip = False
    if 2 * (W + 1) > w_outgrad:
        W_skip = True
    else:
        normalizer *= 2
    H_skip = False
    if 2 * (H + 1) > h_outgrad:
        H_skip = True
    else:
        normalizer *= 2
    meangrad = meangrad / numel_no_channels_inpgrad
    sqmeangrad = 2 * output.to(tl.float32
        ) * sqmeangrad / numel_no_channels_inpgrad
    grad = (inpgrad + meangrad + sqmeangrad) / normalizer
    Tmp_ptr = (Outgrad_ptr + batch * batch_stride_outgrad + 2 * H *
        H_stride_outgrad + 2 * W * W_stride_outgrad)
    tl.store(Tmp_ptr + outgrad_offset, grad, mask=outgrad_mask)
    if not W_skip:
        Tmp_ptr = (Outgrad_ptr + batch * batch_stride_outgrad + 2 * H *
            H_stride_outgrad + (2 * W + 1) * W_stride_outgrad)
        tl.store(Tmp_ptr + outgrad_offset, grad, mask=outgrad_mask)
    if not H_skip:
        Tmp_ptr = Outgrad_ptr + batch * batch_stride_outgrad + (2 * H + 1
            ) * H_stride_outgrad + 2 * W * W_stride_outgrad
        tl.store(Tmp_ptr + outgrad_offset, grad, mask=outgrad_mask)
    if not H_skip and not W_skip:
        Tmp_ptr = Outgrad_ptr + batch * batch_stride_outgrad + (2 * H + 1
            ) * H_stride_outgrad + (2 * W + 1) * W_stride_outgrad
        tl.store(Tmp_ptr + outgrad_offset, grad, mask=outgrad_mask)
