# AOT ID: ['0_inference']
from ctypes import c_void_p, c_long, c_int
import torch
import math
import random
import os
import tempfile
from math import inf, nan
from torch._inductor.hooks import run_intermediate_hooks
from torch._inductor.utils import maybe_profile
from torch._inductor.codegen.memory_planning import _align as align
from torch import device, empty_strided
from torch._inductor.async_compile import AsyncCompile
from torch._inductor.select_algorithm import extern_kernels
from torch._inductor.codegen.multi_kernel import MultiKernelCall
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid, split_scan_grid, grid_combo_kernels, start_graph, end_graph
from torch._C import _cuda_getCurrentRawStream as get_raw_stream

aten = torch.ops.aten
inductor_ops = torch.ops.inductor
_quantized = torch.ops._quantized
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
empty_strided_cpu = torch._C._dynamo.guards._empty_strided_cpu
empty_strided_cuda = torch._C._dynamo.guards._empty_strided_cuda
empty_strided_xpu = torch._C._dynamo.guards._empty_strided_xpu
reinterpret_tensor = torch._C._dynamo.guards._reinterpret_tensor
alloc_from_pool = torch.ops.inductor._alloc_from_pool
async_compile = AsyncCompile()


# kernel path: runs/run_shard_7/inductor_cache/ib/cib3dg3fe7l3dkjniigz2beu5yfyr7rrrxej3svakl6wuls2yap5.py
# Topologically Sorted Source Nodes: [normalize, normalize_1, sub, pow_3, sum_1, add, normalize_2, normalize_3, sub_1, pow_6, sum_2, add_1, normalize_4, normalize_5, sub_2, pow_9, sum_3, add_2, normalize_6, normalize_7, sub_3, pow_12, sum_4, add_3, loss], Original ATen: [aten.linalg_vector_norm, aten.div, aten.sub, aten.pow, aten.sum, aten.add]
# Source node to ATen node mapping:
#   add => add
#   add_1 => add_1
#   add_2 => add_2
#   add_3 => add_3
#   loss => div_8
#   normalize => div, pow_2, sum_1
#   normalize_1 => div_1, pow_5, sum_2
#   normalize_2 => div_2, pow_9, sum_4
#   normalize_3 => div_3, pow_12, sum_5
#   normalize_4 => div_4, pow_16, sum_7
#   normalize_5 => div_5, pow_19, sum_8
#   normalize_6 => div_6, pow_23, sum_10
#   normalize_7 => div_7, pow_26, sum_11
#   pow_12 => pow_28
#   pow_3 => pow_7
#   pow_6 => pow_14
#   pow_9 => pow_21
#   sub => sub
#   sub_1 => sub_1
#   sub_2 => sub_2
#   sub_3 => sub_3
#   sum_1 => sum_3
#   sum_2 => sum_6
#   sum_3 => sum_9
#   sum_4 => sum_12
# Graph fragment:
#   %pow_2 : [num_users=1] = call_function[target=torch.ops.aten.pow.Tensor_Scalar](args = (%view, 2.0), kwargs = {})
#   %sum_1 : [num_users=1] = call_function[target=torch.ops.aten.sum.dim_IntList](args = (%pow_2, [1], True), kwargs = {})
#   %div : [num_users=1] = call_function[target=torch.ops.aten.div.Tensor](args = (%view, %expand), kwargs = {})
#   %pow_5 : [num_users=1] = call_function[target=torch.ops.aten.pow.Tensor_Scalar](args = (%view_1, 2.0), kwargs = {})
#   %sum_2 : [num_users=1] = call_function[target=torch.ops.aten.sum.dim_IntList](args = (%pow_5, [1], True), kwargs = {})
#   %div_1 : [num_users=1] = call_function[target=torch.ops.aten.div.Tensor](args = (%view_1, %expand_1), kwargs = {})
#   %sub : [num_users=1] = call_function[target=torch.ops.aten.sub.Tensor](args = (%div, %div_1), kwargs = {})
#   %pow_7 : [num_users=1] = call_function[target=torch.ops.aten.pow.Tensor_Scalar](args = (%sub, 2), kwargs = {})
#   %sum_3 : [num_users=1] = call_function[target=torch.ops.aten.sum.default](args = (%pow_7,), kwargs = {})
#   %add : [num_users=1] = call_function[target=torch.ops.aten.add.Tensor](args = (%sum_3, 0), kwargs = {})
#   %pow_9 : [num_users=1] = call_function[target=torch.ops.aten.pow.Tensor_Scalar](args = (%view_2, 2.0), kwargs = {})
#   %sum_4 : [num_users=1] = call_function[target=torch.ops.aten.sum.dim_IntList](args = (%pow_9, [1], True), kwargs = {})
#   %div_2 : [num_users=1] = call_function[target=torch.ops.aten.div.Tensor](args = (%view_2, %expand_2), kwargs = {})
#   %pow_12 : [num_users=1] = call_function[target=torch.ops.aten.pow.Tensor_Scalar](args = (%view_3, 2.0), kwargs = {})
#   %sum_5 : [num_users=1] = call_function[target=torch.ops.aten.sum.dim_IntList](args = (%pow_12, [1], True), kwargs = {})
#   %div_3 : [num_users=1] = call_function[target=torch.ops.aten.div.Tensor](args = (%view_3, %expand_3), kwargs = {})
#   %sub_1 : [num_users=1] = call_function[target=torch.ops.aten.sub.Tensor](args = (%div_2, %div_3), kwargs = {})
#   %pow_14 : [num_users=1] = call_function[target=torch.ops.aten.pow.Tensor_Scalar](args = (%sub_1, 2), kwargs = {})
#   %sum_6 : [num_users=1] = call_function[target=torch.ops.aten.sum.default](args = (%pow_14,), kwargs = {})
#   %add_1 : [num_users=1] = call_function[target=torch.ops.aten.add.Tensor](args = (%add, %sum_6), kwargs = {})
#   %pow_16 : [num_users=1] = call_function[target=torch.ops.aten.pow.Tensor_Scalar](args = (%view_4, 2.0), kwargs = {})
#   %sum_7 : [num_users=1] = call_function[target=torch.ops.aten.sum.dim_IntList](args = (%pow_16, [1], True), kwargs = {})
#   %div_4 : [num_users=1] = call_function[target=torch.ops.aten.div.Tensor](args = (%view_4, %expand_4), kwargs = {})
#   %pow_19 : [num_users=1] = call_function[target=torch.ops.aten.pow.Tensor_Scalar](args = (%view_5, 2.0), kwargs = {})
#   %sum_8 : [num_users=1] = call_function[target=torch.ops.aten.sum.dim_IntList](args = (%pow_19, [1], True), kwargs = {})
#   %div_5 : [num_users=1] = call_function[target=torch.ops.aten.div.Tensor](args = (%view_5, %expand_5), kwargs = {})
#   %sub_2 : [num_users=1] = call_function[target=torch.ops.aten.sub.Tensor](args = (%div_4, %div_5), kwargs = {})
#   %pow_21 : [num_users=1] = call_function[target=torch.ops.aten.pow.Tensor_Scalar](args = (%sub_2, 2), kwargs = {})
#   %sum_9 : [num_users=1] = call_function[target=torch.ops.aten.sum.default](args = (%pow_21,), kwargs = {})
#   %add_2 : [num_users=1] = call_function[target=torch.ops.aten.add.Tensor](args = (%add_1, %sum_9), kwargs = {})
#   %pow_23 : [num_users=1] = call_function[target=torch.ops.aten.pow.Tensor_Scalar](args = (%view_6, 2.0), kwargs = {})
#   %sum_10 : [num_users=1] = call_function[target=torch.ops.aten.sum.dim_IntList](args = (%pow_23, [1], True), kwargs = {})
#   %div_6 : [num_users=1] = call_function[target=torch.ops.aten.div.Tensor](args = (%view_6, %expand_6), kwargs = {})
#   %pow_26 : [num_users=1] = call_function[target=torch.ops.aten.pow.Tensor_Scalar](args = (%view_7, 2.0), kwargs = {})
#   %sum_11 : [num_users=1] = call_function[target=torch.ops.aten.sum.dim_IntList](args = (%pow_26, [1], True), kwargs = {})
#   %div_7 : [num_users=1] = call_function[target=torch.ops.aten.div.Tensor](args = (%view_7, %expand_7), kwargs = {})
#   %sub_3 : [num_users=1] = call_function[target=torch.ops.aten.sub.Tensor](args = (%div_6, %div_7), kwargs = {})
#   %pow_28 : [num_users=1] = call_function[target=torch.ops.aten.pow.Tensor_Scalar](args = (%sub_3, 2), kwargs = {})
#   %sum_12 : [num_users=1] = call_function[target=torch.ops.aten.sum.default](args = (%pow_28,), kwargs = {})
#   %add_3 : [num_users=1] = call_function[target=torch.ops.aten.add.Tensor](args = (%add_2, %sum_12), kwargs = {})
#   %div_8 : [num_users=1] = call_function[target=torch.ops.aten.div.Tensor](args = (%add_3, 4), kwargs = {})
triton_per_fused_add_div_linalg_vector_norm_pow_sub_sum_0 = async_compile.triton('triton_per_fused_add_div_linalg_vector_norm_pow_sub_sum_0', '''
import triton
import triton.language as tl
from triton.compiler.compiler import AttrsDescriptor

from torch._inductor.runtime import triton_helpers, triton_heuristics
from torch._inductor.runtime.triton_helpers import libdevice, math as tl_math
from torch._inductor.runtime.hints import AutotuneHint, ReductionHint, TileHint, instance_descriptor, DeviceProperties

@triton_heuristics.persistent_reduction(
    size_hints=[1, 16],
    reduction_hint=ReductionHint.INNER,
    filename=__file__,
    triton_meta={'signature': {0: '*fp32', 1: '*fp32', 2: '*fp32', 3: 'i32', 4: 'i32'}, 'device': DeviceProperties(type='cuda', index=0, cc=80, major=8, regs_per_multiprocessor=65536, max_threads_per_multi_processor=2048, multi_processor_count=108), 'constants': {3: 1}, 'configs': [AttrsDescriptor(divisible_by_16=(0, 1, 2, 4), equal_to_1=(3,))]},
    inductor_meta={'autotune_hints': set(), 'kernel_name': 'triton_per_fused_add_div_linalg_vector_norm_pow_sub_sum_0', 'mutated_arg_names': ['in_out_ptr0'], 'no_x_dim': False, 'num_load': 32, 'num_reduction': 12, 'backend_hash': 'A9C866B4A14FD3277824029365D703C2427B2E685E54EC9B3EF4ADC8D1EEAC1D', 'are_deterministic_algorithms_enabled': False, 'assert_indirect_indexing': True, 'autotune_local_cache': True, 'autotune_pointwise': True, 'autotune_remote_cache': None, 'force_disable_caches': False, 'dynamic_scale_rblock': True, 'max_autotune': False, 'max_autotune_pointwise': False, 'min_split_scan_rblock': 256, 'spill_threshold': 16, 'store_cubin': False}
)
@triton.jit
def triton_per_fused_add_div_linalg_vector_norm_pow_sub_sum_0(in_out_ptr0, in_ptr0, in_ptr1, xnumel, rnumel, XBLOCK : tl.constexpr):
    xnumel = 1
    rnumel = 16
    RBLOCK: tl.constexpr = 16
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:, None]
    xmask = tl.full([XBLOCK, RBLOCK], True, tl.int1)
    rindex = tl.arange(0, RBLOCK)[None, :]
    roffset = 0
    rmask = tl.full([XBLOCK, RBLOCK], True, tl.int1)
    r0 = rindex
    tmp0 = tl.load(in_ptr0 + (r0), None)
    tmp2 = tl.load(in_ptr0 + (16 + r0), None)
    tmp5 = tl.load(in_ptr0 + (32 + r0), None)
    tmp8 = tl.load(in_ptr0 + (48 + r0), None)
    tmp17 = tl.load(in_ptr1 + (r0), None)
    tmp19 = tl.load(in_ptr1 + (16 + r0), None)
    tmp22 = tl.load(in_ptr1 + (32 + r0), None)
    tmp25 = tl.load(in_ptr1 + (48 + r0), None)
    tmp45 = tl.load(in_ptr0 + (64 + r0), None)
    tmp47 = tl.load(in_ptr0 + (80 + r0), None)
    tmp50 = tl.load(in_ptr0 + (96 + r0), None)
    tmp53 = tl.load(in_ptr0 + (112 + r0), None)
    tmp61 = tl.load(in_ptr1 + (64 + r0), None)
    tmp63 = tl.load(in_ptr1 + (80 + r0), None)
    tmp66 = tl.load(in_ptr1 + (96 + r0), None)
    tmp69 = tl.load(in_ptr1 + (112 + r0), None)
    tmp88 = tl.load(in_ptr0 + (128 + r0), None)
    tmp90 = tl.load(in_ptr0 + (144 + r0), None)
    tmp93 = tl.load(in_ptr0 + (160 + r0), None)
    tmp96 = tl.load(in_ptr0 + (176 + r0), None)
    tmp104 = tl.load(in_ptr1 + (128 + r0), None)
    tmp106 = tl.load(in_ptr1 + (144 + r0), None)
    tmp109 = tl.load(in_ptr1 + (160 + r0), None)
    tmp112 = tl.load(in_ptr1 + (176 + r0), None)
    tmp131 = tl.load(in_ptr0 + (192 + r0), None)
    tmp133 = tl.load(in_ptr0 + (208 + r0), None)
    tmp136 = tl.load(in_ptr0 + (224 + r0), None)
    tmp139 = tl.load(in_ptr0 + (240 + r0), None)
    tmp147 = tl.load(in_ptr1 + (192 + r0), None)
    tmp149 = tl.load(in_ptr1 + (208 + r0), None)
    tmp152 = tl.load(in_ptr1 + (224 + r0), None)
    tmp155 = tl.load(in_ptr1 + (240 + r0), None)
    tmp1 = tmp0 * tmp0
    tmp3 = tmp2 * tmp2
    tmp4 = tmp1 + tmp3
    tmp6 = tmp5 * tmp5
    tmp7 = tmp4 + tmp6
    tmp9 = tmp8 * tmp8
    tmp10 = tmp7 + tmp9
    tmp11 = 4.0
    tmp12 = tmp10 / tmp11
    tmp13 = tmp12 * tmp12
    tmp14 = tl.broadcast_to(tmp13, [XBLOCK, RBLOCK])
    tmp16 = tl.sum(tmp14, 1)[:, None]
    tmp18 = tmp17 * tmp17
    tmp20 = tmp19 * tmp19
    tmp21 = tmp18 + tmp20
    tmp23 = tmp22 * tmp22
    tmp24 = tmp21 + tmp23
    tmp26 = tmp25 * tmp25
    tmp27 = tmp24 + tmp26
    tmp28 = tmp27 / tmp11
    tmp29 = tmp28 * tmp28
    tmp30 = tl.broadcast_to(tmp29, [XBLOCK, RBLOCK])
    tmp32 = tl.sum(tmp30, 1)[:, None]
    tmp33 = libdevice.sqrt(tmp16)
    tmp34 = 1e-12
    tmp35 = triton_helpers.maximum(tmp33, tmp34)
    tmp36 = tmp12 / tmp35
    tmp37 = libdevice.sqrt(tmp32)
    tmp38 = triton_helpers.maximum(tmp37, tmp34)
    tmp39 = tmp28 / tmp38
    tmp40 = tmp36 - tmp39
    tmp41 = tmp40 * tmp40
    tmp42 = tl.broadcast_to(tmp41, [XBLOCK, RBLOCK])
    tmp44 = tl.sum(tmp42, 1)[:, None]
    tmp46 = tmp45 * tmp45
    tmp48 = tmp47 * tmp47
    tmp49 = tmp46 + tmp48
    tmp51 = tmp50 * tmp50
    tmp52 = tmp49 + tmp51
    tmp54 = tmp53 * tmp53
    tmp55 = tmp52 + tmp54
    tmp56 = tmp55 / tmp11
    tmp57 = tmp56 * tmp56
    tmp58 = tl.broadcast_to(tmp57, [XBLOCK, RBLOCK])
    tmp60 = tl.sum(tmp58, 1)[:, None]
    tmp62 = tmp61 * tmp61
    tmp64 = tmp63 * tmp63
    tmp65 = tmp62 + tmp64
    tmp67 = tmp66 * tmp66
    tmp68 = tmp65 + tmp67
    tmp70 = tmp69 * tmp69
    tmp71 = tmp68 + tmp70
    tmp72 = tmp71 / tmp11
    tmp73 = tmp72 * tmp72
    tmp74 = tl.broadcast_to(tmp73, [XBLOCK, RBLOCK])
    tmp76 = tl.sum(tmp74, 1)[:, None]
    tmp77 = libdevice.sqrt(tmp60)
    tmp78 = triton_helpers.maximum(tmp77, tmp34)
    tmp79 = tmp56 / tmp78
    tmp80 = libdevice.sqrt(tmp76)
    tmp81 = triton_helpers.maximum(tmp80, tmp34)
    tmp82 = tmp72 / tmp81
    tmp83 = tmp79 - tmp82
    tmp84 = tmp83 * tmp83
    tmp85 = tl.broadcast_to(tmp84, [XBLOCK, RBLOCK])
    tmp87 = tl.sum(tmp85, 1)[:, None]
    tmp89 = tmp88 * tmp88
    tmp91 = tmp90 * tmp90
    tmp92 = tmp89 + tmp91
    tmp94 = tmp93 * tmp93
    tmp95 = tmp92 + tmp94
    tmp97 = tmp96 * tmp96
    tmp98 = tmp95 + tmp97
    tmp99 = tmp98 / tmp11
    tmp100 = tmp99 * tmp99
    tmp101 = tl.broadcast_to(tmp100, [XBLOCK, RBLOCK])
    tmp103 = tl.sum(tmp101, 1)[:, None]
    tmp105 = tmp104 * tmp104
    tmp107 = tmp106 * tmp106
    tmp108 = tmp105 + tmp107
    tmp110 = tmp109 * tmp109
    tmp111 = tmp108 + tmp110
    tmp113 = tmp112 * tmp112
    tmp114 = tmp111 + tmp113
    tmp115 = tmp114 / tmp11
    tmp116 = tmp115 * tmp115
    tmp117 = tl.broadcast_to(tmp116, [XBLOCK, RBLOCK])
    tmp119 = tl.sum(tmp117, 1)[:, None]
    tmp120 = libdevice.sqrt(tmp103)
    tmp121 = triton_helpers.maximum(tmp120, tmp34)
    tmp122 = tmp99 / tmp121
    tmp123 = libdevice.sqrt(tmp119)
    tmp124 = triton_helpers.maximum(tmp123, tmp34)
    tmp125 = tmp115 / tmp124
    tmp126 = tmp122 - tmp125
    tmp127 = tmp126 * tmp126
    tmp128 = tl.broadcast_to(tmp127, [XBLOCK, RBLOCK])
    tmp130 = tl.sum(tmp128, 1)[:, None]
    tmp132 = tmp131 * tmp131
    tmp134 = tmp133 * tmp133
    tmp135 = tmp132 + tmp134
    tmp137 = tmp136 * tmp136
    tmp138 = tmp135 + tmp137
    tmp140 = tmp139 * tmp139
    tmp141 = tmp138 + tmp140
    tmp142 = tmp141 / tmp11
    tmp143 = tmp142 * tmp142
    tmp144 = tl.broadcast_to(tmp143, [XBLOCK, RBLOCK])
    tmp146 = tl.sum(tmp144, 1)[:, None]
    tmp148 = tmp147 * tmp147
    tmp150 = tmp149 * tmp149
    tmp151 = tmp148 + tmp150
    tmp153 = tmp152 * tmp152
    tmp154 = tmp151 + tmp153
    tmp156 = tmp155 * tmp155
    tmp157 = tmp154 + tmp156
    tmp158 = tmp157 / tmp11
    tmp159 = tmp158 * tmp158
    tmp160 = tl.broadcast_to(tmp159, [XBLOCK, RBLOCK])
    tmp162 = tl.sum(tmp160, 1)[:, None]
    tmp163 = libdevice.sqrt(tmp146)
    tmp164 = triton_helpers.maximum(tmp163, tmp34)
    tmp165 = tmp142 / tmp164
    tmp166 = libdevice.sqrt(tmp162)
    tmp167 = triton_helpers.maximum(tmp166, tmp34)
    tmp168 = tmp158 / tmp167
    tmp169 = tmp165 - tmp168
    tmp170 = tmp169 * tmp169
    tmp171 = tl.broadcast_to(tmp170, [XBLOCK, RBLOCK])
    tmp173 = tl.sum(tmp171, 1)[:, None]
    tmp174 = 0.0
    tmp175 = tmp44 + tmp174
    tmp176 = tmp175 + tmp87
    tmp177 = tmp176 + tmp130
    tmp178 = tmp177 + tmp173
    tmp179 = 0.25
    tmp180 = tmp178 * tmp179
    tl.debug_barrier()
    tl.store(in_out_ptr0 + (tl.full([XBLOCK, 1], 0, tl.int32)), tmp180, None)
''', device_str='cuda')


async_compile.wait(globals())
del async_compile

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)
        buf11 = empty_strided_cuda((), (), torch.float32)
        buf16 = buf11; del buf11  # reuse
        # Topologically Sorted Source Nodes: [normalize, normalize_1, sub, pow_3, sum_1, add, normalize_2, normalize_3, sub_1, pow_6, sum_2, add_1, normalize_4, normalize_5, sub_2, pow_9, sum_3, add_2, normalize_6, normalize_7, sub_3, pow_12, sum_4, add_3, loss], Original ATen: [aten.linalg_vector_norm, aten.div, aten.sub, aten.pow, aten.sum, aten.add]
        stream0 = get_raw_stream(0)
        triton_per_fused_add_div_linalg_vector_norm_pow_sub_sum_0.run(buf16, arg1_1, arg0_1, 1, 16, grid=grid(1), stream=stream0)
        del arg0_1
        del arg1_1
    return (buf16, )


def benchmark_compiled_module(times=10, repeat=10):
    from torch._dynamo.testing import rand_strided
    from torch._inductor.utils import print_performance
    arg0_1 = rand_strided((4, 4, 4, 4), (64, 16, 4, 1), device='cuda:0', dtype=torch.float32)
    arg1_1 = rand_strided((4, 4, 4, 4), (64, 16, 4, 1), device='cuda:0', dtype=torch.float32)
    fn = lambda: call([arg0_1, arg1_1])
    return print_performance(fn, times=times, repeat=repeat)


if __name__ == "__main__":
    from torch._inductor.wrapper_benchmark import compiled_module_main
    compiled_module_main('None', benchmark_compiled_module)

import torch
import torch.nn as nn
from torch.nn import functional as F
import torch._utils
import torch.optim


def at(x):
    return F.normalize(x.pow(2).mean(0).reshape(1, -1), dim=1)


class CriterionAT(nn.Module):

    def __init__(self):
        super(CriterionAT, self).__init__()
        self.at = at

    def forward(self, fs, ft):
        n = ft.size(0)
        loss = sum([(self.at(x) - self.at(y)).pow(2).sum() for x, y in zip(
            fs, ft)]) / n
        return loss


def get_inputs():
    return [torch.rand([4, 4, 4, 4]), torch.rand([4, 4, 4, 4])]


def get_init_inputs():
    return [[], {}]

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


@triton.jit
def triton_per_fused_add_div_linalg_vector_norm_pow_sub_sum_0(in_out_ptr0,
    in_ptr0, in_ptr1, xnumel, rnumel, XBLOCK: tl.constexpr):
    RBLOCK: tl.constexpr = 16
    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)
    tmp2 = tl.load(in_ptr0 + (16 + r0), None)
    tmp5 = tl.load(in_ptr0 + (32 + r0), None)
    tmp8 = tl.load(in_ptr0 + (48 + r0), None)
    tmp17 = tl.load(in_ptr1 + r0, None)
    tmp19 = tl.load(in_ptr1 + (16 + r0), None)
    tmp22 = tl.load(in_ptr1 + (32 + r0), None)
    tmp25 = tl.load(in_ptr1 + (48 + r0), None)
    tmp45 = tl.load(in_ptr0 + (64 + r0), None)
    tmp47 = tl.load(in_ptr0 + (80 + r0), None)
    tmp50 = tl.load(in_ptr0 + (96 + r0), None)
    tmp53 = tl.load(in_ptr0 + (112 + r0), None)
    tmp61 = tl.load(in_ptr1 + (64 + r0), None)
    tmp63 = tl.load(in_ptr1 + (80 + r0), None)
    tmp66 = tl.load(in_ptr1 + (96 + r0), None)
    tmp69 = tl.load(in_ptr1 + (112 + r0), None)
    tmp88 = tl.load(in_ptr0 + (128 + r0), None)
    tmp90 = tl.load(in_ptr0 + (144 + r0), None)
    tmp93 = tl.load(in_ptr0 + (160 + r0), None)
    tmp96 = tl.load(in_ptr0 + (176 + r0), None)
    tmp104 = tl.load(in_ptr1 + (128 + r0), None)
    tmp106 = tl.load(in_ptr1 + (144 + r0), None)
    tmp109 = tl.load(in_ptr1 + (160 + r0), None)
    tmp112 = tl.load(in_ptr1 + (176 + r0), None)
    tmp131 = tl.load(in_ptr0 + (192 + r0), None)
    tmp133 = tl.load(in_ptr0 + (208 + r0), None)
    tmp136 = tl.load(in_ptr0 + (224 + r0), None)
    tmp139 = tl.load(in_ptr0 + (240 + r0), None)
    tmp147 = tl.load(in_ptr1 + (192 + r0), None)
    tmp149 = tl.load(in_ptr1 + (208 + r0), None)
    tmp152 = tl.load(in_ptr1 + (224 + r0), None)
    tmp155 = tl.load(in_ptr1 + (240 + r0), None)
    tmp1 = tmp0 * tmp0
    tmp3 = tmp2 * tmp2
    tmp4 = tmp1 + tmp3
    tmp6 = tmp5 * tmp5
    tmp7 = tmp4 + tmp6
    tmp9 = tmp8 * tmp8
    tmp10 = tmp7 + tmp9
    tmp11 = 4.0
    tmp12 = tmp10 / tmp11
    tmp13 = tmp12 * tmp12
    tmp14 = tl.broadcast_to(tmp13, [XBLOCK, RBLOCK])
    tmp16 = tl.sum(tmp14, 1)[:, None]
    tmp18 = tmp17 * tmp17
    tmp20 = tmp19 * tmp19
    tmp21 = tmp18 + tmp20
    tmp23 = tmp22 * tmp22
    tmp24 = tmp21 + tmp23
    tmp26 = tmp25 * tmp25
    tmp27 = tmp24 + tmp26
    tmp28 = tmp27 / tmp11
    tmp29 = tmp28 * tmp28
    tmp30 = tl.broadcast_to(tmp29, [XBLOCK, RBLOCK])
    tmp32 = tl.sum(tmp30, 1)[:, None]
    tmp33 = libdevice.sqrt(tmp16)
    tmp34 = 1e-12
    tmp35 = triton_helpers.maximum(tmp33, tmp34)
    tmp36 = tmp12 / tmp35
    tmp37 = libdevice.sqrt(tmp32)
    tmp38 = triton_helpers.maximum(tmp37, tmp34)
    tmp39 = tmp28 / tmp38
    tmp40 = tmp36 - tmp39
    tmp41 = tmp40 * tmp40
    tmp42 = tl.broadcast_to(tmp41, [XBLOCK, RBLOCK])
    tmp44 = tl.sum(tmp42, 1)[:, None]
    tmp46 = tmp45 * tmp45
    tmp48 = tmp47 * tmp47
    tmp49 = tmp46 + tmp48
    tmp51 = tmp50 * tmp50
    tmp52 = tmp49 + tmp51
    tmp54 = tmp53 * tmp53
    tmp55 = tmp52 + tmp54
    tmp56 = tmp55 / tmp11
    tmp57 = tmp56 * tmp56
    tmp58 = tl.broadcast_to(tmp57, [XBLOCK, RBLOCK])
    tmp60 = tl.sum(tmp58, 1)[:, None]
    tmp62 = tmp61 * tmp61
    tmp64 = tmp63 * tmp63
    tmp65 = tmp62 + tmp64
    tmp67 = tmp66 * tmp66
    tmp68 = tmp65 + tmp67
    tmp70 = tmp69 * tmp69
    tmp71 = tmp68 + tmp70
    tmp72 = tmp71 / tmp11
    tmp73 = tmp72 * tmp72
    tmp74 = tl.broadcast_to(tmp73, [XBLOCK, RBLOCK])
    tmp76 = tl.sum(tmp74, 1)[:, None]
    tmp77 = libdevice.sqrt(tmp60)
    tmp78 = triton_helpers.maximum(tmp77, tmp34)
    tmp79 = tmp56 / tmp78
    tmp80 = libdevice.sqrt(tmp76)
    tmp81 = triton_helpers.maximum(tmp80, tmp34)
    tmp82 = tmp72 / tmp81
    tmp83 = tmp79 - tmp82
    tmp84 = tmp83 * tmp83
    tmp85 = tl.broadcast_to(tmp84, [XBLOCK, RBLOCK])
    tmp87 = tl.sum(tmp85, 1)[:, None]
    tmp89 = tmp88 * tmp88
    tmp91 = tmp90 * tmp90
    tmp92 = tmp89 + tmp91
    tmp94 = tmp93 * tmp93
    tmp95 = tmp92 + tmp94
    tmp97 = tmp96 * tmp96
    tmp98 = tmp95 + tmp97
    tmp99 = tmp98 / tmp11
    tmp100 = tmp99 * tmp99
    tmp101 = tl.broadcast_to(tmp100, [XBLOCK, RBLOCK])
    tmp103 = tl.sum(tmp101, 1)[:, None]
    tmp105 = tmp104 * tmp104
    tmp107 = tmp106 * tmp106
    tmp108 = tmp105 + tmp107
    tmp110 = tmp109 * tmp109
    tmp111 = tmp108 + tmp110
    tmp113 = tmp112 * tmp112
    tmp114 = tmp111 + tmp113
    tmp115 = tmp114 / tmp11
    tmp116 = tmp115 * tmp115
    tmp117 = tl.broadcast_to(tmp116, [XBLOCK, RBLOCK])
    tmp119 = tl.sum(tmp117, 1)[:, None]
    tmp120 = libdevice.sqrt(tmp103)
    tmp121 = triton_helpers.maximum(tmp120, tmp34)
    tmp122 = tmp99 / tmp121
    tmp123 = libdevice.sqrt(tmp119)
    tmp124 = triton_helpers.maximum(tmp123, tmp34)
    tmp125 = tmp115 / tmp124
    tmp126 = tmp122 - tmp125
    tmp127 = tmp126 * tmp126
    tmp128 = tl.broadcast_to(tmp127, [XBLOCK, RBLOCK])
    tmp130 = tl.sum(tmp128, 1)[:, None]
    tmp132 = tmp131 * tmp131
    tmp134 = tmp133 * tmp133
    tmp135 = tmp132 + tmp134
    tmp137 = tmp136 * tmp136
    tmp138 = tmp135 + tmp137
    tmp140 = tmp139 * tmp139
    tmp141 = tmp138 + tmp140
    tmp142 = tmp141 / tmp11
    tmp143 = tmp142 * tmp142
    tmp144 = tl.broadcast_to(tmp143, [XBLOCK, RBLOCK])
    tmp146 = tl.sum(tmp144, 1)[:, None]
    tmp148 = tmp147 * tmp147
    tmp150 = tmp149 * tmp149
    tmp151 = tmp148 + tmp150
    tmp153 = tmp152 * tmp152
    tmp154 = tmp151 + tmp153
    tmp156 = tmp155 * tmp155
    tmp157 = tmp154 + tmp156
    tmp158 = tmp157 / tmp11
    tmp159 = tmp158 * tmp158
    tmp160 = tl.broadcast_to(tmp159, [XBLOCK, RBLOCK])
    tmp162 = tl.sum(tmp160, 1)[:, None]
    tmp163 = libdevice.sqrt(tmp146)
    tmp164 = triton_helpers.maximum(tmp163, tmp34)
    tmp165 = tmp142 / tmp164
    tmp166 = libdevice.sqrt(tmp162)
    tmp167 = triton_helpers.maximum(tmp166, tmp34)
    tmp168 = tmp158 / tmp167
    tmp169 = tmp165 - tmp168
    tmp170 = tmp169 * tmp169
    tmp171 = tl.broadcast_to(tmp170, [XBLOCK, RBLOCK])
    tmp173 = tl.sum(tmp171, 1)[:, None]
    tmp174 = 0.0
    tmp175 = tmp44 + tmp174
    tmp176 = tmp175 + tmp87
    tmp177 = tmp176 + tmp130
    tmp178 = tmp177 + tmp173
    tmp179 = 0.25
    tmp180 = tmp178 * tmp179
    tl.debug_barrier()
    tl.store(in_out_ptr0 + tl.full([XBLOCK, 1], 0, tl.int32), tmp180, 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)
        buf11 = empty_strided_cuda((), (), torch.float32)
        buf16 = buf11
        del buf11
        get_raw_stream(0)
        triton_per_fused_add_div_linalg_vector_norm_pow_sub_sum_0[grid(1)](
            buf16, arg1_1, arg0_1, 1, 16, XBLOCK=1, num_warps=2, num_stages=1)
        del arg0_1
        del arg1_1
    return buf16,


def at(x):
    return F.normalize(x.pow(2).mean(0).reshape(1, -1), dim=1)


class CriterionATNew(nn.Module):

    def __init__(self):
        super(CriterionATNew, self).__init__()
        self.at = at

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