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
import torch.nn.functional as F
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
reinterpret_tensor = torch._C._dynamo.guards._reinterpret_tensor


@triton.jit
def triton_poi_fused_zeros_0(out_ptr0, xnumel, XBLOCK: tl.constexpr):
    xnumel = 16
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x0 = xindex
    tmp0 = 0.0
    tl.store(out_ptr0 + x0, tmp0, xmask)


@triton.jit
def triton_poi_fused_cat_1(in_ptr0, out_ptr0, xnumel, XBLOCK: tl.constexpr):
    xnumel = 32
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x0 = xindex % 8
    x1 = xindex // 8
    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 + (16 * x1 + x0), tmp4 & xmask, eviction_policy=
        'evict_last', other=0.0)
    tmp6 = tmp0 >= tmp3
    tl.full([1], 8, tl.int64)
    tmp9 = 0.0
    tmp10 = tl.full(tmp9.shape, 0.0, tmp9.dtype)
    tmp11 = tl.where(tmp6, tmp9, tmp10)
    tmp12 = tl.where(tmp4, tmp5, tmp11)
    tl.store(out_ptr0 + x2, tmp12, xmask)


@triton.jit
def triton_poi_fused_add_clamp_min_linalg_vector_norm_2(in_ptr0, in_ptr1,
    in_ptr2, in_ptr3, out_ptr0, out_ptr1, out_ptr2, xnumel, XBLOCK: tl.
    constexpr):
    xnumel = 4
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x0 = xindex
    tmp0 = tl.load(in_ptr0 + 4 * x0, xmask, eviction_policy='evict_last')
    tmp1 = tl.load(in_ptr1 + 0)
    tmp2 = tl.broadcast_to(tmp1, [XBLOCK])
    tmp5 = tl.load(in_ptr0 + (1 + 4 * x0), xmask, eviction_policy='evict_last')
    tmp6 = tl.load(in_ptr1 + 1)
    tmp7 = tl.broadcast_to(tmp6, [XBLOCK])
    tmp11 = tl.load(in_ptr0 + (2 + 4 * x0), xmask, eviction_policy='evict_last'
        )
    tmp12 = tl.load(in_ptr1 + 2)
    tmp13 = tl.broadcast_to(tmp12, [XBLOCK])
    tmp17 = tl.load(in_ptr0 + (3 + 4 * x0), xmask, eviction_policy='evict_last'
        )
    tmp18 = tl.load(in_ptr1 + 3)
    tmp19 = tl.broadcast_to(tmp18, [XBLOCK])
    tmp26 = tl.load(in_ptr2 + 4 * x0, xmask, eviction_policy='evict_last')
    tmp29 = tl.load(in_ptr2 + (1 + 4 * x0), xmask, eviction_policy='evict_last'
        )
    tmp33 = tl.load(in_ptr2 + (2 + 4 * x0), xmask, eviction_policy='evict_last'
        )
    tmp37 = tl.load(in_ptr2 + (3 + 4 * x0), xmask, eviction_policy='evict_last'
        )
    tmp43 = tl.load(in_ptr3 + 4 * x0, xmask, eviction_policy='evict_last')
    tmp46 = tl.load(in_ptr3 + (1 + 4 * x0), xmask, eviction_policy='evict_last'
        )
    tmp50 = tl.load(in_ptr3 + (2 + 4 * x0), xmask, eviction_policy='evict_last'
        )
    tmp54 = tl.load(in_ptr3 + (3 + 4 * x0), xmask, eviction_policy='evict_last'
        )
    tmp3 = tmp0 + tmp2
    tmp4 = tmp3 * tmp3
    tmp8 = tmp5 + tmp7
    tmp9 = tmp8 * tmp8
    tmp10 = tmp4 + tmp9
    tmp14 = tmp11 + tmp13
    tmp15 = tmp14 * tmp14
    tmp16 = tmp10 + tmp15
    tmp20 = tmp17 + tmp19
    tmp21 = tmp20 * tmp20
    tmp22 = tmp16 + tmp21
    tmp23 = libdevice.sqrt(tmp22)
    tmp24 = 1e-12
    tmp25 = triton_helpers.maximum(tmp23, tmp24)
    tmp27 = tmp26 + tmp2
    tmp28 = tmp27 * tmp27
    tmp30 = tmp29 + tmp7
    tmp31 = tmp30 * tmp30
    tmp32 = tmp28 + tmp31
    tmp34 = tmp33 + tmp13
    tmp35 = tmp34 * tmp34
    tmp36 = tmp32 + tmp35
    tmp38 = tmp37 + tmp19
    tmp39 = tmp38 * tmp38
    tmp40 = tmp36 + tmp39
    tmp41 = libdevice.sqrt(tmp40)
    tmp42 = triton_helpers.maximum(tmp41, tmp24)
    tmp44 = tmp43 + tmp2
    tmp45 = tmp44 * tmp44
    tmp47 = tmp46 + tmp7
    tmp48 = tmp47 * tmp47
    tmp49 = tmp45 + tmp48
    tmp51 = tmp50 + tmp13
    tmp52 = tmp51 * tmp51
    tmp53 = tmp49 + tmp52
    tmp55 = tmp54 + tmp19
    tmp56 = tmp55 * tmp55
    tmp57 = tmp53 + tmp56
    tmp58 = libdevice.sqrt(tmp57)
    tmp59 = triton_helpers.maximum(tmp58, tmp24)
    tl.store(out_ptr0 + x0, tmp25, xmask)
    tl.store(out_ptr1 + x0, tmp42, xmask)
    tl.store(out_ptr2 + x0, tmp59, xmask)


@triton.jit
def triton_poi_fused_add_div_3(in_ptr0, in_ptr1, in_ptr2, 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
    x0 = xindex % 4
    x1 = xindex // 4
    tmp0 = tl.load(in_ptr0 + x2, xmask)
    tmp1 = tl.load(in_ptr1 + x0, xmask, eviction_policy='evict_last')
    tmp3 = tl.load(in_ptr2 + x1, xmask, eviction_policy='evict_last')
    tmp2 = tmp0 + tmp1
    tmp4 = tmp2 / tmp3
    tl.store(out_ptr0 + x2, tmp4, xmask)


@triton.jit
def triton_poi_fused_add_clamp_min_div_linalg_vector_norm_mul_sum_4(in_out_ptr0
    , in_ptr0, in_ptr1, in_ptr2, out_ptr0, xnumel, XBLOCK: tl.constexpr):
    xnumel = 4
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x0 = xindex
    tmp0 = tl.load(in_ptr0 + 4 * x0, xmask, eviction_policy='evict_last')
    tmp1 = tl.load(in_ptr1 + 0)
    tmp2 = tl.broadcast_to(tmp1, [XBLOCK])
    tmp5 = tl.load(in_ptr0 + (1 + 4 * x0), xmask, eviction_policy='evict_last')
    tmp6 = tl.load(in_ptr1 + 1)
    tmp7 = tl.broadcast_to(tmp6, [XBLOCK])
    tmp11 = tl.load(in_ptr0 + (2 + 4 * x0), xmask, eviction_policy='evict_last'
        )
    tmp12 = tl.load(in_ptr1 + 2)
    tmp13 = tl.broadcast_to(tmp12, [XBLOCK])
    tmp17 = tl.load(in_ptr0 + (3 + 4 * x0), xmask, eviction_policy='evict_last'
        )
    tmp18 = tl.load(in_ptr1 + 3)
    tmp19 = tl.broadcast_to(tmp18, [XBLOCK])
    tmp26 = tl.load(in_ptr2 + 4 * x0, xmask, eviction_policy='evict_last')
    tmp29 = tl.load(in_ptr2 + (1 + 4 * x0), xmask, eviction_policy='evict_last'
        )
    tmp33 = tl.load(in_ptr2 + (2 + 4 * x0), xmask, eviction_policy='evict_last'
        )
    tmp37 = tl.load(in_ptr2 + (3 + 4 * x0), xmask, eviction_policy='evict_last'
        )
    tmp3 = tmp0 + tmp2
    tmp4 = tmp3 * tmp3
    tmp8 = tmp5 + tmp7
    tmp9 = tmp8 * tmp8
    tmp10 = tmp4 + tmp9
    tmp14 = tmp11 + tmp13
    tmp15 = tmp14 * tmp14
    tmp16 = tmp10 + tmp15
    tmp20 = tmp17 + tmp19
    tmp21 = tmp20 * tmp20
    tmp22 = tmp16 + tmp21
    tmp23 = libdevice.sqrt(tmp22)
    tmp24 = 1e-12
    tmp25 = triton_helpers.maximum(tmp23, tmp24)
    tmp27 = tmp3 / tmp25
    tmp28 = tmp26 * tmp27
    tmp30 = tmp8 / tmp25
    tmp31 = tmp29 * tmp30
    tmp32 = tmp28 + tmp31
    tmp34 = tmp14 / tmp25
    tmp35 = tmp33 * tmp34
    tmp36 = tmp32 + tmp35
    tmp38 = tmp20 / tmp25
    tmp39 = tmp37 * tmp38
    tmp40 = tmp36 + tmp39
    tmp41 = tmp26 * tmp3
    tmp42 = tmp29 * tmp8
    tmp43 = tmp41 + tmp42
    tmp44 = tmp33 * tmp14
    tmp45 = tmp43 + tmp44
    tmp46 = tmp37 * tmp20
    tmp47 = tmp45 + tmp46
    tl.store(in_out_ptr0 + x0, tmp40, xmask)
    tl.store(out_ptr0 + x0, tmp47, xmask)


@triton.jit
def triton_poi_fused_add_mul_sub_5(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
    x0 = xindex % 4
    x1 = xindex // 4
    tmp0 = tl.load(in_ptr0 + x2, xmask)
    tmp1 = tl.load(in_ptr1 + x0, xmask, eviction_policy='evict_last')
    tmp3 = tl.load(in_ptr2 + x1, xmask, eviction_policy='evict_last')
    tmp4 = tl.load(in_ptr3 + x2, xmask)
    tmp2 = tmp0 + tmp1
    tmp5 = tmp3 * tmp4
    tmp6 = tmp2 - tmp5
    tl.store(out_ptr0 + x2, tmp6, xmask)


@triton.jit
def triton_poi_fused_div_6(in_ptr0, 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 + x2, xmask)
    tmp1 = tl.load(in_ptr0 + 4 * x1, xmask, eviction_policy='evict_last')
    tmp3 = tl.load(in_ptr0 + (1 + 4 * x1), xmask, eviction_policy='evict_last')
    tmp6 = tl.load(in_ptr0 + (2 + 4 * x1), xmask, eviction_policy='evict_last')
    tmp9 = tl.load(in_ptr0 + (3 + 4 * x1), xmask, eviction_policy='evict_last')
    tmp2 = tmp1 * tmp1
    tmp4 = tmp3 * tmp3
    tmp5 = tmp2 + tmp4
    tmp7 = tmp6 * tmp6
    tmp8 = tmp5 + tmp7
    tmp10 = tmp9 * tmp9
    tmp11 = tmp8 + tmp10
    tmp12 = libdevice.sqrt(tmp11)
    tmp13 = 1e-12
    tmp14 = triton_helpers.maximum(tmp12, tmp13)
    tmp15 = tmp0 / tmp14
    tl.store(out_ptr0 + x2, tmp15, xmask)


@triton.jit
def triton_poi_fused_cat_7(in_ptr0, in_ptr1, out_ptr0, xnumel, XBLOCK: tl.
    constexpr):
    xnumel = 32
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x1 = xindex // 4 % 2
    x0 = xindex % 4
    x2 = xindex // 8
    x3 = xindex
    tmp0 = x1
    tl.full([1], 0, tl.int64)
    tmp3 = tl.full([1], 1, tl.int64)
    tmp4 = tmp0 < tmp3
    tmp5 = tl.load(in_ptr0 + (x0 + 4 * x2), tmp4 & xmask, eviction_policy=
        'evict_last', other=0.0)
    tmp6 = tmp0 >= tmp3
    tl.full([1], 2, tl.int64)
    tmp9 = tl.load(in_ptr1 + (x0 + 4 * x2), tmp6 & xmask, eviction_policy=
        'evict_last', other=0.0)
    tmp10 = tl.where(tmp4, tmp5, tmp9)
    tl.store(out_ptr0 + x3, tmp10, xmask)


@triton.jit
def triton_poi_fused_cat_8(in_ptr0, out_ptr0, xnumel, XBLOCK: tl.constexpr):
    xnumel = 16
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x0 = xindex % 4
    x1 = xindex // 4
    x2 = xindex
    tmp0 = x0
    tl.full([1], 0, tl.int64)
    tmp3 = tl.full([1], 1, tl.int64)
    tmp4 = tmp0 < tmp3
    tmp5 = tl.load(in_ptr0 + x1, tmp4 & xmask, eviction_policy='evict_last',
        other=0.0)
    tmp6 = tmp0 >= tmp3
    tmp7 = tl.full([1], 2, tl.int64)
    tmp8 = tmp0 < tmp7
    tmp9 = tmp6 & tmp8
    tmp10 = tl.load(in_ptr0 + x1, tmp9 & xmask, eviction_policy=
        'evict_last', other=0.0)
    tmp11 = tmp10 * tmp10
    tmp12 = 1.0
    tmp13 = tmp12 - tmp11
    tmp14 = libdevice.sqrt(tmp13)
    tmp15 = -tmp14
    tmp16 = tl.full(tmp15.shape, 0.0, tmp15.dtype)
    tmp17 = tl.where(tmp9, tmp15, tmp16)
    tmp18 = tmp0 >= tmp7
    tmp19 = tl.full([1], 3, tl.int64)
    tmp20 = tmp0 < tmp19
    tmp21 = tmp18 & tmp20
    tmp22 = tl.load(in_ptr0 + x1, tmp21 & xmask, eviction_policy=
        'evict_last', other=0.0)
    tmp23 = tmp22 * tmp22
    tmp24 = tmp12 - tmp23
    tmp25 = libdevice.sqrt(tmp24)
    tmp26 = tl.full(tmp25.shape, 0.0, tmp25.dtype)
    tmp27 = tl.where(tmp21, tmp25, tmp26)
    tmp28 = tmp0 >= tmp19
    tl.full([1], 4, tl.int64)
    tmp31 = tl.load(in_ptr0 + x1, tmp28 & xmask, eviction_policy=
        'evict_last', other=0.0)
    tmp32 = tl.where(tmp21, tmp27, tmp31)
    tmp33 = tl.where(tmp9, tmp17, tmp32)
    tmp34 = tl.where(tmp4, tmp5, tmp33)
    tl.store(out_ptr0 + x2, tmp34, xmask)


@triton.jit
def triton_poi_fused_add_div_mul_relu_rsub_sigmoid_9(in_out_ptr0, in_ptr0,
    in_ptr1, in_ptr2, in_ptr3, in_ptr4, in_ptr5, in_ptr6, in_ptr7, out_ptr0,
    out_ptr1, xnumel, XBLOCK: tl.constexpr):
    xnumel = 16
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x2 = xindex
    x0 = xindex % 4
    x1 = xindex // 4
    tmp0 = tl.load(in_out_ptr0 + x2, xmask)
    tmp2 = tl.load(in_ptr0 + x2, xmask)
    tmp4 = tl.load(in_ptr1 + x2, xmask)
    tmp8 = tl.load(in_ptr2 + x2, xmask)
    tmp9 = tl.load(in_ptr3 + x0, xmask, eviction_policy='evict_last')
    tmp14 = tl.load(in_ptr4 + x2, xmask)
    tmp15 = tl.load(in_ptr5 + x0, xmask, eviction_policy='evict_last')
    tmp23 = tl.load(in_ptr6 + x2, xmask)
    tmp25 = tl.load(in_ptr7 + x1, xmask, eviction_policy='evict_last')
    tmp1 = -tmp0
    tmp3 = tmp1 - tmp2
    tmp5 = tmp3 + tmp4
    tmp6 = 0.0
    tmp7 = tmp6 + tmp5
    tmp10 = tmp8 + tmp9
    tmp11 = tmp7 + tmp10
    tmp12 = tl.full([1], 0, tl.int32)
    tmp13 = triton_helpers.maximum(tmp12, tmp11)
    tmp16 = tmp14 + tmp15
    tmp17 = tl.sigmoid(tmp16)
    tmp18 = tmp17 * tmp6
    tmp19 = 1.0
    tmp20 = tmp19 - tmp17
    tmp21 = tmp20 * tmp13
    tmp22 = tmp18 + tmp21
    tmp24 = tmp23 + tmp9
    tmp26 = tmp24 / tmp25
    tl.store(in_out_ptr0 + x2, tmp13, xmask)
    tl.store(out_ptr0 + x2, tmp22, xmask)
    tl.store(out_ptr1 + x2, tmp26, xmask)


@triton.jit
def triton_poi_fused_cat_10(in_ptr0, in_ptr1, out_ptr0, xnumel, XBLOCK: tl.
    constexpr):
    xnumel = 32
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x0 = xindex % 8
    x1 = xindex // 8
    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 + 16 * x1 + x0), tmp4 & xmask,
        eviction_policy='evict_last', other=0.0)
    tmp6 = tmp0 >= tmp3
    tl.full([1], 8, tl.int64)
    tmp9 = tl.load(in_ptr1 + (4 * x1 + (-4 + x0)), tmp6 & xmask,
        eviction_policy='evict_last', other=0.0)
    tmp10 = tl.where(tmp4, tmp5, tmp9)
    tl.store(out_ptr0 + x2, tmp10, xmask)


@triton.jit
def triton_poi_fused_add_div_mul_relu_rsub_sigmoid_11(in_out_ptr0, in_ptr0,
    in_ptr1, in_ptr2, in_ptr3, in_ptr4, in_ptr5, in_ptr6, in_ptr7, in_ptr8,
    out_ptr0, out_ptr1, xnumel, XBLOCK: tl.constexpr):
    xnumel = 16
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x2 = xindex
    x0 = xindex % 4
    x1 = xindex // 4
    tmp0 = tl.load(in_ptr0 + x2, xmask)
    tmp1 = tl.load(in_out_ptr0 + x2, xmask)
    tmp3 = tl.load(in_ptr1 + x2, xmask)
    tmp5 = tl.load(in_ptr2 + x2, xmask)
    tmp8 = tl.load(in_ptr3 + x2, xmask)
    tmp9 = tl.load(in_ptr4 + x0, xmask, eviction_policy='evict_last')
    tmp14 = tl.load(in_ptr5 + x2, xmask)
    tmp15 = tl.load(in_ptr6 + x0, xmask, eviction_policy='evict_last')
    tmp23 = tl.load(in_ptr7 + x2, xmask)
    tmp25 = tl.load(in_ptr8 + x1, xmask, eviction_policy='evict_last')
    tmp2 = -tmp1
    tmp4 = tmp2 - tmp3
    tmp6 = tmp4 + tmp5
    tmp7 = tmp0 + tmp6
    tmp10 = tmp8 + tmp9
    tmp11 = tmp7 + tmp10
    tmp12 = tl.full([1], 0, tl.int32)
    tmp13 = triton_helpers.maximum(tmp12, tmp11)
    tmp16 = tmp14 + tmp15
    tmp17 = tl.sigmoid(tmp16)
    tmp18 = tmp17 * tmp0
    tmp19 = 1.0
    tmp20 = tmp19 - tmp17
    tmp21 = tmp20 * tmp13
    tmp22 = tmp18 + tmp21
    tmp24 = tmp23 + tmp9
    tmp26 = tmp24 / tmp25
    tl.store(in_out_ptr0 + x2, tmp13, xmask)
    tl.store(out_ptr0 + x2, tmp22, xmask)
    tl.store(out_ptr1 + x2, tmp26, xmask)


@triton.jit
def triton_poi_fused_cat_12(in_ptr0, in_ptr1, out_ptr0, xnumel, XBLOCK: tl.
    constexpr):
    xnumel = 32
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x0 = xindex % 8
    x1 = xindex // 8
    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 + (8 + 16 * x1 + x0), tmp4 & xmask,
        eviction_policy='evict_last', other=0.0)
    tmp6 = tmp0 >= tmp3
    tl.full([1], 8, tl.int64)
    tmp9 = tl.load(in_ptr1 + (4 * x1 + (-4 + x0)), tmp6 & xmask,
        eviction_policy='evict_last', other=0.0)
    tmp10 = tl.where(tmp4, tmp5, tmp9)
    tl.store(out_ptr0 + x2, tmp10, xmask)


@triton.jit
def triton_poi_fused_add_clamp_min_linalg_vector_norm_13(in_ptr0, in_ptr1,
    out_ptr0, xnumel, XBLOCK: tl.constexpr):
    xnumel = 4
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x0 = xindex
    tmp0 = tl.load(in_ptr0 + 4 * x0, xmask, eviction_policy='evict_last')
    tmp1 = tl.load(in_ptr1 + 0)
    tmp2 = tl.broadcast_to(tmp1, [XBLOCK])
    tmp5 = tl.load(in_ptr0 + (1 + 4 * x0), xmask, eviction_policy='evict_last')
    tmp6 = tl.load(in_ptr1 + 1)
    tmp7 = tl.broadcast_to(tmp6, [XBLOCK])
    tmp11 = tl.load(in_ptr0 + (2 + 4 * x0), xmask, eviction_policy='evict_last'
        )
    tmp12 = tl.load(in_ptr1 + 2)
    tmp13 = tl.broadcast_to(tmp12, [XBLOCK])
    tmp17 = tl.load(in_ptr0 + (3 + 4 * x0), xmask, eviction_policy='evict_last'
        )
    tmp18 = tl.load(in_ptr1 + 3)
    tmp19 = tl.broadcast_to(tmp18, [XBLOCK])
    tmp3 = tmp0 + tmp2
    tmp4 = tmp3 * tmp3
    tmp8 = tmp5 + tmp7
    tmp9 = tmp8 * tmp8
    tmp10 = tmp4 + tmp9
    tmp14 = tmp11 + tmp13
    tmp15 = tmp14 * tmp14
    tmp16 = tmp10 + tmp15
    tmp20 = tmp17 + tmp19
    tmp21 = tmp20 * tmp20
    tmp22 = tmp16 + tmp21
    tmp23 = libdevice.sqrt(tmp22)
    tmp24 = 1e-12
    tmp25 = triton_helpers.maximum(tmp23, tmp24)
    tl.store(out_ptr0 + x0, tmp25, xmask)


@triton.jit
def triton_poi_fused_cat_14(in_ptr0, in_ptr1, out_ptr0, xnumel, XBLOCK: tl.
    constexpr):
    xnumel = 32
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x0 = xindex % 8
    x1 = xindex // 8
    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 + (12 + 16 * x1 + x0), tmp4 & xmask,
        eviction_policy='evict_last', other=0.0)
    tmp6 = tmp0 >= tmp3
    tl.full([1], 8, tl.int64)
    tmp9 = tl.load(in_ptr1 + (4 * x1 + (-4 + x0)), tmp6 & xmask,
        eviction_policy='evict_last', other=0.0)
    tmp10 = tl.where(tmp4, tmp5, tmp9)
    tl.store(out_ptr0 + x2, tmp10, xmask)


@triton.jit
def triton_poi_fused_add_mul_relu_rsub_sigmoid_15(in_out_ptr0, in_ptr0,
    in_ptr1, in_ptr2, in_ptr3, in_ptr4, in_ptr5, in_ptr6, 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
    x0 = xindex % 4
    tmp0 = tl.load(in_ptr0 + x2, xmask)
    tmp1 = tl.load(in_out_ptr0 + x2, xmask)
    tmp3 = tl.load(in_ptr1 + x2, xmask)
    tmp5 = tl.load(in_ptr2 + x2, xmask)
    tmp8 = tl.load(in_ptr3 + x2, xmask)
    tmp9 = tl.load(in_ptr4 + x0, xmask, eviction_policy='evict_last')
    tmp14 = tl.load(in_ptr5 + x2, xmask)
    tmp15 = tl.load(in_ptr6 + x0, xmask, eviction_policy='evict_last')
    tmp2 = -tmp1
    tmp4 = tmp2 - tmp3
    tmp6 = tmp4 + tmp5
    tmp7 = tmp0 + tmp6
    tmp10 = tmp8 + tmp9
    tmp11 = tmp7 + tmp10
    tmp12 = tl.full([1], 0, tl.int32)
    tmp13 = triton_helpers.maximum(tmp12, tmp11)
    tmp16 = tmp14 + tmp15
    tmp17 = tl.sigmoid(tmp16)
    tmp18 = tmp17 * tmp0
    tmp19 = 1.0
    tmp20 = tmp19 - tmp17
    tmp21 = tmp20 * tmp13
    tmp22 = tmp18 + tmp21
    tl.store(in_out_ptr0 + x2, tmp13, xmask)
    tl.store(out_ptr0 + x2, tmp22, xmask)


@triton.jit
def triton_poi_fused_stack_16(in_ptr0, in_ptr1, in_ptr2, in_ptr3, 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 % 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 = tmp0 >= tmp3
    tmp7 = tl.full([1], 8, tl.int64)
    tmp8 = tmp0 < tmp7
    tmp9 = tmp6 & tmp8
    tmp10 = tl.load(in_ptr1 + (4 * x1 + (-4 + x0)), tmp9 & xmask,
        eviction_policy='evict_last', other=0.0)
    tmp11 = tmp0 >= tmp7
    tmp12 = tl.full([1], 12, tl.int64)
    tmp13 = tmp0 < tmp12
    tmp14 = tmp11 & tmp13
    tmp15 = tl.load(in_ptr2 + (4 * x1 + (-8 + x0)), tmp14 & xmask,
        eviction_policy='evict_last', other=0.0)
    tmp16 = tmp0 >= tmp12
    tl.full([1], 16, tl.int64)
    tmp19 = tl.load(in_ptr3 + (4 * x1 + (-12 + x0)), tmp16 & xmask,
        eviction_policy='evict_last', other=0.0)
    tmp20 = tl.where(tmp14, tmp15, tmp19)
    tmp21 = tl.where(tmp9, tmp10, tmp20)
    tmp22 = tl.where(tmp4, tmp5, tmp21)
    tl.store(out_ptr0 + x2, tmp22, xmask)


def call(args):
    (primals_1, primals_2, primals_3, primals_4, primals_5, primals_6,
        primals_7) = args
    args.clear()
    assert_size_stride(primals_1, (4, 4, 4), (16, 4, 1))
    assert_size_stride(primals_2, (8, 4), (4, 1))
    assert_size_stride(primals_3, (4,), (1,))
    assert_size_stride(primals_4, (8, 4), (4, 1))
    assert_size_stride(primals_5, (4,), (1,))
    assert_size_stride(primals_6, (4, 4), (4, 1))
    assert_size_stride(primals_7, (4,), (1,))
    with torch.cuda._DeviceGuard(0):
        torch.cuda.set_device(0)
        buf0 = empty_strided_cuda((4, 4), (4, 1), torch.float32)
        get_raw_stream(0)
        triton_poi_fused_zeros_0[grid(16)](buf0, 16, XBLOCK=16, num_warps=1,
            num_stages=1)
        buf1 = empty_strided_cuda((4, 8), (8, 1), torch.float32)
        triton_poi_fused_cat_1[grid(32)](primals_1, buf1, 32, XBLOCK=32,
            num_warps=1, num_stages=1)
        buf2 = empty_strided_cuda((4, 4), (4, 1), torch.float32)
        extern_kernels.mm(buf1, primals_2, out=buf2)
        buf3 = empty_strided_cuda((4, 4), (4, 1), torch.float32)
        extern_kernels.mm(buf1, primals_4, out=buf3)
        buf4 = empty_strided_cuda((4, 4), (4, 1), torch.float32)
        extern_kernels.mm(reinterpret_tensor(primals_1, (4, 4), (16, 1), 0),
            primals_6, out=buf4)
        buf26 = empty_strided_cuda((4, 4), (4, 1), torch.float32)
        extern_kernels.mm(reinterpret_tensor(primals_1, (4, 4), (16, 1), 4),
            primals_6, out=buf26)
        buf48 = empty_strided_cuda((4, 4), (4, 1), torch.float32)
        extern_kernels.mm(reinterpret_tensor(primals_1, (4, 4), (16, 1), 8),
            primals_6, out=buf48)
        buf5 = empty_strided_cuda((4, 1), (1, 4), torch.float32)
        buf27 = empty_strided_cuda((4, 1), (1, 4), torch.float32)
        buf49 = empty_strided_cuda((4, 1), (1, 4), torch.float32)
        triton_poi_fused_add_clamp_min_linalg_vector_norm_2[grid(4)](buf4,
            primals_7, buf26, buf48, buf5, buf27, buf49, 4, XBLOCK=4,
            num_warps=1, num_stages=1)
        buf6 = empty_strided_cuda((4, 4), (4, 1), torch.float32)
        triton_poi_fused_add_div_3[grid(16)](buf4, primals_7, buf5, buf6, 
            16, XBLOCK=16, num_warps=1, num_stages=1)
        buf7 = buf5
        del buf5
        buf8 = reinterpret_tensor(buf7, (4,), (1,), 0)
        del buf7
        buf9 = empty_strided_cuda((4,), (1,), torch.float32)
        triton_poi_fused_add_clamp_min_div_linalg_vector_norm_mul_sum_4[grid(4)
            ](buf8, buf2, primals_3, buf6, buf9, 4, XBLOCK=4, num_warps=1,
            num_stages=1)
        buf10 = empty_strided_cuda((4, 4), (4, 1), torch.float32)
        triton_poi_fused_add_mul_sub_5[grid(16)](buf2, primals_3, buf9,
            buf6, buf10, 16, XBLOCK=16, num_warps=1, num_stages=1)
        buf11 = empty_strided_cuda((4, 4), (4, 1), torch.float32)
        triton_poi_fused_div_6[grid(16)](buf10, buf11, 16, XBLOCK=16,
            num_warps=1, num_stages=1)
        buf12 = empty_strided_cuda((4, 1, 1), (1, 1, 1), torch.float32)
        extern_kernels.bmm(reinterpret_tensor(buf6, (4, 1, 4), (4, 1, 1), 0
            ), reinterpret_tensor(buf0, (4, 4, 1), (4, 1, 1), 0), out=buf12)
        buf13 = empty_strided_cuda((4, 4, 1), (4, 1, 1), torch.float32)
        extern_kernels.bmm(reinterpret_tensor(buf6, (4, 4, 1), (4, 1, 1), 0
            ), buf12, out=buf13)
        buf14 = empty_strided_cuda((4, 1, 1), (1, 1, 1), torch.float32)
        extern_kernels.bmm(reinterpret_tensor(buf11, (4, 1, 4), (4, 1, 1), 
            0), reinterpret_tensor(buf0, (4, 4, 1), (4, 1, 1), 0), out=buf14)
        buf15 = empty_strided_cuda((4, 4, 1), (4, 1, 1), torch.float32)
        extern_kernels.bmm(reinterpret_tensor(buf11, (4, 4, 1), (4, 1, 1), 
            0), buf14, out=buf15)
        buf16 = empty_strided_cuda((4, 2, 4), (8, 4, 1), torch.float32)
        triton_poi_fused_cat_7[grid(32)](buf6, buf11, buf16, 32, XBLOCK=32,
            num_warps=1, num_stages=1)
        buf17 = empty_strided_cuda((4, 2, 1), (2, 1, 1), torch.float32)
        extern_kernels.bmm(buf16, reinterpret_tensor(buf0, (4, 4, 1), (4, 1,
            1), 0), out=buf17)
        buf18 = empty_strided_cuda((4, 4), (4, 1), torch.float32)
        triton_poi_fused_cat_8[grid(16)](buf8, buf18, 16, XBLOCK=16,
            num_warps=1, num_stages=1)
        buf19 = empty_strided_cuda((4, 2, 1), (2, 1, 1), torch.float32)
        extern_kernels.bmm(reinterpret_tensor(buf18, (4, 2, 2), (4, 2, 1), 
            0), buf17, out=buf19)
        buf20 = empty_strided_cuda((4, 4, 1), (4, 1, 1), torch.float32)
        extern_kernels.bmm(reinterpret_tensor(buf16, (4, 4, 2), (8, 1, 4), 
            0), buf19, out=buf20)
        buf21 = reinterpret_tensor(buf13, (4, 4), (4, 1), 0)
        del buf13
        buf22 = empty_strided_cuda((4, 4), (4, 1), torch.float32)
        buf28 = empty_strided_cuda((4, 4), (4, 1), torch.float32)
        triton_poi_fused_add_div_mul_relu_rsub_sigmoid_9[grid(16)](buf21,
            buf15, buf20, buf4, primals_7, buf3, primals_5, buf26, buf27,
            buf22, buf28, 16, XBLOCK=16, num_warps=1, num_stages=1)
        buf23 = empty_strided_cuda((4, 8), (8, 1), torch.float32)
        triton_poi_fused_cat_10[grid(32)](primals_1, buf22, buf23, 32,
            XBLOCK=32, num_warps=1, num_stages=1)
        buf24 = reinterpret_tensor(buf20, (4, 4), (4, 1), 0)
        del buf20
        extern_kernels.mm(buf23, primals_2, out=buf24)
        buf25 = reinterpret_tensor(buf15, (4, 4), (4, 1), 0)
        del buf15
        extern_kernels.mm(buf23, primals_4, out=buf25)
        buf29 = buf27
        del buf27
        buf30 = reinterpret_tensor(buf29, (4,), (1,), 0)
        del buf29
        buf31 = buf8
        del buf8
        triton_poi_fused_add_clamp_min_div_linalg_vector_norm_mul_sum_4[grid(4)
            ](buf30, buf24, primals_3, buf28, buf31, 4, XBLOCK=4, num_warps
            =1, num_stages=1)
        buf32 = empty_strided_cuda((4, 4), (4, 1), torch.float32)
        triton_poi_fused_add_mul_sub_5[grid(16)](buf24, primals_3, buf31,
            buf28, buf32, 16, XBLOCK=16, num_warps=1, num_stages=1)
        buf33 = empty_strided_cuda((4, 4), (4, 1), torch.float32)
        triton_poi_fused_div_6[grid(16)](buf32, buf33, 16, XBLOCK=16,
            num_warps=1, num_stages=1)
        buf34 = empty_strided_cuda((4, 2, 4), (8, 4, 1), torch.float32)
        triton_poi_fused_cat_7[grid(32)](buf28, buf33, buf34, 32, XBLOCK=32,
            num_warps=1, num_stages=1)
        buf35 = empty_strided_cuda((4, 1, 1), (1, 1, 1), torch.float32)
        extern_kernels.bmm(reinterpret_tensor(buf28, (4, 1, 4), (4, 1, 1), 
            0), reinterpret_tensor(buf22, (4, 4, 1), (4, 1, 1), 0), out=buf35)
        buf36 = empty_strided_cuda((4, 4, 1), (4, 1, 1), torch.float32)
        extern_kernels.bmm(reinterpret_tensor(buf28, (4, 4, 1), (4, 1, 1), 
            0), buf35, out=buf36)
        buf37 = empty_strided_cuda((4, 1, 1), (1, 1, 1), torch.float32)
        extern_kernels.bmm(reinterpret_tensor(buf33, (4, 1, 4), (4, 1, 1), 
            0), reinterpret_tensor(buf22, (4, 4, 1), (4, 1, 1), 0), out=buf37)
        buf38 = empty_strided_cuda((4, 4, 1), (4, 1, 1), torch.float32)
        extern_kernels.bmm(reinterpret_tensor(buf33, (4, 4, 1), (4, 1, 1), 
            0), buf37, out=buf38)
        buf39 = empty_strided_cuda((4, 2, 1), (2, 1, 1), torch.float32)
        extern_kernels.bmm(buf34, reinterpret_tensor(buf22, (4, 4, 1), (4, 
            1, 1), 0), out=buf39)
        buf40 = empty_strided_cuda((4, 4), (4, 1), torch.float32)
        triton_poi_fused_cat_8[grid(16)](buf30, buf40, 16, XBLOCK=16,
            num_warps=1, num_stages=1)
        buf41 = empty_strided_cuda((4, 2, 1), (2, 1, 1), torch.float32)
        extern_kernels.bmm(reinterpret_tensor(buf40, (4, 2, 2), (4, 2, 1), 
            0), buf39, out=buf41)
        buf42 = empty_strided_cuda((4, 4, 1), (4, 1, 1), torch.float32)
        extern_kernels.bmm(reinterpret_tensor(buf34, (4, 4, 2), (8, 1, 4), 
            0), buf41, out=buf42)
        buf43 = reinterpret_tensor(buf36, (4, 4), (4, 1), 0)
        del buf36
        buf44 = empty_strided_cuda((4, 4), (4, 1), torch.float32)
        buf50 = empty_strided_cuda((4, 4), (4, 1), torch.float32)
        triton_poi_fused_add_div_mul_relu_rsub_sigmoid_11[grid(16)](buf43,
            buf22, buf38, buf42, buf26, primals_7, buf25, primals_5, buf48,
            buf49, buf44, buf50, 16, XBLOCK=16, num_warps=1, num_stages=1)
        buf45 = empty_strided_cuda((4, 8), (8, 1), torch.float32)
        triton_poi_fused_cat_12[grid(32)](primals_1, buf44, buf45, 32,
            XBLOCK=32, num_warps=1, num_stages=1)
        buf46 = reinterpret_tensor(buf42, (4, 4), (4, 1), 0)
        del buf42
        extern_kernels.mm(buf45, primals_2, out=buf46)
        buf47 = reinterpret_tensor(buf38, (4, 4), (4, 1), 0)
        del buf38
        extern_kernels.mm(buf45, primals_4, out=buf47)
        buf51 = buf49
        del buf49
        buf52 = reinterpret_tensor(buf51, (4,), (1,), 0)
        del buf51
        buf53 = buf30
        del buf30
        triton_poi_fused_add_clamp_min_div_linalg_vector_norm_mul_sum_4[grid(4)
            ](buf52, buf46, primals_3, buf50, buf53, 4, XBLOCK=4, num_warps
            =1, num_stages=1)
        buf54 = empty_strided_cuda((4, 4), (4, 1), torch.float32)
        triton_poi_fused_add_mul_sub_5[grid(16)](buf46, primals_3, buf53,
            buf50, buf54, 16, XBLOCK=16, num_warps=1, num_stages=1)
        buf55 = empty_strided_cuda((4, 4), (4, 1), torch.float32)
        triton_poi_fused_div_6[grid(16)](buf54, buf55, 16, XBLOCK=16,
            num_warps=1, num_stages=1)
        buf56 = empty_strided_cuda((4, 2, 4), (8, 4, 1), torch.float32)
        triton_poi_fused_cat_7[grid(32)](buf50, buf55, buf56, 32, XBLOCK=32,
            num_warps=1, num_stages=1)
        buf57 = empty_strided_cuda((4, 1, 1), (1, 1, 1), torch.float32)
        extern_kernels.bmm(reinterpret_tensor(buf50, (4, 1, 4), (4, 1, 1), 
            0), reinterpret_tensor(buf44, (4, 4, 1), (4, 1, 1), 0), out=buf57)
        buf58 = empty_strided_cuda((4, 4, 1), (4, 1, 1), torch.float32)
        extern_kernels.bmm(reinterpret_tensor(buf50, (4, 4, 1), (4, 1, 1), 
            0), buf57, out=buf58)
        buf59 = empty_strided_cuda((4, 1, 1), (1, 1, 1), torch.float32)
        extern_kernels.bmm(reinterpret_tensor(buf55, (4, 1, 4), (4, 1, 1), 
            0), reinterpret_tensor(buf44, (4, 4, 1), (4, 1, 1), 0), out=buf59)
        buf60 = empty_strided_cuda((4, 4, 1), (4, 1, 1), torch.float32)
        extern_kernels.bmm(reinterpret_tensor(buf55, (4, 4, 1), (4, 1, 1), 
            0), buf59, out=buf60)
        buf61 = empty_strided_cuda((4, 2, 1), (2, 1, 1), torch.float32)
        extern_kernels.bmm(buf56, reinterpret_tensor(buf44, (4, 4, 1), (4, 
            1, 1), 0), out=buf61)
        buf62 = empty_strided_cuda((4, 4), (4, 1), torch.float32)
        triton_poi_fused_cat_8[grid(16)](buf52, buf62, 16, XBLOCK=16,
            num_warps=1, num_stages=1)
        buf63 = empty_strided_cuda((4, 2, 1), (2, 1, 1), torch.float32)
        extern_kernels.bmm(reinterpret_tensor(buf62, (4, 2, 2), (4, 2, 1), 
            0), buf61, out=buf63)
        buf64 = empty_strided_cuda((4, 4, 1), (4, 1, 1), torch.float32)
        extern_kernels.bmm(reinterpret_tensor(buf56, (4, 4, 2), (8, 1, 4), 
            0), buf63, out=buf64)
        buf70 = empty_strided_cuda((4, 4), (4, 1), torch.float32)
        extern_kernels.mm(reinterpret_tensor(primals_1, (4, 4), (16, 1), 12
            ), primals_6, out=buf70)
        del primals_6
        buf71 = reinterpret_tensor(buf52, (4, 1), (1, 4), 0)
        del buf52
        triton_poi_fused_add_clamp_min_linalg_vector_norm_13[grid(4)](buf70,
            primals_7, buf71, 4, XBLOCK=4, num_warps=1, num_stages=1)
        buf65 = reinterpret_tensor(buf58, (4, 4), (4, 1), 0)
        del buf58
        buf66 = empty_strided_cuda((4, 4), (4, 1), torch.float32)
        buf72 = empty_strided_cuda((4, 4), (4, 1), torch.float32)
        triton_poi_fused_add_div_mul_relu_rsub_sigmoid_11[grid(16)](buf65,
            buf44, buf60, buf64, buf48, primals_7, buf47, primals_5, buf70,
            buf71, buf66, buf72, 16, XBLOCK=16, num_warps=1, num_stages=1)
        buf67 = empty_strided_cuda((4, 8), (8, 1), torch.float32)
        triton_poi_fused_cat_14[grid(32)](primals_1, buf66, buf67, 32,
            XBLOCK=32, num_warps=1, num_stages=1)
        buf68 = reinterpret_tensor(buf64, (4, 4), (4, 1), 0)
        del buf64
        extern_kernels.mm(buf67, primals_2, out=buf68)
        buf69 = reinterpret_tensor(buf60, (4, 4), (4, 1), 0)
        del buf60
        extern_kernels.mm(buf67, primals_4, out=buf69)
        buf73 = buf71
        del buf71
        buf74 = reinterpret_tensor(buf73, (4,), (1,), 0)
        del buf73
        buf75 = empty_strided_cuda((4,), (1,), torch.float32)
        triton_poi_fused_add_clamp_min_div_linalg_vector_norm_mul_sum_4[grid(4)
            ](buf74, buf68, primals_3, buf72, buf75, 4, XBLOCK=4, num_warps
            =1, num_stages=1)
        buf76 = empty_strided_cuda((4, 4), (4, 1), torch.float32)
        triton_poi_fused_add_mul_sub_5[grid(16)](buf68, primals_3, buf75,
            buf72, buf76, 16, XBLOCK=16, num_warps=1, num_stages=1)
        buf77 = empty_strided_cuda((4, 4), (4, 1), torch.float32)
        triton_poi_fused_div_6[grid(16)](buf76, buf77, 16, XBLOCK=16,
            num_warps=1, num_stages=1)
        buf78 = empty_strided_cuda((4, 2, 4), (8, 4, 1), torch.float32)
        triton_poi_fused_cat_7[grid(32)](buf72, buf77, buf78, 32, XBLOCK=32,
            num_warps=1, num_stages=1)
        buf79 = empty_strided_cuda((4, 1, 1), (1, 1, 1), torch.float32)
        extern_kernels.bmm(reinterpret_tensor(buf72, (4, 1, 4), (4, 1, 1), 
            0), reinterpret_tensor(buf66, (4, 4, 1), (4, 1, 1), 0), out=buf79)
        buf80 = empty_strided_cuda((4, 4, 1), (4, 1, 1), torch.float32)
        extern_kernels.bmm(reinterpret_tensor(buf72, (4, 4, 1), (4, 1, 1), 
            0), buf79, out=buf80)
        buf81 = empty_strided_cuda((4, 1, 1), (1, 1, 1), torch.float32)
        extern_kernels.bmm(reinterpret_tensor(buf77, (4, 1, 4), (4, 1, 1), 
            0), reinterpret_tensor(buf66, (4, 4, 1), (4, 1, 1), 0), out=buf81)
        buf82 = empty_strided_cuda((4, 4, 1), (4, 1, 1), torch.float32)
        extern_kernels.bmm(reinterpret_tensor(buf77, (4, 4, 1), (4, 1, 1), 
            0), buf81, out=buf82)
        buf83 = empty_strided_cuda((4, 2, 1), (2, 1, 1), torch.float32)
        extern_kernels.bmm(buf78, reinterpret_tensor(buf66, (4, 4, 1), (4, 
            1, 1), 0), out=buf83)
        buf84 = empty_strided_cuda((4, 4), (4, 1), torch.float32)
        triton_poi_fused_cat_8[grid(16)](buf74, buf84, 16, XBLOCK=16,
            num_warps=1, num_stages=1)
        del buf74
        buf85 = empty_strided_cuda((4, 2, 1), (2, 1, 1), torch.float32)
        extern_kernels.bmm(reinterpret_tensor(buf84, (4, 2, 2), (4, 2, 1), 
            0), buf83, out=buf85)
        buf86 = empty_strided_cuda((4, 4, 1), (4, 1, 1), torch.float32)
        extern_kernels.bmm(reinterpret_tensor(buf78, (4, 4, 2), (8, 1, 4), 
            0), buf85, out=buf86)
        buf87 = reinterpret_tensor(buf80, (4, 4), (4, 1), 0)
        del buf80
        buf88 = empty_strided_cuda((4, 4), (4, 1), torch.float32)
        triton_poi_fused_add_mul_relu_rsub_sigmoid_15[grid(16)](buf87,
            buf66, buf82, buf86, buf70, primals_7, buf69, primals_5, buf88,
            16, XBLOCK=16, num_warps=1, num_stages=1)
        del buf82
        del buf86
        buf89 = empty_strided_cuda((4, 16), (16, 1), torch.float32)
        triton_poi_fused_stack_16[grid(64)](buf22, buf44, buf66, buf88,
            buf89, 64, XBLOCK=64, num_warps=1, num_stages=1)
    return (reinterpret_tensor(buf89, (4, 4, 4), (16, 4, 1), 0), buf88,
        primals_3, primals_5, primals_7, buf0, buf2, buf3, buf4, buf6,
        reinterpret_tensor(buf9, (4, 1), (1, 1), 0), buf10, buf11, buf21,
        buf22, buf24, buf25, buf26, buf28, reinterpret_tensor(buf31, (4, 1),
        (1, 1), 0), buf32, buf33, buf34, buf43, buf44, buf46, buf47, buf48,
        buf50, reinterpret_tensor(buf53, (4, 1), (1, 1), 0), buf54, buf55,
        buf56, buf65, buf66, buf68, buf69, buf70, buf72, reinterpret_tensor
        (buf75, (4, 1), (1, 1), 0), buf76, buf77, buf78, buf87,
        reinterpret_tensor(buf85, (4, 1, 2), (2, 1, 1), 0),
        reinterpret_tensor(buf84, (4, 2, 2), (4, 1, 2), 0),
        reinterpret_tensor(buf83, (4, 1, 2), (2, 1, 1), 0), buf81, buf79,
        reinterpret_tensor(primals_1, (4, 4), (1, 16), 12),
        reinterpret_tensor(buf67, (8, 4), (1, 8), 0), reinterpret_tensor(
        primals_4, (4, 8), (1, 4), 0), reinterpret_tensor(primals_2, (4, 8),
        (1, 4), 0), reinterpret_tensor(buf63, (4, 1, 2), (2, 1, 1), 0),
        reinterpret_tensor(buf62, (4, 2, 2), (4, 1, 2), 0),
        reinterpret_tensor(buf61, (4, 1, 2), (2, 1, 1), 0), buf59, buf57,
        reinterpret_tensor(primals_1, (4, 4), (1, 16), 8),
        reinterpret_tensor(buf45, (8, 4), (1, 8), 0), reinterpret_tensor(
        buf41, (4, 1, 2), (2, 1, 1), 0), reinterpret_tensor(buf40, (4, 2, 2
        ), (4, 1, 2), 0), reinterpret_tensor(buf39, (4, 1, 2), (2, 1, 1), 0
        ), buf37, buf35, reinterpret_tensor(primals_1, (4, 4), (1, 16), 4),
        reinterpret_tensor(buf23, (8, 4), (1, 8), 0), buf16,
        reinterpret_tensor(buf19, (4, 1, 2), (2, 1, 1), 0),
        reinterpret_tensor(buf18, (4, 2, 2), (4, 1, 2), 0),
        reinterpret_tensor(buf17, (4, 1, 2), (2, 1, 1), 0), buf14, buf12,
        reinterpret_tensor(primals_1, (4, 4), (1, 16), 0),
        reinterpret_tensor(buf1, (8, 4), (1, 8), 0))


def rotation_components(x, y, eps=1e-12):
    size_batch = x.size()[0]
    hidden_size = x.size()[1]
    u = F.normalize(x, p=2, dim=1, eps=eps)
    costh = torch.sum(u * F.normalize(y, p=2, dim=1, eps=eps), dim=1).view(
        size_batch, 1)
    sinth = torch.sqrt(1 - costh ** 2).view(size_batch, 1)
    Rth = torch.cat((costh, -sinth, sinth, costh), dim=1).view(size_batch, 2, 2
        )
    v = F.normalize(y - torch.sum(u * y, 1).view(size_batch, 1) * u, p=2,
        dim=1, eps=eps)
    tmp = torch.cat((u.view(size_batch, 1, hidden_size), v.view(size_batch,
        1, hidden_size)), dim=1)
    return u.view(size_batch, hidden_size, 1), v.view(size_batch,
        hidden_size, 1), tmp, Rth


def rotate(v1, v2, v):
    size_batch = v1.size()[0]
    hidden_size = v1.size()[1]
    U = rotation_components(v1, v2)
    h = v.view(size_batch, hidden_size, 1)
    return v + (-torch.matmul(U[0], torch.matmul(U[0].transpose(1, 2), h)) -
        torch.matmul(U[1], torch.matmul(U[1].transpose(1, 2), h)) + torch.
        matmul(U[2].transpose(1, 2), torch.matmul(U[3], torch.matmul(U[2], h)))
        ).view(size_batch, hidden_size)


def rotation_operator(x, y, eps=1e-12):
    hidden_size = x.size()[1]
    tmp_u, tmp_v, tmp, Rth = rotation_components(x, y, eps=eps)
    return torch.eye(hidden_size, device=x.device) - torch.matmul(tmp_u,
        torch.transpose(tmp_u, dim0=1, dim1=2)) - torch.matmul(tmp_v, torch
        .transpose(tmp_v, dim0=1, dim1=2)) + torch.matmul(torch.matmul(
        torch.transpose(tmp, dim0=1, dim1=2), Rth), tmp)


class RUMCell(nn.Module):

    def __init__(self, input_size, hidden_size, eta_, lambda_, bias, eps,
        activation):
        super(RUMCell, self).__init__()
        self.input_size = input_size
        self.hidden_size = hidden_size
        self.eta_ = eta_
        self.lambda_ = lambda_
        self.bias = bias
        self.eps = eps
        if activation is None:
            activation = 'relu'
        if activation == 'tanh':
            self.activation = F.tanh
        elif activation == 'relu':
            self.activation = F.relu
        self.r_kernel = nn.Parameter(torch.Tensor(input_size + hidden_size,
            hidden_size))
        nn.init.orthogonal_(self.r_kernel)
        self.r_bias = nn.Parameter(torch.Tensor(hidden_size))
        nn.init.constant_(self.r_bias, 1.0)
        self.u_kernel = nn.Parameter(torch.Tensor(input_size + hidden_size,
            hidden_size))
        nn.init.orthogonal_(self.u_kernel)
        self.u_bias = nn.Parameter(torch.Tensor(hidden_size))
        nn.init.constant_(self.u_bias, 1.0)
        self.inp_emb_kernel = nn.Parameter(torch.Tensor(input_size,
            hidden_size))
        nn.init.xavier_uniform_(self.inp_emb_kernel)
        self.inp_emb_bias = nn.Parameter(torch.Tensor(hidden_size))
        nn.init.constant_(self.inp_emb_bias, 0.0)

    def forward(self, inputs, hidden, assoc_mem):
        if hidden is None:
            hidden = torch.zeros(inputs.size(0), self.hidden_size, device=
                inputs.device)
        if assoc_mem is None and self.lambda_ == 1:
            assoc_mem = torch.eye(self.hidden_size, device=inputs.device
                ).unsqueeze(0)
        r = torch.matmul(torch.cat((inputs, hidden), 1), self.r_kernel
            ) + self.r_bias
        u = torch.matmul(torch.cat((inputs, hidden), 1), self.u_kernel
            ) + self.u_bias
        x_emb = torch.matmul(inputs, self.inp_emb_kernel) + self.inp_emb_bias
        u = u.sigmoid()
        if self.lambda_ == 0:
            hidden_new = rotate(x_emb, r, hidden)
        elif self.lambda_ == 1:
            tmp_rotation = rotation_operator(x_emb, r)
            assoc_mem = torch.matmul(assoc_mem, tmp_rotation)
            hidden_new = torch.matmul(assoc_mem, hidden.unsqueeze(-1)).squeeze(
                -1)
        else:
            raise
        c = F.relu(hidden_new + x_emb)
        new_h = u * hidden + (1 - u) * c
        if self.eta_:
            new_h = F.normalize(new_h, p=2, dim=1, eps=self.eps) * self.eta_
        return new_h, assoc_mem


class RUMNew(nn.Module):

    def __init__(self, input_size, hidden_size, eta_=None, lambda_=0, bias=
        True, eps=1e-12, activation=None):
        super().__init__()
        self.rum_cell = RUMCell(input_size, hidden_size, eta_, lambda_,
            bias, eps, activation)

    def forward(self, input_0):
        primals_2 = self.rum_cell.r_kernel
        primals_3 = self.rum_cell.r_bias
        primals_4 = self.rum_cell.u_kernel
        primals_5 = self.rum_cell.u_bias
        primals_6 = self.rum_cell.inp_emb_kernel
        primals_7 = self.rum_cell.inp_emb_bias
        primals_1 = input_0
        output = call([primals_1, primals_2, primals_3, primals_4,
            primals_5, primals_6, primals_7])
        return output[0], output[1]


Measured latency_ms: 0.7948