import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
import torch.nn as nn
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
empty_strided_cuda = torch._C._dynamo.guards._empty_strided_cuda


@triton.jit
def triton_per_fused_max_min_0(in_ptr0, out_ptr0, out_ptr1, xnumel, rnumel,
    XBLOCK: tl.constexpr):
    RBLOCK: tl.constexpr = 64
    xoffset = tl.program_id(0) * XBLOCK
    xoffset + tl.arange(0, XBLOCK)[:, None]
    tl.full([XBLOCK, RBLOCK], True, tl.int1)
    rindex = tl.arange(0, RBLOCK)[None, :]
    tl.full([XBLOCK, RBLOCK], True, tl.int1)
    r0 = rindex
    tmp0 = tl.load(in_ptr0 + r0, None)
    tmp1 = tl.broadcast_to(tmp0, [XBLOCK, RBLOCK])
    tmp3 = triton_helpers.min2(tmp1, 1)[:, None]
    tmp5 = triton_helpers.max2(tmp1, 1)[:, None]
    tl.store(out_ptr0 + tl.full([XBLOCK, 1], 0, tl.int32), tmp3, None)
    tl.store(out_ptr1 + tl.full([XBLOCK, 1], 0, tl.int32), tmp5, None)


@triton.jit
def triton_per_fused_max_min_1(in_ptr0, out_ptr0, out_ptr1, xnumel, rnumel,
    XBLOCK: tl.constexpr):
    RBLOCK: tl.constexpr = 64
    xoffset = tl.program_id(0) * XBLOCK
    xoffset + tl.arange(0, XBLOCK)[:, None]
    tl.full([XBLOCK, RBLOCK], True, tl.int1)
    rindex = tl.arange(0, RBLOCK)[None, :]
    tl.full([XBLOCK, RBLOCK], True, tl.int1)
    r0 = rindex
    tmp0 = tl.load(in_ptr0 + (64 + r0), None)
    tmp1 = tl.broadcast_to(tmp0, [XBLOCK, RBLOCK])
    tmp3 = triton_helpers.min2(tmp1, 1)[:, None]
    tmp5 = triton_helpers.max2(tmp1, 1)[:, None]
    tl.store(out_ptr0 + tl.full([XBLOCK, 1], 0, tl.int32), tmp3, None)
    tl.store(out_ptr1 + tl.full([XBLOCK, 1], 0, tl.int32), tmp5, None)


@triton.jit
def triton_per_fused_max_min_2(in_ptr0, out_ptr0, out_ptr1, xnumel, rnumel,
    XBLOCK: tl.constexpr):
    RBLOCK: tl.constexpr = 64
    xoffset = tl.program_id(0) * XBLOCK
    xoffset + tl.arange(0, XBLOCK)[:, None]
    tl.full([XBLOCK, RBLOCK], True, tl.int1)
    rindex = tl.arange(0, RBLOCK)[None, :]
    tl.full([XBLOCK, RBLOCK], True, tl.int1)
    r0 = rindex
    tmp0 = tl.load(in_ptr0 + (128 + r0), None)
    tmp1 = tl.broadcast_to(tmp0, [XBLOCK, RBLOCK])
    tmp3 = triton_helpers.min2(tmp1, 1)[:, None]
    tmp5 = triton_helpers.max2(tmp1, 1)[:, None]
    tl.store(out_ptr0 + tl.full([XBLOCK, 1], 0, tl.int32), tmp3, None)
    tl.store(out_ptr1 + tl.full([XBLOCK, 1], 0, tl.int32), tmp5, None)


@triton.jit
def triton_per_fused_max_min_3(in_ptr0, out_ptr0, out_ptr1, xnumel, rnumel,
    XBLOCK: tl.constexpr):
    RBLOCK: tl.constexpr = 64
    xoffset = tl.program_id(0) * XBLOCK
    xoffset + tl.arange(0, XBLOCK)[:, None]
    tl.full([XBLOCK, RBLOCK], True, tl.int1)
    rindex = tl.arange(0, RBLOCK)[None, :]
    tl.full([XBLOCK, RBLOCK], True, tl.int1)
    r0 = rindex
    tmp0 = tl.load(in_ptr0 + (192 + r0), None)
    tmp1 = tl.broadcast_to(tmp0, [XBLOCK, RBLOCK])
    tmp3 = triton_helpers.min2(tmp1, 1)[:, None]
    tmp5 = triton_helpers.max2(tmp1, 1)[:, None]
    tl.store(out_ptr0 + tl.full([XBLOCK, 1], 0, tl.int32), tmp3, None)
    tl.store(out_ptr1 + tl.full([XBLOCK, 1], 0, tl.int32), tmp5, None)


@triton.jit
def triton_poi_fused_div_sub_zeros_like_4(in_out_ptr0, in_ptr0, in_ptr1,
    in_ptr2, in_ptr3, in_ptr4, in_ptr5, in_ptr6, in_ptr7, in_ptr8, xnumel,
    XBLOCK: tl.constexpr):
    xnumel = 256
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x1 = xindex // 64
    x0 = xindex % 64
    x2 = xindex
    tmp3 = tl.load(in_ptr0 + (64 + x0), xmask, eviction_policy='evict_last')
    tmp4 = tl.load(in_ptr1 + 0)
    tmp5 = tl.broadcast_to(tmp4, [XBLOCK])
    tmp7 = tl.load(in_ptr2 + 0)
    tmp8 = tl.broadcast_to(tmp7, [XBLOCK])
    tmp13 = tl.load(in_ptr0 + x0, xmask, eviction_policy='evict_last')
    tmp14 = tl.load(in_ptr3 + 0)
    tmp15 = tl.broadcast_to(tmp14, [XBLOCK])
    tmp17 = tl.load(in_ptr4 + 0)
    tmp18 = tl.broadcast_to(tmp17, [XBLOCK])
    tmp26 = tl.load(in_ptr0 + (192 + x0), xmask, eviction_policy='evict_last')
    tmp27 = tl.load(in_ptr5 + 0)
    tmp28 = tl.broadcast_to(tmp27, [XBLOCK])
    tmp30 = tl.load(in_ptr6 + 0)
    tmp31 = tl.broadcast_to(tmp30, [XBLOCK])
    tmp36 = tl.load(in_ptr0 + (128 + x0), xmask, eviction_policy='evict_last')
    tmp37 = tl.load(in_ptr7 + 0)
    tmp38 = tl.broadcast_to(tmp37, [XBLOCK])
    tmp40 = tl.load(in_ptr8 + 0)
    tmp41 = tl.broadcast_to(tmp40, [XBLOCK])
    tmp0 = x1
    tmp1 = tl.full([1], 1, tl.int32)
    tmp2 = tmp0 == tmp1
    tmp6 = tmp3 - tmp5
    tmp9 = tmp8 - tmp5
    tmp10 = tmp6 / tmp9
    tmp11 = tl.full([1], 0, tl.int32)
    tmp12 = tmp0 == tmp11
    tmp16 = tmp13 - tmp15
    tmp19 = tmp18 - tmp15
    tmp20 = tmp16 / tmp19
    tmp21 = 0.0
    tmp22 = tl.where(tmp12, tmp20, tmp21)
    tmp23 = tl.where(tmp2, tmp10, tmp22)
    tmp24 = tl.full([1], 3, tl.int32)
    tmp25 = tmp0 == tmp24
    tmp29 = tmp26 - tmp28
    tmp32 = tmp31 - tmp28
    tmp33 = tmp29 / tmp32
    tmp34 = tl.full([1], 2, tl.int32)
    tmp35 = tmp0 == tmp34
    tmp39 = tmp36 - tmp38
    tmp42 = tmp41 - tmp38
    tmp43 = tmp39 / tmp42
    tmp44 = tl.where(tmp35, tmp43, tmp23)
    tmp45 = tl.where(tmp25, tmp33, tmp44)
    tl.store(in_out_ptr0 + x2, tmp45, xmask)


def call(args):
    arg0_1, = args
    args.clear()
    assert_size_stride(arg0_1, (4, 4, 4, 4), (64, 16, 4, 1))
    with torch.cuda._DeviceGuard(0):
        torch.cuda.set_device(0)
        buf0 = empty_strided_cuda((), (), torch.float32)
        buf1 = empty_strided_cuda((), (), torch.float32)
        get_raw_stream(0)
        triton_per_fused_max_min_0[grid(1)](arg0_1, buf0, buf1, 1, 64,
            XBLOCK=1, num_warps=2, num_stages=1)
        buf2 = empty_strided_cuda((), (), torch.float32)
        buf3 = empty_strided_cuda((), (), torch.float32)
        triton_per_fused_max_min_1[grid(1)](arg0_1, buf2, buf3, 1, 64,
            XBLOCK=1, num_warps=2, num_stages=1)
        buf5 = empty_strided_cuda((), (), torch.float32)
        buf6 = empty_strided_cuda((), (), torch.float32)
        triton_per_fused_max_min_2[grid(1)](arg0_1, buf5, buf6, 1, 64,
            XBLOCK=1, num_warps=2, num_stages=1)
        buf7 = empty_strided_cuda((), (), torch.float32)
        buf8 = empty_strided_cuda((), (), torch.float32)
        triton_per_fused_max_min_3[grid(1)](arg0_1, buf7, buf8, 1, 64,
            XBLOCK=1, num_warps=2, num_stages=1)
        buf4 = empty_strided_cuda((4, 4, 4, 4), (64, 16, 4, 1), torch.float32)
        buf9 = buf4
        del buf4
        triton_poi_fused_div_sub_zeros_like_4[grid(256)](buf9, arg0_1, buf2,
            buf3, buf0, buf1, buf7, buf8, buf5, buf6, 256, XBLOCK=256,
            num_warps=4, num_stages=1)
        del arg0_1
        del buf0
        del buf1
        del buf2
        del buf3
        del buf5
        del buf6
        del buf7
        del buf8
    return buf9,


class Normalize01New(nn.Module):

    def __init__(self):
        super().__init__()

    def forward(self, input_0):
        arg0_1 = input_0
        output = call([arg0_1])
        return output[0]


Measured latency_ms: 0.07575