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 as nn
import torch.nn.parallel
import torch.utils.data
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_mean_0(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 = tl.load(in_ptr0 + (x0 + 16 * x1), xmask)
    tmp1 = tl.load(in_ptr0 + (64 + x0 + 16 * x1), xmask)
    tmp3 = tl.load(in_ptr0 + (128 + x0 + 16 * x1), xmask)
    tmp5 = tl.load(in_ptr0 + (192 + x0 + 16 * x1), xmask)
    tmp9 = tl.load(in_ptr0 + (4 + x0 + 16 * x1), xmask)
    tmp10 = tl.load(in_ptr0 + (68 + x0 + 16 * x1), xmask)
    tmp12 = tl.load(in_ptr0 + (132 + x0 + 16 * x1), xmask)
    tmp14 = tl.load(in_ptr0 + (196 + x0 + 16 * x1), xmask)
    tmp18 = tl.load(in_ptr0 + (8 + x0 + 16 * x1), xmask)
    tmp19 = tl.load(in_ptr0 + (72 + x0 + 16 * x1), xmask)
    tmp21 = tl.load(in_ptr0 + (136 + x0 + 16 * x1), xmask)
    tmp23 = tl.load(in_ptr0 + (200 + x0 + 16 * x1), xmask)
    tmp27 = tl.load(in_ptr0 + (12 + x0 + 16 * x1), xmask)
    tmp28 = tl.load(in_ptr0 + (76 + x0 + 16 * x1), xmask)
    tmp30 = tl.load(in_ptr0 + (140 + x0 + 16 * x1), xmask)
    tmp32 = tl.load(in_ptr0 + (204 + x0 + 16 * x1), xmask)
    tmp2 = tmp0 + tmp1
    tmp4 = tmp2 + tmp3
    tmp6 = tmp4 + tmp5
    tmp7 = 4.0
    tmp8 = tmp6 / tmp7
    tmp11 = tmp9 + tmp10
    tmp13 = tmp11 + tmp12
    tmp15 = tmp13 + tmp14
    tmp16 = tmp15 / tmp7
    tmp17 = tmp8 + tmp16
    tmp20 = tmp18 + tmp19
    tmp22 = tmp20 + tmp21
    tmp24 = tmp22 + tmp23
    tmp25 = tmp24 / tmp7
    tmp26 = tmp17 + tmp25
    tmp29 = tmp27 + tmp28
    tmp31 = tmp29 + tmp30
    tmp33 = tmp31 + tmp32
    tmp34 = tmp33 / tmp7
    tmp35 = tmp26 + tmp34
    tmp36 = tmp35 / tmp7
    tl.store(out_ptr0 + x2, tmp36, xmask)


@triton.jit
def triton_poi_fused_mean_sub_1(in_ptr0, in_ptr1, in_ptr2, out_ptr0,
    out_ptr1, xnumel, XBLOCK: tl.constexpr):
    xnumel = 256
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x3 = xindex
    x1 = xindex // 16 % 4
    tmp0 = tl.load(in_ptr0 + x3, xmask)
    tmp1 = tl.load(in_ptr1 + 4 * x1, xmask, eviction_policy='evict_last')
    tmp2 = tl.load(in_ptr1 + (1 + 4 * x1), xmask, eviction_policy='evict_last')
    tmp4 = tl.load(in_ptr1 + (2 + 4 * x1), xmask, eviction_policy='evict_last')
    tmp6 = tl.load(in_ptr1 + (3 + 4 * x1), xmask, eviction_policy='evict_last')
    tmp11 = tl.load(in_ptr2 + x3, xmask)
    tmp3 = tmp1 + tmp2
    tmp5 = tmp3 + tmp4
    tmp7 = tmp5 + tmp6
    tmp8 = 4.0
    tmp9 = tmp7 / tmp8
    tmp10 = tmp0 - tmp9
    tmp12 = tmp11 - tmp9
    tl.store(out_ptr0 + x3, tmp10, xmask)
    tl.store(out_ptr1 + x3, tmp12, xmask)


@triton.jit
def triton_poi_fused_div_linalg_vector_norm_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 + 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 = tmp0 / tmp12
    tl.store(out_ptr0 + x3, tmp13, xmask)


@triton.jit
def triton_poi_fused_convolution_3(in_ptr0, out_ptr0, ynumel, xnumel,
    YBLOCK: tl.constexpr, XBLOCK: tl.constexpr):
    ynumel = 4
    xnumel = 16
    yoffset = tl.program_id(1) * YBLOCK
    yindex = yoffset + tl.arange(0, YBLOCK)[None, :]
    ymask = yindex < ynumel
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:, None]
    xmask = xindex < xnumel
    x1 = xindex
    y0 = yindex
    tmp0 = tl.load(in_ptr0 + (x1 + 16 * y0), xmask & ymask, eviction_policy
        ='evict_last')
    tl.store(out_ptr0 + (y0 + 4 * x1), tmp0, xmask & ymask)


@triton.jit
def triton_poi_fused_convolution_4(in_ptr0, out_ptr0, ynumel, xnumel,
    YBLOCK: tl.constexpr, XBLOCK: tl.constexpr):
    ynumel = 16
    xnumel = 4
    yoffset = tl.program_id(1) * YBLOCK
    yindex = yoffset + tl.arange(0, YBLOCK)[None, :]
    ymask = yindex < ynumel
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:, None]
    xmask = xindex < xnumel
    x1 = xindex
    y0 = yindex
    tmp0 = tl.load(in_ptr0 + (y0 + 16 * x1), xmask & ymask, eviction_policy
        ='evict_last')
    tl.store(out_ptr0 + (x1 + 4 * y0), tmp0, xmask & ymask)


@triton.jit
def triton_poi_fused_convolution_5(in_ptr0, out_ptr0, ynumel, xnumel,
    YBLOCK: tl.constexpr, XBLOCK: tl.constexpr):
    ynumel = 4
    xnumel = 16
    yoffset = tl.program_id(1) * YBLOCK
    yindex = yoffset + tl.arange(0, YBLOCK)[None, :]
    ymask = yindex < ynumel
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:, None]
    xmask = xindex < xnumel
    x1 = xindex
    y0 = yindex
    tmp0 = tl.load(in_ptr0 + (64 + x1 + 16 * y0), xmask & ymask,
        eviction_policy='evict_last')
    tl.store(out_ptr0 + (y0 + 4 * x1), tmp0, xmask & ymask)


@triton.jit
def triton_poi_fused_convolution_6(in_ptr0, out_ptr0, ynumel, xnumel,
    YBLOCK: tl.constexpr, XBLOCK: tl.constexpr):
    ynumel = 16
    xnumel = 4
    yoffset = tl.program_id(1) * YBLOCK
    yindex = yoffset + tl.arange(0, YBLOCK)[None, :]
    ymask = yindex < ynumel
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:, None]
    xmask = xindex < xnumel
    x1 = xindex
    y0 = yindex
    tmp0 = tl.load(in_ptr0 + (64 + y0 + 16 * x1), xmask & ymask,
        eviction_policy='evict_last')
    tl.store(out_ptr0 + (x1 + 4 * y0), tmp0, xmask & ymask)


@triton.jit
def triton_poi_fused_convolution_7(in_ptr0, out_ptr0, ynumel, xnumel,
    YBLOCK: tl.constexpr, XBLOCK: tl.constexpr):
    ynumel = 4
    xnumel = 16
    yoffset = tl.program_id(1) * YBLOCK
    yindex = yoffset + tl.arange(0, YBLOCK)[None, :]
    ymask = yindex < ynumel
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:, None]
    xmask = xindex < xnumel
    x1 = xindex
    y0 = yindex
    tmp0 = tl.load(in_ptr0 + (128 + x1 + 16 * y0), xmask & ymask,
        eviction_policy='evict_last')
    tl.store(out_ptr0 + (y0 + 4 * x1), tmp0, xmask & ymask)


@triton.jit
def triton_poi_fused_convolution_8(in_ptr0, out_ptr0, ynumel, xnumel,
    YBLOCK: tl.constexpr, XBLOCK: tl.constexpr):
    ynumel = 16
    xnumel = 4
    yoffset = tl.program_id(1) * YBLOCK
    yindex = yoffset + tl.arange(0, YBLOCK)[None, :]
    ymask = yindex < ynumel
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:, None]
    xmask = xindex < xnumel
    x1 = xindex
    y0 = yindex
    tmp0 = tl.load(in_ptr0 + (128 + y0 + 16 * x1), xmask & ymask,
        eviction_policy='evict_last')
    tl.store(out_ptr0 + (x1 + 4 * y0), tmp0, xmask & ymask)


@triton.jit
def triton_poi_fused_convolution_9(in_ptr0, out_ptr0, ynumel, xnumel,
    YBLOCK: tl.constexpr, XBLOCK: tl.constexpr):
    ynumel = 4
    xnumel = 16
    yoffset = tl.program_id(1) * YBLOCK
    yindex = yoffset + tl.arange(0, YBLOCK)[None, :]
    ymask = yindex < ynumel
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:, None]
    xmask = xindex < xnumel
    x1 = xindex
    y0 = yindex
    tmp0 = tl.load(in_ptr0 + (192 + x1 + 16 * y0), xmask & ymask,
        eviction_policy='evict_last')
    tl.store(out_ptr0 + (y0 + 4 * x1), tmp0, xmask & ymask)


@triton.jit
def triton_poi_fused_convolution_10(in_ptr0, out_ptr0, ynumel, xnumel,
    YBLOCK: tl.constexpr, XBLOCK: tl.constexpr):
    ynumel = 16
    xnumel = 4
    yoffset = tl.program_id(1) * YBLOCK
    yindex = yoffset + tl.arange(0, YBLOCK)[None, :]
    ymask = yindex < ynumel
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:, None]
    xmask = xindex < xnumel
    x1 = xindex
    y0 = yindex
    tmp0 = tl.load(in_ptr0 + (192 + y0 + 16 * x1), xmask & ymask,
        eviction_policy='evict_last')
    tl.store(out_ptr0 + (x1 + 4 * y0), tmp0, xmask & ymask)


@triton.jit
def triton_per_fused_add_cat_div_exp_min_rsub_sum_11(in_ptr0, in_ptr1,
    in_ptr2, in_ptr3, out_ptr0, out_ptr1, 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)
    x1 = xindex // 16
    r2 = rindex
    x0 = xindex % 16
    x3 = xindex
    tmp0 = x1
    tl.full([1, 1], 0, tl.int64)
    tmp3 = tl.full([1, 1], 1, tl.int64)
    tmp4 = tmp0 < tmp3
    tmp5 = tl.load(in_ptr0 + (r2 + 16 * x0), tmp4 & xmask, eviction_policy=
        'evict_last', other=0.0)
    tmp6 = tmp0 >= tmp3
    tmp7 = tl.full([1, 1], 2, tl.int64)
    tmp8 = tmp0 < tmp7
    tmp9 = tmp6 & tmp8
    tmp10 = tl.load(in_ptr1 + (r2 + 16 * x0), tmp9 & xmask, eviction_policy
        ='evict_last', other=0.0)
    tmp11 = tmp0 >= tmp7
    tmp12 = tl.full([1, 1], 3, tl.int64)
    tmp13 = tmp0 < tmp12
    tmp14 = tmp11 & tmp13
    tmp15 = tl.load(in_ptr2 + (r2 + 16 * x0), tmp14 & xmask,
        eviction_policy='evict_last', other=0.0)
    tmp16 = tmp0 >= tmp12
    tl.full([1, 1], 4, tl.int64)
    tmp19 = tl.load(in_ptr3 + (r2 + 16 * 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)
    tmp23 = 1.0
    tmp24 = tmp23 - tmp22
    tmp25 = 0.5
    tmp26 = tmp24 * tmp25
    tmp27 = tl.broadcast_to(tmp26, [XBLOCK, RBLOCK])
    tmp29 = tl.where(xmask, tmp27, float('inf'))
    tmp30 = triton_helpers.min2(tmp29, 1)[:, None]
    tmp31 = 1e-05
    tmp32 = tmp30 + tmp31
    tmp33 = tmp26 / tmp32
    tmp34 = tmp23 - tmp33
    tmp35 = 10.0
    tmp36 = tmp34 * tmp35
    tmp37 = tl_math.exp(tmp36)
    tmp38 = tl.broadcast_to(tmp37, [XBLOCK, RBLOCK])
    tmp40 = tl.where(xmask, tmp38, 0)
    tmp41 = tl.sum(tmp40, 1)[:, None]
    tl.store(out_ptr0 + (r2 + 16 * x3), tmp26, xmask)
    tl.store(out_ptr1 + x3, tmp30, xmask)
    tl.store(out_ptr2 + x3, tmp41, xmask)


@triton.jit
def triton_poi_fused_add_div_exp_max_rsub_12(in_ptr0, in_ptr1, in_ptr2,
    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 = tl.load(in_ptr0 + (x0 + 64 * x1), xmask)
    tmp1 = tl.load(in_ptr1 + 4 * x1, xmask, eviction_policy='evict_last')
    tmp10 = tl.load(in_ptr2 + 4 * x1, xmask, eviction_policy='evict_last')
    tmp12 = tl.load(in_ptr0 + (16 + x0 + 64 * x1), xmask)
    tmp13 = tl.load(in_ptr1 + (1 + 4 * x1), xmask, eviction_policy='evict_last'
        )
    tmp19 = tl.load(in_ptr2 + (1 + 4 * x1), xmask, eviction_policy='evict_last'
        )
    tmp22 = tl.load(in_ptr0 + (32 + x0 + 64 * x1), xmask)
    tmp23 = tl.load(in_ptr1 + (2 + 4 * x1), xmask, eviction_policy='evict_last'
        )
    tmp29 = tl.load(in_ptr2 + (2 + 4 * x1), xmask, eviction_policy='evict_last'
        )
    tmp32 = tl.load(in_ptr0 + (48 + x0 + 64 * x1), xmask)
    tmp33 = tl.load(in_ptr1 + (3 + 4 * x1), xmask, eviction_policy='evict_last'
        )
    tmp39 = tl.load(in_ptr2 + (3 + 4 * x1), xmask, eviction_policy='evict_last'
        )
    tmp2 = 1e-05
    tmp3 = tmp1 + tmp2
    tmp4 = tmp0 / tmp3
    tmp5 = 1.0
    tmp6 = tmp5 - tmp4
    tmp7 = 10.0
    tmp8 = tmp6 * tmp7
    tmp9 = tl_math.exp(tmp8)
    tmp11 = tmp9 / tmp10
    tmp14 = tmp13 + tmp2
    tmp15 = tmp12 / tmp14
    tmp16 = tmp5 - tmp15
    tmp17 = tmp16 * tmp7
    tmp18 = tl_math.exp(tmp17)
    tmp20 = tmp18 / tmp19
    tmp21 = triton_helpers.maximum(tmp11, tmp20)
    tmp24 = tmp23 + tmp2
    tmp25 = tmp22 / tmp24
    tmp26 = tmp5 - tmp25
    tmp27 = tmp26 * tmp7
    tmp28 = tl_math.exp(tmp27)
    tmp30 = tmp28 / tmp29
    tmp31 = triton_helpers.maximum(tmp21, tmp30)
    tmp34 = tmp33 + tmp2
    tmp35 = tmp32 / tmp34
    tmp36 = tmp5 - tmp35
    tmp37 = tmp36 * tmp7
    tmp38 = tl_math.exp(tmp37)
    tmp40 = tmp38 / tmp39
    tmp41 = triton_helpers.maximum(tmp31, tmp40)
    tl.store(out_ptr0 + x2, tmp41, xmask)


@triton.jit
def triton_per_fused_max_mean_13(in_ptr0, out_ptr0, xnumel, rnumel, XBLOCK:
    tl.constexpr):
    xnumel = 4
    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 + 64 * x0), xmask, other=0.0)
    tmp1 = tl.load(in_ptr0 + (16 + r1 + 64 * x0), xmask, other=0.0)
    tmp3 = tl.load(in_ptr0 + (32 + r1 + 64 * x0), xmask, other=0.0)
    tmp5 = tl.load(in_ptr0 + (48 + r1 + 64 * x0), xmask, other=0.0)
    tmp2 = triton_helpers.maximum(tmp0, tmp1)
    tmp4 = triton_helpers.maximum(tmp2, tmp3)
    tmp6 = triton_helpers.maximum(tmp4, tmp5)
    tmp7 = tl.broadcast_to(tmp6, [XBLOCK, RBLOCK])
    tmp9 = tl.where(xmask, tmp7, 0)
    tmp10 = tl.sum(tmp9, 1)[:, None]
    tl.store(out_ptr0 + x0, tmp10, xmask)


@triton.jit
def triton_per_fused_log_max_mean_neg_14(in_out_ptr0, in_ptr0, xnumel,
    rnumel, XBLOCK: tl.constexpr):
    RBLOCK: tl.constexpr = 4
    xoffset = tl.program_id(0) * XBLOCK
    xoffset + tl.arange(0, XBLOCK)[:, None]
    tl.full([XBLOCK, RBLOCK], True, tl.int1)
    rindex = tl.arange(0, RBLOCK)[None, :]
    tl.full([XBLOCK, RBLOCK], True, tl.int1)
    r0 = rindex
    tmp0 = tl.load(in_ptr0 + r0, None)
    tmp1 = 16.0
    tmp2 = tmp0 / tmp1
    tmp3 = tl_math.log(tmp2)
    tmp4 = -tmp3
    tmp5 = tl.broadcast_to(tmp4, [XBLOCK, RBLOCK])
    tmp7 = tl.sum(tmp5, 1)[:, None]
    tmp8 = 4.0
    tmp9 = tmp7 / tmp8
    tl.debug_barrier()
    tl.store(in_out_ptr0 + tl.full([XBLOCK, 1], 0, tl.int32), tmp9, None)


def call(args):
    arg0_1, arg1_1 = args
    args.clear()
    assert_size_stride(arg0_1, (4, 4, 4, 4), (64, 16, 4, 1))
    assert_size_stride(arg1_1, (4, 4, 4, 4), (64, 16, 4, 1))
    with torch.cuda._DeviceGuard(0):
        torch.cuda.set_device(0)
        buf0 = empty_strided_cuda((1, 4, 1, 4), (16, 4, 16, 1), torch.float32)
        get_raw_stream(0)
        triton_poi_fused_mean_0[grid(16)](arg0_1, buf0, 16, XBLOCK=16,
            num_warps=1, num_stages=1)
        buf1 = empty_strided_cuda((4, 4, 4, 4), (64, 16, 4, 1), torch.float32)
        buf3 = empty_strided_cuda((4, 4, 4, 4), (64, 16, 4, 1), torch.float32)
        triton_poi_fused_mean_sub_1[grid(256)](arg1_1, buf0, arg0_1, buf1,
            buf3, 256, XBLOCK=128, num_warps=4, num_stages=1)
        del arg0_1
        del arg1_1
        del buf0
        buf2 = empty_strided_cuda((4, 4, 4, 4), (64, 16, 4, 1), torch.float32)
        triton_poi_fused_div_linalg_vector_norm_2[grid(256)](buf1, buf2, 
            256, XBLOCK=256, num_warps=4, num_stages=1)
        buf4 = buf1
        del buf1
        triton_poi_fused_div_linalg_vector_norm_2[grid(256)](buf3, buf4, 
            256, XBLOCK=256, num_warps=4, num_stages=1)
        del buf3
        buf5 = empty_strided_cuda((1, 4, 4, 4), (64, 1, 16, 4), torch.float32)
        triton_poi_fused_convolution_3[grid(4, 16)](buf2, buf5, 4, 16,
            XBLOCK=16, YBLOCK=4, num_warps=1, num_stages=1)
        buf6 = empty_strided_cuda((16, 4, 1, 1), (4, 1, 4, 4), torch.float32)
        triton_poi_fused_convolution_4[grid(16, 4)](buf4, buf6, 16, 4,
            XBLOCK=4, YBLOCK=16, num_warps=1, num_stages=1)
        buf7 = extern_kernels.convolution(buf5, buf6, stride=(1, 1),
            padding=(0, 0), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf7, (1, 16, 4, 4), (256, 1, 64, 16))
        buf8 = reinterpret_tensor(buf6, (1, 4, 4, 4), (64, 1, 16, 4), 0)
        del buf6
        triton_poi_fused_convolution_5[grid(4, 16)](buf2, buf8, 4, 16,
            XBLOCK=16, YBLOCK=4, num_warps=1, num_stages=1)
        buf9 = reinterpret_tensor(buf5, (16, 4, 1, 1), (4, 1, 4, 4), 0)
        del buf5
        triton_poi_fused_convolution_6[grid(16, 4)](buf4, buf9, 16, 4,
            XBLOCK=4, YBLOCK=16, num_warps=1, num_stages=1)
        buf10 = extern_kernels.convolution(buf8, buf9, stride=(1, 1),
            padding=(0, 0), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf10, (1, 16, 4, 4), (256, 1, 64, 16))
        buf11 = reinterpret_tensor(buf9, (1, 4, 4, 4), (64, 1, 16, 4), 0)
        del buf9
        triton_poi_fused_convolution_7[grid(4, 16)](buf2, buf11, 4, 16,
            XBLOCK=16, YBLOCK=4, num_warps=1, num_stages=1)
        buf12 = reinterpret_tensor(buf8, (16, 4, 1, 1), (4, 1, 4, 4), 0)
        del buf8
        triton_poi_fused_convolution_8[grid(16, 4)](buf4, buf12, 16, 4,
            XBLOCK=4, YBLOCK=16, num_warps=1, num_stages=1)
        buf13 = extern_kernels.convolution(buf11, buf12, stride=(1, 1),
            padding=(0, 0), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf13, (1, 16, 4, 4), (256, 1, 64, 16))
        buf14 = reinterpret_tensor(buf12, (1, 4, 4, 4), (64, 1, 16, 4), 0)
        del buf12
        triton_poi_fused_convolution_9[grid(4, 16)](buf2, buf14, 4, 16,
            XBLOCK=16, YBLOCK=4, num_warps=1, num_stages=1)
        del buf2
        buf15 = reinterpret_tensor(buf11, (16, 4, 1, 1), (4, 1, 4, 4), 0)
        del buf11
        triton_poi_fused_convolution_10[grid(16, 4)](buf4, buf15, 16, 4,
            XBLOCK=4, YBLOCK=16, num_warps=1, num_stages=1)
        del buf4
        buf16 = extern_kernels.convolution(buf14, buf15, stride=(1, 1),
            padding=(0, 0), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf16, (1, 16, 4, 4), (256, 1, 64, 16))
        buf17 = empty_strided_cuda((4, 16, 4, 4), (256, 1, 64, 16), torch.
            float32)
        buf18 = reinterpret_tensor(buf15, (4, 1, 4, 4), (16, 64, 4, 1), 0)
        del buf15
        buf20 = reinterpret_tensor(buf14, (4, 1, 4, 4), (16, 64, 4, 1), 0)
        del buf14
        triton_per_fused_add_cat_div_exp_min_rsub_sum_11[grid(64)](buf7,
            buf10, buf13, buf16, buf17, buf18, buf20, 64, 16, XBLOCK=8,
            num_warps=2, num_stages=1)
        del buf10
        del buf13
        del buf16
        buf21 = reinterpret_tensor(buf7, (4, 16, 4), (64, 1, 16), 0)
        del buf7
        triton_poi_fused_add_div_exp_max_rsub_12[grid(256)](buf17, buf18,
            buf20, buf21, 256, XBLOCK=128, num_warps=4, num_stages=1)
        del buf17
        del buf18
        del buf20
        buf22 = empty_strided_cuda((4,), (1,), torch.float32)
        triton_per_fused_max_mean_13[grid(4)](buf21, buf22, 4, 16, XBLOCK=1,
            num_warps=2, num_stages=1)
        del buf21
        buf23 = empty_strided_cuda((), (), torch.float32)
        buf24 = buf23
        del buf23
        triton_per_fused_log_max_mean_neg_14[grid(1)](buf24, buf22, 1, 4,
            XBLOCK=1, num_warps=2, num_stages=1)
        del buf22
    return buf24,


class CXLossNew(nn.Module):

    def __init__(self, sigma=0.1, b=1.0, similarity='consine'):
        super(CXLossNew, self).__init__()
        self.similarity = similarity
        self.sigma = sigma
        self.b = b

    def center_by_T(self, featureI, featureT):
        meanT = featureT.mean(0, keepdim=True).mean(2, keepdim=True).mean(3,
            keepdim=True)
        return featureI - meanT, featureT - meanT

    def l2_normalize_channelwise(self, features):
        norms = features.norm(p=2, dim=1, keepdim=True)
        features = features.div(norms)
        return features

    def patch_decomposition(self, features):
        N, C, H, W = features.shape
        assert N == 1
        P = H * W
        patches = features.view(1, 1, C, P).permute((3, 2, 0, 1))
        return patches

    def calc_relative_distances(self, raw_dist, axis=1):
        epsilon = 1e-05
        div = torch.min(raw_dist, dim=axis, keepdim=True)[0]
        relative_dist = raw_dist / (div + epsilon)
        return relative_dist

    def calc_CX(self, dist, axis=1):
        W = torch.exp((self.b - dist) / self.sigma)
        W_sum = W.sum(dim=axis, keepdim=True)
        return W.div(W_sum)

    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.256894