# 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_0/inductor_cache/ay/cayo2bjn3aave42aras6vsceeimf72hhz2tj3q2fmjmf5a3feqpc.py
# Topologically Sorted Source Nodes: [add, inv_grid, imul, imul_1, inv_grid_1], Original ATen: [aten.add, aten.div, aten.mul]
# Source node to ATen node mapping:
#   add => add
#   imul => mul
#   imul_1 => mul_1
#   inv_grid => div
#   inv_grid_1 => add_1
# Graph fragment:
#   %add : [num_users=1] = call_function[target=torch.ops.aten.add.Tensor](args = (%arg1_1, 1), kwargs = {})
#   %div : [num_users=2] = call_function[target=torch.ops.aten.div.Tensor](args = (%add, 2.0), kwargs = {})
#   %mul : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%select, 4), kwargs = {})
#   %select_scatter_default : [num_users=3] = call_function[target=torch.ops.aten.select_scatter.default](args = (%div, %mul, 3, 0), kwargs = {})
#   %select_scatter_default_1 : [num_users=2] = call_function[target=torch.ops.aten.select_scatter.default](args = (%select_scatter_default, %select_1, 3, 0), kwargs = {})
#   %mul_1 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%select_6, 4), kwargs = {})
#   %select_scatter_default_2 : [num_users=3] = call_function[target=torch.ops.aten.select_scatter.default](args = (%select_scatter_default_1, %mul_1, 3, 1), kwargs = {})
#   %select_scatter_default_3 : [num_users=1] = call_function[target=torch.ops.aten.select_scatter.default](args = (%select_scatter_default_2, %select_7, 3, 1), kwargs = {})
#   %add_1 : [num_users=2] = call_function[target=torch.ops.aten.add.Tensor](args = (%select_scatter_default_3, 1), kwargs = {})
triton_poi_fused_add_div_mul_0 = async_compile.triton('triton_poi_fused_add_div_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=[256], 
    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, 2), equal_to_1=())]},
    inductor_meta={'autotune_hints': set(), 'kernel_name': 'triton_poi_fused_add_div_mul_0', 'mutated_arg_names': [], 'no_x_dim': False, 'num_load': 3, '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_add_div_mul_0(in_ptr0, out_ptr0, xnumel, XBLOCK : tl.constexpr):
    xnumel = 256
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x0 = xindex % 4
    x1 = (xindex // 4)
    x2 = xindex
    tmp7 = tl.load(in_ptr0 + (4*x1), xmask, eviction_policy='evict_last')
    tmp15 = tl.load(in_ptr0 + (1 + (4*x1)), xmask, eviction_policy='evict_last')
    tmp23 = tl.load(in_ptr0 + (x2), xmask)
    tmp0 = x0
    tmp1 = tl.full([1], 1, tl.int32)
    tmp2 = tmp0 == tmp1
    tmp3 = tmp1 == tmp1
    tmp4 = tl.full([1], 0, tl.int32)
    tmp5 = tmp1 == tmp4
    tmp6 = tmp4 == tmp4
    tmp8 = 1.0
    tmp9 = tmp7 + tmp8
    tmp10 = 0.5
    tmp11 = tmp9 * tmp10
    tmp12 = 4.0
    tmp13 = tmp11 * tmp12
    tmp14 = tl.where(tmp6, tmp13, tmp11)
    tmp16 = tmp15 + tmp8
    tmp17 = tmp16 * tmp10
    tmp18 = tl.where(tmp5, tmp13, tmp17)
    tmp19 = tl.where(tmp5, tmp14, tmp18)
    tmp20 = tmp19 * tmp12
    tmp21 = tl.where(tmp3, tmp20, tmp19)
    tmp22 = tmp0 == tmp4
    tmp24 = tmp23 + tmp8
    tmp25 = tmp24 * tmp10
    tmp26 = tl.where(tmp22, tmp13, tmp25)
    tmp27 = tl.where(tmp22, tmp14, tmp26)
    tmp28 = tl.where(tmp2, tmp20, tmp27)
    tmp29 = tl.where(tmp2, tmp21, tmp28)
    tmp30 = tmp29 + tmp8
    tl.store(out_ptr0 + (x2), tmp30, xmask)
''', device_str='cuda')


# kernel path: runs/run_shard_0/inductor_cache/qm/cqmjs3joxrxwlibqyf2nvzc5eqvezkn2gmg2qxrc47qbzwgdur4t.py
# Topologically Sorted Source Nodes: [t_ravel], Original ATen: [aten.view]
# Source node to ATen node mapping:
#   t_ravel => full_default
# Graph fragment:
#   %full_default : [num_users=1] = call_function[target=torch.ops.aten.full.default](args = ([784], 0.0), kwargs = {dtype: torch.float32, layout: torch.strided, device: cuda:0, pin_memory: False})
triton_poi_fused_view_1 = async_compile.triton('triton_poi_fused_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=[1024], 
    filename=__file__,
    triton_meta={'signature': {0: '*fp32', 1: '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_view_1', 'mutated_arg_names': [], 'no_x_dim': False, 'num_load': 0, '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_view_1(out_ptr0, xnumel, XBLOCK : tl.constexpr):
    xnumel = 784
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x0 = xindex
    tmp0 = 0.0
    tl.store(out_ptr0 + (x0), tmp0, xmask)
''', device_str='cuda')


# kernel path: runs/run_shard_0/inductor_cache/hy/chyu4xmbfwkj2me3ssh3k2jngfvilqjybi3pcg7nf5zcdbrj6hbp.py
# Topologically Sorted Source Nodes: [t_ravel, output_inds_i, indices_ravel_1, output_inds_j, corners_i, sub, abs_1, sub_1, bilinear_weights_i, corners_j, sub_2, abs_2, sub_3, relu_1, bilinear_weights, mul_1, index_add_, indices_ravel_4, output_inds_j_1, corners_j_1, sub_4, abs_3, sub_5, relu_2, bilinear_weights_1, mul_6, index_add__1, output_inds_i_1, indices_ravel_7, output_inds_j_2, corners_i_1, sub_6, abs_4, sub_7, bilinear_weights_i_1, corners_j_2, sub_8, abs_5, sub_9, relu_4, bilinear_weights_2, mul_11, index_add__2, indices_ravel_10, output_inds_j_3, corners_j_3, sub_10, abs_6, sub_11, relu_5, bilinear_weights_3, mul_16, index_add__3], Original ATen: [aten.view, aten.add, aten._to_copy, aten.sub, aten.abs, aten.rsub, aten.relu, aten.mul, aten.index_add]
# Source node to ATen node mapping:
#   abs_1 => abs_1
#   abs_2 => abs_2
#   abs_3 => abs_3
#   abs_4 => abs_4
#   abs_5 => abs_5
#   abs_6 => abs_6
#   bilinear_weights => mul_2
#   bilinear_weights_1 => mul_7
#   bilinear_weights_2 => mul_12
#   bilinear_weights_3 => mul_17
#   bilinear_weights_i => relu
#   bilinear_weights_i_1 => relu_3
#   corners_i => convert_element_type_1
#   corners_i_1 => convert_element_type_4
#   corners_j => convert_element_type_2
#   corners_j_1 => convert_element_type_3
#   corners_j_2 => convert_element_type_5
#   corners_j_3 => convert_element_type_6
#   index_add_ => index_put
#   index_add__1 => index_put_1
#   index_add__2 => index_put_2
#   index_add__3 => index_put_3
#   indices_ravel_1 => add_5
#   indices_ravel_10 => add_18
#   indices_ravel_4 => add_9
#   indices_ravel_7 => add_14
#   mul_1 => mul_3
#   mul_11 => mul_13
#   mul_16 => mul_18
#   mul_6 => mul_8
#   output_inds_i => add_2
#   output_inds_i_1 => add_11
#   output_inds_j => add_3
#   output_inds_j_1 => add_7
#   output_inds_j_2 => add_12
#   output_inds_j_3 => add_16
#   relu_1 => relu_1
#   relu_2 => relu_2
#   relu_4 => relu_4
#   relu_5 => relu_5
#   sub => sub
#   sub_1 => sub_1
#   sub_10 => sub_10
#   sub_11 => sub_11
#   sub_2 => sub_2
#   sub_3 => sub_3
#   sub_4 => sub_4
#   sub_5 => sub_5
#   sub_6 => sub_6
#   sub_7 => sub_7
#   sub_8 => sub_8
#   sub_9 => sub_9
#   t_ravel => full_default
# Graph fragment:
#   %full_default : [num_users=1] = call_function[target=torch.ops.aten.full.default](args = ([784], 0.0), kwargs = {dtype: torch.float32, layout: torch.strided, device: cuda:0, pin_memory: False})
#   %add_2 : [num_users=3] = call_function[target=torch.ops.aten.add.Tensor](args = (%select_17, 0), kwargs = {})
#   %add_5 : [num_users=1] = call_function[target=torch.ops.aten.add.Tensor](args = (%mul_5, %add_2), kwargs = {})
#   %add_3 : [num_users=2] = call_function[target=torch.ops.aten.add.Tensor](args = (%select_19, 0), kwargs = {})
#   %convert_element_type_1 : [num_users=1] = call_function[target=torch.ops.prims.convert_element_type.default](args = (%add_2, torch.float32), kwargs = {})
#   %sub : [num_users=1] = call_function[target=torch.ops.aten.sub.Tensor](args = (%select_18, %convert_element_type_1), kwargs = {})
#   %abs_1 : [num_users=1] = call_function[target=torch.ops.aten.abs.default](args = (%sub,), kwargs = {})
#   %sub_1 : [num_users=1] = call_function[target=torch.ops.aten.sub.Tensor](args = (1, %abs_1), kwargs = {})
#   %relu : [num_users=2] = call_function[target=torch.ops.aten.relu.default](args = (%sub_1,), kwargs = {})
#   %convert_element_type_2 : [num_users=1] = call_function[target=torch.ops.prims.convert_element_type.default](args = (%add_3, torch.float32), kwargs = {})
#   %sub_2 : [num_users=1] = call_function[target=torch.ops.aten.sub.Tensor](args = (%select_20, %convert_element_type_2), kwargs = {})
#   %abs_2 : [num_users=1] = call_function[target=torch.ops.aten.abs.default](args = (%sub_2,), kwargs = {})
#   %sub_3 : [num_users=1] = call_function[target=torch.ops.aten.sub.Tensor](args = (1, %abs_2), kwargs = {})
#   %relu_1 : [num_users=1] = call_function[target=torch.ops.aten.relu.default](args = (%sub_3,), kwargs = {})
#   %mul_2 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%relu, %relu_1), kwargs = {})
#   %mul_3 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%view_6, %mul_2), kwargs = {})
#   %index_put : [num_users=1] = call_function[target=torch.ops.aten.index_put_.default](args = (%full_default, [%add_6], %mul_3, True), kwargs = {})
#   %add_9 : [num_users=1] = call_function[target=torch.ops.aten.add.Tensor](args = (%mul_10, %add_2), kwargs = {})
#   %add_7 : [num_users=2] = call_function[target=torch.ops.aten.add.Tensor](args = (%select_21, 1), kwargs = {})
#   %convert_element_type_3 : [num_users=1] = call_function[target=torch.ops.prims.convert_element_type.default](args = (%add_7, torch.float32), kwargs = {})
#   %sub_4 : [num_users=1] = call_function[target=torch.ops.aten.sub.Tensor](args = (%select_22, %convert_element_type_3), kwargs = {})
#   %abs_3 : [num_users=1] = call_function[target=torch.ops.aten.abs.default](args = (%sub_4,), kwargs = {})
#   %sub_5 : [num_users=1] = call_function[target=torch.ops.aten.sub.Tensor](args = (1, %abs_3), kwargs = {})
#   %relu_2 : [num_users=1] = call_function[target=torch.ops.aten.relu.default](args = (%sub_5,), kwargs = {})
#   %mul_7 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%relu, %relu_2), kwargs = {})
#   %mul_8 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%view_10, %mul_7), kwargs = {})
#   %index_put_1 : [num_users=1] = call_function[target=torch.ops.aten.index_put_.default](args = (%view_12, [%add_10], %mul_8, True), kwargs = {})
#   %add_11 : [num_users=3] = call_function[target=torch.ops.aten.add.Tensor](args = (%select_23, 1), kwargs = {})
#   %add_14 : [num_users=1] = call_function[target=torch.ops.aten.add.Tensor](args = (%mul_15, %add_11), kwargs = {})
#   %add_12 : [num_users=2] = call_function[target=torch.ops.aten.add.Tensor](args = (%select_25, 0), kwargs = {})
#   %convert_element_type_4 : [num_users=1] = call_function[target=torch.ops.prims.convert_element_type.default](args = (%add_11, torch.float32), kwargs = {})
#   %sub_6 : [num_users=1] = call_function[target=torch.ops.aten.sub.Tensor](args = (%select_24, %convert_element_type_4), kwargs = {})
#   %abs_4 : [num_users=1] = call_function[target=torch.ops.aten.abs.default](args = (%sub_6,), kwargs = {})
#   %sub_7 : [num_users=1] = call_function[target=torch.ops.aten.sub.Tensor](args = (1, %abs_4), kwargs = {})
#   %relu_3 : [num_users=2] = call_function[target=torch.ops.aten.relu.default](args = (%sub_7,), kwargs = {})
#   %convert_element_type_5 : [num_users=1] = call_function[target=torch.ops.prims.convert_element_type.default](args = (%add_12, torch.float32), kwargs = {})
#   %sub_8 : [num_users=1] = call_function[target=torch.ops.aten.sub.Tensor](args = (%select_26, %convert_element_type_5), kwargs = {})
#   %abs_5 : [num_users=1] = call_function[target=torch.ops.aten.abs.default](args = (%sub_8,), kwargs = {})
#   %sub_9 : [num_users=1] = call_function[target=torch.ops.aten.sub.Tensor](args = (1, %abs_5), kwargs = {})
#   %relu_4 : [num_users=1] = call_function[target=torch.ops.aten.relu.default](args = (%sub_9,), kwargs = {})
#   %mul_12 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%relu_3, %relu_4), kwargs = {})
#   %mul_13 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%view_15, %mul_12), kwargs = {})
#   %index_put_2 : [num_users=1] = call_function[target=torch.ops.aten.index_put_.default](args = (%view_17, [%add_15], %mul_13, True), kwargs = {})
#   %add_18 : [num_users=1] = call_function[target=torch.ops.aten.add.Tensor](args = (%mul_20, %add_11), kwargs = {})
#   %add_16 : [num_users=2] = call_function[target=torch.ops.aten.add.Tensor](args = (%select_27, 1), kwargs = {})
#   %convert_element_type_6 : [num_users=1] = call_function[target=torch.ops.prims.convert_element_type.default](args = (%add_16, torch.float32), kwargs = {})
#   %sub_10 : [num_users=1] = call_function[target=torch.ops.aten.sub.Tensor](args = (%select_28, %convert_element_type_6), kwargs = {})
#   %abs_6 : [num_users=1] = call_function[target=torch.ops.aten.abs.default](args = (%sub_10,), kwargs = {})
#   %sub_11 : [num_users=1] = call_function[target=torch.ops.aten.sub.Tensor](args = (1, %abs_6), kwargs = {})
#   %relu_5 : [num_users=1] = call_function[target=torch.ops.aten.relu.default](args = (%sub_11,), kwargs = {})
#   %mul_17 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%relu_3, %relu_5), kwargs = {})
#   %mul_18 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%view_20, %mul_17), kwargs = {})
#   %index_put_3 : [num_users=1] = call_function[target=torch.ops.aten.index_put_.default](args = (%view_22, [%add_19], %mul_18, True), kwargs = {})
triton_poi_fused__to_copy_abs_add_index_add_mul_relu_rsub_sub_view_2 = async_compile.triton('triton_poi_fused__to_copy_abs_add_index_add_mul_relu_rsub_sub_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=[256], 
    filename=__file__,
    triton_meta={'signature': {0: '*fp32', 1: '*fp32', 2: '*fp32', 3: '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, 2, 3), equal_to_1=())]},
    inductor_meta={'autotune_hints': set(), 'kernel_name': 'triton_poi_fused__to_copy_abs_add_index_add_mul_relu_rsub_sub_view_2', 'mutated_arg_names': ['out_ptr2'], 'no_x_dim': False, 'num_load': 5, '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__to_copy_abs_add_index_add_mul_relu_rsub_sub_view_2(in_ptr0, in_ptr1, out_ptr2, xnumel, XBLOCK : tl.constexpr):
    xnumel = 256
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x0 = xindex
    tmp100 = tl.load(in_ptr1 + (x0), xmask)
    tmp0 = tl.full([1], 0, tl.int64)
    tmp1 = tmp0 >= tmp0
    tmp2 = tl.full([1], 1, tl.int64)
    tmp3 = tmp0 < tmp2
    tmp4 = tl.load(in_ptr0 + ((4*(x0 % 16)) + (64*(x0 // 64))), tmp3 & xmask, eviction_policy='evict_last', other=0.0)
    tmp5 = 0.0
    tmp6 = triton_helpers.maximum(tmp4, tmp5)
    tmp7 = 4.9999999998
    tmp8 = triton_helpers.minimum(tmp6, tmp7)
    tmp9 = tl.full(tmp8.shape, 0.0, tmp8.dtype)
    tmp10 = tl.where(tmp3, tmp8, tmp9)
    tmp11 = tmp0 >= tmp2
    tmp12 = tl.full([1], 2, tl.int64)
    tmp13 = tmp0 < tmp12
    tmp14 = tl.load(in_ptr0 + (1 + (4*(x0 % 16)) + (64*(x0 // 64))), tmp11 & xmask, eviction_policy='evict_last', other=0.0)
    tmp15 = triton_helpers.maximum(tmp14, tmp5)
    tmp16 = triton_helpers.minimum(tmp15, tmp7)
    tmp17 = tl.full(tmp16.shape, 0.0, tmp16.dtype)
    tmp18 = tl.where(tmp11, tmp16, tmp17)
    tmp19 = tl.where(tmp3, tmp10, tmp18)
    tmp20 = tmp19.to(tl.int64)
    tmp21 = tmp20 + tmp0
    tmp22 = tmp21.to(tl.float32)
    tmp23 = tmp19 - tmp22
    tmp24 = tl_math.abs(tmp23)
    tmp25 = 1.0
    tmp26 = tmp25 - tmp24
    tmp27 = tl.full([1], 0, tl.int32)
    tmp28 = triton_helpers.maximum(tmp27, tmp26)
    tmp29 = tmp2 >= tmp0
    tmp30 = tmp2 < tmp2
    tmp31 = tl.load(in_ptr0 + ((4*(x0 % 16)) + (64*(x0 // 64))), tmp30 & xmask, eviction_policy='evict_last', other=0.0)
    tmp32 = triton_helpers.maximum(tmp31, tmp5)
    tmp33 = triton_helpers.minimum(tmp32, tmp7)
    tmp34 = tl.full(tmp33.shape, 0.0, tmp33.dtype)
    tmp35 = tl.where(tmp30, tmp33, tmp34)
    tmp36 = tmp2 >= tmp2
    tmp37 = tmp2 < tmp12
    tmp38 = tl.load(in_ptr0 + (1 + (4*(x0 % 16)) + (64*(x0 // 64))), tmp36 & xmask, eviction_policy='evict_last', other=0.0)
    tmp39 = triton_helpers.maximum(tmp38, tmp5)
    tmp40 = triton_helpers.minimum(tmp39, tmp7)
    tmp41 = tl.full(tmp40.shape, 0.0, tmp40.dtype)
    tmp42 = tl.where(tmp36, tmp40, tmp41)
    tmp43 = tl.where(tmp30, tmp35, tmp42)
    tmp44 = tmp43.to(tl.int64)
    tmp45 = tmp44 + tmp0
    tmp46 = tmp45.to(tl.float32)
    tmp47 = tmp43 - tmp46
    tmp48 = tl_math.abs(tmp47)
    tmp49 = tmp25 - tmp48
    tmp50 = triton_helpers.maximum(tmp27, tmp49)
    tmp51 = tmp28 * tmp50
    tmp52 = (x0 // 64)
    tmp53 = tl.full(tmp52.shape, 0.0, tmp52.dtype)
    tmp54 = tl.where(tmp3, tmp52, tmp53)
    tmp55 = tmp11 & tmp13
    tmp56 = (x0 // 16) % 4
    tmp57 = tl.full(tmp56.shape, 0.0, tmp56.dtype)
    tmp58 = tl.where(tmp55, tmp56, tmp57)
    tmp59 = tmp0 >= tmp12
    tmp60 = tl.full([1], 3, tl.int64)
    tmp61 = tmp0 < tmp60
    tmp62 = tmp59 & tmp61
    tmp63 = (x0 // 4) % 4
    tmp64 = tl.full(tmp63.shape, 0.0, tmp63.dtype)
    tmp65 = tl.where(tmp62, tmp63, tmp64)
    tmp66 = tmp0 >= tmp60
    tmp67 = tl.full([1], 4, tl.int64)
    tmp68 = tmp0 < tmp67
    tmp69 = x0 % 4
    tmp70 = tl.full(tmp69.shape, 0.0, tmp69.dtype)
    tmp71 = tl.where(tmp66, tmp69, tmp70)
    tmp72 = tl.where(tmp62, tmp65, tmp71)
    tmp73 = tl.where(tmp55, tmp58, tmp72)
    tmp74 = tl.where(tmp3, tmp54, tmp73)
    tmp75 = tmp74 * tmp67
    tmp76 = tl.where(tmp30, tmp52, tmp53)
    tmp77 = tmp36 & tmp37
    tmp78 = tl.where(tmp77, tmp56, tmp57)
    tmp79 = tmp2 >= tmp12
    tmp80 = tmp2 < tmp60
    tmp81 = tmp79 & tmp80
    tmp82 = tl.where(tmp81, tmp63, tmp64)
    tmp83 = tmp2 >= tmp60
    tmp84 = tmp2 < tmp67
    tmp85 = tl.where(tmp83, tmp69, tmp70)
    tmp86 = tl.where(tmp81, tmp82, tmp85)
    tmp87 = tl.where(tmp77, tmp78, tmp86)
    tmp88 = tl.where(tmp30, tmp76, tmp87)
    tmp89 = tmp75 + tmp88
    tmp90 = tl.full([1], 7, tl.int64)
    tmp91 = tmp89 * tmp90
    tmp92 = tmp91 + tmp21
    tmp93 = tmp92 * tmp90
    tmp94 = tmp93 + tmp45
    tmp95 = tl.full([XBLOCK], 784, tl.int32)
    tmp96 = tmp94 + tmp95
    tmp97 = tmp94 < 0
    tmp98 = tl.where(tmp97, tmp96, tmp94)
    tl.device_assert(((0 <= tmp98) & (tmp98 < 784)) | ~(xmask), "index out of bounds: 0 <= tmp98 < 784")
    tmp101 = tmp100 * tmp51
    tmp102 = tmp44 + tmp2
    tmp103 = tmp102.to(tl.float32)
    tmp104 = tmp43 - tmp103
    tmp105 = tl_math.abs(tmp104)
    tmp106 = tmp25 - tmp105
    tmp107 = triton_helpers.maximum(tmp27, tmp106)
    tmp108 = tmp28 * tmp107
    tmp109 = tmp93 + tmp102
    tmp110 = tmp109 + tmp95
    tmp111 = tmp109 < 0
    tmp112 = tl.where(tmp111, tmp110, tmp109)
    tl.device_assert(((0 <= tmp112) & (tmp112 < 784)) | ~(xmask), "index out of bounds: 0 <= tmp112 < 784")
    tmp114 = tmp100 * tmp108
    tmp115 = tmp20 + tmp2
    tmp116 = tmp115.to(tl.float32)
    tmp117 = tmp19 - tmp116
    tmp118 = tl_math.abs(tmp117)
    tmp119 = tmp25 - tmp118
    tmp120 = triton_helpers.maximum(tmp27, tmp119)
    tmp121 = tmp120 * tmp50
    tmp122 = tmp91 + tmp115
    tmp123 = tmp122 * tmp90
    tmp124 = tmp123 + tmp45
    tmp125 = tmp124 + tmp95
    tmp126 = tmp124 < 0
    tmp127 = tl.where(tmp126, tmp125, tmp124)
    tl.device_assert(((0 <= tmp127) & (tmp127 < 784)) | ~(xmask), "index out of bounds: 0 <= tmp127 < 784")
    tmp129 = tmp100 * tmp121
    tmp130 = tmp120 * tmp107
    tmp131 = tmp123 + tmp102
    tmp132 = tmp131 + tmp95
    tmp133 = tmp131 < 0
    tmp134 = tl.where(tmp133, tmp132, tmp131)
    tl.device_assert(((0 <= tmp134) & (tmp134 < 784)) | ~(xmask), "index out of bounds: 0 <= tmp134 < 784")
    tmp136 = tmp100 * tmp130
    tl.atomic_add(out_ptr2 + (tl.broadcast_to(tmp98, [XBLOCK])), tmp101, xmask, sem='relaxed')
    tl.atomic_add(out_ptr2 + (tl.broadcast_to(tmp112, [XBLOCK])), tmp114, xmask, sem='relaxed')
    tl.atomic_add(out_ptr2 + (tl.broadcast_to(tmp127, [XBLOCK])), tmp129, xmask, sem='relaxed')
    tl.atomic_add(out_ptr2 + (tl.broadcast_to(tmp134, [XBLOCK])), tmp136, xmask, sem='relaxed')
''', 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)
        buf2 = empty_strided_cuda((4, 4, 4, 4), (64, 16, 4, 1), torch.float32)
        # Topologically Sorted Source Nodes: [add, inv_grid, imul, imul_1, inv_grid_1], Original ATen: [aten.add, aten.div, aten.mul]
        stream0 = get_raw_stream(0)
        triton_poi_fused_add_div_mul_0.run(arg1_1, buf2, 256, grid=grid(256), stream=stream0)
        del arg1_1
        buf5 = empty_strided_cuda((784, ), (1, ), torch.float32)
        # Topologically Sorted Source Nodes: [t_ravel], Original ATen: [aten.view]
        triton_poi_fused_view_1.run(buf5, 784, grid=grid(784), stream=stream0)
        # Topologically Sorted Source Nodes: [t_ravel, output_inds_i, indices_ravel_1, output_inds_j, corners_i, sub, abs_1, sub_1, bilinear_weights_i, corners_j, sub_2, abs_2, sub_3, relu_1, bilinear_weights, mul_1, index_add_, indices_ravel_4, output_inds_j_1, corners_j_1, sub_4, abs_3, sub_5, relu_2, bilinear_weights_1, mul_6, index_add__1, output_inds_i_1, indices_ravel_7, output_inds_j_2, corners_i_1, sub_6, abs_4, sub_7, bilinear_weights_i_1, corners_j_2, sub_8, abs_5, sub_9, relu_4, bilinear_weights_2, mul_11, index_add__2, indices_ravel_10, output_inds_j_3, corners_j_3, sub_10, abs_6, sub_11, relu_5, bilinear_weights_3, mul_16, index_add__3], Original ATen: [aten.view, aten.add, aten._to_copy, aten.sub, aten.abs, aten.rsub, aten.relu, aten.mul, aten.index_add]
        triton_poi_fused__to_copy_abs_add_index_add_mul_relu_rsub_sub_view_2.run(buf2, arg0_1, buf5, 256, grid=grid(256), stream=stream0)
        del arg0_1
        del buf2
    return (reinterpret_tensor(buf5, (4, 4, 4, 4), (196, 49, 7, 1), 8), )


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 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 math as tl_math
import numpy as np
import torch.utils.data
import torch
from torch import nn
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
empty_strided_cuda = torch._C._dynamo.guards._empty_strided_cuda
reinterpret_tensor = torch._C._dynamo.guards._reinterpret_tensor


@triton.jit
def triton_poi_fused_add_div_mul_0(in_ptr0, out_ptr0, xnumel, XBLOCK: tl.
    constexpr):
    xnumel = 256
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x0 = xindex % 4
    x1 = xindex // 4
    x2 = xindex
    tmp7 = tl.load(in_ptr0 + 4 * x1, xmask, eviction_policy='evict_last')
    tmp15 = tl.load(in_ptr0 + (1 + 4 * x1), xmask, eviction_policy='evict_last'
        )
    tmp23 = tl.load(in_ptr0 + x2, xmask)
    tmp0 = x0
    tmp1 = tl.full([1], 1, tl.int32)
    tmp2 = tmp0 == tmp1
    tmp3 = tmp1 == tmp1
    tmp4 = tl.full([1], 0, tl.int32)
    tmp5 = tmp1 == tmp4
    tmp6 = tmp4 == tmp4
    tmp8 = 1.0
    tmp9 = tmp7 + tmp8
    tmp10 = 0.5
    tmp11 = tmp9 * tmp10
    tmp12 = 4.0
    tmp13 = tmp11 * tmp12
    tmp14 = tl.where(tmp6, tmp13, tmp11)
    tmp16 = tmp15 + tmp8
    tmp17 = tmp16 * tmp10
    tmp18 = tl.where(tmp5, tmp13, tmp17)
    tmp19 = tl.where(tmp5, tmp14, tmp18)
    tmp20 = tmp19 * tmp12
    tmp21 = tl.where(tmp3, tmp20, tmp19)
    tmp22 = tmp0 == tmp4
    tmp24 = tmp23 + tmp8
    tmp25 = tmp24 * tmp10
    tmp26 = tl.where(tmp22, tmp13, tmp25)
    tmp27 = tl.where(tmp22, tmp14, tmp26)
    tmp28 = tl.where(tmp2, tmp20, tmp27)
    tmp29 = tl.where(tmp2, tmp21, tmp28)
    tmp30 = tmp29 + tmp8
    tl.store(out_ptr0 + x2, tmp30, xmask)


@triton.jit
def triton_poi_fused_view_1(out_ptr0, xnumel, XBLOCK: tl.constexpr):
    xnumel = 784
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x0 = xindex
    tmp0 = 0.0
    tl.store(out_ptr0 + x0, tmp0, xmask)


@triton.jit
def triton_poi_fused__to_copy_abs_add_index_add_mul_relu_rsub_sub_view_2(
    in_ptr0, in_ptr1, out_ptr2, xnumel, XBLOCK: tl.constexpr):
    xnumel = 256
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x0 = xindex
    tmp100 = tl.load(in_ptr1 + x0, xmask)
    tmp0 = tl.full([1], 0, tl.int64)
    tmp2 = tl.full([1], 1, tl.int64)
    tmp3 = tmp0 < tmp2
    tmp4 = tl.load(in_ptr0 + (4 * (x0 % 16) + 64 * (x0 // 64)), tmp3 &
        xmask, eviction_policy='evict_last', other=0.0)
    tmp5 = 0.0
    tmp6 = triton_helpers.maximum(tmp4, tmp5)
    tmp7 = 4.9999999998
    tmp8 = triton_helpers.minimum(tmp6, tmp7)
    tmp9 = tl.full(tmp8.shape, 0.0, tmp8.dtype)
    tmp10 = tl.where(tmp3, tmp8, tmp9)
    tmp11 = tmp0 >= tmp2
    tmp12 = tl.full([1], 2, tl.int64)
    tmp13 = tmp0 < tmp12
    tmp14 = tl.load(in_ptr0 + (1 + 4 * (x0 % 16) + 64 * (x0 // 64)), tmp11 &
        xmask, eviction_policy='evict_last', other=0.0)
    tmp15 = triton_helpers.maximum(tmp14, tmp5)
    tmp16 = triton_helpers.minimum(tmp15, tmp7)
    tmp17 = tl.full(tmp16.shape, 0.0, tmp16.dtype)
    tmp18 = tl.where(tmp11, tmp16, tmp17)
    tmp19 = tl.where(tmp3, tmp10, tmp18)
    tmp20 = tmp19.to(tl.int64)
    tmp21 = tmp20 + tmp0
    tmp22 = tmp21.to(tl.float32)
    tmp23 = tmp19 - tmp22
    tmp24 = tl_math.abs(tmp23)
    tmp25 = 1.0
    tmp26 = tmp25 - tmp24
    tmp27 = tl.full([1], 0, tl.int32)
    tmp28 = triton_helpers.maximum(tmp27, tmp26)
    tmp30 = tmp2 < tmp2
    tmp31 = tl.load(in_ptr0 + (4 * (x0 % 16) + 64 * (x0 // 64)), tmp30 &
        xmask, eviction_policy='evict_last', other=0.0)
    tmp32 = triton_helpers.maximum(tmp31, tmp5)
    tmp33 = triton_helpers.minimum(tmp32, tmp7)
    tmp34 = tl.full(tmp33.shape, 0.0, tmp33.dtype)
    tmp35 = tl.where(tmp30, tmp33, tmp34)
    tmp36 = tmp2 >= tmp2
    tmp37 = tmp2 < tmp12
    tmp38 = tl.load(in_ptr0 + (1 + 4 * (x0 % 16) + 64 * (x0 // 64)), tmp36 &
        xmask, eviction_policy='evict_last', other=0.0)
    tmp39 = triton_helpers.maximum(tmp38, tmp5)
    tmp40 = triton_helpers.minimum(tmp39, tmp7)
    tmp41 = tl.full(tmp40.shape, 0.0, tmp40.dtype)
    tmp42 = tl.where(tmp36, tmp40, tmp41)
    tmp43 = tl.where(tmp30, tmp35, tmp42)
    tmp44 = tmp43.to(tl.int64)
    tmp45 = tmp44 + tmp0
    tmp46 = tmp45.to(tl.float32)
    tmp47 = tmp43 - tmp46
    tmp48 = tl_math.abs(tmp47)
    tmp49 = tmp25 - tmp48
    tmp50 = triton_helpers.maximum(tmp27, tmp49)
    tmp51 = tmp28 * tmp50
    tmp52 = x0 // 64
    tmp53 = tl.full(tmp52.shape, 0.0, tmp52.dtype)
    tmp54 = tl.where(tmp3, tmp52, tmp53)
    tmp55 = tmp11 & tmp13
    tmp56 = x0 // 16 % 4
    tmp57 = tl.full(tmp56.shape, 0.0, tmp56.dtype)
    tmp58 = tl.where(tmp55, tmp56, tmp57)
    tmp59 = tmp0 >= tmp12
    tmp60 = tl.full([1], 3, tl.int64)
    tmp61 = tmp0 < tmp60
    tmp62 = tmp59 & tmp61
    tmp63 = x0 // 4 % 4
    tmp64 = tl.full(tmp63.shape, 0.0, tmp63.dtype)
    tmp65 = tl.where(tmp62, tmp63, tmp64)
    tmp66 = tmp0 >= tmp60
    tmp67 = tl.full([1], 4, tl.int64)
    tmp69 = x0 % 4
    tmp70 = tl.full(tmp69.shape, 0.0, tmp69.dtype)
    tmp71 = tl.where(tmp66, tmp69, tmp70)
    tmp72 = tl.where(tmp62, tmp65, tmp71)
    tmp73 = tl.where(tmp55, tmp58, tmp72)
    tmp74 = tl.where(tmp3, tmp54, tmp73)
    tmp75 = tmp74 * tmp67
    tmp76 = tl.where(tmp30, tmp52, tmp53)
    tmp77 = tmp36 & tmp37
    tmp78 = tl.where(tmp77, tmp56, tmp57)
    tmp79 = tmp2 >= tmp12
    tmp80 = tmp2 < tmp60
    tmp81 = tmp79 & tmp80
    tmp82 = tl.where(tmp81, tmp63, tmp64)
    tmp83 = tmp2 >= tmp60
    tmp85 = tl.where(tmp83, tmp69, tmp70)
    tmp86 = tl.where(tmp81, tmp82, tmp85)
    tmp87 = tl.where(tmp77, tmp78, tmp86)
    tmp88 = tl.where(tmp30, tmp76, tmp87)
    tmp89 = tmp75 + tmp88
    tmp90 = tl.full([1], 7, tl.int64)
    tmp91 = tmp89 * tmp90
    tmp92 = tmp91 + tmp21
    tmp93 = tmp92 * tmp90
    tmp94 = tmp93 + tmp45
    tmp95 = tl.full([XBLOCK], 784, tl.int32)
    tmp96 = tmp94 + tmp95
    tmp97 = tmp94 < 0
    tmp98 = tl.where(tmp97, tmp96, tmp94)
    tl.device_assert((0 <= tmp98) & (tmp98 < 784) | ~xmask,
        'index out of bounds: 0 <= tmp98 < 784')
    tmp101 = tmp100 * tmp51
    tmp102 = tmp44 + tmp2
    tmp103 = tmp102.to(tl.float32)
    tmp104 = tmp43 - tmp103
    tmp105 = tl_math.abs(tmp104)
    tmp106 = tmp25 - tmp105
    tmp107 = triton_helpers.maximum(tmp27, tmp106)
    tmp108 = tmp28 * tmp107
    tmp109 = tmp93 + tmp102
    tmp110 = tmp109 + tmp95
    tmp111 = tmp109 < 0
    tmp112 = tl.where(tmp111, tmp110, tmp109)
    tl.device_assert((0 <= tmp112) & (tmp112 < 784) | ~xmask,
        'index out of bounds: 0 <= tmp112 < 784')
    tmp114 = tmp100 * tmp108
    tmp115 = tmp20 + tmp2
    tmp116 = tmp115.to(tl.float32)
    tmp117 = tmp19 - tmp116
    tmp118 = tl_math.abs(tmp117)
    tmp119 = tmp25 - tmp118
    tmp120 = triton_helpers.maximum(tmp27, tmp119)
    tmp121 = tmp120 * tmp50
    tmp122 = tmp91 + tmp115
    tmp123 = tmp122 * tmp90
    tmp124 = tmp123 + tmp45
    tmp125 = tmp124 + tmp95
    tmp126 = tmp124 < 0
    tmp127 = tl.where(tmp126, tmp125, tmp124)
    tl.device_assert((0 <= tmp127) & (tmp127 < 784) | ~xmask,
        'index out of bounds: 0 <= tmp127 < 784')
    tmp129 = tmp100 * tmp121
    tmp130 = tmp120 * tmp107
    tmp131 = tmp123 + tmp102
    tmp132 = tmp131 + tmp95
    tmp133 = tmp131 < 0
    tmp134 = tl.where(tmp133, tmp132, tmp131)
    tl.device_assert((0 <= tmp134) & (tmp134 < 784) | ~xmask,
        'index out of bounds: 0 <= tmp134 < 784')
    tmp136 = tmp100 * tmp130
    tl.atomic_add(out_ptr2 + tl.broadcast_to(tmp98, [XBLOCK]), tmp101,
        xmask, sem='relaxed')
    tl.atomic_add(out_ptr2 + tl.broadcast_to(tmp112, [XBLOCK]), tmp114,
        xmask, sem='relaxed')
    tl.atomic_add(out_ptr2 + tl.broadcast_to(tmp127, [XBLOCK]), tmp129,
        xmask, sem='relaxed')
    tl.atomic_add(out_ptr2 + tl.broadcast_to(tmp134, [XBLOCK]), tmp136,
        xmask, sem='relaxed')


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)
        buf2 = empty_strided_cuda((4, 4, 4, 4), (64, 16, 4, 1), torch.float32)
        get_raw_stream(0)
        triton_poi_fused_add_div_mul_0[grid(256)](arg1_1, buf2, 256, XBLOCK
            =256, num_warps=4, num_stages=1)
        del arg1_1
        buf5 = empty_strided_cuda((784,), (1,), torch.float32)
        triton_poi_fused_view_1[grid(784)](buf5, 784, XBLOCK=256, num_warps
            =4, num_stages=1)
        triton_poi_fused__to_copy_abs_add_index_add_mul_relu_rsub_sub_view_2[
            grid(256)](buf2, arg0_1, buf5, 256, XBLOCK=128, num_warps=4,
            num_stages=1)
        del arg0_1
        del buf2
    return reinterpret_tensor(buf5, (4, 4, 4, 4), (196, 49, 7, 1), 8),


def ravel_multi_index(indices, shape):
    indices_ravel = indices[0]
    for i in range(1, len(indices)):
        indices_ravel = indices_ravel * shape[i] + indices[i]
    return indices_ravel


def add_repeated(t, indices, values):
    shape = t.shape
    t_ravel = t.view(t.numel())
    indices_ravel = ravel_multi_index(indices, shape)
    t_ravel.index_add_(0, indices_ravel, values)


def meshgrid_tensor(*sizes, normalize=True, device='cuda:0'):
    if not normalize:
        aranges = [torch.arange(cur_size, device=device) for cur_size in sizes]
        grids = torch.meshgrid(aranges)
        grid = torch.stack(grids, dim=-1)
    else:
        aranges = [torch.arange(cur_size, device=device).float() for
            cur_size in sizes]
        grids = torch.meshgrid(aranges)
        grid = np.stack([(cur_grid / float(max(sizes[i] - 1, 1))) for i,
            cur_grid in enumerate(grids)], dim=-1)
    return grid


class InvGridSamplerNumeratorNew(nn.Module):
    eps = 1e-10

    def __init__(self, OH=None, OW=None):
        super(InvGridSamplerNumeratorNew, self).__init__()
        self.OH = OH
        self.OW = OW

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