import torch
from torch._inductor.select_algorithm import extern_kernels
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
from torch._inductor.runtime.triton_helpers import libdevice, math as tl_math
from torch import nn
import torch.nn.functional as F
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
empty_strided_cuda = torch._C._dynamo.guards._empty_strided_cuda
reinterpret_tensor = torch._C._dynamo.guards._reinterpret_tensor


@triton.jit
def triton_poi_fused_add_leaky_relu_0(in_ptr0, in_ptr1, out_ptr0, xnumel,
    XBLOCK: tl.constexpr):
    xnumel = 64
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x3 = xindex // 4
    x0 = xindex % 4
    x2 = xindex // 16
    x4 = xindex
    tmp0 = tl.load(in_ptr0 + x3, xmask, eviction_policy='evict_last')
    tmp1 = tl.load(in_ptr1 + (x0 + 4 * x2), xmask, eviction_policy='evict_last'
        )
    tmp2 = tmp0 + tmp1
    tmp3 = 0.0
    tmp4 = tmp2 > tmp3
    tl.store(out_ptr0 + x4, tmp4, xmask)


@triton.jit
def triton_poi_fused_gt_1(in_ptr0, out_ptr0, xnumel, XBLOCK: tl.constexpr):
    xnumel = 64
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x0 = xindex
    tmp0 = tl.load(in_ptr0 + x0, xmask)
    tmp1 = 0.0
    tmp2 = tmp0 > tmp1
    tl.store(out_ptr0 + x0, tmp2, xmask)


@triton.jit
def triton_poi_fused__softmax_add_leaky_relu_mul_where_2(in_ptr0, in_ptr1,
    in_ptr2, in_ptr3, in_ptr4, in_ptr5, in_ptr6, in_ptr7, in_ptr8, in_ptr9,
    in_ptr10, in_ptr11, in_ptr12, out_ptr0, out_ptr1, out_ptr2, out_ptr3,
    xnumel, XBLOCK: tl.constexpr):
    xnumel = 16
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x2 = xindex
    x1 = xindex // 4
    tmp0 = tl.load(in_ptr0 + 4 * x2, xmask, eviction_policy='evict_last').to(tl
        .int1)
    tmp1 = tl.load(in_ptr1 + 4 * x2, xmask, eviction_policy='evict_last').to(tl
        .int1)
    tmp2 = tl.load(in_ptr2 + x2, xmask)
    tmp3 = tl.load(in_ptr3 + 4 * x1, xmask, eviction_policy='evict_last')
    tmp10 = tl.load(in_ptr0 + (1 + 4 * x2), xmask, eviction_policy='evict_last'
        ).to(tl.int1)
    tmp11 = tl.load(in_ptr1 + (1 + 4 * x2), xmask, eviction_policy='evict_last'
        ).to(tl.int1)
    tmp12 = tl.load(in_ptr3 + (1 + 4 * x1), xmask, eviction_policy='evict_last'
        )
    tmp18 = tl.load(in_ptr0 + (2 + 4 * x2), xmask, eviction_policy='evict_last'
        ).to(tl.int1)
    tmp19 = tl.load(in_ptr1 + (2 + 4 * x2), xmask, eviction_policy='evict_last'
        ).to(tl.int1)
    tmp20 = tl.load(in_ptr3 + (2 + 4 * x1), xmask, eviction_policy='evict_last'
        )
    tmp26 = tl.load(in_ptr0 + (3 + 4 * x2), xmask, eviction_policy='evict_last'
        ).to(tl.int1)
    tmp27 = tl.load(in_ptr1 + (3 + 4 * x2), xmask, eviction_policy='evict_last'
        ).to(tl.int1)
    tmp28 = tl.load(in_ptr3 + (3 + 4 * x1), xmask, eviction_policy='evict_last'
        )
    tmp34 = tl.load(in_ptr4 + 4 * x2, xmask, eviction_policy='evict_last').to(
        tl.int1)
    tmp35 = tl.load(in_ptr5 + x2, xmask)
    tmp36 = tl.load(in_ptr6 + 4 * x1, xmask, eviction_policy='evict_last')
    tmp41 = tl.load(in_ptr4 + (1 + 4 * x2), xmask, eviction_policy='evict_last'
        ).to(tl.int1)
    tmp42 = tl.load(in_ptr6 + (1 + 4 * x1), xmask, eviction_policy='evict_last'
        )
    tmp48 = tl.load(in_ptr4 + (2 + 4 * x2), xmask, eviction_policy='evict_last'
        ).to(tl.int1)
    tmp49 = tl.load(in_ptr6 + (2 + 4 * x1), xmask, eviction_policy='evict_last'
        )
    tmp55 = tl.load(in_ptr4 + (3 + 4 * x2), xmask, eviction_policy='evict_last'
        ).to(tl.int1)
    tmp56 = tl.load(in_ptr6 + (3 + 4 * x1), xmask, eviction_policy='evict_last'
        )
    tmp62 = tl.load(in_ptr7 + 4 * x2, xmask, eviction_policy='evict_last').to(
        tl.int1)
    tmp63 = tl.load(in_ptr8 + x2, xmask)
    tmp64 = tl.load(in_ptr9 + 4 * x1, xmask, eviction_policy='evict_last')
    tmp69 = tl.load(in_ptr7 + (1 + 4 * x2), xmask, eviction_policy='evict_last'
        ).to(tl.int1)
    tmp70 = tl.load(in_ptr9 + (1 + 4 * x1), xmask, eviction_policy='evict_last'
        )
    tmp76 = tl.load(in_ptr7 + (2 + 4 * x2), xmask, eviction_policy='evict_last'
        ).to(tl.int1)
    tmp77 = tl.load(in_ptr9 + (2 + 4 * x1), xmask, eviction_policy='evict_last'
        )
    tmp83 = tl.load(in_ptr7 + (3 + 4 * x2), xmask, eviction_policy='evict_last'
        ).to(tl.int1)
    tmp84 = tl.load(in_ptr9 + (3 + 4 * x1), xmask, eviction_policy='evict_last'
        )
    tmp90 = tl.load(in_ptr10 + 4 * x2, xmask, eviction_policy='evict_last').to(
        tl.int1)
    tmp91 = tl.load(in_ptr11 + x2, xmask)
    tmp92 = tl.load(in_ptr12 + 4 * x1, xmask, eviction_policy='evict_last')
    tmp97 = tl.load(in_ptr10 + (1 + 4 * x2), xmask, eviction_policy=
        'evict_last').to(tl.int1)
    tmp98 = tl.load(in_ptr12 + (1 + 4 * x1), xmask, eviction_policy=
        'evict_last')
    tmp104 = tl.load(in_ptr10 + (2 + 4 * x2), xmask, eviction_policy=
        'evict_last').to(tl.int1)
    tmp105 = tl.load(in_ptr12 + (2 + 4 * x1), xmask, eviction_policy=
        'evict_last')
    tmp111 = tl.load(in_ptr10 + (3 + 4 * x2), xmask, eviction_policy=
        'evict_last').to(tl.int1)
    tmp112 = tl.load(in_ptr12 + (3 + 4 * x1), xmask, eviction_policy=
        'evict_last')
    tmp4 = tmp2 + tmp3
    tmp5 = 4.0
    tmp6 = tmp4 * tmp5
    tmp7 = tl.where(tmp1, tmp4, tmp6)
    tmp8 = -8999999815811072.0
    tmp9 = tl.where(tmp0, tmp7, tmp8)
    tmp13 = tmp2 + tmp12
    tmp14 = tmp13 * tmp5
    tmp15 = tl.where(tmp11, tmp13, tmp14)
    tmp16 = tl.where(tmp10, tmp15, tmp8)
    tmp17 = triton_helpers.maximum(tmp9, tmp16)
    tmp21 = tmp2 + tmp20
    tmp22 = tmp21 * tmp5
    tmp23 = tl.where(tmp19, tmp21, tmp22)
    tmp24 = tl.where(tmp18, tmp23, tmp8)
    tmp25 = triton_helpers.maximum(tmp17, tmp24)
    tmp29 = tmp2 + tmp28
    tmp30 = tmp29 * tmp5
    tmp31 = tl.where(tmp27, tmp29, tmp30)
    tmp32 = tl.where(tmp26, tmp31, tmp8)
    tmp33 = triton_helpers.maximum(tmp25, tmp32)
    tmp37 = tmp35 + tmp36
    tmp38 = tmp37 * tmp5
    tmp39 = tl.where(tmp34, tmp37, tmp38)
    tmp40 = tl.where(tmp0, tmp39, tmp8)
    tmp43 = tmp35 + tmp42
    tmp44 = tmp43 * tmp5
    tmp45 = tl.where(tmp41, tmp43, tmp44)
    tmp46 = tl.where(tmp10, tmp45, tmp8)
    tmp47 = triton_helpers.maximum(tmp40, tmp46)
    tmp50 = tmp35 + tmp49
    tmp51 = tmp50 * tmp5
    tmp52 = tl.where(tmp48, tmp50, tmp51)
    tmp53 = tl.where(tmp18, tmp52, tmp8)
    tmp54 = triton_helpers.maximum(tmp47, tmp53)
    tmp57 = tmp35 + tmp56
    tmp58 = tmp57 * tmp5
    tmp59 = tl.where(tmp55, tmp57, tmp58)
    tmp60 = tl.where(tmp26, tmp59, tmp8)
    tmp61 = triton_helpers.maximum(tmp54, tmp60)
    tmp65 = tmp63 + tmp64
    tmp66 = tmp65 * tmp5
    tmp67 = tl.where(tmp62, tmp65, tmp66)
    tmp68 = tl.where(tmp0, tmp67, tmp8)
    tmp71 = tmp63 + tmp70
    tmp72 = tmp71 * tmp5
    tmp73 = tl.where(tmp69, tmp71, tmp72)
    tmp74 = tl.where(tmp10, tmp73, tmp8)
    tmp75 = triton_helpers.maximum(tmp68, tmp74)
    tmp78 = tmp63 + tmp77
    tmp79 = tmp78 * tmp5
    tmp80 = tl.where(tmp76, tmp78, tmp79)
    tmp81 = tl.where(tmp18, tmp80, tmp8)
    tmp82 = triton_helpers.maximum(tmp75, tmp81)
    tmp85 = tmp63 + tmp84
    tmp86 = tmp85 * tmp5
    tmp87 = tl.where(tmp83, tmp85, tmp86)
    tmp88 = tl.where(tmp26, tmp87, tmp8)
    tmp89 = triton_helpers.maximum(tmp82, tmp88)
    tmp93 = tmp91 + tmp92
    tmp94 = tmp93 * tmp5
    tmp95 = tl.where(tmp90, tmp93, tmp94)
    tmp96 = tl.where(tmp0, tmp95, tmp8)
    tmp99 = tmp91 + tmp98
    tmp100 = tmp99 * tmp5
    tmp101 = tl.where(tmp97, tmp99, tmp100)
    tmp102 = tl.where(tmp10, tmp101, tmp8)
    tmp103 = triton_helpers.maximum(tmp96, tmp102)
    tmp106 = tmp91 + tmp105
    tmp107 = tmp106 * tmp5
    tmp108 = tl.where(tmp104, tmp106, tmp107)
    tmp109 = tl.where(tmp18, tmp108, tmp8)
    tmp110 = triton_helpers.maximum(tmp103, tmp109)
    tmp113 = tmp91 + tmp112
    tmp114 = tmp113 * tmp5
    tmp115 = tl.where(tmp111, tmp113, tmp114)
    tmp116 = tl.where(tmp26, tmp115, tmp8)
    tmp117 = triton_helpers.maximum(tmp110, tmp116)
    tl.store(out_ptr0 + x2, tmp33, xmask)
    tl.store(out_ptr1 + x2, tmp61, xmask)
    tl.store(out_ptr2 + x2, tmp89, xmask)
    tl.store(out_ptr3 + x2, tmp117, xmask)


@triton.jit
def triton_poi_fused__softmax_add_leaky_relu_mul_where_3(in_ptr0, in_ptr1,
    in_ptr2, in_ptr3, in_ptr4, in_ptr5, in_ptr6, in_ptr7, in_ptr8, in_ptr9,
    in_ptr10, in_ptr11, in_ptr12, in_ptr13, in_ptr14, in_ptr15, in_ptr16,
    out_ptr0, out_ptr1, out_ptr2, out_ptr3, xnumel, XBLOCK: tl.constexpr):
    xnumel = 64
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x3 = xindex
    x4 = xindex // 4
    x0 = xindex % 4
    x2 = xindex // 16
    tmp0 = tl.load(in_ptr0 + x3, xmask).to(tl.int1)
    tmp1 = tl.load(in_ptr1 + x3, xmask).to(tl.int1)
    tmp2 = tl.load(in_ptr2 + x4, xmask, eviction_policy='evict_last')
    tmp3 = tl.load(in_ptr3 + (x0 + 4 * x2), xmask, eviction_policy='evict_last'
        )
    tmp10 = tl.load(in_ptr4 + x4, xmask, eviction_policy='evict_last')
    tmp13 = tl.load(in_ptr5 + x3, xmask).to(tl.int1)
    tmp14 = tl.load(in_ptr6 + x4, xmask, eviction_policy='evict_last')
    tmp15 = tl.load(in_ptr7 + (x0 + 4 * x2), xmask, eviction_policy=
        'evict_last')
    tmp20 = tl.load(in_ptr8 + x4, xmask, eviction_policy='evict_last')
    tmp23 = tl.load(in_ptr9 + x3, xmask).to(tl.int1)
    tmp24 = tl.load(in_ptr10 + x4, xmask, eviction_policy='evict_last')
    tmp25 = tl.load(in_ptr11 + (x0 + 4 * x2), xmask, eviction_policy=
        'evict_last')
    tmp30 = tl.load(in_ptr12 + x4, xmask, eviction_policy='evict_last')
    tmp33 = tl.load(in_ptr13 + x3, xmask).to(tl.int1)
    tmp34 = tl.load(in_ptr14 + x4, xmask, eviction_policy='evict_last')
    tmp35 = tl.load(in_ptr15 + (x0 + 4 * x2), xmask, eviction_policy=
        'evict_last')
    tmp40 = tl.load(in_ptr16 + x4, xmask, eviction_policy='evict_last')
    tmp4 = tmp2 + tmp3
    tmp5 = 4.0
    tmp6 = tmp4 * tmp5
    tmp7 = tl.where(tmp1, tmp4, tmp6)
    tmp8 = -8999999815811072.0
    tmp9 = tl.where(tmp0, tmp7, tmp8)
    tmp11 = tmp9 - tmp10
    tmp12 = tl_math.exp(tmp11)
    tmp16 = tmp14 + tmp15
    tmp17 = tmp16 * tmp5
    tmp18 = tl.where(tmp13, tmp16, tmp17)
    tmp19 = tl.where(tmp0, tmp18, tmp8)
    tmp21 = tmp19 - tmp20
    tmp22 = tl_math.exp(tmp21)
    tmp26 = tmp24 + tmp25
    tmp27 = tmp26 * tmp5
    tmp28 = tl.where(tmp23, tmp26, tmp27)
    tmp29 = tl.where(tmp0, tmp28, tmp8)
    tmp31 = tmp29 - tmp30
    tmp32 = tl_math.exp(tmp31)
    tmp36 = tmp34 + tmp35
    tmp37 = tmp36 * tmp5
    tmp38 = tl.where(tmp33, tmp36, tmp37)
    tmp39 = tl.where(tmp0, tmp38, tmp8)
    tmp41 = tmp39 - tmp40
    tmp42 = tl_math.exp(tmp41)
    tl.store(out_ptr0 + x3, tmp12, xmask)
    tl.store(out_ptr1 + x3, tmp22, xmask)
    tl.store(out_ptr2 + x3, tmp32, xmask)
    tl.store(out_ptr3 + x3, tmp42, xmask)


@triton.jit
def triton_poi_fused__softmax_4(in_ptr0, out_ptr0, xnumel, XBLOCK: tl.constexpr
    ):
    xnumel = 64
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x2 = xindex
    x1 = xindex // 4
    tmp0 = tl.load(in_ptr0 + x2, xmask)
    tmp1 = tl.load(in_ptr0 + 4 * x1, xmask, eviction_policy='evict_last')
    tmp2 = tl.load(in_ptr0 + (1 + 4 * x1), xmask, eviction_policy='evict_last')
    tmp4 = tl.load(in_ptr0 + (2 + 4 * x1), xmask, eviction_policy='evict_last')
    tmp6 = tl.load(in_ptr0 + (3 + 4 * x1), xmask, eviction_policy='evict_last')
    tmp3 = tmp1 + tmp2
    tmp5 = tmp3 + tmp4
    tmp7 = tmp5 + tmp6
    tmp8 = tmp0 / tmp7
    tl.store(out_ptr0 + x2, tmp8, xmask)


@triton.jit
def triton_poi_fused_cat_5(in_ptr0, in_ptr1, in_ptr2, in_ptr3, out_ptr0,
    xnumel, XBLOCK: tl.constexpr):
    xnumel = 256
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x0 = xindex % 16
    x1 = xindex // 16
    x2 = xindex
    tmp0 = x0
    tl.full([1], 0, tl.int64)
    tmp3 = tl.full([1], 4, tl.int64)
    tmp4 = tmp0 < tmp3
    tmp5 = tl.load(in_ptr0 + (4 * x1 + x0), tmp4 & xmask, eviction_policy=
        'evict_last', other=0.0)
    tmp6 = 0.0
    tmp7 = tmp5 > tmp6
    tmp8 = 1.0
    tmp9 = tmp5 * tmp8
    tmp10 = libdevice.expm1(tmp9)
    tmp11 = tmp10 * tmp8
    tmp12 = tl.where(tmp7, tmp9, tmp11)
    tmp13 = tl.full(tmp12.shape, 0.0, tmp12.dtype)
    tmp14 = tl.where(tmp4, tmp12, tmp13)
    tmp15 = tmp0 >= tmp3
    tmp16 = tl.full([1], 8, tl.int64)
    tmp17 = tmp0 < tmp16
    tmp18 = tmp15 & tmp17
    tmp19 = tl.load(in_ptr1 + (4 * x1 + (-4 + x0)), tmp18 & xmask,
        eviction_policy='evict_last', other=0.0)
    tmp20 = tmp19 > tmp6
    tmp21 = tmp19 * tmp8
    tmp22 = libdevice.expm1(tmp21)
    tmp23 = tmp22 * tmp8
    tmp24 = tl.where(tmp20, tmp21, tmp23)
    tmp25 = tl.full(tmp24.shape, 0.0, tmp24.dtype)
    tmp26 = tl.where(tmp18, tmp24, tmp25)
    tmp27 = tmp0 >= tmp16
    tmp28 = tl.full([1], 12, tl.int64)
    tmp29 = tmp0 < tmp28
    tmp30 = tmp27 & tmp29
    tmp31 = tl.load(in_ptr2 + (4 * x1 + (-8 + x0)), tmp30 & xmask,
        eviction_policy='evict_last', other=0.0)
    tmp32 = tmp31 > tmp6
    tmp33 = tmp31 * tmp8
    tmp34 = libdevice.expm1(tmp33)
    tmp35 = tmp34 * tmp8
    tmp36 = tl.where(tmp32, tmp33, tmp35)
    tmp37 = tl.full(tmp36.shape, 0.0, tmp36.dtype)
    tmp38 = tl.where(tmp30, tmp36, tmp37)
    tmp39 = tmp0 >= tmp28
    tl.full([1], 16, tl.int64)
    tmp42 = tl.load(in_ptr3 + (4 * x1 + (-12 + x0)), tmp39 & xmask,
        eviction_policy='evict_last', other=0.0)
    tmp43 = tmp42 > tmp6
    tmp44 = tmp42 * tmp8
    tmp45 = libdevice.expm1(tmp44)
    tmp46 = tmp45 * tmp8
    tmp47 = tl.where(tmp43, tmp44, tmp46)
    tmp48 = tl.full(tmp47.shape, 0.0, tmp47.dtype)
    tmp49 = tl.where(tmp39, tmp47, tmp48)
    tmp50 = tl.where(tmp30, tmp38, tmp49)
    tmp51 = tl.where(tmp18, tmp26, tmp50)
    tmp52 = tl.where(tmp4, tmp14, tmp51)
    tl.store(out_ptr0 + x2, tmp52, xmask)


@triton.jit
def triton_poi_fused__softmax_add_leaky_relu_mul_where_6(in_ptr0, in_ptr1,
    in_ptr2, in_ptr3, out_ptr0, xnumel, XBLOCK: tl.constexpr):
    xnumel = 16
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x2 = xindex
    x1 = xindex // 4
    tmp0 = tl.load(in_ptr0 + 4 * x2, xmask, eviction_policy='evict_last').to(tl
        .int1)
    tmp1 = tl.load(in_ptr1 + 4 * x2, xmask, eviction_policy='evict_last').to(tl
        .int1)
    tmp2 = tl.load(in_ptr2 + x2, xmask)
    tmp3 = tl.load(in_ptr3 + 4 * x1, xmask, eviction_policy='evict_last')
    tmp10 = tl.load(in_ptr0 + (1 + 4 * x2), xmask, eviction_policy='evict_last'
        ).to(tl.int1)
    tmp11 = tl.load(in_ptr1 + (1 + 4 * x2), xmask, eviction_policy='evict_last'
        ).to(tl.int1)
    tmp12 = tl.load(in_ptr3 + (1 + 4 * x1), xmask, eviction_policy='evict_last'
        )
    tmp18 = tl.load(in_ptr0 + (2 + 4 * x2), xmask, eviction_policy='evict_last'
        ).to(tl.int1)
    tmp19 = tl.load(in_ptr1 + (2 + 4 * x2), xmask, eviction_policy='evict_last'
        ).to(tl.int1)
    tmp20 = tl.load(in_ptr3 + (2 + 4 * x1), xmask, eviction_policy='evict_last'
        )
    tmp26 = tl.load(in_ptr0 + (3 + 4 * x2), xmask, eviction_policy='evict_last'
        ).to(tl.int1)
    tmp27 = tl.load(in_ptr1 + (3 + 4 * x2), xmask, eviction_policy='evict_last'
        ).to(tl.int1)
    tmp28 = tl.load(in_ptr3 + (3 + 4 * x1), xmask, eviction_policy='evict_last'
        )
    tmp4 = tmp2 + tmp3
    tmp5 = 4.0
    tmp6 = tmp4 * tmp5
    tmp7 = tl.where(tmp1, tmp4, tmp6)
    tmp8 = -8999999815811072.0
    tmp9 = tl.where(tmp0, tmp7, tmp8)
    tmp13 = tmp2 + tmp12
    tmp14 = tmp13 * tmp5
    tmp15 = tl.where(tmp11, tmp13, tmp14)
    tmp16 = tl.where(tmp10, tmp15, tmp8)
    tmp17 = triton_helpers.maximum(tmp9, tmp16)
    tmp21 = tmp2 + tmp20
    tmp22 = tmp21 * tmp5
    tmp23 = tl.where(tmp19, tmp21, tmp22)
    tmp24 = tl.where(tmp18, tmp23, tmp8)
    tmp25 = triton_helpers.maximum(tmp17, tmp24)
    tmp29 = tmp2 + tmp28
    tmp30 = tmp29 * tmp5
    tmp31 = tl.where(tmp27, tmp29, tmp30)
    tmp32 = tl.where(tmp26, tmp31, tmp8)
    tmp33 = triton_helpers.maximum(tmp25, tmp32)
    tl.store(out_ptr0 + x2, tmp33, xmask)


@triton.jit
def triton_poi_fused__softmax_add_leaky_relu_mul_where_7(in_ptr0, in_ptr1,
    in_ptr2, in_ptr3, in_ptr4, out_ptr0, xnumel, XBLOCK: tl.constexpr):
    xnumel = 64
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x3 = xindex
    x4 = xindex // 4
    x0 = xindex % 4
    x2 = xindex // 16
    tmp0 = tl.load(in_ptr0 + x3, xmask).to(tl.int1)
    tmp1 = tl.load(in_ptr1 + x3, xmask).to(tl.int1)
    tmp2 = tl.load(in_ptr2 + x4, xmask, eviction_policy='evict_last')
    tmp3 = tl.load(in_ptr3 + (x0 + 4 * x2), xmask, eviction_policy='evict_last'
        )
    tmp10 = tl.load(in_ptr4 + x4, xmask, eviction_policy='evict_last')
    tmp4 = tmp2 + tmp3
    tmp5 = 4.0
    tmp6 = tmp4 * tmp5
    tmp7 = tl.where(tmp1, tmp4, tmp6)
    tmp8 = -8999999815811072.0
    tmp9 = tl.where(tmp0, tmp7, tmp8)
    tmp11 = tmp9 - tmp10
    tmp12 = tl_math.exp(tmp11)
    tl.store(out_ptr0 + x3, tmp12, xmask)


@triton.jit
def triton_poi_fused__log_softmax_elu_8(in_ptr0, out_ptr0, xnumel, XBLOCK:
    tl.constexpr):
    xnumel = 64
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x3 = xindex
    x0 = xindex % 4
    x2 = xindex // 16
    tmp0 = tl.load(in_ptr0 + x3, xmask)
    tmp8 = tl.load(in_ptr0 + (x0 + 16 * x2), xmask, eviction_policy=
        'evict_last')
    tmp14 = tl.load(in_ptr0 + (4 + x0 + 16 * x2), xmask, eviction_policy=
        'evict_last')
    tmp21 = tl.load(in_ptr0 + (8 + x0 + 16 * x2), xmask, eviction_policy=
        'evict_last')
    tmp28 = tl.load(in_ptr0 + (12 + x0 + 16 * x2), xmask, eviction_policy=
        'evict_last')
    tmp1 = 0.0
    tmp2 = tmp0 > tmp1
    tmp3 = 1.0
    tmp4 = tmp0 * tmp3
    tmp5 = libdevice.expm1(tmp4)
    tmp6 = tmp5 * tmp3
    tmp7 = tl.where(tmp2, tmp4, tmp6)
    tmp9 = tmp8 > tmp1
    tmp10 = tmp8 * tmp3
    tmp11 = libdevice.expm1(tmp10)
    tmp12 = tmp11 * tmp3
    tmp13 = tl.where(tmp9, tmp10, tmp12)
    tmp15 = tmp14 > tmp1
    tmp16 = tmp14 * tmp3
    tmp17 = libdevice.expm1(tmp16)
    tmp18 = tmp17 * tmp3
    tmp19 = tl.where(tmp15, tmp16, tmp18)
    tmp20 = triton_helpers.maximum(tmp13, tmp19)
    tmp22 = tmp21 > tmp1
    tmp23 = tmp21 * tmp3
    tmp24 = libdevice.expm1(tmp23)
    tmp25 = tmp24 * tmp3
    tmp26 = tl.where(tmp22, tmp23, tmp25)
    tmp27 = triton_helpers.maximum(tmp20, tmp26)
    tmp29 = tmp28 > tmp1
    tmp30 = tmp28 * tmp3
    tmp31 = libdevice.expm1(tmp30)
    tmp32 = tmp31 * tmp3
    tmp33 = tl.where(tmp29, tmp30, tmp32)
    tmp34 = triton_helpers.maximum(tmp27, tmp33)
    tmp35 = tmp7 - tmp34
    tl.store(out_ptr0 + x3, tmp35, xmask)


@triton.jit
def triton_poi_fused__log_softmax_9(in_ptr0, out_ptr0, xnumel, XBLOCK: tl.
    constexpr):
    xnumel = 64
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x3 = xindex
    x0 = xindex % 4
    x2 = xindex // 16
    tmp0 = tl.load(in_ptr0 + x3, xmask)
    tmp1 = tl.load(in_ptr0 + (x0 + 16 * x2), xmask, eviction_policy=
        'evict_last')
    tmp3 = tl.load(in_ptr0 + (4 + x0 + 16 * x2), xmask, eviction_policy=
        'evict_last')
    tmp6 = tl.load(in_ptr0 + (8 + x0 + 16 * x2), xmask, eviction_policy=
        'evict_last')
    tmp9 = tl.load(in_ptr0 + (12 + x0 + 16 * x2), xmask, eviction_policy=
        'evict_last')
    tmp2 = tl_math.exp(tmp1)
    tmp4 = tl_math.exp(tmp3)
    tmp5 = tmp2 + tmp4
    tmp7 = tl_math.exp(tmp6)
    tmp8 = tmp5 + tmp7
    tmp10 = tl_math.exp(tmp9)
    tmp11 = tmp8 + tmp10
    tmp12 = tl_math.log(tmp11)
    tmp13 = tmp0 - tmp12
    tl.store(out_ptr0 + x3, tmp13, xmask)


def call(args):
    (primals_1, primals_2, primals_3, primals_4, primals_5, primals_6,
        primals_7, primals_8, primals_9, primals_10, primals_11, primals_12
        ) = args
    args.clear()
    assert_size_stride(primals_1, (4, 4, 4), (16, 4, 1))
    assert_size_stride(primals_2, (4, 4, 4), (16, 4, 1))
    assert_size_stride(primals_3, (4, 4), (4, 1))
    assert_size_stride(primals_4, (8, 1), (1, 1))
    assert_size_stride(primals_5, (4, 4), (4, 1))
    assert_size_stride(primals_6, (8, 1), (1, 1))
    assert_size_stride(primals_7, (4, 4), (4, 1))
    assert_size_stride(primals_8, (8, 1), (1, 1))
    assert_size_stride(primals_9, (4, 4), (4, 1))
    assert_size_stride(primals_10, (8, 1), (1, 1))
    assert_size_stride(primals_11, (16, 4), (4, 1))
    assert_size_stride(primals_12, (8, 1), (1, 1))
    with torch.cuda._DeviceGuard(0):
        torch.cuda.set_device(0)
        buf0 = empty_strided_cuda((16, 4), (4, 1), torch.float32)
        extern_kernels.mm(reinterpret_tensor(primals_1, (16, 4), (4, 1), 0),
            primals_3, out=buf0)
        del primals_3
        buf1 = empty_strided_cuda((16, 1), (1, 1), torch.float32)
        extern_kernels.mm(buf0, reinterpret_tensor(primals_4, (4, 1), (1, 1
            ), 0), out=buf1)
        buf2 = empty_strided_cuda((16, 1), (1, 1), torch.float32)
        extern_kernels.mm(buf0, reinterpret_tensor(primals_4, (4, 1), (1, 1
            ), 4), out=buf2)
        buf3 = empty_strided_cuda((4, 4, 4), (16, 4, 1), torch.bool)
        get_raw_stream(0)
        triton_poi_fused_add_leaky_relu_0[grid(64)](buf1, buf2, buf3, 64,
            XBLOCK=64, num_warps=1, num_stages=1)
        buf4 = empty_strided_cuda((4, 4, 4), (16, 4, 1), torch.bool)
        triton_poi_fused_gt_1[grid(64)](primals_2, buf4, 64, XBLOCK=64,
            num_warps=1, num_stages=1)
        del primals_2
        buf9 = empty_strided_cuda((16, 4), (4, 1), torch.float32)
        extern_kernels.mm(reinterpret_tensor(primals_1, (16, 4), (4, 1), 0),
            primals_5, out=buf9)
        del primals_5
        buf10 = empty_strided_cuda((16, 1), (1, 1), torch.float32)
        extern_kernels.mm(buf9, reinterpret_tensor(primals_6, (4, 1), (1, 1
            ), 0), out=buf10)
        buf11 = empty_strided_cuda((16, 1), (1, 1), torch.float32)
        extern_kernels.mm(buf9, reinterpret_tensor(primals_6, (4, 1), (1, 1
            ), 4), out=buf11)
        buf12 = empty_strided_cuda((4, 4, 4), (16, 4, 1), torch.bool)
        triton_poi_fused_add_leaky_relu_0[grid(64)](buf10, buf11, buf12, 64,
            XBLOCK=64, num_warps=1, num_stages=1)
        buf17 = empty_strided_cuda((16, 4), (4, 1), torch.float32)
        extern_kernels.mm(reinterpret_tensor(primals_1, (16, 4), (4, 1), 0),
            primals_7, out=buf17)
        del primals_7
        buf18 = empty_strided_cuda((16, 1), (1, 1), torch.float32)
        extern_kernels.mm(buf17, reinterpret_tensor(primals_8, (4, 1), (1, 
            1), 0), out=buf18)
        buf19 = empty_strided_cuda((16, 1), (1, 1), torch.float32)
        extern_kernels.mm(buf17, reinterpret_tensor(primals_8, (4, 1), (1, 
            1), 4), out=buf19)
        buf20 = empty_strided_cuda((4, 4, 4), (16, 4, 1), torch.bool)
        triton_poi_fused_add_leaky_relu_0[grid(64)](buf18, buf19, buf20, 64,
            XBLOCK=64, num_warps=1, num_stages=1)
        buf25 = empty_strided_cuda((16, 4), (4, 1), torch.float32)
        extern_kernels.mm(reinterpret_tensor(primals_1, (16, 4), (4, 1), 0),
            primals_9, out=buf25)
        del primals_9
        buf26 = empty_strided_cuda((16, 1), (1, 1), torch.float32)
        extern_kernels.mm(buf25, reinterpret_tensor(primals_10, (4, 1), (1,
            1), 0), out=buf26)
        buf27 = empty_strided_cuda((16, 1), (1, 1), torch.float32)
        extern_kernels.mm(buf25, reinterpret_tensor(primals_10, (4, 1), (1,
            1), 4), out=buf27)
        buf28 = empty_strided_cuda((4, 4, 4), (16, 4, 1), torch.bool)
        triton_poi_fused_add_leaky_relu_0[grid(64)](buf26, buf27, buf28, 64,
            XBLOCK=64, num_warps=1, num_stages=1)
        buf5 = empty_strided_cuda((4, 4, 1), (4, 1, 16), torch.float32)
        buf13 = empty_strided_cuda((4, 4, 1), (4, 1, 16), torch.float32)
        buf21 = empty_strided_cuda((4, 4, 1), (4, 1, 16), torch.float32)
        buf29 = empty_strided_cuda((4, 4, 1), (4, 1, 16), torch.float32)
        triton_poi_fused__softmax_add_leaky_relu_mul_where_2[grid(16)](buf4,
            buf3, buf1, buf2, buf12, buf10, buf11, buf20, buf18, buf19,
            buf28, buf26, buf27, buf5, buf13, buf21, buf29, 16, XBLOCK=16,
            num_warps=1, num_stages=1)
        buf6 = empty_strided_cuda((4, 4, 4), (16, 4, 1), torch.float32)
        buf14 = empty_strided_cuda((4, 4, 4), (16, 4, 1), torch.float32)
        buf22 = empty_strided_cuda((4, 4, 4), (16, 4, 1), torch.float32)
        buf30 = empty_strided_cuda((4, 4, 4), (16, 4, 1), torch.float32)
        triton_poi_fused__softmax_add_leaky_relu_mul_where_3[grid(64)](buf4,
            buf3, buf1, buf2, buf5, buf12, buf10, buf11, buf13, buf20,
            buf18, buf19, buf21, buf28, buf26, buf27, buf29, buf6, buf14,
            buf22, buf30, 64, XBLOCK=64, num_warps=1, num_stages=1)
        del buf1
        del buf10
        del buf11
        del buf13
        del buf18
        del buf19
        del buf2
        del buf21
        del buf26
        buf7 = empty_strided_cuda((4, 4, 4), (16, 4, 1), torch.float32)
        triton_poi_fused__softmax_4[grid(64)](buf6, buf7, 64, XBLOCK=64,
            num_warps=1, num_stages=1)
        buf8 = buf6
        del buf6
        extern_kernels.bmm(buf7, reinterpret_tensor(buf0, (4, 4, 4), (16, 4,
            1), 0), out=buf8)
        buf15 = empty_strided_cuda((4, 4, 4), (16, 4, 1), torch.float32)
        triton_poi_fused__softmax_4[grid(64)](buf14, buf15, 64, XBLOCK=64,
            num_warps=1, num_stages=1)
        buf16 = buf14
        del buf14
        extern_kernels.bmm(buf15, reinterpret_tensor(buf9, (4, 4, 4), (16, 
            4, 1), 0), out=buf16)
        buf23 = empty_strided_cuda((4, 4, 4), (16, 4, 1), torch.float32)
        triton_poi_fused__softmax_4[grid(64)](buf22, buf23, 64, XBLOCK=64,
            num_warps=1, num_stages=1)
        buf24 = buf22
        del buf22
        extern_kernels.bmm(buf23, reinterpret_tensor(buf17, (4, 4, 4), (16,
            4, 1), 0), out=buf24)
        buf31 = empty_strided_cuda((4, 4, 4), (16, 4, 1), torch.float32)
        triton_poi_fused__softmax_4[grid(64)](buf30, buf31, 64, XBLOCK=64,
            num_warps=1, num_stages=1)
        buf32 = buf30
        del buf30
        extern_kernels.bmm(buf31, reinterpret_tensor(buf25, (4, 4, 4), (16,
            4, 1), 0), out=buf32)
        buf33 = empty_strided_cuda((4, 4, 16), (64, 16, 1), torch.float32)
        triton_poi_fused_cat_5[grid(256)](buf8, buf16, buf24, buf32, buf33,
            256, XBLOCK=256, num_warps=4, num_stages=1)
        buf34 = empty_strided_cuda((16, 4), (4, 1), torch.float32)
        extern_kernels.mm(reinterpret_tensor(buf33, (16, 16), (16, 1), 0),
            primals_11, out=buf34)
        buf35 = reinterpret_tensor(buf5, (16, 1), (1, 1), 0)
        del buf5
        extern_kernels.mm(buf34, reinterpret_tensor(primals_12, (4, 1), (1,
            1), 0), out=buf35)
        buf36 = reinterpret_tensor(buf29, (16, 1), (1, 1), 0)
        del buf29
        extern_kernels.mm(buf34, reinterpret_tensor(primals_12, (4, 1), (1,
            1), 4), out=buf36)
        buf37 = empty_strided_cuda((4, 4, 4), (16, 4, 1), torch.bool)
        triton_poi_fused_add_leaky_relu_0[grid(64)](buf35, buf36, buf37, 64,
            XBLOCK=64, num_warps=1, num_stages=1)
        buf38 = reinterpret_tensor(buf27, (4, 4, 1), (4, 1, 16), 0)
        del buf27
        triton_poi_fused__softmax_add_leaky_relu_mul_where_6[grid(16)](buf4,
            buf37, buf35, buf36, buf38, 16, XBLOCK=16, num_warps=1,
            num_stages=1)
        buf39 = empty_strided_cuda((4, 4, 4), (16, 4, 1), torch.float32)
        triton_poi_fused__softmax_add_leaky_relu_mul_where_7[grid(64)](buf4,
            buf37, buf35, buf36, buf38, buf39, 64, XBLOCK=64, num_warps=1,
            num_stages=1)
        del buf35
        del buf36
        del buf38
        buf40 = empty_strided_cuda((4, 4, 4), (16, 4, 1), torch.float32)
        triton_poi_fused__softmax_4[grid(64)](buf39, buf40, 64, XBLOCK=64,
            num_warps=1, num_stages=1)
        buf41 = buf39
        del buf39
        extern_kernels.bmm(buf40, reinterpret_tensor(buf34, (4, 4, 4), (16,
            4, 1), 0), out=buf41)
        buf42 = empty_strided_cuda((4, 4, 4), (16, 4, 1), torch.float32)
        triton_poi_fused__log_softmax_elu_8[grid(64)](buf41, buf42, 64,
            XBLOCK=64, num_warps=1, num_stages=1)
        buf43 = empty_strided_cuda((4, 4, 4), (16, 4, 1), torch.float32)
        triton_poi_fused__log_softmax_9[grid(64)](buf42, buf43, 64, XBLOCK=
            64, num_warps=1, num_stages=1)
        del buf42
    return (buf43, buf0, buf3, buf4, buf7, buf8, buf9, buf12, buf15, buf16,
        buf17, buf20, buf23, buf24, buf25, buf28, buf31, buf32, buf34,
        buf37, buf40, buf41, buf43, reinterpret_tensor(primals_12, (1, 4),
        (1, 1), 4), reinterpret_tensor(primals_12, (1, 4), (1, 1), 0),
        reinterpret_tensor(buf33, (16, 16), (1, 16), 0), reinterpret_tensor
        (primals_11, (4, 16), (1, 4), 0), reinterpret_tensor(primals_10, (1,
        4), (1, 1), 4), reinterpret_tensor(primals_10, (1, 4), (1, 1), 0),
        reinterpret_tensor(primals_1, (4, 16), (1, 4), 0),
        reinterpret_tensor(primals_8, (1, 4), (1, 1), 4),
        reinterpret_tensor(primals_8, (1, 4), (1, 1), 0),
        reinterpret_tensor(primals_6, (1, 4), (1, 1), 4),
        reinterpret_tensor(primals_6, (1, 4), (1, 1), 0),
        reinterpret_tensor(primals_4, (1, 4), (1, 1), 4),
        reinterpret_tensor(primals_4, (1, 4), (1, 1), 0))


class GraphAttentionLayer(nn.Module):
    """
    https://github.com/Diego999/pyGAT/blob/master/layers.py
    Simple GAT layer, similar to https://arxiv.org/abs/1710.10903
    """

    def __init__(self, in_features, out_features, dropout, alpha, batch_num,
        node_num, concat=True):
        super(GraphAttentionLayer, self).__init__()
        self.dropout = dropout
        self.in_features = in_features
        self.out_features = out_features
        self.alpha = alpha
        self.concat = concat
        self.batch_num = batch_num
        self.node_num = node_num
        torch.device('cuda')
        self.W = nn.Parameter(torch.empty(size=(in_features, out_features)))
        nn.init.xavier_uniform_(self.W.data, gain=1.414)
        self.a = nn.Parameter(torch.empty(size=(2 * out_features, 1)))
        nn.init.xavier_uniform_(self.a.data, gain=1.414)
        self.leakyrelu = nn.LeakyReLU(self.alpha)

    def forward(self, h, adj):
        """
        :param h: (batch_size, number_nodes, in_features)
        :param adj: (batch_size, number_nodes, number_nodes)
        :return: (batch_size, number_nodes, out_features)
        """
        Wh = torch.matmul(h, self.W)
        e = self.prepare_batch(Wh)
        zero_vec = -9000000000000000.0 * torch.ones_like(e)
        attention = torch.where(adj > 0, e, zero_vec)
        attention = F.softmax(attention, dim=-1)
        attention = F.dropout(attention, self.dropout, training=self.training)
        h_prime = torch.matmul(attention, Wh)
        if self.concat:
            return F.elu(h_prime)
        else:
            return h_prime

    def prepare_batch(self, Wh):
        """
        with batch training
        :param Wh: (batch_size, number_nodes, out_features)
        :return:
        """
        _B, _N, _E = Wh.shape
        Wh1 = torch.matmul(Wh, self.a[:self.out_features, :])
        Wh2 = torch.matmul(Wh, self.a[self.out_features:, :])
        e = Wh1 + Wh2.permute(0, 2, 1)
        return self.leakyrelu(e)

    def __repr__(self):
        return self.__class__.__name__ + ' (' + str(self.in_features
            ) + ' -> ' + str(self.out_features) + ')'


class GATNew(nn.Module):

    def __init__(self, in_feat_dim, nhid, out_feat_dim, dropout, alpha,
        nheads, batch_num, node_num):
        """Dense version of GAT."""
        super(GATNew, self).__init__()
        self.dropout = dropout
        self.batch_num = batch_num
        self.node_num = node_num
        torch.device('cuda')
        self.adj = nn.Parameter(torch.ones(self.batch_num, self.node_num,
            self.node_num))
        self.attentions = [GraphAttentionLayer(in_feat_dim, nhid, dropout=
            dropout, alpha=alpha, batch_num=batch_num, node_num=node_num,
            concat=True) for _ in range(nheads)]
        for i, attention in enumerate(self.attentions):
            self.add_module('attention_{}'.format(i), attention)
        self.out_att = GraphAttentionLayer(nhid * nheads, out_feat_dim,
            dropout=dropout, alpha=alpha, batch_num=batch_num, node_num=
            node_num, concat=False)

    def forward(self, input_0):
        primals_1 = self.adj
        primals_3 = self.attention_0.W
        primals_4 = self.attention_0.a
        primals_5 = self.attention_1.W
        primals_6 = self.attention_1.a
        primals_7 = self.attention_2.W
        primals_8 = self.attention_2.a
        primals_9 = self.attention_3.W
        primals_10 = self.attention_3.a
        primals_11 = self.out_att.W
        primals_12 = self.out_att.a
        primals_2 = input_0
        output = call([primals_1, primals_2, primals_3, primals_4,
            primals_5, primals_6, primals_7, primals_8, primals_9,
            primals_10, primals_11, primals_12])
        return output[0]


Measured latency_ms: 0.418011