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
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_div_0(in_ptr0, out_ptr0, xnumel, XBLOCK: tl.constexpr):
    xnumel = 256
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x3 = xindex
    x0 = xindex % 16
    x2 = xindex // 64
    tmp0 = tl.load(in_ptr0 + x3, xmask)
    tmp1 = tl.load(in_ptr0 + (x0 + 64 * x2), xmask, eviction_policy=
        'evict_last')
    tmp3 = tl.load(in_ptr0 + (16 + x0 + 64 * x2), xmask, eviction_policy=
        'evict_last')
    tmp6 = tl.load(in_ptr0 + (32 + x0 + 64 * x2), xmask, eviction_policy=
        'evict_last')
    tmp9 = tl.load(in_ptr0 + (48 + x0 + 64 * x2), 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 + x3, tmp15, xmask)


@triton.jit
def triton_poi_fused_div_1(in_ptr0, out_ptr0, xnumel, XBLOCK: tl.constexpr):
    xnumel = 256
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x3 = xindex
    x0 = xindex % 16
    x2 = xindex // 64
    tmp0 = tl.load(in_ptr0 + (256 + x3), xmask)
    tmp1 = tl.load(in_ptr0 + (256 + x0 + 64 * x2), xmask, eviction_policy=
        'evict_last')
    tmp3 = tl.load(in_ptr0 + (272 + x0 + 64 * x2), xmask, eviction_policy=
        'evict_last')
    tmp6 = tl.load(in_ptr0 + (288 + x0 + 64 * x2), xmask, eviction_policy=
        'evict_last')
    tmp9 = tl.load(in_ptr0 + (304 + x0 + 64 * x2), 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 + x3, tmp15, xmask)


@triton.jit
def triton_poi_fused_div_2(in_ptr0, out_ptr0, xnumel, XBLOCK: tl.constexpr):
    xnumel = 256
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x3 = xindex
    x0 = xindex % 16
    x2 = xindex // 64
    tmp0 = tl.load(in_ptr0 + (512 + x3), xmask)
    tmp1 = tl.load(in_ptr0 + (512 + x0 + 64 * x2), xmask, eviction_policy=
        'evict_last')
    tmp3 = tl.load(in_ptr0 + (528 + x0 + 64 * x2), xmask, eviction_policy=
        'evict_last')
    tmp6 = tl.load(in_ptr0 + (544 + x0 + 64 * x2), xmask, eviction_policy=
        'evict_last')
    tmp9 = tl.load(in_ptr0 + (560 + x0 + 64 * x2), 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 + x3, tmp15, xmask)


@triton.jit
def triton_poi_fused_div_3(in_ptr0, out_ptr0, xnumel, XBLOCK: tl.constexpr):
    xnumel = 256
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x3 = xindex
    x0 = xindex % 16
    x2 = xindex // 64
    tmp0 = tl.load(in_ptr0 + (768 + x3), xmask)
    tmp1 = tl.load(in_ptr0 + (768 + x0 + 64 * x2), xmask, eviction_policy=
        'evict_last')
    tmp3 = tl.load(in_ptr0 + (784 + x0 + 64 * x2), xmask, eviction_policy=
        'evict_last')
    tmp6 = tl.load(in_ptr0 + (800 + x0 + 64 * x2), xmask, eviction_policy=
        'evict_last')
    tmp9 = tl.load(in_ptr0 + (816 + x0 + 64 * x2), 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 + x3, tmp15, xmask)


@triton.jit
def triton_poi_fused_sub_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
    x1 = xindex // 4
    x2 = xindex
    tmp0 = tl.load(in_ptr0 + 4 * x1, xmask, eviction_policy='evict_last')
    tmp1 = tl.load(in_ptr0 + (1 + 4 * x1), xmask, eviction_policy='evict_last')
    tmp3 = tl.load(in_ptr0 + (2 + 4 * x1), xmask, eviction_policy='evict_last')
    tmp5 = tl.load(in_ptr0 + (3 + 4 * x1), xmask, eviction_policy='evict_last')
    tmp7 = tl.load(in_ptr0 + x2, xmask)
    tmp2 = triton_helpers.maximum(tmp0, tmp1)
    tmp4 = triton_helpers.maximum(tmp2, tmp3)
    tmp6 = triton_helpers.maximum(tmp4, tmp5)
    tmp8 = tmp6 - tmp7
    tl.store(out_ptr0 + x2, tmp8, xmask)


@triton.jit
def triton_poi_fused__softmax_5(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 = triton_helpers.maximum(tmp1, tmp2)
    tmp5 = triton_helpers.maximum(tmp3, tmp4)
    tmp7 = triton_helpers.maximum(tmp5, tmp6)
    tmp8 = tmp0 - tmp7
    tmp9 = tl_math.exp(tmp8)
    tl.store(out_ptr0 + x2, tmp9, xmask)


@triton.jit
def triton_poi_fused__softmax_6(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_per_fused__softmax_7(in_ptr0, out_ptr2, xnumel, rnumel, XBLOCK:
    tl.constexpr):
    xnumel = 64
    RBLOCK: tl.constexpr = 16
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:, None]
    xmask = xindex < xnumel
    rindex = tl.arange(0, RBLOCK)[None, :]
    tl.full([XBLOCK, RBLOCK], True, tl.int1)
    r1 = rindex
    x0 = xindex
    tmp0 = tl.load(in_ptr0 + (r1 + 16 * x0), xmask, other=0.0)
    tmp1 = tl.broadcast_to(tmp0, [XBLOCK, RBLOCK])
    tmp3 = tl.where(xmask, tmp1, float('-inf'))
    tmp4 = triton_helpers.max2(tmp3, 1)[:, None]
    tmp5 = tmp0 - tmp4
    tmp6 = tl_math.exp(tmp5)
    tmp7 = tl.broadcast_to(tmp6, [XBLOCK, RBLOCK])
    tmp9 = tl.where(xmask, tmp7, 0)
    tmp10 = tl.sum(tmp9, 1)[:, None]
    tmp11 = tmp6 / tmp10
    tl.store(out_ptr2 + (r1 + 16 * x0), tmp11, xmask)


@triton.jit
def triton_per_fused_abs_add_mean_mul_sub_8(in_out_ptr0, 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,
    in_ptr17, in_ptr18, in_ptr19, in_ptr20, in_ptr21, in_ptr22, in_ptr23,
    xnumel, rnumel):
    XBLOCK: tl.constexpr = 1
    RBLOCK: tl.constexpr = 256
    xoffset = tl.program_id(0) * XBLOCK
    tl.full([1], xoffset, tl.int32)
    tl.full([RBLOCK], True, tl.int1)
    rindex = tl.arange(0, RBLOCK)[:]
    tl.full([RBLOCK], True, tl.int1)
    r0 = rindex
    tmp0 = tl.load(in_ptr0 + r0, None)
    tmp3 = tl.load(in_ptr1 + r0, None)
    tmp5 = tl.load(in_ptr2 + r0, None)
    tmp7 = tl.load(in_ptr3 + r0, None)
    tmp14 = tl.load(in_ptr4 + r0, None)
    tmp17 = tl.load(in_ptr5 + r0, None)
    tmp25 = tl.load(in_ptr6 + r0, None)
    tmp27 = tl.load(in_ptr7 + r0, None)
    tmp29 = tl.load(in_ptr8 + r0, None)
    tmp31 = tl.load(in_ptr9 + r0, None)
    tmp38 = tl.load(in_ptr10 + r0, None)
    tmp41 = tl.load(in_ptr11 + r0, None)
    tmp49 = tl.load(in_ptr12 + r0, None)
    tmp51 = tl.load(in_ptr13 + r0, None)
    tmp53 = tl.load(in_ptr14 + r0, None)
    tmp55 = tl.load(in_ptr15 + r0, None)
    tmp62 = tl.load(in_ptr16 + r0, None)
    tmp65 = tl.load(in_ptr17 + r0, None)
    tmp73 = tl.load(in_ptr18 + r0, None)
    tmp75 = tl.load(in_ptr19 + r0, None)
    tmp77 = tl.load(in_ptr20 + r0, None)
    tmp79 = tl.load(in_ptr21 + r0, None)
    tmp86 = tl.load(in_ptr22 + r0, None)
    tmp89 = tl.load(in_ptr23 + r0, None)
    tmp1 = 0.1
    tmp2 = tmp0 * tmp1
    tmp4 = tmp2 + tmp3
    tmp6 = tmp5 * tmp1
    tmp8 = tmp6 + tmp7
    tmp9 = tmp4 - tmp8
    tmp10 = tl_math.abs(tmp9)
    tmp11 = tl.broadcast_to(tmp10, [RBLOCK])
    tmp13 = triton_helpers.promote_to_tensor(tl.sum(tmp11, 0))
    tmp15 = tmp14 * tmp1
    tmp16 = tmp15 + tmp3
    tmp18 = tmp17 * tmp1
    tmp19 = tmp18 + tmp7
    tmp20 = tmp16 - tmp19
    tmp21 = tl_math.abs(tmp20)
    tmp22 = tl.broadcast_to(tmp21, [RBLOCK])
    tmp24 = triton_helpers.promote_to_tensor(tl.sum(tmp22, 0))
    tmp26 = tmp25 * tmp1
    tmp28 = tmp26 + tmp27
    tmp30 = tmp29 * tmp1
    tmp32 = tmp30 + tmp31
    tmp33 = tmp28 - tmp32
    tmp34 = tl_math.abs(tmp33)
    tmp35 = tl.broadcast_to(tmp34, [RBLOCK])
    tmp37 = triton_helpers.promote_to_tensor(tl.sum(tmp35, 0))
    tmp39 = tmp38 * tmp1
    tmp40 = tmp39 + tmp27
    tmp42 = tmp41 * tmp1
    tmp43 = tmp42 + tmp31
    tmp44 = tmp40 - tmp43
    tmp45 = tl_math.abs(tmp44)
    tmp46 = tl.broadcast_to(tmp45, [RBLOCK])
    tmp48 = triton_helpers.promote_to_tensor(tl.sum(tmp46, 0))
    tmp50 = tmp49 * tmp1
    tmp52 = tmp50 + tmp51
    tmp54 = tmp53 * tmp1
    tmp56 = tmp54 + tmp55
    tmp57 = tmp52 - tmp56
    tmp58 = tl_math.abs(tmp57)
    tmp59 = tl.broadcast_to(tmp58, [RBLOCK])
    tmp61 = triton_helpers.promote_to_tensor(tl.sum(tmp59, 0))
    tmp63 = tmp62 * tmp1
    tmp64 = tmp63 + tmp51
    tmp66 = tmp65 * tmp1
    tmp67 = tmp66 + tmp55
    tmp68 = tmp64 - tmp67
    tmp69 = tl_math.abs(tmp68)
    tmp70 = tl.broadcast_to(tmp69, [RBLOCK])
    tmp72 = triton_helpers.promote_to_tensor(tl.sum(tmp70, 0))
    tmp74 = tmp73 * tmp1
    tmp76 = tmp74 + tmp75
    tmp78 = tmp77 * tmp1
    tmp80 = tmp78 + tmp79
    tmp81 = tmp76 - tmp80
    tmp82 = tl_math.abs(tmp81)
    tmp83 = tl.broadcast_to(tmp82, [RBLOCK])
    tmp85 = triton_helpers.promote_to_tensor(tl.sum(tmp83, 0))
    tmp87 = tmp86 * tmp1
    tmp88 = tmp87 + tmp75
    tmp90 = tmp89 * tmp1
    tmp91 = tmp90 + tmp79
    tmp92 = tmp88 - tmp91
    tmp93 = tl_math.abs(tmp92)
    tmp94 = tl.broadcast_to(tmp93, [RBLOCK])
    tmp96 = triton_helpers.promote_to_tensor(tl.sum(tmp94, 0))
    tmp97 = 256.0
    tmp98 = tmp13 / tmp97
    tmp99 = tmp24 / tmp97
    tmp100 = tmp98 + tmp99
    tmp101 = 0.0
    tmp102 = tmp100 + tmp101
    tmp103 = tmp37 / tmp97
    tmp104 = tmp48 / tmp97
    tmp105 = tmp103 + tmp104
    tmp106 = tmp102 + tmp105
    tmp107 = tmp61 / tmp97
    tmp108 = tmp72 / tmp97
    tmp109 = tmp107 + tmp108
    tmp110 = tmp106 + tmp109
    tmp111 = tmp85 / tmp97
    tmp112 = tmp96 / tmp97
    tmp113 = tmp111 + tmp112
    tmp114 = tmp110 + tmp113
    tl.debug_barrier()
    tl.store(in_out_ptr0 + tl.full([1], 0, tl.int32), tmp114, None)


def call(args):
    arg0_1, arg1_1 = args
    args.clear()
    assert_size_stride(arg0_1, (4, 4, 4, 4, 4), (256, 64, 16, 4, 1))
    assert_size_stride(arg1_1, (4, 4, 4, 4, 4), (256, 64, 16, 4, 1))
    with torch.cuda._DeviceGuard(0):
        torch.cuda.set_device(0)
        buf0 = empty_strided_cuda((4, 4, 4, 4), (64, 16, 4, 1), torch.float32)
        get_raw_stream(0)
        triton_poi_fused_div_0[grid(256)](arg0_1, buf0, 256, XBLOCK=256,
            num_warps=4, num_stages=1)
        buf1 = empty_strided_cuda((4, 4, 4), (16, 4, 1), torch.float32)
        extern_kernels.bmm(reinterpret_tensor(buf0, (4, 4, 16), (64, 16, 1),
            0), reinterpret_tensor(buf0, (4, 16, 4), (64, 1, 16), 0), out=buf1)
        buf2 = empty_strided_cuda((4, 4, 4, 4), (64, 16, 4, 1), torch.float32)
        triton_poi_fused_div_0[grid(256)](arg1_1, buf2, 256, XBLOCK=256,
            num_warps=4, num_stages=1)
        buf3 = empty_strided_cuda((4, 4, 4), (16, 4, 1), torch.float32)
        extern_kernels.bmm(reinterpret_tensor(buf2, (4, 4, 16), (64, 16, 1),
            0), reinterpret_tensor(buf2, (4, 16, 4), (64, 1, 16), 0), out=buf3)
        buf4 = empty_strided_cuda((4, 4, 4, 4), (64, 16, 4, 1), torch.float32)
        triton_poi_fused_div_1[grid(256)](arg0_1, buf4, 256, XBLOCK=128,
            num_warps=4, num_stages=1)
        buf5 = empty_strided_cuda((4, 4, 4), (16, 4, 1), torch.float32)
        extern_kernels.bmm(reinterpret_tensor(buf4, (4, 4, 16), (64, 16, 1),
            0), reinterpret_tensor(buf4, (4, 16, 4), (64, 1, 16), 0), out=buf5)
        buf6 = empty_strided_cuda((4, 4, 4, 4), (64, 16, 4, 1), torch.float32)
        triton_poi_fused_div_1[grid(256)](arg1_1, buf6, 256, XBLOCK=128,
            num_warps=4, num_stages=1)
        buf7 = empty_strided_cuda((4, 4, 4), (16, 4, 1), torch.float32)
        extern_kernels.bmm(reinterpret_tensor(buf6, (4, 4, 16), (64, 16, 1),
            0), reinterpret_tensor(buf6, (4, 16, 4), (64, 1, 16), 0), out=buf7)
        buf8 = empty_strided_cuda((4, 4, 4, 4), (64, 16, 4, 1), torch.float32)
        triton_poi_fused_div_2[grid(256)](arg0_1, buf8, 256, XBLOCK=128,
            num_warps=4, num_stages=1)
        buf9 = empty_strided_cuda((4, 4, 4), (16, 4, 1), torch.float32)
        extern_kernels.bmm(reinterpret_tensor(buf8, (4, 4, 16), (64, 16, 1),
            0), reinterpret_tensor(buf8, (4, 16, 4), (64, 1, 16), 0), out=buf9)
        buf10 = empty_strided_cuda((4, 4, 4, 4), (64, 16, 4, 1), torch.float32)
        triton_poi_fused_div_2[grid(256)](arg1_1, buf10, 256, XBLOCK=128,
            num_warps=4, num_stages=1)
        buf11 = empty_strided_cuda((4, 4, 4), (16, 4, 1), torch.float32)
        extern_kernels.bmm(reinterpret_tensor(buf10, (4, 4, 16), (64, 16, 1
            ), 0), reinterpret_tensor(buf10, (4, 16, 4), (64, 1, 16), 0),
            out=buf11)
        buf12 = empty_strided_cuda((4, 4, 4, 4), (64, 16, 4, 1), torch.float32)
        triton_poi_fused_div_3[grid(256)](arg0_1, buf12, 256, XBLOCK=128,
            num_warps=4, num_stages=1)
        del arg0_1
        buf13 = empty_strided_cuda((4, 4, 4), (16, 4, 1), torch.float32)
        extern_kernels.bmm(reinterpret_tensor(buf12, (4, 4, 16), (64, 16, 1
            ), 0), reinterpret_tensor(buf12, (4, 16, 4), (64, 1, 16), 0),
            out=buf13)
        buf14 = empty_strided_cuda((4, 4, 4, 4), (64, 16, 4, 1), torch.float32)
        triton_poi_fused_div_3[grid(256)](arg1_1, buf14, 256, XBLOCK=128,
            num_warps=4, num_stages=1)
        del arg1_1
        buf15 = empty_strided_cuda((4, 4, 4), (16, 4, 1), torch.float32)
        extern_kernels.bmm(reinterpret_tensor(buf14, (4, 4, 16), (64, 16, 1
            ), 0), reinterpret_tensor(buf14, (4, 16, 4), (64, 1, 16), 0),
            out=buf15)
        buf16 = empty_strided_cuda((4, 4, 4), (16, 4, 1), torch.float32)
        triton_poi_fused_sub_4[grid(64)](buf1, buf16, 64, XBLOCK=64,
            num_warps=1, num_stages=1)
        buf17 = buf1
        del buf1
        triton_poi_fused__softmax_5[grid(64)](buf16, buf17, 64, XBLOCK=64,
            num_warps=1, num_stages=1)
        buf18 = buf16
        del buf16
        triton_poi_fused__softmax_6[grid(64)](buf17, buf18, 64, XBLOCK=64,
            num_warps=1, num_stages=1)
        del buf17
        buf19 = empty_strided_cuda((4, 4, 16), (64, 16, 1), torch.float32)
        extern_kernels.bmm(buf18, reinterpret_tensor(buf0, (4, 4, 16), (64,
            16, 1), 0), out=buf19)
        buf20 = buf18
        del buf18
        triton_poi_fused_sub_4[grid(64)](buf3, buf20, 64, XBLOCK=64,
            num_warps=1, num_stages=1)
        buf21 = buf3
        del buf3
        triton_poi_fused__softmax_5[grid(64)](buf20, buf21, 64, XBLOCK=64,
            num_warps=1, num_stages=1)
        buf22 = buf20
        del buf20
        triton_poi_fused__softmax_6[grid(64)](buf21, buf22, 64, XBLOCK=64,
            num_warps=1, num_stages=1)
        del buf21
        buf23 = empty_strided_cuda((4, 4, 16), (64, 16, 1), torch.float32)
        extern_kernels.bmm(buf22, reinterpret_tensor(buf2, (4, 4, 16), (64,
            16, 1), 0), out=buf23)
        buf25 = empty_strided_cuda((4, 16, 16), (256, 16, 1), torch.float32)
        extern_kernels.bmm(reinterpret_tensor(buf0, (4, 16, 4), (64, 1, 16),
            0), reinterpret_tensor(buf0, (4, 4, 16), (64, 16, 1), 0), out=buf25
            )
        buf28 = empty_strided_cuda((4, 16, 16), (256, 16, 1), torch.float32)
        triton_per_fused__softmax_7[grid(64)](buf25, buf28, 64, 16, XBLOCK=
            8, num_warps=2, num_stages=1)
        buf29 = empty_strided_cuda((4, 4, 16), (64, 16, 1), torch.float32)
        extern_kernels.bmm(reinterpret_tensor(buf0, (4, 4, 16), (64, 16, 1),
            0), reinterpret_tensor(buf28, (4, 16, 16), (256, 1, 16), 0),
            out=buf29)
        buf30 = buf28
        del buf28
        extern_kernels.bmm(reinterpret_tensor(buf2, (4, 16, 4), (64, 1, 16),
            0), reinterpret_tensor(buf2, (4, 4, 16), (64, 16, 1), 0), out=buf30
            )
        buf33 = buf25
        del buf25
        triton_per_fused__softmax_7[grid(64)](buf30, buf33, 64, 16, XBLOCK=
            8, num_warps=2, num_stages=1)
        buf34 = empty_strided_cuda((4, 4, 16), (64, 16, 1), torch.float32)
        extern_kernels.bmm(reinterpret_tensor(buf2, (4, 4, 16), (64, 16, 1),
            0), reinterpret_tensor(buf33, (4, 16, 16), (256, 1, 16), 0),
            out=buf34)
        buf36 = buf22
        del buf22
        triton_poi_fused_sub_4[grid(64)](buf5, buf36, 64, XBLOCK=64,
            num_warps=1, num_stages=1)
        buf37 = buf5
        del buf5
        triton_poi_fused__softmax_5[grid(64)](buf36, buf37, 64, XBLOCK=64,
            num_warps=1, num_stages=1)
        buf38 = buf36
        del buf36
        triton_poi_fused__softmax_6[grid(64)](buf37, buf38, 64, XBLOCK=64,
            num_warps=1, num_stages=1)
        del buf37
        buf39 = empty_strided_cuda((4, 4, 16), (64, 16, 1), torch.float32)
        extern_kernels.bmm(buf38, reinterpret_tensor(buf4, (4, 4, 16), (64,
            16, 1), 0), out=buf39)
        buf40 = buf38
        del buf38
        triton_poi_fused_sub_4[grid(64)](buf7, buf40, 64, XBLOCK=64,
            num_warps=1, num_stages=1)
        buf41 = buf7
        del buf7
        triton_poi_fused__softmax_5[grid(64)](buf40, buf41, 64, XBLOCK=64,
            num_warps=1, num_stages=1)
        buf42 = buf40
        del buf40
        triton_poi_fused__softmax_6[grid(64)](buf41, buf42, 64, XBLOCK=64,
            num_warps=1, num_stages=1)
        del buf41
        buf43 = empty_strided_cuda((4, 4, 16), (64, 16, 1), torch.float32)
        extern_kernels.bmm(buf42, reinterpret_tensor(buf6, (4, 4, 16), (64,
            16, 1), 0), out=buf43)
        buf45 = buf33
        del buf33
        extern_kernels.bmm(reinterpret_tensor(buf4, (4, 16, 4), (64, 1, 16),
            0), reinterpret_tensor(buf4, (4, 4, 16), (64, 16, 1), 0), out=buf45
            )
        buf48 = buf30
        del buf30
        triton_per_fused__softmax_7[grid(64)](buf45, buf48, 64, 16, XBLOCK=
            8, num_warps=2, num_stages=1)
        buf49 = empty_strided_cuda((4, 4, 16), (64, 16, 1), torch.float32)
        extern_kernels.bmm(reinterpret_tensor(buf4, (4, 4, 16), (64, 16, 1),
            0), reinterpret_tensor(buf48, (4, 16, 16), (256, 1, 16), 0),
            out=buf49)
        buf50 = buf48
        del buf48
        extern_kernels.bmm(reinterpret_tensor(buf6, (4, 16, 4), (64, 1, 16),
            0), reinterpret_tensor(buf6, (4, 4, 16), (64, 16, 1), 0), out=buf50
            )
        buf53 = buf45
        del buf45
        triton_per_fused__softmax_7[grid(64)](buf50, buf53, 64, 16, XBLOCK=
            8, num_warps=2, num_stages=1)
        buf54 = empty_strided_cuda((4, 4, 16), (64, 16, 1), torch.float32)
        extern_kernels.bmm(reinterpret_tensor(buf6, (4, 4, 16), (64, 16, 1),
            0), reinterpret_tensor(buf53, (4, 16, 16), (256, 1, 16), 0),
            out=buf54)
        buf56 = buf42
        del buf42
        triton_poi_fused_sub_4[grid(64)](buf9, buf56, 64, XBLOCK=64,
            num_warps=1, num_stages=1)
        buf57 = buf9
        del buf9
        triton_poi_fused__softmax_5[grid(64)](buf56, buf57, 64, XBLOCK=64,
            num_warps=1, num_stages=1)
        buf58 = buf56
        del buf56
        triton_poi_fused__softmax_6[grid(64)](buf57, buf58, 64, XBLOCK=64,
            num_warps=1, num_stages=1)
        del buf57
        buf59 = empty_strided_cuda((4, 4, 16), (64, 16, 1), torch.float32)
        extern_kernels.bmm(buf58, reinterpret_tensor(buf8, (4, 4, 16), (64,
            16, 1), 0), out=buf59)
        buf60 = buf58
        del buf58
        triton_poi_fused_sub_4[grid(64)](buf11, buf60, 64, XBLOCK=64,
            num_warps=1, num_stages=1)
        buf61 = buf11
        del buf11
        triton_poi_fused__softmax_5[grid(64)](buf60, buf61, 64, XBLOCK=64,
            num_warps=1, num_stages=1)
        buf62 = buf60
        del buf60
        triton_poi_fused__softmax_6[grid(64)](buf61, buf62, 64, XBLOCK=64,
            num_warps=1, num_stages=1)
        del buf61
        buf63 = empty_strided_cuda((4, 4, 16), (64, 16, 1), torch.float32)
        extern_kernels.bmm(buf62, reinterpret_tensor(buf10, (4, 4, 16), (64,
            16, 1), 0), out=buf63)
        buf65 = buf53
        del buf53
        extern_kernels.bmm(reinterpret_tensor(buf8, (4, 16, 4), (64, 1, 16),
            0), reinterpret_tensor(buf8, (4, 4, 16), (64, 16, 1), 0), out=buf65
            )
        buf68 = buf50
        del buf50
        triton_per_fused__softmax_7[grid(64)](buf65, buf68, 64, 16, XBLOCK=
            8, num_warps=2, num_stages=1)
        buf69 = empty_strided_cuda((4, 4, 16), (64, 16, 1), torch.float32)
        extern_kernels.bmm(reinterpret_tensor(buf8, (4, 4, 16), (64, 16, 1),
            0), reinterpret_tensor(buf68, (4, 16, 16), (256, 1, 16), 0),
            out=buf69)
        buf70 = buf68
        del buf68
        extern_kernels.bmm(reinterpret_tensor(buf10, (4, 16, 4), (64, 1, 16
            ), 0), reinterpret_tensor(buf10, (4, 4, 16), (64, 16, 1), 0),
            out=buf70)
        buf73 = buf65
        del buf65
        triton_per_fused__softmax_7[grid(64)](buf70, buf73, 64, 16, XBLOCK=
            8, num_warps=2, num_stages=1)
        buf74 = empty_strided_cuda((4, 4, 16), (64, 16, 1), torch.float32)
        extern_kernels.bmm(reinterpret_tensor(buf10, (4, 4, 16), (64, 16, 1
            ), 0), reinterpret_tensor(buf73, (4, 16, 16), (256, 1, 16), 0),
            out=buf74)
        buf76 = buf62
        del buf62
        triton_poi_fused_sub_4[grid(64)](buf13, buf76, 64, XBLOCK=64,
            num_warps=1, num_stages=1)
        buf77 = buf13
        del buf13
        triton_poi_fused__softmax_5[grid(64)](buf76, buf77, 64, XBLOCK=64,
            num_warps=1, num_stages=1)
        buf78 = buf76
        del buf76
        triton_poi_fused__softmax_6[grid(64)](buf77, buf78, 64, XBLOCK=64,
            num_warps=1, num_stages=1)
        del buf77
        buf79 = empty_strided_cuda((4, 4, 16), (64, 16, 1), torch.float32)
        extern_kernels.bmm(buf78, reinterpret_tensor(buf12, (4, 4, 16), (64,
            16, 1), 0), out=buf79)
        buf80 = buf78
        del buf78
        triton_poi_fused_sub_4[grid(64)](buf15, buf80, 64, XBLOCK=64,
            num_warps=1, num_stages=1)
        buf81 = buf15
        del buf15
        triton_poi_fused__softmax_5[grid(64)](buf80, buf81, 64, XBLOCK=64,
            num_warps=1, num_stages=1)
        buf82 = buf80
        del buf80
        triton_poi_fused__softmax_6[grid(64)](buf81, buf82, 64, XBLOCK=64,
            num_warps=1, num_stages=1)
        del buf81
        buf83 = empty_strided_cuda((4, 4, 16), (64, 16, 1), torch.float32)
        extern_kernels.bmm(buf82, reinterpret_tensor(buf14, (4, 4, 16), (64,
            16, 1), 0), out=buf83)
        del buf82
        buf85 = buf73
        del buf73
        extern_kernels.bmm(reinterpret_tensor(buf12, (4, 16, 4), (64, 1, 16
            ), 0), reinterpret_tensor(buf12, (4, 4, 16), (64, 16, 1), 0),
            out=buf85)
        buf88 = buf70
        del buf70
        triton_per_fused__softmax_7[grid(64)](buf85, buf88, 64, 16, XBLOCK=
            8, num_warps=2, num_stages=1)
        buf89 = empty_strided_cuda((4, 4, 16), (64, 16, 1), torch.float32)
        extern_kernels.bmm(reinterpret_tensor(buf12, (4, 4, 16), (64, 16, 1
            ), 0), reinterpret_tensor(buf88, (4, 16, 16), (256, 1, 16), 0),
            out=buf89)
        buf90 = buf88
        del buf88
        extern_kernels.bmm(reinterpret_tensor(buf14, (4, 16, 4), (64, 1, 16
            ), 0), reinterpret_tensor(buf14, (4, 4, 16), (64, 16, 1), 0),
            out=buf90)
        buf93 = buf85
        del buf85
        triton_per_fused__softmax_7[grid(64)](buf90, buf93, 64, 16, XBLOCK=
            8, num_warps=2, num_stages=1)
        del buf90
        buf94 = empty_strided_cuda((4, 4, 16), (64, 16, 1), torch.float32)
        extern_kernels.bmm(reinterpret_tensor(buf14, (4, 4, 16), (64, 16, 1
            ), 0), reinterpret_tensor(buf93, (4, 16, 16), (256, 1, 16), 0),
            out=buf94)
        del buf93
        buf24 = empty_strided_cuda((), (), torch.float32)
        buf96 = buf24
        del buf24
        triton_per_fused_abs_add_mean_mul_sub_8[grid(1)](buf96, buf19, buf0,
            buf23, buf2, buf29, buf34, buf39, buf4, buf43, buf6, buf49,
            buf54, buf59, buf8, buf63, buf10, buf69, buf74, buf79, buf12,
            buf83, buf14, buf89, buf94, 1, 256, num_warps=2, num_stages=1)
        del buf0
        del buf10
        del buf12
        del buf14
        del buf19
        del buf2
        del buf23
        del buf29
        del buf34
        del buf39
        del buf4
        del buf43
        del buf49
        del buf54
        del buf59
        del buf6
        del buf63
        del buf69
        del buf74
        del buf79
        del buf8
        del buf83
        del buf89
        del buf94
    return buf96,


class SCRMNew(nn.Module):
    """
    spatial & channel wise relation loss
    """

    def __init__(self, gamma=0.1):
        super(SCRMNew, self).__init__()
        self.softmax = nn.Softmax(dim=-1)
        self.gamma = gamma

    def spatial_wise(self, x):
        m_batchsize, C, height, width = x.size()
        proj_query = x.view(m_batchsize, -1, width * height).permute(0, 2, 1)
        proj_key = x.view(m_batchsize, -1, width * height)
        energy = torch.bmm(proj_query, proj_key)
        attention = self.softmax(energy)
        proj_value = x.view(m_batchsize, -1, width * height)
        out = torch.bmm(proj_value, attention.permute(0, 2, 1))
        out = out.view(m_batchsize, C, height, width)
        out = self.gamma * out + x
        return out

    def channel_wise(self, x):
        m_batchsize, C, height, width = x.size()
        proj_query = x.view(m_batchsize, C, -1)
        proj_key = x.view(m_batchsize, C, -1).permute(0, 2, 1)
        energy = torch.bmm(proj_query, proj_key)
        energy_new = torch.max(energy, -1, keepdim=True)[0].expand_as(energy
            ) - energy
        attention = self.softmax(energy_new)
        proj_value = x.view(m_batchsize, C, -1)
        out = torch.bmm(attention, proj_value)
        out = out.view(m_batchsize, C, height, width)
        out = self.gamma * out + x
        return out

    def cal_loss(self, f_s, f_t):
        f_s = F.normalize(f_s, dim=1)
        f_t = F.normalize(f_t, dim=1)
        sa_loss = F.l1_loss(self.spatial_wise(f_s), self.spatial_wise(f_t))
        ca_loss = F.l1_loss(self.channel_wise(f_s), self.channel_wise(f_t))
        return ca_loss + sa_loss

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


Measured latency_ms: 0.071478