# 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/b5/cb5jk3crx33kn6vxoefz2ccunrf65n2pxkom4gzxn2lov6ze7r4n.py
# Topologically Sorted Source Nodes: [cross_entropy, cross_entropy_1], Original ATen: [aten._log_softmax]
# Source node to ATen node mapping:
#   cross_entropy => amax, sub
#   cross_entropy_1 => amax_1, sub_2
# Graph fragment:
#   %amax : [num_users=1] = call_function[target=torch.ops.aten.amax.default](args = (%arg1_1, [1], True), kwargs = {})
#   %sub : [num_users=2] = call_function[target=torch.ops.aten.sub.Tensor](args = (%arg1_1, %amax), kwargs = {})
#   %amax_1 : [num_users=1] = call_function[target=torch.ops.aten.amax.default](args = (%arg1_1, [1], True), kwargs = {})
#   %sub_2 : [num_users=2] = call_function[target=torch.ops.aten.sub.Tensor](args = (%arg1_1, %amax_1), kwargs = {})
triton_poi_fused__log_softmax_0 = async_compile.triton('triton_poi_fused__log_softmax_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: '*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__log_softmax_0', 'mutated_arg_names': [], 'no_x_dim': False, 'num_load': 5, '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__log_softmax_0(in_ptr0, out_ptr0, out_ptr1, xnumel, XBLOCK : tl.constexpr):
    xnumel = 256
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x3 = xindex
    x0 = xindex % 16
    x2 = (xindex // 64)
    tmp0 = tl.load(in_ptr0 + (x3), xmask)
    tmp1 = tl.load(in_ptr0 + (x0 + (64*x2)), xmask, eviction_policy='evict_last')
    tmp2 = tl.load(in_ptr0 + (16 + x0 + (64*x2)), xmask, eviction_policy='evict_last')
    tmp4 = tl.load(in_ptr0 + (32 + x0 + (64*x2)), xmask, eviction_policy='evict_last')
    tmp6 = tl.load(in_ptr0 + (48 + x0 + (64*x2)), xmask, eviction_policy='evict_last')
    tmp3 = triton_helpers.maximum(tmp1, tmp2)
    tmp5 = triton_helpers.maximum(tmp3, tmp4)
    tmp7 = triton_helpers.maximum(tmp5, tmp6)
    tmp8 = tmp0 - tmp7
    tl.store(out_ptr0 + (x3), tmp8, xmask)
    tl.store(out_ptr1 + (x3), tmp8, xmask)
''', device_str='cuda')


# kernel path: runs/run_shard_1/inductor_cache/k7/ck74ibzkhizd2qk4whd4yyiurqnch67rweqz3vbgxiwqp7djcpfw.py
# Topologically Sorted Source Nodes: [trues1, cross_entropy], Original ATen: [aten._to_copy, aten.nll_loss2d_forward]
# Source node to ATen node mapping:
#   cross_entropy => full_default_1, ne_1, ne_2, neg, sum_2, sum_3, where_1
#   trues1 => convert_element_type
# Graph fragment:
#   %convert_element_type : [num_users=4] = call_function[target=torch.ops.prims.convert_element_type.default](args = (%select_2, torch.int64), kwargs = {})
#   %ne_1 : [num_users=1] = call_function[target=torch.ops.aten.ne.Scalar](args = (%convert_element_type, -100), kwargs = {})
#   %neg : [num_users=1] = call_function[target=torch.ops.aten.neg.default](args = (%squeeze,), kwargs = {})
#   %full_default_1 : [num_users=1] = call_function[target=torch.ops.aten.full.default](args = ([], 0.0), kwargs = {dtype: torch.float32, layout: torch.strided, device: cuda:0, pin_memory: False})
#   %where_1 : [num_users=1] = call_function[target=torch.ops.aten.where.self](args = (%ne_1, %neg, %full_default_1), kwargs = {})
#   %sum_3 : [num_users=1] = call_function[target=torch.ops.aten.sum.default](args = (%where_1,), kwargs = {})
#   %ne_2 : [num_users=1] = call_function[target=torch.ops.aten.ne.Scalar](args = (%convert_element_type, -100), kwargs = {})
#   %sum_2 : [num_users=1] = call_function[target=torch.ops.aten.sum.default](args = (%ne_2,), kwargs = {})
triton_per_fused__to_copy_nll_loss2d_forward_1 = async_compile.triton('triton_per_fused__to_copy_nll_loss2d_forward_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, 64],
    reduction_hint=ReductionHint.INNER,
    filename=__file__,
    triton_meta={'signature': {0: '*fp32', 1: '*fp32', 2: '*fp32', 3: '*i64', 4: 'i32', 5: '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': {4: 1}, 'configs': [AttrsDescriptor(divisible_by_16=(0, 1, 2, 3, 5), equal_to_1=(4,))]},
    inductor_meta={'autotune_hints': set(), 'kernel_name': 'triton_per_fused__to_copy_nll_loss2d_forward_1', 'mutated_arg_names': [], 'no_x_dim': False, 'num_load': 5, 'num_reduction': 2, '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__to_copy_nll_loss2d_forward_1(in_ptr0, in_ptr1, out_ptr0, out_ptr1, xnumel, rnumel, XBLOCK : tl.constexpr):
    xnumel = 1
    rnumel = 64
    RBLOCK: tl.constexpr = 64
    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)
    r2 = rindex
    r0 = rindex % 16
    r1 = (rindex // 16)
    tmp0 = tl.load(in_ptr0 + (r2), None)
    tmp12 = tl.load(in_ptr1 + (r0 + (64*r1)), None)
    tmp14 = tl.load(in_ptr1 + (16 + r0 + (64*r1)), None)
    tmp17 = tl.load(in_ptr1 + (32 + r0 + (64*r1)), None)
    tmp20 = tl.load(in_ptr1 + (48 + r0 + (64*r1)), None)
    tmp1 = tmp0.to(tl.int64)
    tmp2 = tl.full([1, 1], -100, tl.int64)
    tmp3 = tmp1 != tmp2
    tmp4 = tl.full([1, 1], 0, tl.int64)
    tmp5 = tl.where(tmp3, tmp1, tmp4)
    tmp6 = tl.full([XBLOCK, RBLOCK], 4, tl.int32)
    tmp7 = tmp5 + tmp6
    tmp8 = tmp5 < 0
    tmp9 = tl.where(tmp8, tmp7, tmp5)
    tl.device_assert((0 <= tmp9) & (tmp9 < 4), "index out of bounds: 0 <= tmp9 < 4")
    tmp11 = tl.load(in_ptr1 + (r0 + (16*tmp9) + (64*r1)), None)
    tmp13 = tl_math.exp(tmp12)
    tmp15 = tl_math.exp(tmp14)
    tmp16 = tmp13 + tmp15
    tmp18 = tl_math.exp(tmp17)
    tmp19 = tmp16 + tmp18
    tmp21 = tl_math.exp(tmp20)
    tmp22 = tmp19 + tmp21
    tmp23 = tl_math.log(tmp22)
    tmp24 = tmp11 - tmp23
    tmp25 = -tmp24
    tmp26 = 0.0
    tmp27 = tl.where(tmp3, tmp25, tmp26)
    tmp28 = tl.broadcast_to(tmp27, [XBLOCK, RBLOCK])
    tmp30 = tl.sum(tmp28, 1)[:, None]
    tmp31 = tmp3.to(tl.int64)
    tmp32 = tl.broadcast_to(tmp31, [XBLOCK, RBLOCK])
    tmp34 = tl.sum(tmp32, 1)[:, None]
    tl.store(out_ptr0 + (tl.full([XBLOCK, 1], 0, tl.int32)), tmp30, None)
    tl.store(out_ptr1 + (tl.full([XBLOCK, 1], 0, tl.int32)), tmp34, None)
''', device_str='cuda')


# kernel path: runs/run_shard_1/inductor_cache/ei/ceimgl2hwvul4obyyrtzgmervwa4zbjy7ve6mhxrqnthpt42ulbt.py
# Topologically Sorted Source Nodes: [trues2, cross_entropy_1], Original ATen: [aten._to_copy, aten.nll_loss2d_forward]
# Source node to ATen node mapping:
#   cross_entropy_1 => full_default_3, ne_4, ne_5, neg_1, sum_5, sum_6, where_3
#   trues2 => convert_element_type_1
# Graph fragment:
#   %convert_element_type_1 : [num_users=4] = call_function[target=torch.ops.prims.convert_element_type.default](args = (%select_3, torch.int64), kwargs = {})
#   %ne_4 : [num_users=1] = call_function[target=torch.ops.aten.ne.Scalar](args = (%convert_element_type_1, -100), kwargs = {})
#   %neg_1 : [num_users=1] = call_function[target=torch.ops.aten.neg.default](args = (%squeeze_1,), kwargs = {})
#   %full_default_3 : [num_users=1] = call_function[target=torch.ops.aten.full.default](args = ([], 0.0), kwargs = {dtype: torch.float32, layout: torch.strided, device: cuda:0, pin_memory: False})
#   %where_3 : [num_users=1] = call_function[target=torch.ops.aten.where.self](args = (%ne_4, %neg_1, %full_default_3), kwargs = {})
#   %sum_6 : [num_users=1] = call_function[target=torch.ops.aten.sum.default](args = (%where_3,), kwargs = {})
#   %ne_5 : [num_users=1] = call_function[target=torch.ops.aten.ne.Scalar](args = (%convert_element_type_1, -100), kwargs = {})
#   %sum_5 : [num_users=1] = call_function[target=torch.ops.aten.sum.default](args = (%ne_5,), kwargs = {})
triton_per_fused__to_copy_nll_loss2d_forward_2 = async_compile.triton('triton_per_fused__to_copy_nll_loss2d_forward_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.persistent_reduction(
    size_hints=[1, 64],
    reduction_hint=ReductionHint.INNER,
    filename=__file__,
    triton_meta={'signature': {0: '*fp32', 1: '*fp32', 2: '*fp32', 3: '*i64', 4: 'i32', 5: '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': {4: 1}, 'configs': [AttrsDescriptor(divisible_by_16=(0, 1, 2, 3, 5), equal_to_1=(4,))]},
    inductor_meta={'autotune_hints': set(), 'kernel_name': 'triton_per_fused__to_copy_nll_loss2d_forward_2', 'mutated_arg_names': [], 'no_x_dim': False, 'num_load': 5, 'num_reduction': 2, '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__to_copy_nll_loss2d_forward_2(in_ptr0, in_ptr1, out_ptr0, out_ptr1, xnumel, rnumel, XBLOCK : tl.constexpr):
    xnumel = 1
    rnumel = 64
    RBLOCK: tl.constexpr = 64
    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)
    r2 = rindex
    r0 = rindex % 16
    r1 = (rindex // 16)
    tmp0 = tl.load(in_ptr0 + (64 + r2), None)
    tmp12 = tl.load(in_ptr1 + (r0 + (64*r1)), None)
    tmp14 = tl.load(in_ptr1 + (16 + r0 + (64*r1)), None)
    tmp17 = tl.load(in_ptr1 + (32 + r0 + (64*r1)), None)
    tmp20 = tl.load(in_ptr1 + (48 + r0 + (64*r1)), None)
    tmp1 = tmp0.to(tl.int64)
    tmp2 = tl.full([1, 1], -100, tl.int64)
    tmp3 = tmp1 != tmp2
    tmp4 = tl.full([1, 1], 0, tl.int64)
    tmp5 = tl.where(tmp3, tmp1, tmp4)
    tmp6 = tl.full([XBLOCK, RBLOCK], 4, tl.int32)
    tmp7 = tmp5 + tmp6
    tmp8 = tmp5 < 0
    tmp9 = tl.where(tmp8, tmp7, tmp5)
    tl.device_assert((0 <= tmp9) & (tmp9 < 4), "index out of bounds: 0 <= tmp9 < 4")
    tmp11 = tl.load(in_ptr1 + (r0 + (16*tmp9) + (64*r1)), None)
    tmp13 = tl_math.exp(tmp12)
    tmp15 = tl_math.exp(tmp14)
    tmp16 = tmp13 + tmp15
    tmp18 = tl_math.exp(tmp17)
    tmp19 = tmp16 + tmp18
    tmp21 = tl_math.exp(tmp20)
    tmp22 = tmp19 + tmp21
    tmp23 = tl_math.log(tmp22)
    tmp24 = tmp11 - tmp23
    tmp25 = -tmp24
    tmp26 = 0.0
    tmp27 = tl.where(tmp3, tmp25, tmp26)
    tmp28 = tl.broadcast_to(tmp27, [XBLOCK, RBLOCK])
    tmp30 = tl.sum(tmp28, 1)[:, None]
    tmp31 = tmp3.to(tl.int64)
    tmp32 = tl.broadcast_to(tmp31, [XBLOCK, RBLOCK])
    tmp34 = tl.sum(tmp32, 1)[:, None]
    tl.store(out_ptr0 + (tl.full([XBLOCK, 1], 0, tl.int32)), tmp30, None)
    tl.store(out_ptr1 + (tl.full([XBLOCK, 1], 0, tl.int32)), tmp34, None)
''', device_str='cuda')


# kernel path: runs/run_shard_1/inductor_cache/zd/czdyhcm636chtdkvsfo234ieox46sxe2vfejbylo3mwgb2vsmtbq.py
# Topologically Sorted Source Nodes: [cross_entropy, mul, cross_entropy_1, sub, mul_1, loss], Original ATen: [aten.nll_loss2d_forward, aten.mul, aten.rsub, aten.add]
# Source node to ATen node mapping:
#   cross_entropy => convert_element_type_2, div
#   cross_entropy_1 => convert_element_type_3, div_1
#   loss => add
#   mul => mul
#   mul_1 => mul_1
#   sub => sub_4
# Graph fragment:
#   %convert_element_type_2 : [num_users=1] = call_function[target=torch.ops.prims.convert_element_type.default](args = (%sum_2, torch.float32), kwargs = {})
#   %div : [num_users=1] = call_function[target=torch.ops.aten.div.Tensor](args = (%sum_3, %convert_element_type_2), kwargs = {})
#   %mul : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%div, %select_1), kwargs = {})
#   %convert_element_type_3 : [num_users=1] = call_function[target=torch.ops.prims.convert_element_type.default](args = (%sum_5, torch.float32), kwargs = {})
#   %div_1 : [num_users=1] = call_function[target=torch.ops.aten.div.Tensor](args = (%sum_6, %convert_element_type_3), kwargs = {})
#   %sub_4 : [num_users=1] = call_function[target=torch.ops.aten.sub.Tensor](args = (1, %select_1), kwargs = {})
#   %mul_1 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%div_1, %sub_4), kwargs = {})
#   %add : [num_users=1] = call_function[target=torch.ops.aten.add.Tensor](args = (%mul, %mul_1), kwargs = {})
triton_poi_fused_add_mul_nll_loss2d_forward_rsub_3 = async_compile.triton('triton_poi_fused_add_mul_nll_loss2d_forward_rsub_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=[16], 
    filename=__file__,
    triton_meta={'signature': {0: '*fp32', 1: '*i64', 2: '*fp32', 3: '*fp32', 4: '*i64', 5: '*fp32', 6: '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), equal_to_1=())]},
    inductor_meta={'autotune_hints': set(), 'kernel_name': 'triton_poi_fused_add_mul_nll_loss2d_forward_rsub_3', 'mutated_arg_names': [], 'no_x_dim': False, 'num_load': 5, '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_mul_nll_loss2d_forward_rsub_3(in_ptr0, in_ptr1, in_ptr2, in_ptr3, in_ptr4, out_ptr0, xnumel, XBLOCK : tl.constexpr):
    xnumel = 16
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x0 = xindex
    tmp0 = tl.load(in_ptr0 + (0))
    tmp1 = tl.broadcast_to(tmp0, [XBLOCK])
    tmp2 = tl.load(in_ptr1 + (0))
    tmp3 = tl.broadcast_to(tmp2, [XBLOCK])
    tmp6 = tl.load(in_ptr2 + (192 + x0), xmask)
    tmp8 = tl.load(in_ptr3 + (0))
    tmp9 = tl.broadcast_to(tmp8, [XBLOCK])
    tmp10 = tl.load(in_ptr4 + (0))
    tmp11 = tl.broadcast_to(tmp10, [XBLOCK])
    tmp4 = tmp3.to(tl.float32)
    tmp5 = tmp1 / tmp4
    tmp7 = tmp5 * tmp6
    tmp12 = tmp11.to(tl.float32)
    tmp13 = tmp9 / tmp12
    tmp14 = 1.0
    tmp15 = tmp14 - tmp6
    tmp16 = tmp13 * tmp15
    tmp17 = tmp7 + tmp16
    tl.store(out_ptr0 + (x0), tmp17, 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, 4), (64, 16, 4, 1), torch.float32)
        buf3 = empty_strided_cuda((4, 4, 4, 4), (64, 16, 4, 1), torch.float32)
        # Topologically Sorted Source Nodes: [cross_entropy, cross_entropy_1], Original ATen: [aten._log_softmax]
        stream0 = get_raw_stream(0)
        triton_poi_fused__log_softmax_0.run(arg1_1, buf0, buf3, 256, grid=grid(256), stream=stream0)
        del arg1_1
        buf1 = empty_strided_cuda((), (), torch.float32)
        buf2 = empty_strided_cuda((), (), torch.int64)
        # Topologically Sorted Source Nodes: [trues1, cross_entropy], Original ATen: [aten._to_copy, aten.nll_loss2d_forward]
        triton_per_fused__to_copy_nll_loss2d_forward_1.run(arg0_1, buf0, buf1, buf2, 1, 64, grid=grid(1), stream=stream0)
        del buf0
        buf4 = empty_strided_cuda((), (), torch.float32)
        buf5 = empty_strided_cuda((), (), torch.int64)
        # Topologically Sorted Source Nodes: [trues2, cross_entropy_1], Original ATen: [aten._to_copy, aten.nll_loss2d_forward]
        triton_per_fused__to_copy_nll_loss2d_forward_2.run(arg0_1, buf3, buf4, buf5, 1, 64, grid=grid(1), stream=stream0)
        del buf3
        buf6 = empty_strided_cuda((4, 4), (4, 1), torch.float32)
        # Topologically Sorted Source Nodes: [cross_entropy, mul, cross_entropy_1, sub, mul_1, loss], Original ATen: [aten.nll_loss2d_forward, aten.mul, aten.rsub, aten.add]
        triton_poi_fused_add_mul_nll_loss2d_forward_rsub_3.run(buf1, buf2, arg0_1, buf4, buf5, buf6, 16, grid=grid(16), stream=stream0)
        del arg0_1
        del buf1
        del buf2
        del buf4
        del buf5
    return (buf6, )


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 math
import random
import torch
import numpy as np
import typing as t
from torch import nn


class GridMixupLoss(nn.Module):
    """ Implementation of GridMixup loss

    :param alpha: Percent of the first image on the crop. Can be float or Tuple[float, float]
                    - if float: lambda parameter gets from the beta-distribution np.random.beta(alpha, alpha)
                    - if Tuple[float, float]: lambda parameter gets from the uniform
                        distribution np.random.uniform(alpha[0], alpha[1])
    :param n_holes_x: Number of holes by OX
    :param hole_aspect_ratio: hole aspect ratio
    :param crop_area_ratio: Define percentage of the crop area
    :param crop_aspect_ratio: Define crop aspect ratio
    """

    def __init__(self, alpha: 't.Union[float, t.Tuple[float, float]]'=(0.1,
        0.9), n_holes_x: 't.Union[int, t.Tuple[int, int]]'=20,
        hole_aspect_ratio: 't.Union[float, t.Tuple[float, float]]'=1.0,
        crop_area_ratio: 't.Union[float, t.Tuple[float, float]]'=1.0,
        crop_aspect_ratio: 't.Union[float, t.Tuple[float, float]]'=1.0):
        super().__init__()
        self.alpha = alpha
        self.n_holes_x = n_holes_x
        self.hole_aspect_ratio = hole_aspect_ratio
        self.crop_area_ratio = crop_area_ratio
        self.crop_aspect_ratio = crop_aspect_ratio
        if isinstance(self.n_holes_x, int):
            self.n_holes_x = self.n_holes_x, self.n_holes_x
        if isinstance(self.hole_aspect_ratio, float):
            self.hole_aspect_ratio = (self.hole_aspect_ratio, self.
                hole_aspect_ratio)
        if isinstance(self.crop_area_ratio, float):
            self.crop_area_ratio = self.crop_area_ratio, self.crop_area_ratio
        if isinstance(self.crop_aspect_ratio, float):
            self.crop_aspect_ratio = (self.crop_aspect_ratio, self.
                crop_aspect_ratio)
        self.loss = nn.CrossEntropyLoss()

    def __str__(self):
        return 'gridmixup'

    @staticmethod
    def _get_random_crop(height: 'int', width: 'int', crop_area_ratio:
        'float', crop_aspect_ratio: 'float') ->t.Tuple:
        crop_area = int(height * width * crop_area_ratio)
        crop_width = int(np.sqrt(crop_area / crop_aspect_ratio))
        crop_height = int(crop_width * crop_aspect_ratio)
        cx = np.random.random()
        cy = np.random.random()
        y1 = int((height - crop_height) * cy)
        y2 = y1 + crop_height
        x1 = int((width - crop_width) * cx)
        x2 = x1 + crop_width
        return x1, y1, x2, y2

    def _get_gridmask(self, image_shape: 't.Tuple[int, int]',
        crop_area_ratio: 'float', crop_aspect_ratio: 'float', lam: 'float',
        nx: 'int', ar: 'float') ->np.ndarray:
        """ Method make grid mask

        :param image_shape: Shape of the images
        :param lam: Lambda parameter
        :param crop_area_ratio: Ratio of the crop area
        :param crop_aspect_ratio: Aspect ratio of the crop
        :param nx: Amount of holes by width
        :param ar: Aspect ratio of the hole
        :return: Binary mask, where holes == 1, background == 0
        """
        img_height, img_width = image_shape
        xc1, yc1, xc2, yc2 = self._get_random_crop(height=img_height, width
            =img_width, crop_area_ratio=crop_area_ratio, crop_aspect_ratio=
            crop_aspect_ratio)
        height = yc2 - yc1
        width = xc2 - xc1
        if not 1 <= nx <= width // 2:
            raise ValueError(
                f'The nx must be between 1 and {width // 2}.\nGive: {nx}')
        patch_width = math.ceil(width / nx)
        patch_height = int(patch_width * ar)
        ny = math.ceil(height / patch_height)
        ratio = np.sqrt(1 - lam)
        hole_width = int(patch_width * ratio)
        hole_height = int(patch_height * ratio)
        hole_width = min(max(hole_width, 1), patch_width - 1)
        hole_height = min(max(hole_height, 1), patch_height - 1)
        holes = []
        for i in range(nx + 1):
            for j in range(ny + 1):
                x1 = min(patch_width * i, width)
                y1 = min(patch_height * j, height)
                x2 = min(x1 + hole_width, width)
                y2 = min(y1 + hole_height, height)
                holes.append((x1, y1, x2, y2))
        mask = np.zeros(shape=image_shape, dtype=np.uint8)
        for x1, y1, x2, y2 in holes:
            mask[yc1 + y1:yc1 + y2, xc1 + x1:xc1 + x2] = 1
        return mask

    def get_sample(self, images: 'torch.Tensor', targets: 'torch.Tensor'
        ) ->t.Tuple[torch.Tensor, torch.Tensor]:
        """ Method returns augmented images and targets

        :param images: Batch of non-augmented images
        :param targets: Batch of non-augmented targets
        :return: Augmented images and targets
        """
        indices = torch.randperm(images.size(0))
        shuffled_targets = targets[indices]
        height, width = images.shape[2:]
        if isinstance(self.alpha, float):
            lam = np.random.beta(self.alpha, self.alpha)
        else:
            lam = np.random.uniform(self.alpha[0], self.alpha[1])
        nx = random.randint(self.n_holes_x[0], self.n_holes_x[1])
        ar = np.random.uniform(self.hole_aspect_ratio[0], self.
            hole_aspect_ratio[1])
        crop_area_ratio = np.random.uniform(self.crop_area_ratio[0], self.
            crop_area_ratio[1])
        crop_aspect_ratio = np.random.uniform(self.crop_aspect_ratio[0],
            self.crop_aspect_ratio[1])
        mask = self._get_gridmask(image_shape=(height, width),
            crop_area_ratio=crop_area_ratio, crop_aspect_ratio=
            crop_aspect_ratio, lam=lam, nx=nx, ar=ar)
        lam = 1 - mask.sum() / (images.size()[-1] * images.size()[-2])
        mask = torch.from_numpy(mask)
        images = images * (1 - mask) + images[indices, ...] * mask
        lam_list = torch.from_numpy(np.ones(shape=targets.shape) * lam)
        out_targets = torch.cat([targets, shuffled_targets, lam_list], dim=1
            ).transpose(0, 1)
        return images, out_targets

    def forward(self, preds: 'torch.Tensor', trues: 'torch.Tensor'
        ) ->torch.Tensor:
        lam = trues[-1][0].float()
        trues1, trues2 = trues[0].long(), trues[1].long()
        loss = self.loss(preds, trues1) * lam + self.loss(preds, trues2) * (
            1 - lam)
        return loss


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


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

import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch._inductor.runtime.triton_helpers import math as tl_math
import math
import random
import numpy as np
import typing as t
from torch import 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__log_softmax_0(in_ptr0, out_ptr0, out_ptr1, xnumel,
    XBLOCK: tl.constexpr):
    xnumel = 256
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x3 = xindex
    x0 = xindex % 16
    x2 = xindex // 64
    tmp0 = tl.load(in_ptr0 + x3, xmask)
    tmp1 = tl.load(in_ptr0 + (x0 + 64 * x2), xmask, eviction_policy=
        'evict_last')
    tmp2 = tl.load(in_ptr0 + (16 + x0 + 64 * x2), xmask, eviction_policy=
        'evict_last')
    tmp4 = tl.load(in_ptr0 + (32 + x0 + 64 * x2), xmask, eviction_policy=
        'evict_last')
    tmp6 = tl.load(in_ptr0 + (48 + x0 + 64 * x2), xmask, eviction_policy=
        'evict_last')
    tmp3 = triton_helpers.maximum(tmp1, tmp2)
    tmp5 = triton_helpers.maximum(tmp3, tmp4)
    tmp7 = triton_helpers.maximum(tmp5, tmp6)
    tmp8 = tmp0 - tmp7
    tl.store(out_ptr0 + x3, tmp8, xmask)
    tl.store(out_ptr1 + x3, tmp8, xmask)


@triton.jit
def triton_per_fused__to_copy_nll_loss2d_forward_1(in_ptr0, in_ptr1,
    out_ptr0, out_ptr1, xnumel, rnumel, XBLOCK: tl.constexpr):
    RBLOCK: tl.constexpr = 64
    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)
    r2 = rindex
    r0 = rindex % 16
    r1 = rindex // 16
    tmp0 = tl.load(in_ptr0 + r2, None)
    tmp12 = tl.load(in_ptr1 + (r0 + 64 * r1), None)
    tmp14 = tl.load(in_ptr1 + (16 + r0 + 64 * r1), None)
    tmp17 = tl.load(in_ptr1 + (32 + r0 + 64 * r1), None)
    tmp20 = tl.load(in_ptr1 + (48 + r0 + 64 * r1), None)
    tmp1 = tmp0.to(tl.int64)
    tmp2 = tl.full([1, 1], -100, tl.int64)
    tmp3 = tmp1 != tmp2
    tmp4 = tl.full([1, 1], 0, tl.int64)
    tmp5 = tl.where(tmp3, tmp1, tmp4)
    tmp6 = tl.full([XBLOCK, RBLOCK], 4, tl.int32)
    tmp7 = tmp5 + tmp6
    tmp8 = tmp5 < 0
    tmp9 = tl.where(tmp8, tmp7, tmp5)
    tl.device_assert((0 <= tmp9) & (tmp9 < 4),
        'index out of bounds: 0 <= tmp9 < 4')
    tmp11 = tl.load(in_ptr1 + (r0 + 16 * tmp9 + 64 * r1), None)
    tmp13 = tl_math.exp(tmp12)
    tmp15 = tl_math.exp(tmp14)
    tmp16 = tmp13 + tmp15
    tmp18 = tl_math.exp(tmp17)
    tmp19 = tmp16 + tmp18
    tmp21 = tl_math.exp(tmp20)
    tmp22 = tmp19 + tmp21
    tmp23 = tl_math.log(tmp22)
    tmp24 = tmp11 - tmp23
    tmp25 = -tmp24
    tmp26 = 0.0
    tmp27 = tl.where(tmp3, tmp25, tmp26)
    tmp28 = tl.broadcast_to(tmp27, [XBLOCK, RBLOCK])
    tmp30 = tl.sum(tmp28, 1)[:, None]
    tmp31 = tmp3.to(tl.int64)
    tmp32 = tl.broadcast_to(tmp31, [XBLOCK, RBLOCK])
    tmp34 = tl.sum(tmp32, 1)[:, None]
    tl.store(out_ptr0 + tl.full([XBLOCK, 1], 0, tl.int32), tmp30, None)
    tl.store(out_ptr1 + tl.full([XBLOCK, 1], 0, tl.int32), tmp34, None)


@triton.jit
def triton_per_fused__to_copy_nll_loss2d_forward_2(in_ptr0, in_ptr1,
    out_ptr0, out_ptr1, xnumel, rnumel, XBLOCK: tl.constexpr):
    RBLOCK: tl.constexpr = 64
    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)
    r2 = rindex
    r0 = rindex % 16
    r1 = rindex // 16
    tmp0 = tl.load(in_ptr0 + (64 + r2), None)
    tmp12 = tl.load(in_ptr1 + (r0 + 64 * r1), None)
    tmp14 = tl.load(in_ptr1 + (16 + r0 + 64 * r1), None)
    tmp17 = tl.load(in_ptr1 + (32 + r0 + 64 * r1), None)
    tmp20 = tl.load(in_ptr1 + (48 + r0 + 64 * r1), None)
    tmp1 = tmp0.to(tl.int64)
    tmp2 = tl.full([1, 1], -100, tl.int64)
    tmp3 = tmp1 != tmp2
    tmp4 = tl.full([1, 1], 0, tl.int64)
    tmp5 = tl.where(tmp3, tmp1, tmp4)
    tmp6 = tl.full([XBLOCK, RBLOCK], 4, tl.int32)
    tmp7 = tmp5 + tmp6
    tmp8 = tmp5 < 0
    tmp9 = tl.where(tmp8, tmp7, tmp5)
    tl.device_assert((0 <= tmp9) & (tmp9 < 4),
        'index out of bounds: 0 <= tmp9 < 4')
    tmp11 = tl.load(in_ptr1 + (r0 + 16 * tmp9 + 64 * r1), None)
    tmp13 = tl_math.exp(tmp12)
    tmp15 = tl_math.exp(tmp14)
    tmp16 = tmp13 + tmp15
    tmp18 = tl_math.exp(tmp17)
    tmp19 = tmp16 + tmp18
    tmp21 = tl_math.exp(tmp20)
    tmp22 = tmp19 + tmp21
    tmp23 = tl_math.log(tmp22)
    tmp24 = tmp11 - tmp23
    tmp25 = -tmp24
    tmp26 = 0.0
    tmp27 = tl.where(tmp3, tmp25, tmp26)
    tmp28 = tl.broadcast_to(tmp27, [XBLOCK, RBLOCK])
    tmp30 = tl.sum(tmp28, 1)[:, None]
    tmp31 = tmp3.to(tl.int64)
    tmp32 = tl.broadcast_to(tmp31, [XBLOCK, RBLOCK])
    tmp34 = tl.sum(tmp32, 1)[:, None]
    tl.store(out_ptr0 + tl.full([XBLOCK, 1], 0, tl.int32), tmp30, None)
    tl.store(out_ptr1 + tl.full([XBLOCK, 1], 0, tl.int32), tmp34, None)


@triton.jit
def triton_poi_fused_add_mul_nll_loss2d_forward_rsub_3(in_ptr0, in_ptr1,
    in_ptr2, in_ptr3, in_ptr4, out_ptr0, xnumel, XBLOCK: tl.constexpr):
    xnumel = 16
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x0 = xindex
    tmp0 = tl.load(in_ptr0 + 0)
    tmp1 = tl.broadcast_to(tmp0, [XBLOCK])
    tmp2 = tl.load(in_ptr1 + 0)
    tmp3 = tl.broadcast_to(tmp2, [XBLOCK])
    tmp6 = tl.load(in_ptr2 + (192 + x0), xmask)
    tmp8 = tl.load(in_ptr3 + 0)
    tmp9 = tl.broadcast_to(tmp8, [XBLOCK])
    tmp10 = tl.load(in_ptr4 + 0)
    tmp11 = tl.broadcast_to(tmp10, [XBLOCK])
    tmp4 = tmp3.to(tl.float32)
    tmp5 = tmp1 / tmp4
    tmp7 = tmp5 * tmp6
    tmp12 = tmp11.to(tl.float32)
    tmp13 = tmp9 / tmp12
    tmp14 = 1.0
    tmp15 = tmp14 - tmp6
    tmp16 = tmp13 * tmp15
    tmp17 = tmp7 + tmp16
    tl.store(out_ptr0 + x0, tmp17, 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, 4), (64, 16, 4, 1), torch.float32)
        buf3 = empty_strided_cuda((4, 4, 4, 4), (64, 16, 4, 1), torch.float32)
        get_raw_stream(0)
        triton_poi_fused__log_softmax_0[grid(256)](arg1_1, buf0, buf3, 256,
            XBLOCK=256, num_warps=4, num_stages=1)
        del arg1_1
        buf1 = empty_strided_cuda((), (), torch.float32)
        buf2 = empty_strided_cuda((), (), torch.int64)
        triton_per_fused__to_copy_nll_loss2d_forward_1[grid(1)](arg0_1,
            buf0, buf1, buf2, 1, 64, XBLOCK=1, num_warps=2, num_stages=1)
        del buf0
        buf4 = empty_strided_cuda((), (), torch.float32)
        buf5 = empty_strided_cuda((), (), torch.int64)
        triton_per_fused__to_copy_nll_loss2d_forward_2[grid(1)](arg0_1,
            buf3, buf4, buf5, 1, 64, XBLOCK=1, num_warps=2, num_stages=1)
        del buf3
        buf6 = empty_strided_cuda((4, 4), (4, 1), torch.float32)
        triton_poi_fused_add_mul_nll_loss2d_forward_rsub_3[grid(16)](buf1,
            buf2, arg0_1, buf4, buf5, buf6, 16, XBLOCK=16, num_warps=1,
            num_stages=1)
        del arg0_1
        del buf1
        del buf2
        del buf4
        del buf5
    return buf6,


class GridMixupLossNew(nn.Module):
    """ Implementation of GridMixup loss

    :param alpha: Percent of the first image on the crop. Can be float or Tuple[float, float]
                    - if float: lambda parameter gets from the beta-distribution np.random.beta(alpha, alpha)
                    - if Tuple[float, float]: lambda parameter gets from the uniform
                        distribution np.random.uniform(alpha[0], alpha[1])
    :param n_holes_x: Number of holes by OX
    :param hole_aspect_ratio: hole aspect ratio
    :param crop_area_ratio: Define percentage of the crop area
    :param crop_aspect_ratio: Define crop aspect ratio
    """

    def __init__(self, alpha: 't.Union[float, t.Tuple[float, float]]'=(0.1,
        0.9), n_holes_x: 't.Union[int, t.Tuple[int, int]]'=20,
        hole_aspect_ratio: 't.Union[float, t.Tuple[float, float]]'=1.0,
        crop_area_ratio: 't.Union[float, t.Tuple[float, float]]'=1.0,
        crop_aspect_ratio: 't.Union[float, t.Tuple[float, float]]'=1.0):
        super().__init__()
        self.alpha = alpha
        self.n_holes_x = n_holes_x
        self.hole_aspect_ratio = hole_aspect_ratio
        self.crop_area_ratio = crop_area_ratio
        self.crop_aspect_ratio = crop_aspect_ratio
        if isinstance(self.n_holes_x, int):
            self.n_holes_x = self.n_holes_x, self.n_holes_x
        if isinstance(self.hole_aspect_ratio, float):
            self.hole_aspect_ratio = (self.hole_aspect_ratio, self.
                hole_aspect_ratio)
        if isinstance(self.crop_area_ratio, float):
            self.crop_area_ratio = self.crop_area_ratio, self.crop_area_ratio
        if isinstance(self.crop_aspect_ratio, float):
            self.crop_aspect_ratio = (self.crop_aspect_ratio, self.
                crop_aspect_ratio)
        self.loss = nn.CrossEntropyLoss()

    def __str__(self):
        return 'gridmixup'

    @staticmethod
    def _get_random_crop(height: 'int', width: 'int', crop_area_ratio:
        'float', crop_aspect_ratio: 'float') ->t.Tuple:
        crop_area = int(height * width * crop_area_ratio)
        crop_width = int(np.sqrt(crop_area / crop_aspect_ratio))
        crop_height = int(crop_width * crop_aspect_ratio)
        cx = np.random.random()
        cy = np.random.random()
        y1 = int((height - crop_height) * cy)
        y2 = y1 + crop_height
        x1 = int((width - crop_width) * cx)
        x2 = x1 + crop_width
        return x1, y1, x2, y2

    def _get_gridmask(self, image_shape: 't.Tuple[int, int]',
        crop_area_ratio: 'float', crop_aspect_ratio: 'float', lam: 'float',
        nx: 'int', ar: 'float') ->np.ndarray:
        """ Method make grid mask

        :param image_shape: Shape of the images
        :param lam: Lambda parameter
        :param crop_area_ratio: Ratio of the crop area
        :param crop_aspect_ratio: Aspect ratio of the crop
        :param nx: Amount of holes by width
        :param ar: Aspect ratio of the hole
        :return: Binary mask, where holes == 1, background == 0
        """
        img_height, img_width = image_shape
        xc1, yc1, xc2, yc2 = self._get_random_crop(height=img_height, width
            =img_width, crop_area_ratio=crop_area_ratio, crop_aspect_ratio=
            crop_aspect_ratio)
        height = yc2 - yc1
        width = xc2 - xc1
        if not 1 <= nx <= width // 2:
            raise ValueError(
                f'The nx must be between 1 and {width // 2}.\nGive: {nx}')
        patch_width = math.ceil(width / nx)
        patch_height = int(patch_width * ar)
        ny = math.ceil(height / patch_height)
        ratio = np.sqrt(1 - lam)
        hole_width = int(patch_width * ratio)
        hole_height = int(patch_height * ratio)
        hole_width = min(max(hole_width, 1), patch_width - 1)
        hole_height = min(max(hole_height, 1), patch_height - 1)
        holes = []
        for i in range(nx + 1):
            for j in range(ny + 1):
                x1 = min(patch_width * i, width)
                y1 = min(patch_height * j, height)
                x2 = min(x1 + hole_width, width)
                y2 = min(y1 + hole_height, height)
                holes.append((x1, y1, x2, y2))
        mask = np.zeros(shape=image_shape, dtype=np.uint8)
        for x1, y1, x2, y2 in holes:
            mask[yc1 + y1:yc1 + y2, xc1 + x1:xc1 + x2] = 1
        return mask

    def get_sample(self, images: 'torch.Tensor', targets: 'torch.Tensor'
        ) ->t.Tuple[torch.Tensor, torch.Tensor]:
        """ Method returns augmented images and targets

        :param images: Batch of non-augmented images
        :param targets: Batch of non-augmented targets
        :return: Augmented images and targets
        """
        indices = torch.randperm(images.size(0))
        shuffled_targets = targets[indices]
        height, width = images.shape[2:]
        if isinstance(self.alpha, float):
            lam = np.random.beta(self.alpha, self.alpha)
        else:
            lam = np.random.uniform(self.alpha[0], self.alpha[1])
        nx = random.randint(self.n_holes_x[0], self.n_holes_x[1])
        ar = np.random.uniform(self.hole_aspect_ratio[0], self.
            hole_aspect_ratio[1])
        crop_area_ratio = np.random.uniform(self.crop_area_ratio[0], self.
            crop_area_ratio[1])
        crop_aspect_ratio = np.random.uniform(self.crop_aspect_ratio[0],
            self.crop_aspect_ratio[1])
        mask = self._get_gridmask(image_shape=(height, width),
            crop_area_ratio=crop_area_ratio, crop_aspect_ratio=
            crop_aspect_ratio, lam=lam, nx=nx, ar=ar)
        lam = 1 - mask.sum() / (images.size()[-1] * images.size()[-2])
        mask = torch.from_numpy(mask)
        images = images * (1 - mask) + images[indices, ...] * mask
        lam_list = torch.from_numpy(np.ones(shape=targets.shape) * lam)
        out_targets = torch.cat([targets, shuffled_targets, lam_list], dim=1
            ).transpose(0, 1)
        return images, out_targets

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