# 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_1/inductor_cache/po/cpoe4jf5rd2jtxre5frkxszfgta5tmna5miyocthivabzvjnckhw.py
# Topologically Sorted Source Nodes: [similarities], Original ATen: [aten.linalg_vector_norm, aten.clamp_min, aten.div, aten.mul]
# Source node to ATen node mapping:
#   similarities => clamp_min, clamp_min_1, div, div_1, mul, pow_1, pow_2, pow_3, pow_4, sum_1, sum_2
# Graph fragment:
#   %pow_1 : [num_users=1] = call_function[target=torch.ops.aten.pow.Tensor_Scalar](args = (%select, 2), kwargs = {})
#   %sum_1 : [num_users=1] = call_function[target=torch.ops.aten.sum.dim_IntList](args = (%pow_1, [1], True), kwargs = {})
#   %pow_2 : [num_users=1] = call_function[target=torch.ops.aten.pow.Tensor_Scalar](args = (%sum_1, 0.5), kwargs = {})
#   %clamp_min : [num_users=1] = call_function[target=torch.ops.aten.clamp_min.default](args = (%pow_2, 1e-08), kwargs = {})
#   %div_1 : [num_users=1] = call_function[target=torch.ops.aten.div.Tensor](args = (%select, %clamp_min), kwargs = {})
#   %pow_3 : [num_users=1] = call_function[target=torch.ops.aten.pow.Tensor_Scalar](args = (%select_4, 2), kwargs = {})
#   %sum_2 : [num_users=1] = call_function[target=torch.ops.aten.sum.dim_IntList](args = (%pow_3, [1], True), kwargs = {})
#   %pow_4 : [num_users=1] = call_function[target=torch.ops.aten.pow.Tensor_Scalar](args = (%sum_2, 0.5), kwargs = {})
#   %clamp_min_1 : [num_users=1] = call_function[target=torch.ops.aten.clamp_min.default](args = (%pow_4, 1e-08), kwargs = {})
#   %div : [num_users=1] = call_function[target=torch.ops.aten.div.Tensor](args = (%select_4, %clamp_min_1), kwargs = {})
#   %mul : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%div_1, %div), kwargs = {})
triton_poi_fused_clamp_min_div_linalg_vector_norm_mul_0 = async_compile.triton('triton_poi_fused_clamp_min_div_linalg_vector_norm_mul_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=[64], 
    filename=__file__,
    triton_meta={'signature': {0: '*fp32', 1: '*fp32', 2: '*fp32', 3: 'i32'}, 'device': DeviceProperties(type='cuda', index=0, cc=90, major=9, regs_per_multiprocessor=65536, max_threads_per_multi_processor=2048, multi_processor_count=132), 'constants': {}, 'configs': [AttrsDescriptor(divisible_by_16=(0, 1, 2, 3), equal_to_1=())]},
    inductor_meta={'autotune_hints': set(), 'kernel_name': 'triton_poi_fused_clamp_min_div_linalg_vector_norm_mul_0', 'mutated_arg_names': [], 'no_x_dim': False, 'num_load': 10, 'num_reduction': 0, 'backend_hash': 'B098E03CDA7B8ADC90DAFFDF24A2956451D1B13F297756A5DCC209498AA53705', '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_clamp_min_div_linalg_vector_norm_mul_0(in_ptr0, in_ptr1, out_ptr0, xnumel, XBLOCK : tl.constexpr):
    xnumel = 64
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x3 = xindex
    x0 = xindex % 4
    x2 = (xindex // 16)
    tmp0 = tl.load(in_ptr0 + (x3), xmask)
    tmp1 = tl.load(in_ptr0 + (x0 + (16*x2)), xmask, eviction_policy='evict_last')
    tmp3 = tl.load(in_ptr0 + (4 + x0 + (16*x2)), xmask, eviction_policy='evict_last')
    tmp6 = tl.load(in_ptr0 + (8 + x0 + (16*x2)), xmask, eviction_policy='evict_last')
    tmp9 = tl.load(in_ptr0 + (12 + x0 + (16*x2)), xmask, eviction_policy='evict_last')
    tmp16 = tl.load(in_ptr1 + (x3), xmask)
    tmp17 = tl.load(in_ptr1 + (x0 + (16*x2)), xmask, eviction_policy='evict_last')
    tmp19 = tl.load(in_ptr1 + (4 + x0 + (16*x2)), xmask, eviction_policy='evict_last')
    tmp22 = tl.load(in_ptr1 + (8 + x0 + (16*x2)), xmask, eviction_policy='evict_last')
    tmp25 = tl.load(in_ptr1 + (12 + x0 + (16*x2)), xmask, eviction_policy='evict_last')
    tmp2 = tmp1 * tmp1
    tmp4 = tmp3 * tmp3
    tmp5 = tmp2 + tmp4
    tmp7 = tmp6 * tmp6
    tmp8 = tmp5 + tmp7
    tmp10 = tmp9 * tmp9
    tmp11 = tmp8 + tmp10
    tmp12 = libdevice.sqrt(tmp11)
    tmp13 = 1e-08
    tmp14 = triton_helpers.maximum(tmp12, tmp13)
    tmp15 = tmp0 / tmp14
    tmp18 = tmp17 * tmp17
    tmp20 = tmp19 * tmp19
    tmp21 = tmp18 + tmp20
    tmp23 = tmp22 * tmp22
    tmp24 = tmp21 + tmp23
    tmp26 = tmp25 * tmp25
    tmp27 = tmp24 + tmp26
    tmp28 = libdevice.sqrt(tmp27)
    tmp29 = triton_helpers.maximum(tmp28, tmp13)
    tmp30 = tmp16 / tmp29
    tmp31 = tmp15 * tmp30
    tl.store(out_ptr0 + (x3), tmp31, xmask)
''', device_str='cuda')


# kernel path: runs/run_shard_1/inductor_cache/x4/cx4ikvss35qp72zdkepsqffz766walj3bsti724i3txsoupnbzik.py
# Topologically Sorted Source Nodes: [similarities, similarities_1, exp_tensor, sum_1], Original ATen: [aten.sum, aten.div, aten.exp]
# Source node to ATen node mapping:
#   exp_tensor => exp
#   similarities => sum_3
#   similarities_1 => div_2
#   sum_1 => sum_4
# Graph fragment:
#   %sum_3 : [num_users=1] = call_function[target=torch.ops.aten.sum.dim_IntList](args = (%mul, [1]), kwargs = {})
#   %div_2 : [num_users=1] = call_function[target=torch.ops.aten.div.Tensor](args = (%sum_3, 4), kwargs = {})
#   %exp : [num_users=2] = call_function[target=torch.ops.aten.exp.default](args = (%div_2,), kwargs = {})
#   %sum_4 : [num_users=1] = call_function[target=torch.ops.aten.sum.default](args = (%exp,), kwargs = {})
triton_per_fused_div_exp_sum_1 = async_compile.triton('triton_per_fused_div_exp_sum_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.persistent_reduction(
    size_hints=[1, 16],
    reduction_hint=ReductionHint.INNER,
    filename=__file__,
    triton_meta={'signature': {0: '*fp32', 1: '*fp32', 2: 'i32', 3: 'i32'}, 'device': DeviceProperties(type='cuda', index=0, cc=90, major=9, regs_per_multiprocessor=65536, max_threads_per_multi_processor=2048, multi_processor_count=132), 'constants': {2: 1}, 'configs': [AttrsDescriptor(divisible_by_16=(0, 1, 3), equal_to_1=(2,))]},
    inductor_meta={'autotune_hints': set(), 'kernel_name': 'triton_per_fused_div_exp_sum_1', 'mutated_arg_names': [], 'no_x_dim': False, 'num_load': 4, 'num_reduction': 1, 'backend_hash': 'B098E03CDA7B8ADC90DAFFDF24A2956451D1B13F297756A5DCC209498AA53705', '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_div_exp_sum_1(in_ptr0, out_ptr0, 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)
    tmp0 = tl.load(in_ptr0 + (r0 + (16*r1)), None)
    tmp1 = tl.load(in_ptr0 + (4 + r0 + (16*r1)), None)
    tmp3 = tl.load(in_ptr0 + (8 + r0 + (16*r1)), None)
    tmp5 = tl.load(in_ptr0 + (12 + r0 + (16*r1)), None)
    tmp2 = tmp0 + tmp1
    tmp4 = tmp2 + tmp3
    tmp6 = tmp4 + tmp5
    tmp7 = 0.25
    tmp8 = tmp6 * tmp7
    tmp9 = tl_math.exp(tmp8)
    tmp10 = tl.broadcast_to(tmp9, [XBLOCK, RBLOCK])
    tmp12 = tl.sum(tmp10, 1)[:, None]
    tl.store(out_ptr0 + (tl.full([XBLOCK, 1], 0, tl.int32)), tmp12, None)
''', device_str='cuda')


# kernel path: runs/run_shard_1/inductor_cache/re/crefqcphnx7mocofjtm62ovu6wh7k3msevqr2iapwbareettmfmc.py
# Topologically Sorted Source Nodes: [similarities_2], Original ATen: [aten.linalg_vector_norm, aten.clamp_min, aten.div, aten.mul]
# Source node to ATen node mapping:
#   similarities_2 => clamp_min_2, clamp_min_3, div_4, div_5, mul_1, pow_5, pow_6, pow_7, pow_8, sum_5, sum_6
# Graph fragment:
#   %pow_5 : [num_users=1] = call_function[target=torch.ops.aten.pow.Tensor_Scalar](args = (%select_1, 2), kwargs = {})
#   %sum_5 : [num_users=1] = call_function[target=torch.ops.aten.sum.dim_IntList](args = (%pow_5, [1], True), kwargs = {})
#   %pow_6 : [num_users=1] = call_function[target=torch.ops.aten.pow.Tensor_Scalar](args = (%sum_5, 0.5), kwargs = {})
#   %clamp_min_2 : [num_users=1] = call_function[target=torch.ops.aten.clamp_min.default](args = (%pow_6, 1e-08), kwargs = {})
#   %div_5 : [num_users=1] = call_function[target=torch.ops.aten.div.Tensor](args = (%select_1, %clamp_min_2), kwargs = {})
#   %pow_7 : [num_users=1] = call_function[target=torch.ops.aten.pow.Tensor_Scalar](args = (%select_5, 2), kwargs = {})
#   %sum_6 : [num_users=1] = call_function[target=torch.ops.aten.sum.dim_IntList](args = (%pow_7, [1], True), kwargs = {})
#   %pow_8 : [num_users=1] = call_function[target=torch.ops.aten.pow.Tensor_Scalar](args = (%sum_6, 0.5), kwargs = {})
#   %clamp_min_3 : [num_users=1] = call_function[target=torch.ops.aten.clamp_min.default](args = (%pow_8, 1e-08), kwargs = {})
#   %div_4 : [num_users=1] = call_function[target=torch.ops.aten.div.Tensor](args = (%select_5, %clamp_min_3), kwargs = {})
#   %mul_1 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%div_5, %div_4), kwargs = {})
triton_poi_fused_clamp_min_div_linalg_vector_norm_mul_2 = async_compile.triton('triton_poi_fused_clamp_min_div_linalg_vector_norm_mul_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=[64], 
    filename=__file__,
    triton_meta={'signature': {0: '*fp32', 1: '*fp32', 2: '*fp32', 3: 'i32'}, 'device': DeviceProperties(type='cuda', index=0, cc=90, major=9, regs_per_multiprocessor=65536, max_threads_per_multi_processor=2048, multi_processor_count=132), 'constants': {}, 'configs': [AttrsDescriptor(divisible_by_16=(0, 1, 2, 3), equal_to_1=())]},
    inductor_meta={'autotune_hints': set(), 'kernel_name': 'triton_poi_fused_clamp_min_div_linalg_vector_norm_mul_2', 'mutated_arg_names': [], 'no_x_dim': False, 'num_load': 10, 'num_reduction': 0, 'backend_hash': 'B098E03CDA7B8ADC90DAFFDF24A2956451D1B13F297756A5DCC209498AA53705', '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_clamp_min_div_linalg_vector_norm_mul_2(in_ptr0, in_ptr1, out_ptr0, xnumel, XBLOCK : tl.constexpr):
    xnumel = 64
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x3 = xindex
    x0 = xindex % 4
    x2 = (xindex // 16)
    tmp0 = tl.load(in_ptr0 + (64 + x3), xmask)
    tmp1 = tl.load(in_ptr0 + (64 + x0 + (16*x2)), xmask, eviction_policy='evict_last')
    tmp3 = tl.load(in_ptr0 + (68 + x0 + (16*x2)), xmask, eviction_policy='evict_last')
    tmp6 = tl.load(in_ptr0 + (72 + x0 + (16*x2)), xmask, eviction_policy='evict_last')
    tmp9 = tl.load(in_ptr0 + (76 + x0 + (16*x2)), xmask, eviction_policy='evict_last')
    tmp16 = tl.load(in_ptr1 + (64 + x3), xmask)
    tmp17 = tl.load(in_ptr1 + (64 + x0 + (16*x2)), xmask, eviction_policy='evict_last')
    tmp19 = tl.load(in_ptr1 + (68 + x0 + (16*x2)), xmask, eviction_policy='evict_last')
    tmp22 = tl.load(in_ptr1 + (72 + x0 + (16*x2)), xmask, eviction_policy='evict_last')
    tmp25 = tl.load(in_ptr1 + (76 + x0 + (16*x2)), xmask, eviction_policy='evict_last')
    tmp2 = tmp1 * tmp1
    tmp4 = tmp3 * tmp3
    tmp5 = tmp2 + tmp4
    tmp7 = tmp6 * tmp6
    tmp8 = tmp5 + tmp7
    tmp10 = tmp9 * tmp9
    tmp11 = tmp8 + tmp10
    tmp12 = libdevice.sqrt(tmp11)
    tmp13 = 1e-08
    tmp14 = triton_helpers.maximum(tmp12, tmp13)
    tmp15 = tmp0 / tmp14
    tmp18 = tmp17 * tmp17
    tmp20 = tmp19 * tmp19
    tmp21 = tmp18 + tmp20
    tmp23 = tmp22 * tmp22
    tmp24 = tmp21 + tmp23
    tmp26 = tmp25 * tmp25
    tmp27 = tmp24 + tmp26
    tmp28 = libdevice.sqrt(tmp27)
    tmp29 = triton_helpers.maximum(tmp28, tmp13)
    tmp30 = tmp16 / tmp29
    tmp31 = tmp15 * tmp30
    tl.store(out_ptr0 + (x3), tmp31, xmask)
''', device_str='cuda')


# kernel path: runs/run_shard_1/inductor_cache/eg/cegv7ez4r3nhfbyjr5a7iemqrcp577x7uxyjeedmiwgjcevua72k.py
# Topologically Sorted Source Nodes: [similarities_4], Original ATen: [aten.linalg_vector_norm, aten.clamp_min, aten.div, aten.mul]
# Source node to ATen node mapping:
#   similarities_4 => clamp_min_4, clamp_min_5, div_8, div_9, mul_2, pow_10, pow_11, pow_12, pow_9, sum_10, sum_9
# Graph fragment:
#   %pow_9 : [num_users=1] = call_function[target=torch.ops.aten.pow.Tensor_Scalar](args = (%select_2, 2), kwargs = {})
#   %sum_9 : [num_users=1] = call_function[target=torch.ops.aten.sum.dim_IntList](args = (%pow_9, [1], True), kwargs = {})
#   %pow_10 : [num_users=1] = call_function[target=torch.ops.aten.pow.Tensor_Scalar](args = (%sum_9, 0.5), kwargs = {})
#   %clamp_min_4 : [num_users=1] = call_function[target=torch.ops.aten.clamp_min.default](args = (%pow_10, 1e-08), kwargs = {})
#   %div_9 : [num_users=1] = call_function[target=torch.ops.aten.div.Tensor](args = (%select_2, %clamp_min_4), kwargs = {})
#   %pow_11 : [num_users=1] = call_function[target=torch.ops.aten.pow.Tensor_Scalar](args = (%select_6, 2), kwargs = {})
#   %sum_10 : [num_users=1] = call_function[target=torch.ops.aten.sum.dim_IntList](args = (%pow_11, [1], True), kwargs = {})
#   %pow_12 : [num_users=1] = call_function[target=torch.ops.aten.pow.Tensor_Scalar](args = (%sum_10, 0.5), kwargs = {})
#   %clamp_min_5 : [num_users=1] = call_function[target=torch.ops.aten.clamp_min.default](args = (%pow_12, 1e-08), kwargs = {})
#   %div_8 : [num_users=1] = call_function[target=torch.ops.aten.div.Tensor](args = (%select_6, %clamp_min_5), kwargs = {})
#   %mul_2 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%div_9, %div_8), kwargs = {})
triton_poi_fused_clamp_min_div_linalg_vector_norm_mul_3 = async_compile.triton('triton_poi_fused_clamp_min_div_linalg_vector_norm_mul_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.pointwise(
    size_hints=[64], 
    filename=__file__,
    triton_meta={'signature': {0: '*fp32', 1: '*fp32', 2: '*fp32', 3: 'i32'}, 'device': DeviceProperties(type='cuda', index=0, cc=90, major=9, regs_per_multiprocessor=65536, max_threads_per_multi_processor=2048, multi_processor_count=132), 'constants': {}, 'configs': [AttrsDescriptor(divisible_by_16=(0, 1, 2, 3), equal_to_1=())]},
    inductor_meta={'autotune_hints': set(), 'kernel_name': 'triton_poi_fused_clamp_min_div_linalg_vector_norm_mul_3', 'mutated_arg_names': [], 'no_x_dim': False, 'num_load': 10, 'num_reduction': 0, 'backend_hash': 'B098E03CDA7B8ADC90DAFFDF24A2956451D1B13F297756A5DCC209498AA53705', '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_clamp_min_div_linalg_vector_norm_mul_3(in_ptr0, in_ptr1, out_ptr0, xnumel, XBLOCK : tl.constexpr):
    xnumel = 64
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x3 = xindex
    x0 = xindex % 4
    x2 = (xindex // 16)
    tmp0 = tl.load(in_ptr0 + (128 + x3), xmask)
    tmp1 = tl.load(in_ptr0 + (128 + x0 + (16*x2)), xmask, eviction_policy='evict_last')
    tmp3 = tl.load(in_ptr0 + (132 + x0 + (16*x2)), xmask, eviction_policy='evict_last')
    tmp6 = tl.load(in_ptr0 + (136 + x0 + (16*x2)), xmask, eviction_policy='evict_last')
    tmp9 = tl.load(in_ptr0 + (140 + x0 + (16*x2)), xmask, eviction_policy='evict_last')
    tmp16 = tl.load(in_ptr1 + (128 + x3), xmask)
    tmp17 = tl.load(in_ptr1 + (128 + x0 + (16*x2)), xmask, eviction_policy='evict_last')
    tmp19 = tl.load(in_ptr1 + (132 + x0 + (16*x2)), xmask, eviction_policy='evict_last')
    tmp22 = tl.load(in_ptr1 + (136 + x0 + (16*x2)), xmask, eviction_policy='evict_last')
    tmp25 = tl.load(in_ptr1 + (140 + x0 + (16*x2)), xmask, eviction_policy='evict_last')
    tmp2 = tmp1 * tmp1
    tmp4 = tmp3 * tmp3
    tmp5 = tmp2 + tmp4
    tmp7 = tmp6 * tmp6
    tmp8 = tmp5 + tmp7
    tmp10 = tmp9 * tmp9
    tmp11 = tmp8 + tmp10
    tmp12 = libdevice.sqrt(tmp11)
    tmp13 = 1e-08
    tmp14 = triton_helpers.maximum(tmp12, tmp13)
    tmp15 = tmp0 / tmp14
    tmp18 = tmp17 * tmp17
    tmp20 = tmp19 * tmp19
    tmp21 = tmp18 + tmp20
    tmp23 = tmp22 * tmp22
    tmp24 = tmp21 + tmp23
    tmp26 = tmp25 * tmp25
    tmp27 = tmp24 + tmp26
    tmp28 = libdevice.sqrt(tmp27)
    tmp29 = triton_helpers.maximum(tmp28, tmp13)
    tmp30 = tmp16 / tmp29
    tmp31 = tmp15 * tmp30
    tl.store(out_ptr0 + (x3), tmp31, xmask)
''', device_str='cuda')


# kernel path: runs/run_shard_1/inductor_cache/eg/cegftiqockibyeggghlmjar4rbd4k4shclu3hnfs4etbkoqng5eq.py
# Topologically Sorted Source Nodes: [similarities_6], Original ATen: [aten.linalg_vector_norm, aten.clamp_min, aten.div, aten.mul]
# Source node to ATen node mapping:
#   similarities_6 => clamp_min_6, clamp_min_7, div_12, div_13, mul_3, pow_13, pow_14, pow_15, pow_16, sum_13, sum_14
# Graph fragment:
#   %pow_13 : [num_users=1] = call_function[target=torch.ops.aten.pow.Tensor_Scalar](args = (%select_3, 2), kwargs = {})
#   %sum_13 : [num_users=1] = call_function[target=torch.ops.aten.sum.dim_IntList](args = (%pow_13, [1], True), kwargs = {})
#   %pow_14 : [num_users=1] = call_function[target=torch.ops.aten.pow.Tensor_Scalar](args = (%sum_13, 0.5), kwargs = {})
#   %clamp_min_6 : [num_users=1] = call_function[target=torch.ops.aten.clamp_min.default](args = (%pow_14, 1e-08), kwargs = {})
#   %div_13 : [num_users=1] = call_function[target=torch.ops.aten.div.Tensor](args = (%select_3, %clamp_min_6), kwargs = {})
#   %pow_15 : [num_users=1] = call_function[target=torch.ops.aten.pow.Tensor_Scalar](args = (%select_7, 2), kwargs = {})
#   %sum_14 : [num_users=1] = call_function[target=torch.ops.aten.sum.dim_IntList](args = (%pow_15, [1], True), kwargs = {})
#   %pow_16 : [num_users=1] = call_function[target=torch.ops.aten.pow.Tensor_Scalar](args = (%sum_14, 0.5), kwargs = {})
#   %clamp_min_7 : [num_users=1] = call_function[target=torch.ops.aten.clamp_min.default](args = (%pow_16, 1e-08), kwargs = {})
#   %div_12 : [num_users=1] = call_function[target=torch.ops.aten.div.Tensor](args = (%select_7, %clamp_min_7), kwargs = {})
#   %mul_3 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%div_13, %div_12), kwargs = {})
triton_poi_fused_clamp_min_div_linalg_vector_norm_mul_4 = async_compile.triton('triton_poi_fused_clamp_min_div_linalg_vector_norm_mul_4', '''
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=[64], 
    filename=__file__,
    triton_meta={'signature': {0: '*fp32', 1: '*fp32', 2: '*fp32', 3: 'i32'}, 'device': DeviceProperties(type='cuda', index=0, cc=90, major=9, regs_per_multiprocessor=65536, max_threads_per_multi_processor=2048, multi_processor_count=132), 'constants': {}, 'configs': [AttrsDescriptor(divisible_by_16=(0, 1, 2, 3), equal_to_1=())]},
    inductor_meta={'autotune_hints': set(), 'kernel_name': 'triton_poi_fused_clamp_min_div_linalg_vector_norm_mul_4', 'mutated_arg_names': [], 'no_x_dim': False, 'num_load': 10, 'num_reduction': 0, 'backend_hash': 'B098E03CDA7B8ADC90DAFFDF24A2956451D1B13F297756A5DCC209498AA53705', '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_clamp_min_div_linalg_vector_norm_mul_4(in_ptr0, in_ptr1, out_ptr0, xnumel, XBLOCK : tl.constexpr):
    xnumel = 64
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x3 = xindex
    x0 = xindex % 4
    x2 = (xindex // 16)
    tmp0 = tl.load(in_ptr0 + (192 + x3), xmask)
    tmp1 = tl.load(in_ptr0 + (192 + x0 + (16*x2)), xmask, eviction_policy='evict_last')
    tmp3 = tl.load(in_ptr0 + (196 + x0 + (16*x2)), xmask, eviction_policy='evict_last')
    tmp6 = tl.load(in_ptr0 + (200 + x0 + (16*x2)), xmask, eviction_policy='evict_last')
    tmp9 = tl.load(in_ptr0 + (204 + x0 + (16*x2)), xmask, eviction_policy='evict_last')
    tmp16 = tl.load(in_ptr1 + (192 + x3), xmask)
    tmp17 = tl.load(in_ptr1 + (192 + x0 + (16*x2)), xmask, eviction_policy='evict_last')
    tmp19 = tl.load(in_ptr1 + (196 + x0 + (16*x2)), xmask, eviction_policy='evict_last')
    tmp22 = tl.load(in_ptr1 + (200 + x0 + (16*x2)), xmask, eviction_policy='evict_last')
    tmp25 = tl.load(in_ptr1 + (204 + x0 + (16*x2)), xmask, eviction_policy='evict_last')
    tmp2 = tmp1 * tmp1
    tmp4 = tmp3 * tmp3
    tmp5 = tmp2 + tmp4
    tmp7 = tmp6 * tmp6
    tmp8 = tmp5 + tmp7
    tmp10 = tmp9 * tmp9
    tmp11 = tmp8 + tmp10
    tmp12 = libdevice.sqrt(tmp11)
    tmp13 = 1e-08
    tmp14 = triton_helpers.maximum(tmp12, tmp13)
    tmp15 = tmp0 / tmp14
    tmp18 = tmp17 * tmp17
    tmp20 = tmp19 * tmp19
    tmp21 = tmp18 + tmp20
    tmp23 = tmp22 * tmp22
    tmp24 = tmp21 + tmp23
    tmp26 = tmp25 * tmp25
    tmp27 = tmp24 + tmp26
    tmp28 = libdevice.sqrt(tmp27)
    tmp29 = triton_helpers.maximum(tmp28, tmp13)
    tmp30 = tmp16 / tmp29
    tmp31 = tmp15 * tmp30
    tl.store(out_ptr0 + (x3), tmp31, xmask)
''', device_str='cuda')


# kernel path: runs/run_shard_1/inductor_cache/dx/cdxpinddr5taszdtmg7xcwnaano7mpoidpebaefrqoq7vjbxtdw7.py
# Topologically Sorted Source Nodes: [loss, log, loss_1, total_loss, loss_2, log_1, loss_3, total_loss_1, loss_4, log_2, loss_5, total_loss_2, loss_6, log_3, loss_7, total_loss_3, total_loss_final], Original ATen: [aten.div, aten.log, aten.neg, aten.add]
# Source node to ATen node mapping:
#   log => log
#   log_1 => log_1
#   log_2 => log_2
#   log_3 => log_3
#   loss => div_3
#   loss_1 => neg
#   loss_2 => div_7
#   loss_3 => neg_1
#   loss_4 => div_11
#   loss_5 => neg_2
#   loss_6 => div_15
#   loss_7 => neg_3
#   total_loss => add
#   total_loss_1 => add_1
#   total_loss_2 => add_2
#   total_loss_3 => add_3
#   total_loss_final => div_16
# Graph fragment:
#   %div_3 : [num_users=1] = call_function[target=torch.ops.aten.div.Tensor](args = (%select_8, %sum_4), kwargs = {})
#   %log : [num_users=1] = call_function[target=torch.ops.aten.log.default](args = (%div_3,), kwargs = {})
#   %neg : [num_users=1] = call_function[target=torch.ops.aten.neg.default](args = (%log,), kwargs = {})
#   %add : [num_users=1] = call_function[target=torch.ops.aten.add.Tensor](args = (%neg, 0), kwargs = {})
#   %div_7 : [num_users=1] = call_function[target=torch.ops.aten.div.Tensor](args = (%select_9, %sum_8), kwargs = {})
#   %log_1 : [num_users=1] = call_function[target=torch.ops.aten.log.default](args = (%div_7,), kwargs = {})
#   %neg_1 : [num_users=1] = call_function[target=torch.ops.aten.neg.default](args = (%log_1,), kwargs = {})
#   %add_1 : [num_users=1] = call_function[target=torch.ops.aten.add.Tensor](args = (%add, %neg_1), kwargs = {})
#   %div_11 : [num_users=1] = call_function[target=torch.ops.aten.div.Tensor](args = (%select_10, %sum_12), kwargs = {})
#   %log_2 : [num_users=1] = call_function[target=torch.ops.aten.log.default](args = (%div_11,), kwargs = {})
#   %neg_2 : [num_users=1] = call_function[target=torch.ops.aten.neg.default](args = (%log_2,), kwargs = {})
#   %add_2 : [num_users=1] = call_function[target=torch.ops.aten.add.Tensor](args = (%add_1, %neg_2), kwargs = {})
#   %div_15 : [num_users=1] = call_function[target=torch.ops.aten.div.Tensor](args = (%select_11, %sum_16), kwargs = {})
#   %log_3 : [num_users=1] = call_function[target=torch.ops.aten.log.default](args = (%div_15,), kwargs = {})
#   %neg_3 : [num_users=1] = call_function[target=torch.ops.aten.neg.default](args = (%log_3,), kwargs = {})
#   %add_3 : [num_users=1] = call_function[target=torch.ops.aten.add.Tensor](args = (%add_2, %neg_3), kwargs = {})
#   %div_16 : [num_users=1] = call_function[target=torch.ops.aten.div.Tensor](args = (%add_3, 4), kwargs = {})
triton_poi_fused_add_div_log_neg_5 = async_compile.triton('triton_poi_fused_add_div_log_neg_5', '''
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: '*fp32', 3: '*fp32', 4: '*fp32', 5: '*fp32', 6: '*fp32', 7: '*fp32', 8: '*fp32', 9: 'i32'}, 'device': DeviceProperties(type='cuda', index=0, cc=90, major=9, regs_per_multiprocessor=65536, max_threads_per_multi_processor=2048, multi_processor_count=132), 'constants': {}, 'configs': [AttrsDescriptor(divisible_by_16=(0, 1, 2, 3, 4, 5, 6, 7, 8), equal_to_1=())]},
    inductor_meta={'autotune_hints': set(), 'kernel_name': 'triton_poi_fused_add_div_log_neg_5', 'mutated_arg_names': ['in_out_ptr0'], 'no_x_dim': False, 'num_load': 20, 'num_reduction': 0, 'backend_hash': 'B098E03CDA7B8ADC90DAFFDF24A2956451D1B13F297756A5DCC209498AA53705', '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_add_div_log_neg_5(in_out_ptr0, in_ptr0, in_ptr1, in_ptr2, in_ptr3, in_ptr4, in_ptr5, in_ptr6, in_ptr7, 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 + (x0), xmask)
    tmp1 = tl.load(in_ptr0 + (4 + x0), xmask)
    tmp3 = tl.load(in_ptr0 + (8 + x0), xmask)
    tmp5 = tl.load(in_ptr0 + (12 + x0), xmask)
    tmp10 = tl.load(in_ptr1 + (0))
    tmp11 = tl.broadcast_to(tmp10, [XBLOCK])
    tmp17 = tl.load(in_ptr2 + (x0), xmask)
    tmp18 = tl.load(in_ptr2 + (4 + x0), xmask)
    tmp20 = tl.load(in_ptr2 + (8 + x0), xmask)
    tmp22 = tl.load(in_ptr2 + (12 + x0), xmask)
    tmp26 = tl.load(in_ptr3 + (0))
    tmp27 = tl.broadcast_to(tmp26, [XBLOCK])
    tmp32 = tl.load(in_ptr4 + (x0), xmask)
    tmp33 = tl.load(in_ptr4 + (4 + x0), xmask)
    tmp35 = tl.load(in_ptr4 + (8 + x0), xmask)
    tmp37 = tl.load(in_ptr4 + (12 + x0), xmask)
    tmp41 = tl.load(in_ptr5 + (0))
    tmp42 = tl.broadcast_to(tmp41, [XBLOCK])
    tmp47 = tl.load(in_ptr6 + (x0), xmask)
    tmp48 = tl.load(in_ptr6 + (4 + x0), xmask)
    tmp50 = tl.load(in_ptr6 + (8 + x0), xmask)
    tmp52 = tl.load(in_ptr6 + (12 + x0), xmask)
    tmp56 = tl.load(in_ptr7 + (0))
    tmp57 = tl.broadcast_to(tmp56, [XBLOCK])
    tmp2 = tmp0 + tmp1
    tmp4 = tmp2 + tmp3
    tmp6 = tmp4 + tmp5
    tmp7 = 0.25
    tmp8 = tmp6 * tmp7
    tmp9 = tl_math.exp(tmp8)
    tmp12 = tmp9 / tmp11
    tmp13 = tl_math.log(tmp12)
    tmp14 = -tmp13
    tmp15 = 0.0
    tmp16 = tmp14 + tmp15
    tmp19 = tmp17 + tmp18
    tmp21 = tmp19 + tmp20
    tmp23 = tmp21 + tmp22
    tmp24 = tmp23 * tmp7
    tmp25 = tl_math.exp(tmp24)
    tmp28 = tmp25 / tmp27
    tmp29 = tl_math.log(tmp28)
    tmp30 = -tmp29
    tmp31 = tmp16 + tmp30
    tmp34 = tmp32 + tmp33
    tmp36 = tmp34 + tmp35
    tmp38 = tmp36 + tmp37
    tmp39 = tmp38 * tmp7
    tmp40 = tl_math.exp(tmp39)
    tmp43 = tmp40 / tmp42
    tmp44 = tl_math.log(tmp43)
    tmp45 = -tmp44
    tmp46 = tmp31 + tmp45
    tmp49 = tmp47 + tmp48
    tmp51 = tmp49 + tmp50
    tmp53 = tmp51 + tmp52
    tmp54 = tmp53 * tmp7
    tmp55 = tl_math.exp(tmp54)
    tmp58 = tmp55 / tmp57
    tmp59 = tl_math.log(tmp58)
    tmp60 = -tmp59
    tmp61 = tmp46 + tmp60
    tmp62 = tmp61 * tmp7
    tl.store(in_out_ptr0 + (x0), tmp62, xmask)
''', 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, 4, 4), (16, 4, 1), torch.float32)
        # Topologically Sorted Source Nodes: [similarities], Original ATen: [aten.linalg_vector_norm, aten.clamp_min, aten.div, aten.mul]
        stream0 = get_raw_stream(0)
        triton_poi_fused_clamp_min_div_linalg_vector_norm_mul_0.run(arg0_1, arg1_1, buf0, 64, grid=grid(64), stream=stream0)
        buf1 = empty_strided_cuda((), (), torch.float32)
        # Topologically Sorted Source Nodes: [similarities, similarities_1, exp_tensor, sum_1], Original ATen: [aten.sum, aten.div, aten.exp]
        triton_per_fused_div_exp_sum_1.run(buf0, buf1, 1, 16, grid=grid(1), stream=stream0)
        buf2 = empty_strided_cuda((4, 4, 4), (16, 4, 1), torch.float32)
        # Topologically Sorted Source Nodes: [similarities_2], Original ATen: [aten.linalg_vector_norm, aten.clamp_min, aten.div, aten.mul]
        triton_poi_fused_clamp_min_div_linalg_vector_norm_mul_2.run(arg0_1, arg1_1, buf2, 64, grid=grid(64), stream=stream0)
        buf3 = empty_strided_cuda((), (), torch.float32)
        # Topologically Sorted Source Nodes: [similarities_2, similarities_3, exp_tensor_1, sum_2], Original ATen: [aten.sum, aten.div, aten.exp]
        triton_per_fused_div_exp_sum_1.run(buf2, buf3, 1, 16, grid=grid(1), stream=stream0)
        buf5 = empty_strided_cuda((4, 4, 4), (16, 4, 1), torch.float32)
        # Topologically Sorted Source Nodes: [similarities_4], Original ATen: [aten.linalg_vector_norm, aten.clamp_min, aten.div, aten.mul]
        triton_poi_fused_clamp_min_div_linalg_vector_norm_mul_3.run(arg0_1, arg1_1, buf5, 64, grid=grid(64), stream=stream0)
        buf6 = empty_strided_cuda((), (), torch.float32)
        # Topologically Sorted Source Nodes: [similarities_4, similarities_5, exp_tensor_2, sum_3], Original ATen: [aten.sum, aten.div, aten.exp]
        triton_per_fused_div_exp_sum_1.run(buf5, buf6, 1, 16, grid=grid(1), stream=stream0)
        buf7 = empty_strided_cuda((4, 4, 4), (16, 4, 1), torch.float32)
        # Topologically Sorted Source Nodes: [similarities_6], Original ATen: [aten.linalg_vector_norm, aten.clamp_min, aten.div, aten.mul]
        triton_poi_fused_clamp_min_div_linalg_vector_norm_mul_4.run(arg0_1, arg1_1, buf7, 64, grid=grid(64), stream=stream0)
        del arg0_1
        del arg1_1
        buf8 = empty_strided_cuda((), (), torch.float32)
        # Topologically Sorted Source Nodes: [similarities_6, similarities_7, exp_tensor_3, sum_4], Original ATen: [aten.sum, aten.div, aten.exp]
        triton_per_fused_div_exp_sum_1.run(buf7, buf8, 1, 16, grid=grid(1), stream=stream0)
        buf4 = empty_strided_cuda((4, ), (1, ), torch.float32)
        buf9 = buf4; del buf4  # reuse
        buf10 = buf9; del buf9  # reuse
        # Topologically Sorted Source Nodes: [loss, log, loss_1, total_loss, loss_2, log_1, loss_3, total_loss_1, loss_4, log_2, loss_5, total_loss_2, loss_6, log_3, loss_7, total_loss_3, total_loss_final], Original ATen: [aten.div, aten.log, aten.neg, aten.add]
        triton_poi_fused_add_div_log_neg_5.run(buf10, buf0, buf1, buf2, buf3, buf5, buf6, buf7, buf8, 4, grid=grid(4), stream=stream0)
        del buf0
        del buf1
        del buf2
        del buf3
        del buf5
        del buf6
        del buf7
        del buf8
    return (buf10, )


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


class InfoNCE_loss_vectorized(nn.Module):
    """
        SimCLR loss: https://github.com/google-research/simclr // https://github.com/sthalles/SimCLR
    """

    def __init__(self, temperature):
        super(InfoNCE_loss_vectorized, self).__init__()
        self.temperature = temperature
        self.cos = nn.CosineSimilarity(dim=1)

    def forward(self, graph_out, sent_out):
        total_loss = 0
        for g, s in zip(graph_out, sent_out):
            similarities = self.cos(g, s)
            similarities = similarities / self.temperature
            exp_tensor = torch.exp(similarities)
            loss = exp_tensor[0] / torch.sum(exp_tensor)
            loss = -torch.log(loss)
            total_loss = total_loss + loss
        total_loss_final = total_loss / len(graph_out)
        return total_loss_final


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


def get_init_inputs():
    return [[], {'temperature': 4}]

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


@triton.jit
def triton_poi_fused_clamp_min_div_linalg_vector_norm_mul_0(in_ptr0,
    in_ptr1, out_ptr0, xnumel, XBLOCK: tl.constexpr):
    xnumel = 64
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x3 = xindex
    x0 = xindex % 4
    x2 = xindex // 16
    tmp0 = tl.load(in_ptr0 + x3, xmask)
    tmp1 = tl.load(in_ptr0 + (x0 + 16 * x2), xmask, eviction_policy=
        'evict_last')
    tmp3 = tl.load(in_ptr0 + (4 + x0 + 16 * x2), xmask, eviction_policy=
        'evict_last')
    tmp6 = tl.load(in_ptr0 + (8 + x0 + 16 * x2), xmask, eviction_policy=
        'evict_last')
    tmp9 = tl.load(in_ptr0 + (12 + x0 + 16 * x2), xmask, eviction_policy=
        'evict_last')
    tmp16 = tl.load(in_ptr1 + x3, xmask)
    tmp17 = tl.load(in_ptr1 + (x0 + 16 * x2), xmask, eviction_policy=
        'evict_last')
    tmp19 = tl.load(in_ptr1 + (4 + x0 + 16 * x2), xmask, eviction_policy=
        'evict_last')
    tmp22 = tl.load(in_ptr1 + (8 + x0 + 16 * x2), xmask, eviction_policy=
        'evict_last')
    tmp25 = tl.load(in_ptr1 + (12 + x0 + 16 * x2), xmask, eviction_policy=
        'evict_last')
    tmp2 = tmp1 * tmp1
    tmp4 = tmp3 * tmp3
    tmp5 = tmp2 + tmp4
    tmp7 = tmp6 * tmp6
    tmp8 = tmp5 + tmp7
    tmp10 = tmp9 * tmp9
    tmp11 = tmp8 + tmp10
    tmp12 = libdevice.sqrt(tmp11)
    tmp13 = 1e-08
    tmp14 = triton_helpers.maximum(tmp12, tmp13)
    tmp15 = tmp0 / tmp14
    tmp18 = tmp17 * tmp17
    tmp20 = tmp19 * tmp19
    tmp21 = tmp18 + tmp20
    tmp23 = tmp22 * tmp22
    tmp24 = tmp21 + tmp23
    tmp26 = tmp25 * tmp25
    tmp27 = tmp24 + tmp26
    tmp28 = libdevice.sqrt(tmp27)
    tmp29 = triton_helpers.maximum(tmp28, tmp13)
    tmp30 = tmp16 / tmp29
    tmp31 = tmp15 * tmp30
    tl.store(out_ptr0 + x3, tmp31, xmask)


@triton.jit
def triton_per_fused_div_exp_sum_1(in_ptr0, out_ptr0, 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 + (r0 + 16 * r1), None)
    tmp1 = tl.load(in_ptr0 + (4 + r0 + 16 * r1), None)
    tmp3 = tl.load(in_ptr0 + (8 + r0 + 16 * r1), None)
    tmp5 = tl.load(in_ptr0 + (12 + r0 + 16 * r1), None)
    tmp2 = tmp0 + tmp1
    tmp4 = tmp2 + tmp3
    tmp6 = tmp4 + tmp5
    tmp7 = 0.25
    tmp8 = tmp6 * tmp7
    tmp9 = tl_math.exp(tmp8)
    tmp10 = tl.broadcast_to(tmp9, [XBLOCK, RBLOCK])
    tmp12 = tl.sum(tmp10, 1)[:, None]
    tl.store(out_ptr0 + tl.full([XBLOCK, 1], 0, tl.int32), tmp12, None)


@triton.jit
def triton_poi_fused_clamp_min_div_linalg_vector_norm_mul_2(in_ptr0,
    in_ptr1, out_ptr0, xnumel, XBLOCK: tl.constexpr):
    xnumel = 64
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x3 = xindex
    x0 = xindex % 4
    x2 = xindex // 16
    tmp0 = tl.load(in_ptr0 + (64 + x3), xmask)
    tmp1 = tl.load(in_ptr0 + (64 + x0 + 16 * x2), xmask, eviction_policy=
        'evict_last')
    tmp3 = tl.load(in_ptr0 + (68 + x0 + 16 * x2), xmask, eviction_policy=
        'evict_last')
    tmp6 = tl.load(in_ptr0 + (72 + x0 + 16 * x2), xmask, eviction_policy=
        'evict_last')
    tmp9 = tl.load(in_ptr0 + (76 + x0 + 16 * x2), xmask, eviction_policy=
        'evict_last')
    tmp16 = tl.load(in_ptr1 + (64 + x3), xmask)
    tmp17 = tl.load(in_ptr1 + (64 + x0 + 16 * x2), xmask, eviction_policy=
        'evict_last')
    tmp19 = tl.load(in_ptr1 + (68 + x0 + 16 * x2), xmask, eviction_policy=
        'evict_last')
    tmp22 = tl.load(in_ptr1 + (72 + x0 + 16 * x2), xmask, eviction_policy=
        'evict_last')
    tmp25 = tl.load(in_ptr1 + (76 + x0 + 16 * x2), xmask, eviction_policy=
        'evict_last')
    tmp2 = tmp1 * tmp1
    tmp4 = tmp3 * tmp3
    tmp5 = tmp2 + tmp4
    tmp7 = tmp6 * tmp6
    tmp8 = tmp5 + tmp7
    tmp10 = tmp9 * tmp9
    tmp11 = tmp8 + tmp10
    tmp12 = libdevice.sqrt(tmp11)
    tmp13 = 1e-08
    tmp14 = triton_helpers.maximum(tmp12, tmp13)
    tmp15 = tmp0 / tmp14
    tmp18 = tmp17 * tmp17
    tmp20 = tmp19 * tmp19
    tmp21 = tmp18 + tmp20
    tmp23 = tmp22 * tmp22
    tmp24 = tmp21 + tmp23
    tmp26 = tmp25 * tmp25
    tmp27 = tmp24 + tmp26
    tmp28 = libdevice.sqrt(tmp27)
    tmp29 = triton_helpers.maximum(tmp28, tmp13)
    tmp30 = tmp16 / tmp29
    tmp31 = tmp15 * tmp30
    tl.store(out_ptr0 + x3, tmp31, xmask)


@triton.jit
def triton_poi_fused_clamp_min_div_linalg_vector_norm_mul_3(in_ptr0,
    in_ptr1, out_ptr0, xnumel, XBLOCK: tl.constexpr):
    xnumel = 64
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x3 = xindex
    x0 = xindex % 4
    x2 = xindex // 16
    tmp0 = tl.load(in_ptr0 + (128 + x3), xmask)
    tmp1 = tl.load(in_ptr0 + (128 + x0 + 16 * x2), xmask, eviction_policy=
        'evict_last')
    tmp3 = tl.load(in_ptr0 + (132 + x0 + 16 * x2), xmask, eviction_policy=
        'evict_last')
    tmp6 = tl.load(in_ptr0 + (136 + x0 + 16 * x2), xmask, eviction_policy=
        'evict_last')
    tmp9 = tl.load(in_ptr0 + (140 + x0 + 16 * x2), xmask, eviction_policy=
        'evict_last')
    tmp16 = tl.load(in_ptr1 + (128 + x3), xmask)
    tmp17 = tl.load(in_ptr1 + (128 + x0 + 16 * x2), xmask, eviction_policy=
        'evict_last')
    tmp19 = tl.load(in_ptr1 + (132 + x0 + 16 * x2), xmask, eviction_policy=
        'evict_last')
    tmp22 = tl.load(in_ptr1 + (136 + x0 + 16 * x2), xmask, eviction_policy=
        'evict_last')
    tmp25 = tl.load(in_ptr1 + (140 + x0 + 16 * x2), xmask, eviction_policy=
        'evict_last')
    tmp2 = tmp1 * tmp1
    tmp4 = tmp3 * tmp3
    tmp5 = tmp2 + tmp4
    tmp7 = tmp6 * tmp6
    tmp8 = tmp5 + tmp7
    tmp10 = tmp9 * tmp9
    tmp11 = tmp8 + tmp10
    tmp12 = libdevice.sqrt(tmp11)
    tmp13 = 1e-08
    tmp14 = triton_helpers.maximum(tmp12, tmp13)
    tmp15 = tmp0 / tmp14
    tmp18 = tmp17 * tmp17
    tmp20 = tmp19 * tmp19
    tmp21 = tmp18 + tmp20
    tmp23 = tmp22 * tmp22
    tmp24 = tmp21 + tmp23
    tmp26 = tmp25 * tmp25
    tmp27 = tmp24 + tmp26
    tmp28 = libdevice.sqrt(tmp27)
    tmp29 = triton_helpers.maximum(tmp28, tmp13)
    tmp30 = tmp16 / tmp29
    tmp31 = tmp15 * tmp30
    tl.store(out_ptr0 + x3, tmp31, xmask)


@triton.jit
def triton_poi_fused_clamp_min_div_linalg_vector_norm_mul_4(in_ptr0,
    in_ptr1, out_ptr0, xnumel, XBLOCK: tl.constexpr):
    xnumel = 64
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x3 = xindex
    x0 = xindex % 4
    x2 = xindex // 16
    tmp0 = tl.load(in_ptr0 + (192 + x3), xmask)
    tmp1 = tl.load(in_ptr0 + (192 + x0 + 16 * x2), xmask, eviction_policy=
        'evict_last')
    tmp3 = tl.load(in_ptr0 + (196 + x0 + 16 * x2), xmask, eviction_policy=
        'evict_last')
    tmp6 = tl.load(in_ptr0 + (200 + x0 + 16 * x2), xmask, eviction_policy=
        'evict_last')
    tmp9 = tl.load(in_ptr0 + (204 + x0 + 16 * x2), xmask, eviction_policy=
        'evict_last')
    tmp16 = tl.load(in_ptr1 + (192 + x3), xmask)
    tmp17 = tl.load(in_ptr1 + (192 + x0 + 16 * x2), xmask, eviction_policy=
        'evict_last')
    tmp19 = tl.load(in_ptr1 + (196 + x0 + 16 * x2), xmask, eviction_policy=
        'evict_last')
    tmp22 = tl.load(in_ptr1 + (200 + x0 + 16 * x2), xmask, eviction_policy=
        'evict_last')
    tmp25 = tl.load(in_ptr1 + (204 + x0 + 16 * x2), xmask, eviction_policy=
        'evict_last')
    tmp2 = tmp1 * tmp1
    tmp4 = tmp3 * tmp3
    tmp5 = tmp2 + tmp4
    tmp7 = tmp6 * tmp6
    tmp8 = tmp5 + tmp7
    tmp10 = tmp9 * tmp9
    tmp11 = tmp8 + tmp10
    tmp12 = libdevice.sqrt(tmp11)
    tmp13 = 1e-08
    tmp14 = triton_helpers.maximum(tmp12, tmp13)
    tmp15 = tmp0 / tmp14
    tmp18 = tmp17 * tmp17
    tmp20 = tmp19 * tmp19
    tmp21 = tmp18 + tmp20
    tmp23 = tmp22 * tmp22
    tmp24 = tmp21 + tmp23
    tmp26 = tmp25 * tmp25
    tmp27 = tmp24 + tmp26
    tmp28 = libdevice.sqrt(tmp27)
    tmp29 = triton_helpers.maximum(tmp28, tmp13)
    tmp30 = tmp16 / tmp29
    tmp31 = tmp15 * tmp30
    tl.store(out_ptr0 + x3, tmp31, xmask)


@triton.jit
def triton_poi_fused_add_div_log_neg_5(in_out_ptr0, in_ptr0, in_ptr1,
    in_ptr2, in_ptr3, in_ptr4, in_ptr5, in_ptr6, in_ptr7, 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 + x0, xmask)
    tmp1 = tl.load(in_ptr0 + (4 + x0), xmask)
    tmp3 = tl.load(in_ptr0 + (8 + x0), xmask)
    tmp5 = tl.load(in_ptr0 + (12 + x0), xmask)
    tmp10 = tl.load(in_ptr1 + 0)
    tmp11 = tl.broadcast_to(tmp10, [XBLOCK])
    tmp17 = tl.load(in_ptr2 + x0, xmask)
    tmp18 = tl.load(in_ptr2 + (4 + x0), xmask)
    tmp20 = tl.load(in_ptr2 + (8 + x0), xmask)
    tmp22 = tl.load(in_ptr2 + (12 + x0), xmask)
    tmp26 = tl.load(in_ptr3 + 0)
    tmp27 = tl.broadcast_to(tmp26, [XBLOCK])
    tmp32 = tl.load(in_ptr4 + x0, xmask)
    tmp33 = tl.load(in_ptr4 + (4 + x0), xmask)
    tmp35 = tl.load(in_ptr4 + (8 + x0), xmask)
    tmp37 = tl.load(in_ptr4 + (12 + x0), xmask)
    tmp41 = tl.load(in_ptr5 + 0)
    tmp42 = tl.broadcast_to(tmp41, [XBLOCK])
    tmp47 = tl.load(in_ptr6 + x0, xmask)
    tmp48 = tl.load(in_ptr6 + (4 + x0), xmask)
    tmp50 = tl.load(in_ptr6 + (8 + x0), xmask)
    tmp52 = tl.load(in_ptr6 + (12 + x0), xmask)
    tmp56 = tl.load(in_ptr7 + 0)
    tmp57 = tl.broadcast_to(tmp56, [XBLOCK])
    tmp2 = tmp0 + tmp1
    tmp4 = tmp2 + tmp3
    tmp6 = tmp4 + tmp5
    tmp7 = 0.25
    tmp8 = tmp6 * tmp7
    tmp9 = tl_math.exp(tmp8)
    tmp12 = tmp9 / tmp11
    tmp13 = tl_math.log(tmp12)
    tmp14 = -tmp13
    tmp15 = 0.0
    tmp16 = tmp14 + tmp15
    tmp19 = tmp17 + tmp18
    tmp21 = tmp19 + tmp20
    tmp23 = tmp21 + tmp22
    tmp24 = tmp23 * tmp7
    tmp25 = tl_math.exp(tmp24)
    tmp28 = tmp25 / tmp27
    tmp29 = tl_math.log(tmp28)
    tmp30 = -tmp29
    tmp31 = tmp16 + tmp30
    tmp34 = tmp32 + tmp33
    tmp36 = tmp34 + tmp35
    tmp38 = tmp36 + tmp37
    tmp39 = tmp38 * tmp7
    tmp40 = tl_math.exp(tmp39)
    tmp43 = tmp40 / tmp42
    tmp44 = tl_math.log(tmp43)
    tmp45 = -tmp44
    tmp46 = tmp31 + tmp45
    tmp49 = tmp47 + tmp48
    tmp51 = tmp49 + tmp50
    tmp53 = tmp51 + tmp52
    tmp54 = tmp53 * tmp7
    tmp55 = tl_math.exp(tmp54)
    tmp58 = tmp55 / tmp57
    tmp59 = tl_math.log(tmp58)
    tmp60 = -tmp59
    tmp61 = tmp46 + tmp60
    tmp62 = tmp61 * tmp7
    tl.store(in_out_ptr0 + x0, tmp62, xmask)


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, 4, 4), (16, 4, 1), torch.float32)
        get_raw_stream(0)
        triton_poi_fused_clamp_min_div_linalg_vector_norm_mul_0[grid(64)](
            arg0_1, arg1_1, buf0, 64, XBLOCK=64, num_warps=1, num_stages=1)
        buf1 = empty_strided_cuda((), (), torch.float32)
        triton_per_fused_div_exp_sum_1[grid(1)](buf0, buf1, 1, 16, XBLOCK=1,
            num_warps=2, num_stages=1)
        buf2 = empty_strided_cuda((4, 4, 4), (16, 4, 1), torch.float32)
        triton_poi_fused_clamp_min_div_linalg_vector_norm_mul_2[grid(64)](
            arg0_1, arg1_1, buf2, 64, XBLOCK=64, num_warps=1, num_stages=1)
        buf3 = empty_strided_cuda((), (), torch.float32)
        triton_per_fused_div_exp_sum_1[grid(1)](buf2, buf3, 1, 16, XBLOCK=1,
            num_warps=2, num_stages=1)
        buf5 = empty_strided_cuda((4, 4, 4), (16, 4, 1), torch.float32)
        triton_poi_fused_clamp_min_div_linalg_vector_norm_mul_3[grid(64)](
            arg0_1, arg1_1, buf5, 64, XBLOCK=64, num_warps=1, num_stages=1)
        buf6 = empty_strided_cuda((), (), torch.float32)
        triton_per_fused_div_exp_sum_1[grid(1)](buf5, buf6, 1, 16, XBLOCK=1,
            num_warps=2, num_stages=1)
        buf7 = empty_strided_cuda((4, 4, 4), (16, 4, 1), torch.float32)
        triton_poi_fused_clamp_min_div_linalg_vector_norm_mul_4[grid(64)](
            arg0_1, arg1_1, buf7, 64, XBLOCK=64, num_warps=1, num_stages=1)
        del arg0_1
        del arg1_1
        buf8 = empty_strided_cuda((), (), torch.float32)
        triton_per_fused_div_exp_sum_1[grid(1)](buf7, buf8, 1, 16, XBLOCK=1,
            num_warps=2, num_stages=1)
        buf4 = empty_strided_cuda((4,), (1,), torch.float32)
        buf9 = buf4
        del buf4
        buf10 = buf9
        del buf9
        triton_poi_fused_add_div_log_neg_5[grid(4)](buf10, buf0, buf1, buf2,
            buf3, buf5, buf6, buf7, buf8, 4, XBLOCK=4, num_warps=1,
            num_stages=1)
        del buf0
        del buf1
        del buf2
        del buf3
        del buf5
        del buf6
        del buf7
        del buf8
    return buf10,


class InfoNCE_loss_vectorizedNew(nn.Module):
    """
        SimCLR loss: https://github.com/google-research/simclr // https://github.com/sthalles/SimCLR
    """

    def __init__(self, temperature):
        super(InfoNCE_loss_vectorizedNew, self).__init__()
        self.temperature = temperature
        self.cos = nn.CosineSimilarity(dim=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]
