# 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_4/inductor_cache/r4/cr4ijbql3n46yiy5we5s6weyb7allspkr7oarogqxgaxw5tz6nva.py
# Topologically Sorted Source Nodes: [pow_2, mean_1, view_1, xS], Original ATen: [aten.pow, aten.mean, aten.view, aten.linalg_vector_norm]
# Source node to ATen node mapping:
#   mean_1 => mean_1
#   pow_2 => pow_4
#   view_1 => view_1
#   xS => pow_5, sum_2
# Graph fragment:
#   %pow_4 : [num_users=1] = call_function[target=torch.ops.aten.pow.Tensor_Scalar](args = (%select_3, 2), kwargs = {})
#   %mean_1 : [num_users=1] = call_function[target=torch.ops.aten.mean.dim](args = (%pow_4, [1]), kwargs = {})
#   %view_1 : [num_users=2] = call_function[target=torch.ops.aten.reshape.default](args = (%mean_1, [4, -1]), 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 = {})
triton_poi_fused_linalg_vector_norm_mean_pow_view_0 = async_compile.triton('triton_poi_fused_linalg_vector_norm_mean_pow_view_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.pointwise(
    size_hints=[4], 
    filename=__file__,
    triton_meta={'signature': {0: '*fp32', 1: '*fp32', 2: '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': {}, 'configs': [AttrsDescriptor(divisible_by_16=(0, 1), equal_to_1=())]},
    inductor_meta={'autotune_hints': set(), 'kernel_name': 'triton_poi_fused_linalg_vector_norm_mean_pow_view_0', 'mutated_arg_names': [], 'no_x_dim': False, 'num_load': 16, 'num_reduction': 0, '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},
    min_elem_per_thread=0
)
@triton.jit
def triton_poi_fused_linalg_vector_norm_mean_pow_view_0(in_ptr0, 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 + (64 + (16*x0)), xmask, eviction_policy='evict_last')
    tmp2 = tl.load(in_ptr0 + (68 + (16*x0)), xmask, eviction_policy='evict_last')
    tmp5 = tl.load(in_ptr0 + (72 + (16*x0)), xmask, eviction_policy='evict_last')
    tmp8 = tl.load(in_ptr0 + (76 + (16*x0)), xmask, eviction_policy='evict_last')
    tmp14 = tl.load(in_ptr0 + (65 + (16*x0)), xmask, eviction_policy='evict_last')
    tmp16 = tl.load(in_ptr0 + (69 + (16*x0)), xmask, eviction_policy='evict_last')
    tmp19 = tl.load(in_ptr0 + (73 + (16*x0)), xmask, eviction_policy='evict_last')
    tmp22 = tl.load(in_ptr0 + (77 + (16*x0)), xmask, eviction_policy='evict_last')
    tmp28 = tl.load(in_ptr0 + (66 + (16*x0)), xmask, eviction_policy='evict_last')
    tmp30 = tl.load(in_ptr0 + (70 + (16*x0)), xmask, eviction_policy='evict_last')
    tmp33 = tl.load(in_ptr0 + (74 + (16*x0)), xmask, eviction_policy='evict_last')
    tmp36 = tl.load(in_ptr0 + (78 + (16*x0)), xmask, eviction_policy='evict_last')
    tmp42 = tl.load(in_ptr0 + (67 + (16*x0)), xmask, eviction_policy='evict_last')
    tmp44 = tl.load(in_ptr0 + (71 + (16*x0)), xmask, eviction_policy='evict_last')
    tmp47 = tl.load(in_ptr0 + (75 + (16*x0)), xmask, eviction_policy='evict_last')
    tmp50 = tl.load(in_ptr0 + (79 + (16*x0)), xmask, eviction_policy='evict_last')
    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
    tmp15 = tmp14 * tmp14
    tmp17 = tmp16 * tmp16
    tmp18 = tmp15 + tmp17
    tmp20 = tmp19 * tmp19
    tmp21 = tmp18 + tmp20
    tmp23 = tmp22 * tmp22
    tmp24 = tmp21 + tmp23
    tmp25 = tmp24 / tmp11
    tmp26 = tmp25 * tmp25
    tmp27 = tmp13 + tmp26
    tmp29 = tmp28 * tmp28
    tmp31 = tmp30 * tmp30
    tmp32 = tmp29 + tmp31
    tmp34 = tmp33 * tmp33
    tmp35 = tmp32 + tmp34
    tmp37 = tmp36 * tmp36
    tmp38 = tmp35 + tmp37
    tmp39 = tmp38 / tmp11
    tmp40 = tmp39 * tmp39
    tmp41 = tmp27 + tmp40
    tmp43 = tmp42 * tmp42
    tmp45 = tmp44 * tmp44
    tmp46 = tmp43 + tmp45
    tmp48 = tmp47 * tmp47
    tmp49 = tmp46 + tmp48
    tmp51 = tmp50 * tmp50
    tmp52 = tmp49 + tmp51
    tmp53 = tmp52 / tmp11
    tmp54 = tmp53 * tmp53
    tmp55 = tmp41 + tmp54
    tl.store(out_ptr0 + (x0), tmp55, xmask)
''', device_str='cuda')


# kernel path: runs/run_shard_4/inductor_cache/va/cvacg3rkk3nsf7xm7fpn4m5gee6woqje7dwczibojkydtc4qbeh6.py
# Topologically Sorted Source Nodes: [pow_5, mean_4, view_3, xS_1], Original ATen: [aten.pow, aten.mean, aten.view, aten.linalg_vector_norm]
# Source node to ATen node mapping:
#   mean_4 => mean_4
#   pow_5 => pow_11
#   view_3 => view_3
#   xS_1 => pow_12, sum_4
# Graph fragment:
#   %pow_11 : [num_users=1] = call_function[target=torch.ops.aten.pow.Tensor_Scalar](args = (%select_4, 2), kwargs = {})
#   %mean_4 : [num_users=1] = call_function[target=torch.ops.aten.mean.dim](args = (%pow_11, [1]), kwargs = {})
#   %view_3 : [num_users=2] = call_function[target=torch.ops.aten.reshape.default](args = (%mean_4, [4, -1]), kwargs = {})
#   %pow_12 : [num_users=1] = call_function[target=torch.ops.aten.pow.Tensor_Scalar](args = (%view_3, 2.0), kwargs = {})
#   %sum_4 : [num_users=1] = call_function[target=torch.ops.aten.sum.dim_IntList](args = (%pow_12, [1], True), kwargs = {})
triton_poi_fused_linalg_vector_norm_mean_pow_view_1 = async_compile.triton('triton_poi_fused_linalg_vector_norm_mean_pow_view_1', '''
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.pointwise(
    size_hints=[4], 
    filename=__file__,
    triton_meta={'signature': {0: '*fp32', 1: '*fp32', 2: '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': {}, 'configs': [AttrsDescriptor(divisible_by_16=(0, 1), equal_to_1=())]},
    inductor_meta={'autotune_hints': set(), 'kernel_name': 'triton_poi_fused_linalg_vector_norm_mean_pow_view_1', 'mutated_arg_names': [], 'no_x_dim': False, 'num_load': 16, 'num_reduction': 0, '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},
    min_elem_per_thread=0
)
@triton.jit
def triton_poi_fused_linalg_vector_norm_mean_pow_view_1(in_ptr0, 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 + (128 + (16*x0)), xmask, eviction_policy='evict_last')
    tmp2 = tl.load(in_ptr0 + (132 + (16*x0)), xmask, eviction_policy='evict_last')
    tmp5 = tl.load(in_ptr0 + (136 + (16*x0)), xmask, eviction_policy='evict_last')
    tmp8 = tl.load(in_ptr0 + (140 + (16*x0)), xmask, eviction_policy='evict_last')
    tmp14 = tl.load(in_ptr0 + (129 + (16*x0)), xmask, eviction_policy='evict_last')
    tmp16 = tl.load(in_ptr0 + (133 + (16*x0)), xmask, eviction_policy='evict_last')
    tmp19 = tl.load(in_ptr0 + (137 + (16*x0)), xmask, eviction_policy='evict_last')
    tmp22 = tl.load(in_ptr0 + (141 + (16*x0)), xmask, eviction_policy='evict_last')
    tmp28 = tl.load(in_ptr0 + (130 + (16*x0)), xmask, eviction_policy='evict_last')
    tmp30 = tl.load(in_ptr0 + (134 + (16*x0)), xmask, eviction_policy='evict_last')
    tmp33 = tl.load(in_ptr0 + (138 + (16*x0)), xmask, eviction_policy='evict_last')
    tmp36 = tl.load(in_ptr0 + (142 + (16*x0)), xmask, eviction_policy='evict_last')
    tmp42 = tl.load(in_ptr0 + (131 + (16*x0)), xmask, eviction_policy='evict_last')
    tmp44 = tl.load(in_ptr0 + (135 + (16*x0)), xmask, eviction_policy='evict_last')
    tmp47 = tl.load(in_ptr0 + (139 + (16*x0)), xmask, eviction_policy='evict_last')
    tmp50 = tl.load(in_ptr0 + (143 + (16*x0)), xmask, eviction_policy='evict_last')
    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
    tmp15 = tmp14 * tmp14
    tmp17 = tmp16 * tmp16
    tmp18 = tmp15 + tmp17
    tmp20 = tmp19 * tmp19
    tmp21 = tmp18 + tmp20
    tmp23 = tmp22 * tmp22
    tmp24 = tmp21 + tmp23
    tmp25 = tmp24 / tmp11
    tmp26 = tmp25 * tmp25
    tmp27 = tmp13 + tmp26
    tmp29 = tmp28 * tmp28
    tmp31 = tmp30 * tmp30
    tmp32 = tmp29 + tmp31
    tmp34 = tmp33 * tmp33
    tmp35 = tmp32 + tmp34
    tmp37 = tmp36 * tmp36
    tmp38 = tmp35 + tmp37
    tmp39 = tmp38 / tmp11
    tmp40 = tmp39 * tmp39
    tmp41 = tmp27 + tmp40
    tmp43 = tmp42 * tmp42
    tmp45 = tmp44 * tmp44
    tmp46 = tmp43 + tmp45
    tmp48 = tmp47 * tmp47
    tmp49 = tmp46 + tmp48
    tmp51 = tmp50 * tmp50
    tmp52 = tmp49 + tmp51
    tmp53 = tmp52 / tmp11
    tmp54 = tmp53 * tmp53
    tmp55 = tmp41 + tmp54
    tl.store(out_ptr0 + (x0), tmp55, xmask)
''', device_str='cuda')


# kernel path: runs/run_shard_4/inductor_cache/yv/cyvgwhhtm6ud63hewz3gf7fjbda6dnxb5eanbapyo64o2foifa4x.py
# Topologically Sorted Source Nodes: [pow_8, mean_7, view_5, xS_2], Original ATen: [aten.pow, aten.mean, aten.view, aten.linalg_vector_norm]
# Source node to ATen node mapping:
#   mean_7 => mean_7
#   pow_8 => pow_18
#   view_5 => view_5
#   xS_2 => pow_19, sum_6
# Graph fragment:
#   %pow_18 : [num_users=1] = call_function[target=torch.ops.aten.pow.Tensor_Scalar](args = (%select_5, 2), kwargs = {})
#   %mean_7 : [num_users=1] = call_function[target=torch.ops.aten.mean.dim](args = (%pow_18, [1]), kwargs = {})
#   %view_5 : [num_users=2] = call_function[target=torch.ops.aten.reshape.default](args = (%mean_7, [4, -1]), kwargs = {})
#   %pow_19 : [num_users=1] = call_function[target=torch.ops.aten.pow.Tensor_Scalar](args = (%view_5, 2.0), kwargs = {})
#   %sum_6 : [num_users=1] = call_function[target=torch.ops.aten.sum.dim_IntList](args = (%pow_19, [1], True), kwargs = {})
triton_poi_fused_linalg_vector_norm_mean_pow_view_2 = async_compile.triton('triton_poi_fused_linalg_vector_norm_mean_pow_view_2', '''
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.pointwise(
    size_hints=[4], 
    filename=__file__,
    triton_meta={'signature': {0: '*fp32', 1: '*fp32', 2: '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': {}, 'configs': [AttrsDescriptor(divisible_by_16=(0, 1), equal_to_1=())]},
    inductor_meta={'autotune_hints': set(), 'kernel_name': 'triton_poi_fused_linalg_vector_norm_mean_pow_view_2', 'mutated_arg_names': [], 'no_x_dim': False, 'num_load': 16, 'num_reduction': 0, '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},
    min_elem_per_thread=0
)
@triton.jit
def triton_poi_fused_linalg_vector_norm_mean_pow_view_2(in_ptr0, 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 + (192 + (16*x0)), xmask, eviction_policy='evict_last')
    tmp2 = tl.load(in_ptr0 + (196 + (16*x0)), xmask, eviction_policy='evict_last')
    tmp5 = tl.load(in_ptr0 + (200 + (16*x0)), xmask, eviction_policy='evict_last')
    tmp8 = tl.load(in_ptr0 + (204 + (16*x0)), xmask, eviction_policy='evict_last')
    tmp14 = tl.load(in_ptr0 + (193 + (16*x0)), xmask, eviction_policy='evict_last')
    tmp16 = tl.load(in_ptr0 + (197 + (16*x0)), xmask, eviction_policy='evict_last')
    tmp19 = tl.load(in_ptr0 + (201 + (16*x0)), xmask, eviction_policy='evict_last')
    tmp22 = tl.load(in_ptr0 + (205 + (16*x0)), xmask, eviction_policy='evict_last')
    tmp28 = tl.load(in_ptr0 + (194 + (16*x0)), xmask, eviction_policy='evict_last')
    tmp30 = tl.load(in_ptr0 + (198 + (16*x0)), xmask, eviction_policy='evict_last')
    tmp33 = tl.load(in_ptr0 + (202 + (16*x0)), xmask, eviction_policy='evict_last')
    tmp36 = tl.load(in_ptr0 + (206 + (16*x0)), xmask, eviction_policy='evict_last')
    tmp42 = tl.load(in_ptr0 + (195 + (16*x0)), xmask, eviction_policy='evict_last')
    tmp44 = tl.load(in_ptr0 + (199 + (16*x0)), xmask, eviction_policy='evict_last')
    tmp47 = tl.load(in_ptr0 + (203 + (16*x0)), xmask, eviction_policy='evict_last')
    tmp50 = tl.load(in_ptr0 + (207 + (16*x0)), xmask, eviction_policy='evict_last')
    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
    tmp15 = tmp14 * tmp14
    tmp17 = tmp16 * tmp16
    tmp18 = tmp15 + tmp17
    tmp20 = tmp19 * tmp19
    tmp21 = tmp18 + tmp20
    tmp23 = tmp22 * tmp22
    tmp24 = tmp21 + tmp23
    tmp25 = tmp24 / tmp11
    tmp26 = tmp25 * tmp25
    tmp27 = tmp13 + tmp26
    tmp29 = tmp28 * tmp28
    tmp31 = tmp30 * tmp30
    tmp32 = tmp29 + tmp31
    tmp34 = tmp33 * tmp33
    tmp35 = tmp32 + tmp34
    tmp37 = tmp36 * tmp36
    tmp38 = tmp35 + tmp37
    tmp39 = tmp38 / tmp11
    tmp40 = tmp39 * tmp39
    tmp41 = tmp27 + tmp40
    tmp43 = tmp42 * tmp42
    tmp45 = tmp44 * tmp44
    tmp46 = tmp43 + tmp45
    tmp48 = tmp47 * tmp47
    tmp49 = tmp46 + tmp48
    tmp51 = tmp50 * tmp50
    tmp52 = tmp49 + tmp51
    tmp53 = tmp52 / tmp11
    tmp54 = tmp53 * tmp53
    tmp55 = tmp41 + tmp54
    tl.store(out_ptr0 + (x0), tmp55, xmask)
''', device_str='cuda')


# kernel path: runs/run_shard_4/inductor_cache/mz/cmzocfsmq7r332qu4m52gvaaglopfmxjfxpzgw344zi7wa6qlyr7.py
# Topologically Sorted Source Nodes: [pow_2, mean_1, view_1, xS, pow_1, mean, view, xT, sub, pow_3, mean_2, loss, pow_5, mean_4, view_3, xS_1, pow_4, mean_3, view_2, xT_1, sub_1, pow_6, mean_5, loss_1, pow_8, mean_7, view_5, xS_2, pow_7, mean_6, view_4, xT_2, sub_2, pow_9, mean_8, loss_2], Original ATen: [aten.pow, aten.mean, aten.view, aten.div, aten.sub, aten.add]
# Source node to ATen node mapping:
#   loss => add
#   loss_1 => add_1
#   loss_2 => add_2
#   mean => mean
#   mean_1 => mean_1
#   mean_2 => mean_2
#   mean_3 => mean_3
#   mean_4 => mean_4
#   mean_5 => mean_5
#   mean_6 => mean_6
#   mean_7 => mean_7
#   mean_8 => mean_8
#   pow_1 => pow_1
#   pow_2 => pow_4
#   pow_3 => pow_7
#   pow_4 => pow_8
#   pow_5 => pow_11
#   pow_6 => pow_14
#   pow_7 => pow_15
#   pow_8 => pow_18
#   pow_9 => pow_21
#   sub => sub
#   sub_1 => sub_1
#   sub_2 => sub_2
#   view => view
#   view_1 => view_1
#   view_2 => view_2
#   view_3 => view_3
#   view_4 => view_4
#   view_5 => view_5
#   xS => div_1
#   xS_1 => div_3
#   xS_2 => div_5
#   xT => div
#   xT_1 => div_2
#   xT_2 => div_4
# Graph fragment:
#   %pow_4 : [num_users=1] = call_function[target=torch.ops.aten.pow.Tensor_Scalar](args = (%select_3, 2), kwargs = {})
#   %mean_1 : [num_users=1] = call_function[target=torch.ops.aten.mean.dim](args = (%pow_4, [1]), kwargs = {})
#   %view_1 : [num_users=2] = call_function[target=torch.ops.aten.reshape.default](args = (%mean_1, [4, -1]), kwargs = {})
#   %div_1 : [num_users=1] = call_function[target=torch.ops.aten.div.Tensor](args = (%view_1, %expand_1), kwargs = {})
#   %pow_1 : [num_users=1] = call_function[target=torch.ops.aten.pow.Tensor_Scalar](args = (%select, 2), kwargs = {})
#   %mean : [num_users=1] = call_function[target=torch.ops.aten.mean.dim](args = (%pow_1, [1]), kwargs = {})
#   %view : [num_users=2] = call_function[target=torch.ops.aten.reshape.default](args = (%mean, [4, -1]), kwargs = {})
#   %div : [num_users=1] = call_function[target=torch.ops.aten.div.Tensor](args = (%view, %expand), kwargs = {})
#   %sub : [num_users=1] = call_function[target=torch.ops.aten.sub.Tensor](args = (%div_1, %div), kwargs = {})
#   %pow_7 : [num_users=1] = call_function[target=torch.ops.aten.pow.Tensor_Scalar](args = (%sub, 2), kwargs = {})
#   %mean_2 : [num_users=1] = call_function[target=torch.ops.aten.mean.default](args = (%pow_7,), kwargs = {})
#   %add : [num_users=1] = call_function[target=torch.ops.aten.add.Tensor](args = (%mean_2, 0.0), kwargs = {})
#   %pow_11 : [num_users=1] = call_function[target=torch.ops.aten.pow.Tensor_Scalar](args = (%select_4, 2), kwargs = {})
#   %mean_4 : [num_users=1] = call_function[target=torch.ops.aten.mean.dim](args = (%pow_11, [1]), kwargs = {})
#   %view_3 : [num_users=2] = call_function[target=torch.ops.aten.reshape.default](args = (%mean_4, [4, -1]), kwargs = {})
#   %div_3 : [num_users=1] = call_function[target=torch.ops.aten.div.Tensor](args = (%view_3, %expand_3), kwargs = {})
#   %pow_8 : [num_users=1] = call_function[target=torch.ops.aten.pow.Tensor_Scalar](args = (%select_1, 2), kwargs = {})
#   %mean_3 : [num_users=1] = call_function[target=torch.ops.aten.mean.dim](args = (%pow_8, [1]), kwargs = {})
#   %view_2 : [num_users=2] = call_function[target=torch.ops.aten.reshape.default](args = (%mean_3, [4, -1]), kwargs = {})
#   %div_2 : [num_users=1] = call_function[target=torch.ops.aten.div.Tensor](args = (%view_2, %expand_2), kwargs = {})
#   %sub_1 : [num_users=1] = call_function[target=torch.ops.aten.sub.Tensor](args = (%div_3, %div_2), kwargs = {})
#   %pow_14 : [num_users=1] = call_function[target=torch.ops.aten.pow.Tensor_Scalar](args = (%sub_1, 2), kwargs = {})
#   %mean_5 : [num_users=1] = call_function[target=torch.ops.aten.mean.default](args = (%pow_14,), kwargs = {})
#   %add_1 : [num_users=1] = call_function[target=torch.ops.aten.add.Tensor](args = (%add, %mean_5), kwargs = {})
#   %pow_18 : [num_users=1] = call_function[target=torch.ops.aten.pow.Tensor_Scalar](args = (%select_5, 2), kwargs = {})
#   %mean_7 : [num_users=1] = call_function[target=torch.ops.aten.mean.dim](args = (%pow_18, [1]), kwargs = {})
#   %view_5 : [num_users=2] = call_function[target=torch.ops.aten.reshape.default](args = (%mean_7, [4, -1]), kwargs = {})
#   %div_5 : [num_users=1] = call_function[target=torch.ops.aten.div.Tensor](args = (%view_5, %expand_5), kwargs = {})
#   %pow_15 : [num_users=1] = call_function[target=torch.ops.aten.pow.Tensor_Scalar](args = (%select_2, 2), kwargs = {})
#   %mean_6 : [num_users=1] = call_function[target=torch.ops.aten.mean.dim](args = (%pow_15, [1]), kwargs = {})
#   %view_4 : [num_users=2] = call_function[target=torch.ops.aten.reshape.default](args = (%mean_6, [4, -1]), kwargs = {})
#   %div_4 : [num_users=1] = call_function[target=torch.ops.aten.div.Tensor](args = (%view_4, %expand_4), kwargs = {})
#   %sub_2 : [num_users=1] = call_function[target=torch.ops.aten.sub.Tensor](args = (%div_5, %div_4), kwargs = {})
#   %pow_21 : [num_users=1] = call_function[target=torch.ops.aten.pow.Tensor_Scalar](args = (%sub_2, 2), kwargs = {})
#   %mean_8 : [num_users=1] = call_function[target=torch.ops.aten.mean.default](args = (%pow_21,), kwargs = {})
#   %add_2 : [num_users=1] = call_function[target=torch.ops.aten.add.Tensor](args = (%add_1, %mean_8), kwargs = {})
triton_per_fused_add_div_mean_pow_sub_view_3 = async_compile.triton('triton_per_fused_add_div_mean_pow_sub_view_3', '''
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: '*fp32', 4: '*fp32', 5: '*fp32', 6: '*fp32', 7: '*fp32', 8: '*fp32', 9: 'i32', 10: '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': {9: 1}, 'configs': [AttrsDescriptor(divisible_by_16=(0, 1, 2, 3, 4, 5, 6, 7, 8, 10), equal_to_1=(9,))]},
    inductor_meta={'autotune_hints': set(), 'kernel_name': 'triton_per_fused_add_div_mean_pow_sub_view_3', 'mutated_arg_names': ['in_out_ptr0'], 'no_x_dim': False, 'num_load': 30, 'num_reduction': 3, '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_mean_pow_sub_view_3(in_out_ptr0, in_ptr0, in_ptr1, in_ptr2, in_ptr3, in_ptr4, in_ptr5, in_ptr6, in_ptr7, 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 % 4
    r1 = (rindex // 4)
    r2 = rindex
    tmp0 = tl.load(in_ptr0 + (64 + r0 + (16*r1)), None)
    tmp2 = tl.load(in_ptr0 + (68 + r0 + (16*r1)), None)
    tmp5 = tl.load(in_ptr0 + (72 + r0 + (16*r1)), None)
    tmp8 = tl.load(in_ptr0 + (76 + r0 + (16*r1)), None)
    tmp13 = tl.load(in_ptr1 + (r1), None, eviction_policy='evict_last')
    tmp18 = tl.load(in_ptr2 + (64 + r0 + (16*r1)), None)
    tmp20 = tl.load(in_ptr2 + (68 + r0 + (16*r1)), None)
    tmp23 = tl.load(in_ptr2 + (72 + r0 + (16*r1)), None)
    tmp26 = tl.load(in_ptr2 + (76 + r0 + (16*r1)), None)
    tmp30 = tl.load(in_ptr3 + (r1), None, eviction_policy='evict_last')
    tmp39 = tl.load(in_ptr0 + (128 + r0 + (16*r1)), None)
    tmp41 = tl.load(in_ptr0 + (132 + r0 + (16*r1)), None)
    tmp44 = tl.load(in_ptr0 + (136 + r0 + (16*r1)), None)
    tmp47 = tl.load(in_ptr0 + (140 + r0 + (16*r1)), None)
    tmp51 = tl.load(in_ptr4 + (r1), None, eviction_policy='evict_last')
    tmp55 = tl.load(in_ptr2 + (128 + r0 + (16*r1)), None)
    tmp57 = tl.load(in_ptr2 + (132 + r0 + (16*r1)), None)
    tmp60 = tl.load(in_ptr2 + (136 + r0 + (16*r1)), None)
    tmp63 = tl.load(in_ptr2 + (140 + r0 + (16*r1)), None)
    tmp67 = tl.load(in_ptr5 + (r1), None, eviction_policy='evict_last')
    tmp76 = tl.load(in_ptr0 + (192 + r0 + (16*r1)), None)
    tmp78 = tl.load(in_ptr0 + (196 + r0 + (16*r1)), None)
    tmp81 = tl.load(in_ptr0 + (200 + r0 + (16*r1)), None)
    tmp84 = tl.load(in_ptr0 + (204 + r0 + (16*r1)), None)
    tmp88 = tl.load(in_ptr6 + (r1), None, eviction_policy='evict_last')
    tmp92 = tl.load(in_ptr2 + (192 + r0 + (16*r1)), None)
    tmp94 = tl.load(in_ptr2 + (196 + r0 + (16*r1)), None)
    tmp97 = tl.load(in_ptr2 + (200 + r0 + (16*r1)), None)
    tmp100 = tl.load(in_ptr2 + (204 + r0 + (16*r1)), None)
    tmp104 = tl.load(in_ptr7 + (r1), None, eviction_policy='evict_last')
    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
    tmp14 = libdevice.sqrt(tmp13)
    tmp15 = 1e-12
    tmp16 = triton_helpers.maximum(tmp14, tmp15)
    tmp17 = tmp12 / tmp16
    tmp19 = tmp18 * tmp18
    tmp21 = tmp20 * tmp20
    tmp22 = tmp19 + tmp21
    tmp24 = tmp23 * tmp23
    tmp25 = tmp22 + tmp24
    tmp27 = tmp26 * tmp26
    tmp28 = tmp25 + tmp27
    tmp29 = tmp28 / tmp11
    tmp31 = libdevice.sqrt(tmp30)
    tmp32 = triton_helpers.maximum(tmp31, tmp15)
    tmp33 = tmp29 / tmp32
    tmp34 = tmp17 - tmp33
    tmp35 = tmp34 * tmp34
    tmp36 = tl.broadcast_to(tmp35, [XBLOCK, RBLOCK])
    tmp38 = tl.sum(tmp36, 1)[:, None]
    tmp40 = tmp39 * tmp39
    tmp42 = tmp41 * tmp41
    tmp43 = tmp40 + tmp42
    tmp45 = tmp44 * tmp44
    tmp46 = tmp43 + tmp45
    tmp48 = tmp47 * tmp47
    tmp49 = tmp46 + tmp48
    tmp50 = tmp49 / tmp11
    tmp52 = libdevice.sqrt(tmp51)
    tmp53 = triton_helpers.maximum(tmp52, tmp15)
    tmp54 = tmp50 / tmp53
    tmp56 = tmp55 * tmp55
    tmp58 = tmp57 * tmp57
    tmp59 = tmp56 + tmp58
    tmp61 = tmp60 * tmp60
    tmp62 = tmp59 + tmp61
    tmp64 = tmp63 * tmp63
    tmp65 = tmp62 + tmp64
    tmp66 = tmp65 / tmp11
    tmp68 = libdevice.sqrt(tmp67)
    tmp69 = triton_helpers.maximum(tmp68, tmp15)
    tmp70 = tmp66 / tmp69
    tmp71 = tmp54 - tmp70
    tmp72 = tmp71 * tmp71
    tmp73 = tl.broadcast_to(tmp72, [XBLOCK, RBLOCK])
    tmp75 = tl.sum(tmp73, 1)[:, None]
    tmp77 = tmp76 * tmp76
    tmp79 = tmp78 * tmp78
    tmp80 = tmp77 + tmp79
    tmp82 = tmp81 * tmp81
    tmp83 = tmp80 + tmp82
    tmp85 = tmp84 * tmp84
    tmp86 = tmp83 + tmp85
    tmp87 = tmp86 / tmp11
    tmp89 = libdevice.sqrt(tmp88)
    tmp90 = triton_helpers.maximum(tmp89, tmp15)
    tmp91 = tmp87 / tmp90
    tmp93 = tmp92 * tmp92
    tmp95 = tmp94 * tmp94
    tmp96 = tmp93 + tmp95
    tmp98 = tmp97 * tmp97
    tmp99 = tmp96 + tmp98
    tmp101 = tmp100 * tmp100
    tmp102 = tmp99 + tmp101
    tmp103 = tmp102 / tmp11
    tmp105 = libdevice.sqrt(tmp104)
    tmp106 = triton_helpers.maximum(tmp105, tmp15)
    tmp107 = tmp103 / tmp106
    tmp108 = tmp91 - tmp107
    tmp109 = tmp108 * tmp108
    tmp110 = tl.broadcast_to(tmp109, [XBLOCK, RBLOCK])
    tmp112 = tl.sum(tmp110, 1)[:, None]
    tmp113 = 16.0
    tmp114 = tmp38 / tmp113
    tmp115 = 0.0
    tmp116 = tmp114 + tmp115
    tmp117 = tmp75 / tmp113
    tmp118 = tmp116 + tmp117
    tmp119 = tmp112 / tmp113
    tmp120 = tmp118 + tmp119
    tl.debug_barrier()
    tl.store(in_out_ptr0 + (tl.full([XBLOCK, 1], 0, tl.int32)), tmp120, 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)
        buf0 = empty_strided_cuda((4, 1), (1, 4), torch.float32)
        # Topologically Sorted Source Nodes: [pow_2, mean_1, view_1, xS], Original ATen: [aten.pow, aten.mean, aten.view, aten.linalg_vector_norm]
        stream0 = get_raw_stream(0)
        triton_poi_fused_linalg_vector_norm_mean_pow_view_0.run(arg1_1, buf0, 4, grid=grid(4), stream=stream0)
        buf1 = empty_strided_cuda((4, 1), (1, 4), torch.float32)
        # Topologically Sorted Source Nodes: [pow_1, mean, view, xT], Original ATen: [aten.pow, aten.mean, aten.view, aten.linalg_vector_norm]
        triton_poi_fused_linalg_vector_norm_mean_pow_view_0.run(arg0_1, buf1, 4, grid=grid(4), stream=stream0)
        buf4 = empty_strided_cuda((4, 1), (1, 4), torch.float32)
        # Topologically Sorted Source Nodes: [pow_5, mean_4, view_3, xS_1], Original ATen: [aten.pow, aten.mean, aten.view, aten.linalg_vector_norm]
        triton_poi_fused_linalg_vector_norm_mean_pow_view_1.run(arg1_1, buf4, 4, grid=grid(4), stream=stream0)
        buf5 = empty_strided_cuda((4, 1), (1, 4), torch.float32)
        # Topologically Sorted Source Nodes: [pow_4, mean_3, view_2, xT_1], Original ATen: [aten.pow, aten.mean, aten.view, aten.linalg_vector_norm]
        triton_poi_fused_linalg_vector_norm_mean_pow_view_1.run(arg0_1, buf5, 4, grid=grid(4), stream=stream0)
        buf8 = empty_strided_cuda((4, 1), (1, 4), torch.float32)
        # Topologically Sorted Source Nodes: [pow_8, mean_7, view_5, xS_2], Original ATen: [aten.pow, aten.mean, aten.view, aten.linalg_vector_norm]
        triton_poi_fused_linalg_vector_norm_mean_pow_view_2.run(arg1_1, buf8, 4, grid=grid(4), stream=stream0)
        buf9 = empty_strided_cuda((4, 1), (1, 4), torch.float32)
        # Topologically Sorted Source Nodes: [pow_7, mean_6, view_4, xT_2], Original ATen: [aten.pow, aten.mean, aten.view, aten.linalg_vector_norm]
        triton_poi_fused_linalg_vector_norm_mean_pow_view_2.run(arg0_1, buf9, 4, grid=grid(4), stream=stream0)
        buf11 = empty_strided_cuda((), (), torch.float32)
        buf12 = buf11; del buf11  # reuse
        # Topologically Sorted Source Nodes: [pow_2, mean_1, view_1, xS, pow_1, mean, view, xT, sub, pow_3, mean_2, loss, pow_5, mean_4, view_3, xS_1, pow_4, mean_3, view_2, xT_1, sub_1, pow_6, mean_5, loss_1, pow_8, mean_7, view_5, xS_2, pow_7, mean_6, view_4, xT_2, sub_2, pow_9, mean_8, loss_2], Original ATen: [aten.pow, aten.mean, aten.view, aten.div, aten.sub, aten.add]
        triton_per_fused_add_div_mean_pow_sub_view_3.run(buf12, arg1_1, buf0, arg0_1, buf1, buf4, buf5, buf8, buf9, 1, 16, grid=grid(1), stream=stream0)
        del arg0_1
        del arg1_1
        del buf0
        del buf1
        del buf4
        del buf5
        del buf8
        del buf9
    return (buf12, )


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
import torch.nn.functional as F


class ATLoss(nn.Module):
    """
    Module for calculating AT Loss
    
    :param norm_type (int): Norm to be used in calculating loss
    """

    def __init__(self, norm_type=2):
        super(ATLoss, self).__init__()
        self.p = norm_type

    def forward(self, teacher_output, student_output):
        """
        Forward function

        :param teacher_output (torch.FloatTensor): Prediction made by the teacher model
        :param student_output (torch.FloatTensor): Prediction made by the student model 
        """
        A_t = teacher_output[1:]
        A_s = student_output[1:]
        loss = 0.0
        for layerT, layerS in zip(A_t, A_s):
            xT = self.single_at_loss(layerT)
            xS = self.single_at_loss(layerS)
            loss += (xS - xT).pow(self.p).mean()
        return loss

    def single_at_loss(self, activation):
        """
        Function for calculating single attention loss
        """
        return F.normalize(activation.pow(self.p).mean(1).view(activation.
            size(0), -1))


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
import torch.nn.functional as F
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
empty_strided_cuda = torch._C._dynamo.guards._empty_strided_cuda


@triton.jit
def triton_poi_fused_linalg_vector_norm_mean_pow_view_0(in_ptr0, 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 + (64 + 16 * x0), xmask, eviction_policy=
        'evict_last')
    tmp2 = tl.load(in_ptr0 + (68 + 16 * x0), xmask, eviction_policy=
        'evict_last')
    tmp5 = tl.load(in_ptr0 + (72 + 16 * x0), xmask, eviction_policy=
        'evict_last')
    tmp8 = tl.load(in_ptr0 + (76 + 16 * x0), xmask, eviction_policy=
        'evict_last')
    tmp14 = tl.load(in_ptr0 + (65 + 16 * x0), xmask, eviction_policy=
        'evict_last')
    tmp16 = tl.load(in_ptr0 + (69 + 16 * x0), xmask, eviction_policy=
        'evict_last')
    tmp19 = tl.load(in_ptr0 + (73 + 16 * x0), xmask, eviction_policy=
        'evict_last')
    tmp22 = tl.load(in_ptr0 + (77 + 16 * x0), xmask, eviction_policy=
        'evict_last')
    tmp28 = tl.load(in_ptr0 + (66 + 16 * x0), xmask, eviction_policy=
        'evict_last')
    tmp30 = tl.load(in_ptr0 + (70 + 16 * x0), xmask, eviction_policy=
        'evict_last')
    tmp33 = tl.load(in_ptr0 + (74 + 16 * x0), xmask, eviction_policy=
        'evict_last')
    tmp36 = tl.load(in_ptr0 + (78 + 16 * x0), xmask, eviction_policy=
        'evict_last')
    tmp42 = tl.load(in_ptr0 + (67 + 16 * x0), xmask, eviction_policy=
        'evict_last')
    tmp44 = tl.load(in_ptr0 + (71 + 16 * x0), xmask, eviction_policy=
        'evict_last')
    tmp47 = tl.load(in_ptr0 + (75 + 16 * x0), xmask, eviction_policy=
        'evict_last')
    tmp50 = tl.load(in_ptr0 + (79 + 16 * x0), xmask, eviction_policy=
        'evict_last')
    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
    tmp15 = tmp14 * tmp14
    tmp17 = tmp16 * tmp16
    tmp18 = tmp15 + tmp17
    tmp20 = tmp19 * tmp19
    tmp21 = tmp18 + tmp20
    tmp23 = tmp22 * tmp22
    tmp24 = tmp21 + tmp23
    tmp25 = tmp24 / tmp11
    tmp26 = tmp25 * tmp25
    tmp27 = tmp13 + tmp26
    tmp29 = tmp28 * tmp28
    tmp31 = tmp30 * tmp30
    tmp32 = tmp29 + tmp31
    tmp34 = tmp33 * tmp33
    tmp35 = tmp32 + tmp34
    tmp37 = tmp36 * tmp36
    tmp38 = tmp35 + tmp37
    tmp39 = tmp38 / tmp11
    tmp40 = tmp39 * tmp39
    tmp41 = tmp27 + tmp40
    tmp43 = tmp42 * tmp42
    tmp45 = tmp44 * tmp44
    tmp46 = tmp43 + tmp45
    tmp48 = tmp47 * tmp47
    tmp49 = tmp46 + tmp48
    tmp51 = tmp50 * tmp50
    tmp52 = tmp49 + tmp51
    tmp53 = tmp52 / tmp11
    tmp54 = tmp53 * tmp53
    tmp55 = tmp41 + tmp54
    tl.store(out_ptr0 + x0, tmp55, xmask)


@triton.jit
def triton_poi_fused_linalg_vector_norm_mean_pow_view_1(in_ptr0, 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 + (128 + 16 * x0), xmask, eviction_policy=
        'evict_last')
    tmp2 = tl.load(in_ptr0 + (132 + 16 * x0), xmask, eviction_policy=
        'evict_last')
    tmp5 = tl.load(in_ptr0 + (136 + 16 * x0), xmask, eviction_policy=
        'evict_last')
    tmp8 = tl.load(in_ptr0 + (140 + 16 * x0), xmask, eviction_policy=
        'evict_last')
    tmp14 = tl.load(in_ptr0 + (129 + 16 * x0), xmask, eviction_policy=
        'evict_last')
    tmp16 = tl.load(in_ptr0 + (133 + 16 * x0), xmask, eviction_policy=
        'evict_last')
    tmp19 = tl.load(in_ptr0 + (137 + 16 * x0), xmask, eviction_policy=
        'evict_last')
    tmp22 = tl.load(in_ptr0 + (141 + 16 * x0), xmask, eviction_policy=
        'evict_last')
    tmp28 = tl.load(in_ptr0 + (130 + 16 * x0), xmask, eviction_policy=
        'evict_last')
    tmp30 = tl.load(in_ptr0 + (134 + 16 * x0), xmask, eviction_policy=
        'evict_last')
    tmp33 = tl.load(in_ptr0 + (138 + 16 * x0), xmask, eviction_policy=
        'evict_last')
    tmp36 = tl.load(in_ptr0 + (142 + 16 * x0), xmask, eviction_policy=
        'evict_last')
    tmp42 = tl.load(in_ptr0 + (131 + 16 * x0), xmask, eviction_policy=
        'evict_last')
    tmp44 = tl.load(in_ptr0 + (135 + 16 * x0), xmask, eviction_policy=
        'evict_last')
    tmp47 = tl.load(in_ptr0 + (139 + 16 * x0), xmask, eviction_policy=
        'evict_last')
    tmp50 = tl.load(in_ptr0 + (143 + 16 * x0), xmask, eviction_policy=
        'evict_last')
    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
    tmp15 = tmp14 * tmp14
    tmp17 = tmp16 * tmp16
    tmp18 = tmp15 + tmp17
    tmp20 = tmp19 * tmp19
    tmp21 = tmp18 + tmp20
    tmp23 = tmp22 * tmp22
    tmp24 = tmp21 + tmp23
    tmp25 = tmp24 / tmp11
    tmp26 = tmp25 * tmp25
    tmp27 = tmp13 + tmp26
    tmp29 = tmp28 * tmp28
    tmp31 = tmp30 * tmp30
    tmp32 = tmp29 + tmp31
    tmp34 = tmp33 * tmp33
    tmp35 = tmp32 + tmp34
    tmp37 = tmp36 * tmp36
    tmp38 = tmp35 + tmp37
    tmp39 = tmp38 / tmp11
    tmp40 = tmp39 * tmp39
    tmp41 = tmp27 + tmp40
    tmp43 = tmp42 * tmp42
    tmp45 = tmp44 * tmp44
    tmp46 = tmp43 + tmp45
    tmp48 = tmp47 * tmp47
    tmp49 = tmp46 + tmp48
    tmp51 = tmp50 * tmp50
    tmp52 = tmp49 + tmp51
    tmp53 = tmp52 / tmp11
    tmp54 = tmp53 * tmp53
    tmp55 = tmp41 + tmp54
    tl.store(out_ptr0 + x0, tmp55, xmask)


@triton.jit
def triton_poi_fused_linalg_vector_norm_mean_pow_view_2(in_ptr0, 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 + (192 + 16 * x0), xmask, eviction_policy=
        'evict_last')
    tmp2 = tl.load(in_ptr0 + (196 + 16 * x0), xmask, eviction_policy=
        'evict_last')
    tmp5 = tl.load(in_ptr0 + (200 + 16 * x0), xmask, eviction_policy=
        'evict_last')
    tmp8 = tl.load(in_ptr0 + (204 + 16 * x0), xmask, eviction_policy=
        'evict_last')
    tmp14 = tl.load(in_ptr0 + (193 + 16 * x0), xmask, eviction_policy=
        'evict_last')
    tmp16 = tl.load(in_ptr0 + (197 + 16 * x0), xmask, eviction_policy=
        'evict_last')
    tmp19 = tl.load(in_ptr0 + (201 + 16 * x0), xmask, eviction_policy=
        'evict_last')
    tmp22 = tl.load(in_ptr0 + (205 + 16 * x0), xmask, eviction_policy=
        'evict_last')
    tmp28 = tl.load(in_ptr0 + (194 + 16 * x0), xmask, eviction_policy=
        'evict_last')
    tmp30 = tl.load(in_ptr0 + (198 + 16 * x0), xmask, eviction_policy=
        'evict_last')
    tmp33 = tl.load(in_ptr0 + (202 + 16 * x0), xmask, eviction_policy=
        'evict_last')
    tmp36 = tl.load(in_ptr0 + (206 + 16 * x0), xmask, eviction_policy=
        'evict_last')
    tmp42 = tl.load(in_ptr0 + (195 + 16 * x0), xmask, eviction_policy=
        'evict_last')
    tmp44 = tl.load(in_ptr0 + (199 + 16 * x0), xmask, eviction_policy=
        'evict_last')
    tmp47 = tl.load(in_ptr0 + (203 + 16 * x0), xmask, eviction_policy=
        'evict_last')
    tmp50 = tl.load(in_ptr0 + (207 + 16 * x0), xmask, eviction_policy=
        'evict_last')
    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
    tmp15 = tmp14 * tmp14
    tmp17 = tmp16 * tmp16
    tmp18 = tmp15 + tmp17
    tmp20 = tmp19 * tmp19
    tmp21 = tmp18 + tmp20
    tmp23 = tmp22 * tmp22
    tmp24 = tmp21 + tmp23
    tmp25 = tmp24 / tmp11
    tmp26 = tmp25 * tmp25
    tmp27 = tmp13 + tmp26
    tmp29 = tmp28 * tmp28
    tmp31 = tmp30 * tmp30
    tmp32 = tmp29 + tmp31
    tmp34 = tmp33 * tmp33
    tmp35 = tmp32 + tmp34
    tmp37 = tmp36 * tmp36
    tmp38 = tmp35 + tmp37
    tmp39 = tmp38 / tmp11
    tmp40 = tmp39 * tmp39
    tmp41 = tmp27 + tmp40
    tmp43 = tmp42 * tmp42
    tmp45 = tmp44 * tmp44
    tmp46 = tmp43 + tmp45
    tmp48 = tmp47 * tmp47
    tmp49 = tmp46 + tmp48
    tmp51 = tmp50 * tmp50
    tmp52 = tmp49 + tmp51
    tmp53 = tmp52 / tmp11
    tmp54 = tmp53 * tmp53
    tmp55 = tmp41 + tmp54
    tl.store(out_ptr0 + x0, tmp55, xmask)


@triton.jit
def triton_per_fused_add_div_mean_pow_sub_view_3(in_out_ptr0, in_ptr0,
    in_ptr1, in_ptr2, in_ptr3, in_ptr4, in_ptr5, in_ptr6, in_ptr7, 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 % 4
    r1 = rindex // 4
    tmp0 = tl.load(in_ptr0 + (64 + r0 + 16 * r1), None)
    tmp2 = tl.load(in_ptr0 + (68 + r0 + 16 * r1), None)
    tmp5 = tl.load(in_ptr0 + (72 + r0 + 16 * r1), None)
    tmp8 = tl.load(in_ptr0 + (76 + r0 + 16 * r1), None)
    tmp13 = tl.load(in_ptr1 + r1, None, eviction_policy='evict_last')
    tmp18 = tl.load(in_ptr2 + (64 + r0 + 16 * r1), None)
    tmp20 = tl.load(in_ptr2 + (68 + r0 + 16 * r1), None)
    tmp23 = tl.load(in_ptr2 + (72 + r0 + 16 * r1), None)
    tmp26 = tl.load(in_ptr2 + (76 + r0 + 16 * r1), None)
    tmp30 = tl.load(in_ptr3 + r1, None, eviction_policy='evict_last')
    tmp39 = tl.load(in_ptr0 + (128 + r0 + 16 * r1), None)
    tmp41 = tl.load(in_ptr0 + (132 + r0 + 16 * r1), None)
    tmp44 = tl.load(in_ptr0 + (136 + r0 + 16 * r1), None)
    tmp47 = tl.load(in_ptr0 + (140 + r0 + 16 * r1), None)
    tmp51 = tl.load(in_ptr4 + r1, None, eviction_policy='evict_last')
    tmp55 = tl.load(in_ptr2 + (128 + r0 + 16 * r1), None)
    tmp57 = tl.load(in_ptr2 + (132 + r0 + 16 * r1), None)
    tmp60 = tl.load(in_ptr2 + (136 + r0 + 16 * r1), None)
    tmp63 = tl.load(in_ptr2 + (140 + r0 + 16 * r1), None)
    tmp67 = tl.load(in_ptr5 + r1, None, eviction_policy='evict_last')
    tmp76 = tl.load(in_ptr0 + (192 + r0 + 16 * r1), None)
    tmp78 = tl.load(in_ptr0 + (196 + r0 + 16 * r1), None)
    tmp81 = tl.load(in_ptr0 + (200 + r0 + 16 * r1), None)
    tmp84 = tl.load(in_ptr0 + (204 + r0 + 16 * r1), None)
    tmp88 = tl.load(in_ptr6 + r1, None, eviction_policy='evict_last')
    tmp92 = tl.load(in_ptr2 + (192 + r0 + 16 * r1), None)
    tmp94 = tl.load(in_ptr2 + (196 + r0 + 16 * r1), None)
    tmp97 = tl.load(in_ptr2 + (200 + r0 + 16 * r1), None)
    tmp100 = tl.load(in_ptr2 + (204 + r0 + 16 * r1), None)
    tmp104 = tl.load(in_ptr7 + r1, None, eviction_policy='evict_last')
    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
    tmp14 = libdevice.sqrt(tmp13)
    tmp15 = 1e-12
    tmp16 = triton_helpers.maximum(tmp14, tmp15)
    tmp17 = tmp12 / tmp16
    tmp19 = tmp18 * tmp18
    tmp21 = tmp20 * tmp20
    tmp22 = tmp19 + tmp21
    tmp24 = tmp23 * tmp23
    tmp25 = tmp22 + tmp24
    tmp27 = tmp26 * tmp26
    tmp28 = tmp25 + tmp27
    tmp29 = tmp28 / tmp11
    tmp31 = libdevice.sqrt(tmp30)
    tmp32 = triton_helpers.maximum(tmp31, tmp15)
    tmp33 = tmp29 / tmp32
    tmp34 = tmp17 - tmp33
    tmp35 = tmp34 * tmp34
    tmp36 = tl.broadcast_to(tmp35, [XBLOCK, RBLOCK])
    tmp38 = tl.sum(tmp36, 1)[:, None]
    tmp40 = tmp39 * tmp39
    tmp42 = tmp41 * tmp41
    tmp43 = tmp40 + tmp42
    tmp45 = tmp44 * tmp44
    tmp46 = tmp43 + tmp45
    tmp48 = tmp47 * tmp47
    tmp49 = tmp46 + tmp48
    tmp50 = tmp49 / tmp11
    tmp52 = libdevice.sqrt(tmp51)
    tmp53 = triton_helpers.maximum(tmp52, tmp15)
    tmp54 = tmp50 / tmp53
    tmp56 = tmp55 * tmp55
    tmp58 = tmp57 * tmp57
    tmp59 = tmp56 + tmp58
    tmp61 = tmp60 * tmp60
    tmp62 = tmp59 + tmp61
    tmp64 = tmp63 * tmp63
    tmp65 = tmp62 + tmp64
    tmp66 = tmp65 / tmp11
    tmp68 = libdevice.sqrt(tmp67)
    tmp69 = triton_helpers.maximum(tmp68, tmp15)
    tmp70 = tmp66 / tmp69
    tmp71 = tmp54 - tmp70
    tmp72 = tmp71 * tmp71
    tmp73 = tl.broadcast_to(tmp72, [XBLOCK, RBLOCK])
    tmp75 = tl.sum(tmp73, 1)[:, None]
    tmp77 = tmp76 * tmp76
    tmp79 = tmp78 * tmp78
    tmp80 = tmp77 + tmp79
    tmp82 = tmp81 * tmp81
    tmp83 = tmp80 + tmp82
    tmp85 = tmp84 * tmp84
    tmp86 = tmp83 + tmp85
    tmp87 = tmp86 / tmp11
    tmp89 = libdevice.sqrt(tmp88)
    tmp90 = triton_helpers.maximum(tmp89, tmp15)
    tmp91 = tmp87 / tmp90
    tmp93 = tmp92 * tmp92
    tmp95 = tmp94 * tmp94
    tmp96 = tmp93 + tmp95
    tmp98 = tmp97 * tmp97
    tmp99 = tmp96 + tmp98
    tmp101 = tmp100 * tmp100
    tmp102 = tmp99 + tmp101
    tmp103 = tmp102 / tmp11
    tmp105 = libdevice.sqrt(tmp104)
    tmp106 = triton_helpers.maximum(tmp105, tmp15)
    tmp107 = tmp103 / tmp106
    tmp108 = tmp91 - tmp107
    tmp109 = tmp108 * tmp108
    tmp110 = tl.broadcast_to(tmp109, [XBLOCK, RBLOCK])
    tmp112 = tl.sum(tmp110, 1)[:, None]
    tmp113 = 16.0
    tmp114 = tmp38 / tmp113
    tmp115 = 0.0
    tmp116 = tmp114 + tmp115
    tmp117 = tmp75 / tmp113
    tmp118 = tmp116 + tmp117
    tmp119 = tmp112 / tmp113
    tmp120 = tmp118 + tmp119
    tl.debug_barrier()
    tl.store(in_out_ptr0 + tl.full([XBLOCK, 1], 0, tl.int32), tmp120, 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((4, 1), (1, 4), torch.float32)
        get_raw_stream(0)
        triton_poi_fused_linalg_vector_norm_mean_pow_view_0[grid(4)](arg1_1,
            buf0, 4, XBLOCK=4, num_warps=1, num_stages=1)
        buf1 = empty_strided_cuda((4, 1), (1, 4), torch.float32)
        triton_poi_fused_linalg_vector_norm_mean_pow_view_0[grid(4)](arg0_1,
            buf1, 4, XBLOCK=4, num_warps=1, num_stages=1)
        buf4 = empty_strided_cuda((4, 1), (1, 4), torch.float32)
        triton_poi_fused_linalg_vector_norm_mean_pow_view_1[grid(4)](arg1_1,
            buf4, 4, XBLOCK=4, num_warps=1, num_stages=1)
        buf5 = empty_strided_cuda((4, 1), (1, 4), torch.float32)
        triton_poi_fused_linalg_vector_norm_mean_pow_view_1[grid(4)](arg0_1,
            buf5, 4, XBLOCK=4, num_warps=1, num_stages=1)
        buf8 = empty_strided_cuda((4, 1), (1, 4), torch.float32)
        triton_poi_fused_linalg_vector_norm_mean_pow_view_2[grid(4)](arg1_1,
            buf8, 4, XBLOCK=4, num_warps=1, num_stages=1)
        buf9 = empty_strided_cuda((4, 1), (1, 4), torch.float32)
        triton_poi_fused_linalg_vector_norm_mean_pow_view_2[grid(4)](arg0_1,
            buf9, 4, XBLOCK=4, num_warps=1, num_stages=1)
        buf11 = empty_strided_cuda((), (), torch.float32)
        buf12 = buf11
        del buf11
        triton_per_fused_add_div_mean_pow_sub_view_3[grid(1)](buf12, arg1_1,
            buf0, arg0_1, buf1, buf4, buf5, buf8, buf9, 1, 16, XBLOCK=1,
            num_warps=2, num_stages=1)
        del arg0_1
        del arg1_1
        del buf0
        del buf1
        del buf4
        del buf5
        del buf8
        del buf9
    return buf12,


class ATLossNew(nn.Module):
    """
    Module for calculating AT Loss
    
    :param norm_type (int): Norm to be used in calculating loss
    """

    def __init__(self, norm_type=2):
        super(ATLossNew, self).__init__()
        self.p = norm_type

    def single_at_loss(self, activation):
        """
        Function for calculating single attention loss
        """
        return F.normalize(activation.pow(self.p).mean(1).view(activation.
            size(0), -1))

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