# 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_6/inductor_cache/vg/cvgg2fijk3fjanwfoyz5tqsq5zl466ja33p5ct3cux3cbat6w24y.py
# Topologically Sorted Source Nodes: [abs_1, suppression_field, add, truediv], Original ATen: [aten.abs, aten.max_pool2d_with_indices, aten.add, aten.div]
# Source node to ATen node mapping:
#   abs_1 => abs_1
#   add => add
#   suppression_field => _low_memory_max_pool2d_with_offsets
#   truediv => div
# Graph fragment:
#   %abs_1 : [num_users=1] = call_function[target=torch.ops.aten.abs.default](args = (%arg0_1,), kwargs = {})
#   %_low_memory_max_pool2d_with_offsets : [num_users=1] = call_function[target=torch.ops.prims._low_memory_max_pool2d_with_offsets.default](args = (%abs_1, [5, 5], [1, 1], [2, 2], [1, 1], False), kwargs = {})
#   %add : [num_users=1] = call_function[target=torch.ops.aten.add.Tensor](args = (%getitem, 1.0), kwargs = {})
#   %div : [num_users=1] = call_function[target=torch.ops.aten.div.Tensor](args = (%arg0_1, %add), kwargs = {})
triton_poi_fused_abs_add_div_max_pool2d_with_indices_0 = async_compile.triton('triton_poi_fused_abs_add_div_max_pool2d_with_indices_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_abs_add_div_max_pool2d_with_indices_0', 'mutated_arg_names': ['in_out_ptr0'], 'no_x_dim': False, 'num_load': 26, '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_abs_add_div_max_pool2d_with_indices_0(in_out_ptr0, in_ptr0, xnumel, XBLOCK : tl.constexpr):
    xnumel = 256
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x1 = (xindex // 4) % 4
    x0 = xindex % 4
    x3 = xindex
    tmp191 = tl.load(in_ptr0 + (x3), xmask)
    tmp0 = (-2) + x1
    tmp1 = tl.full([1], 0, tl.int64)
    tmp2 = tmp0 >= tmp1
    tmp3 = tl.full([1], 4, tl.int64)
    tmp4 = tmp0 < tmp3
    tmp5 = tmp2 & tmp4
    tmp6 = (-2) + x0
    tmp7 = tmp6 >= tmp1
    tmp8 = tmp6 < tmp3
    tmp9 = tmp7 & tmp8
    tmp10 = tmp5 & tmp9
    tmp11 = tl.load(in_ptr0 + ((-10) + x3), tmp10 & xmask, other=0.0)
    tmp12 = tl_math.abs(tmp11)
    tmp13 = tl.full(tmp12.shape, float("-inf"), tmp12.dtype)
    tmp14 = tl.where(tmp10, tmp12, tmp13)
    tmp15 = (-1) + x0
    tmp16 = tmp15 >= tmp1
    tmp17 = tmp15 < tmp3
    tmp18 = tmp16 & tmp17
    tmp19 = tmp5 & tmp18
    tmp20 = tl.load(in_ptr0 + ((-9) + x3), tmp19 & xmask, other=0.0)
    tmp21 = tl_math.abs(tmp20)
    tmp22 = tl.full(tmp21.shape, float("-inf"), tmp21.dtype)
    tmp23 = tl.where(tmp19, tmp21, tmp22)
    tmp24 = triton_helpers.maximum(tmp23, tmp14)
    tmp25 = x0
    tmp26 = tmp25 >= tmp1
    tmp27 = tmp25 < tmp3
    tmp28 = tmp26 & tmp27
    tmp29 = tmp5 & tmp28
    tmp30 = tl.load(in_ptr0 + ((-8) + x3), tmp29 & xmask, other=0.0)
    tmp31 = tl_math.abs(tmp30)
    tmp32 = tl.full(tmp31.shape, float("-inf"), tmp31.dtype)
    tmp33 = tl.where(tmp29, tmp31, tmp32)
    tmp34 = triton_helpers.maximum(tmp33, tmp24)
    tmp35 = 1 + x0
    tmp36 = tmp35 >= tmp1
    tmp37 = tmp35 < tmp3
    tmp38 = tmp36 & tmp37
    tmp39 = tmp5 & tmp38
    tmp40 = tl.load(in_ptr0 + ((-7) + x3), tmp39 & xmask, other=0.0)
    tmp41 = tl_math.abs(tmp40)
    tmp42 = tl.full(tmp41.shape, float("-inf"), tmp41.dtype)
    tmp43 = tl.where(tmp39, tmp41, tmp42)
    tmp44 = triton_helpers.maximum(tmp43, tmp34)
    tmp45 = 2 + x0
    tmp46 = tmp45 >= tmp1
    tmp47 = tmp45 < tmp3
    tmp48 = tmp46 & tmp47
    tmp49 = tmp5 & tmp48
    tmp50 = tl.load(in_ptr0 + ((-6) + x3), tmp49 & xmask, other=0.0)
    tmp51 = tl_math.abs(tmp50)
    tmp52 = tl.full(tmp51.shape, float("-inf"), tmp51.dtype)
    tmp53 = tl.where(tmp49, tmp51, tmp52)
    tmp54 = triton_helpers.maximum(tmp53, tmp44)
    tmp55 = (-1) + x1
    tmp56 = tmp55 >= tmp1
    tmp57 = tmp55 < tmp3
    tmp58 = tmp56 & tmp57
    tmp59 = tmp58 & tmp9
    tmp60 = tl.load(in_ptr0 + ((-6) + x3), tmp59 & xmask, other=0.0)
    tmp61 = tl_math.abs(tmp60)
    tmp62 = tl.full(tmp61.shape, float("-inf"), tmp61.dtype)
    tmp63 = tl.where(tmp59, tmp61, tmp62)
    tmp64 = triton_helpers.maximum(tmp63, tmp54)
    tmp65 = tmp58 & tmp18
    tmp66 = tl.load(in_ptr0 + ((-5) + x3), tmp65 & xmask, other=0.0)
    tmp67 = tl_math.abs(tmp66)
    tmp68 = tl.full(tmp67.shape, float("-inf"), tmp67.dtype)
    tmp69 = tl.where(tmp65, tmp67, tmp68)
    tmp70 = triton_helpers.maximum(tmp69, tmp64)
    tmp71 = tmp58 & tmp28
    tmp72 = tl.load(in_ptr0 + ((-4) + x3), tmp71 & xmask, other=0.0)
    tmp73 = tl_math.abs(tmp72)
    tmp74 = tl.full(tmp73.shape, float("-inf"), tmp73.dtype)
    tmp75 = tl.where(tmp71, tmp73, tmp74)
    tmp76 = triton_helpers.maximum(tmp75, tmp70)
    tmp77 = tmp58 & tmp38
    tmp78 = tl.load(in_ptr0 + ((-3) + x3), tmp77 & xmask, other=0.0)
    tmp79 = tl_math.abs(tmp78)
    tmp80 = tl.full(tmp79.shape, float("-inf"), tmp79.dtype)
    tmp81 = tl.where(tmp77, tmp79, tmp80)
    tmp82 = triton_helpers.maximum(tmp81, tmp76)
    tmp83 = tmp58 & tmp48
    tmp84 = tl.load(in_ptr0 + ((-2) + x3), tmp83 & xmask, other=0.0)
    tmp85 = tl_math.abs(tmp84)
    tmp86 = tl.full(tmp85.shape, float("-inf"), tmp85.dtype)
    tmp87 = tl.where(tmp83, tmp85, tmp86)
    tmp88 = triton_helpers.maximum(tmp87, tmp82)
    tmp89 = x1
    tmp90 = tmp89 >= tmp1
    tmp91 = tmp89 < tmp3
    tmp92 = tmp90 & tmp91
    tmp93 = tmp92 & tmp9
    tmp94 = tl.load(in_ptr0 + ((-2) + x3), tmp93 & xmask, other=0.0)
    tmp95 = tl_math.abs(tmp94)
    tmp96 = tl.full(tmp95.shape, float("-inf"), tmp95.dtype)
    tmp97 = tl.where(tmp93, tmp95, tmp96)
    tmp98 = triton_helpers.maximum(tmp97, tmp88)
    tmp99 = tmp92 & tmp18
    tmp100 = tl.load(in_ptr0 + ((-1) + x3), tmp99 & xmask, other=0.0)
    tmp101 = tl_math.abs(tmp100)
    tmp102 = tl.full(tmp101.shape, float("-inf"), tmp101.dtype)
    tmp103 = tl.where(tmp99, tmp101, tmp102)
    tmp104 = triton_helpers.maximum(tmp103, tmp98)
    tmp105 = tmp92 & tmp28
    tmp106 = tl.load(in_ptr0 + (x3), tmp105 & xmask, other=0.0)
    tmp107 = tl_math.abs(tmp106)
    tmp108 = tl.full(tmp107.shape, float("-inf"), tmp107.dtype)
    tmp109 = tl.where(tmp105, tmp107, tmp108)
    tmp110 = triton_helpers.maximum(tmp109, tmp104)
    tmp111 = tmp92 & tmp38
    tmp112 = tl.load(in_ptr0 + (1 + x3), tmp111 & xmask, other=0.0)
    tmp113 = tl_math.abs(tmp112)
    tmp114 = tl.full(tmp113.shape, float("-inf"), tmp113.dtype)
    tmp115 = tl.where(tmp111, tmp113, tmp114)
    tmp116 = triton_helpers.maximum(tmp115, tmp110)
    tmp117 = tmp92 & tmp48
    tmp118 = tl.load(in_ptr0 + (2 + x3), tmp117 & xmask, other=0.0)
    tmp119 = tl_math.abs(tmp118)
    tmp120 = tl.full(tmp119.shape, float("-inf"), tmp119.dtype)
    tmp121 = tl.where(tmp117, tmp119, tmp120)
    tmp122 = triton_helpers.maximum(tmp121, tmp116)
    tmp123 = 1 + x1
    tmp124 = tmp123 >= tmp1
    tmp125 = tmp123 < tmp3
    tmp126 = tmp124 & tmp125
    tmp127 = tmp126 & tmp9
    tmp128 = tl.load(in_ptr0 + (2 + x3), tmp127 & xmask, other=0.0)
    tmp129 = tl_math.abs(tmp128)
    tmp130 = tl.full(tmp129.shape, float("-inf"), tmp129.dtype)
    tmp131 = tl.where(tmp127, tmp129, tmp130)
    tmp132 = triton_helpers.maximum(tmp131, tmp122)
    tmp133 = tmp126 & tmp18
    tmp134 = tl.load(in_ptr0 + (3 + x3), tmp133 & xmask, other=0.0)
    tmp135 = tl_math.abs(tmp134)
    tmp136 = tl.full(tmp135.shape, float("-inf"), tmp135.dtype)
    tmp137 = tl.where(tmp133, tmp135, tmp136)
    tmp138 = triton_helpers.maximum(tmp137, tmp132)
    tmp139 = tmp126 & tmp28
    tmp140 = tl.load(in_ptr0 + (4 + x3), tmp139 & xmask, other=0.0)
    tmp141 = tl_math.abs(tmp140)
    tmp142 = tl.full(tmp141.shape, float("-inf"), tmp141.dtype)
    tmp143 = tl.where(tmp139, tmp141, tmp142)
    tmp144 = triton_helpers.maximum(tmp143, tmp138)
    tmp145 = tmp126 & tmp38
    tmp146 = tl.load(in_ptr0 + (5 + x3), tmp145 & xmask, other=0.0)
    tmp147 = tl_math.abs(tmp146)
    tmp148 = tl.full(tmp147.shape, float("-inf"), tmp147.dtype)
    tmp149 = tl.where(tmp145, tmp147, tmp148)
    tmp150 = triton_helpers.maximum(tmp149, tmp144)
    tmp151 = tmp126 & tmp48
    tmp152 = tl.load(in_ptr0 + (6 + x3), tmp151 & xmask, other=0.0)
    tmp153 = tl_math.abs(tmp152)
    tmp154 = tl.full(tmp153.shape, float("-inf"), tmp153.dtype)
    tmp155 = tl.where(tmp151, tmp153, tmp154)
    tmp156 = triton_helpers.maximum(tmp155, tmp150)
    tmp157 = 2 + x1
    tmp158 = tmp157 >= tmp1
    tmp159 = tmp157 < tmp3
    tmp160 = tmp158 & tmp159
    tmp161 = tmp160 & tmp9
    tmp162 = tl.load(in_ptr0 + (6 + x3), tmp161 & xmask, other=0.0)
    tmp163 = tl_math.abs(tmp162)
    tmp164 = tl.full(tmp163.shape, float("-inf"), tmp163.dtype)
    tmp165 = tl.where(tmp161, tmp163, tmp164)
    tmp166 = triton_helpers.maximum(tmp165, tmp156)
    tmp167 = tmp160 & tmp18
    tmp168 = tl.load(in_ptr0 + (7 + x3), tmp167 & xmask, other=0.0)
    tmp169 = tl_math.abs(tmp168)
    tmp170 = tl.full(tmp169.shape, float("-inf"), tmp169.dtype)
    tmp171 = tl.where(tmp167, tmp169, tmp170)
    tmp172 = triton_helpers.maximum(tmp171, tmp166)
    tmp173 = tmp160 & tmp28
    tmp174 = tl.load(in_ptr0 + (8 + x3), tmp173 & xmask, other=0.0)
    tmp175 = tl_math.abs(tmp174)
    tmp176 = tl.full(tmp175.shape, float("-inf"), tmp175.dtype)
    tmp177 = tl.where(tmp173, tmp175, tmp176)
    tmp178 = triton_helpers.maximum(tmp177, tmp172)
    tmp179 = tmp160 & tmp38
    tmp180 = tl.load(in_ptr0 + (9 + x3), tmp179 & xmask, other=0.0)
    tmp181 = tl_math.abs(tmp180)
    tmp182 = tl.full(tmp181.shape, float("-inf"), tmp181.dtype)
    tmp183 = tl.where(tmp179, tmp181, tmp182)
    tmp184 = triton_helpers.maximum(tmp183, tmp178)
    tmp185 = tmp160 & tmp48
    tmp186 = tl.load(in_ptr0 + (10 + x3), tmp185 & xmask, other=0.0)
    tmp187 = tl_math.abs(tmp186)
    tmp188 = tl.full(tmp187.shape, float("-inf"), tmp187.dtype)
    tmp189 = tl.where(tmp185, tmp187, tmp188)
    tmp190 = triton_helpers.maximum(tmp189, tmp184)
    tmp192 = 1.0
    tmp193 = tmp190 + tmp192
    tmp194 = tmp191 / tmp193
    tl.store(in_out_ptr0 + (x3), tmp194, xmask)
''', device_str='cuda')


async_compile.wait(globals())
del async_compile

def call(args):
    arg0_1, = args
    args.clear()
    assert_size_stride(arg0_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)
        buf1 = buf0; del buf0  # reuse
        # Topologically Sorted Source Nodes: [abs_1, suppression_field, add, truediv], Original ATen: [aten.abs, aten.max_pool2d_with_indices, aten.add, aten.div]
        stream0 = get_raw_stream(0)
        triton_poi_fused_abs_add_div_max_pool2d_with_indices_0.run(buf1, arg0_1, 256, grid=grid(256), stream=stream0)
        del arg0_1
    return (buf1, )


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)
    fn = lambda: call([arg0_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)

from torch.nn import Module
import torch
from torch import Tensor
from typing import Union
from typing import Tuple
import torch.nn.functional as F


class DivisiveNormalization2d(Module):
    """Applies a 2D divisive normalization over an input signal composed of several input
    planes.

    In the simplest case, the output value of the layer with input size :math:`(N, C, H, W)`
    and output :math:`(N, C, H, W)`.

    Args:
        b_type: Type of suppressin field, must be one of (`linf`, `l1`, `l2`).
        b_size: The size of the suppression field, must be > 0.
        sigma: Constant added to suppression field, must be > 0.

    Shape:
        - Input: :math:`(N, C, H, W)`
        - Output: :math:`(N, C, H, W)`

    Examples::

        >>> # suppression of size=3, sigma=1
        >>> d = DivisiveNormalization2d(b_size=3, sigma=1)
        >>> input = torch.randn(20, 16, 50, 50)
        >>> output = d(input)
    """

    def __init__(self, b_type: 'str'='linf', b_size:
        'Union[int, Tuple[int, int]]'=(5, 5), sigma: 'float'=1.0) ->None:
        super(DivisiveNormalization2d, self).__init__()
        self.sigma = sigma
        if isinstance(b_size, int):
            self.b_size = b_size, b_size
        else:
            self.b_size = b_size
        self.padding = self.b_size[0] // 2, self.b_size[1] // 2
        self.b_type = b_type

    def forward(self, input: 'Tensor') ->Tensor:
        if self.b_type == 'linf':
            suppression_field = F.max_pool2d(torch.abs(input), self.b_size,
                1, self.padding, 1)
        elif self.b_type == 'l1':
            weight = torch.ones((input.shape[1], 1, self.b_size[0], self.
                b_size[1]))
            suppression_field = F.conv2d(torch.abs(input), weight=weight,
                padding=self.padding, groups=input.shape[1])
        elif self.b_type == 'l2':
            weight = torch.ones((input.shape[1], 1, self.b_size[0], self.
                b_size[1]))
            suppression_field = torch.sqrt(F.conv2d(input ** 2, weight=
                weight, padding=self.padding, groups=input.shape[1]))
        else:
            raise NotImplementedError
        return input / (self.sigma + suppression_field)

    def __repr__(self) ->str:
        s = 'DivisiveNormalization2d('
        s += f'b_type={self.b_type}, b_size={self.b_size}, sigma={self.sigma}'
        s += ')'
        return s.format(**self.__dict__)


def get_inputs():
    return [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
from torch.nn import Module
from typing import Union
from typing import Tuple
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_abs_add_div_max_pool2d_with_indices_0(in_out_ptr0,
    in_ptr0, xnumel, XBLOCK: tl.constexpr):
    xnumel = 256
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x1 = xindex // 4 % 4
    x0 = xindex % 4
    x3 = xindex
    tmp191 = tl.load(in_ptr0 + x3, xmask)
    tmp0 = -2 + x1
    tmp1 = tl.full([1], 0, tl.int64)
    tmp2 = tmp0 >= tmp1
    tmp3 = tl.full([1], 4, tl.int64)
    tmp4 = tmp0 < tmp3
    tmp5 = tmp2 & tmp4
    tmp6 = -2 + x0
    tmp7 = tmp6 >= tmp1
    tmp8 = tmp6 < tmp3
    tmp9 = tmp7 & tmp8
    tmp10 = tmp5 & tmp9
    tmp11 = tl.load(in_ptr0 + (-10 + x3), tmp10 & xmask, other=0.0)
    tmp12 = tl_math.abs(tmp11)
    tmp13 = tl.full(tmp12.shape, float('-inf'), tmp12.dtype)
    tmp14 = tl.where(tmp10, tmp12, tmp13)
    tmp15 = -1 + x0
    tmp16 = tmp15 >= tmp1
    tmp17 = tmp15 < tmp3
    tmp18 = tmp16 & tmp17
    tmp19 = tmp5 & tmp18
    tmp20 = tl.load(in_ptr0 + (-9 + x3), tmp19 & xmask, other=0.0)
    tmp21 = tl_math.abs(tmp20)
    tmp22 = tl.full(tmp21.shape, float('-inf'), tmp21.dtype)
    tmp23 = tl.where(tmp19, tmp21, tmp22)
    tmp24 = triton_helpers.maximum(tmp23, tmp14)
    tmp25 = x0
    tmp26 = tmp25 >= tmp1
    tmp27 = tmp25 < tmp3
    tmp28 = tmp26 & tmp27
    tmp29 = tmp5 & tmp28
    tmp30 = tl.load(in_ptr0 + (-8 + x3), tmp29 & xmask, other=0.0)
    tmp31 = tl_math.abs(tmp30)
    tmp32 = tl.full(tmp31.shape, float('-inf'), tmp31.dtype)
    tmp33 = tl.where(tmp29, tmp31, tmp32)
    tmp34 = triton_helpers.maximum(tmp33, tmp24)
    tmp35 = 1 + x0
    tmp36 = tmp35 >= tmp1
    tmp37 = tmp35 < tmp3
    tmp38 = tmp36 & tmp37
    tmp39 = tmp5 & tmp38
    tmp40 = tl.load(in_ptr0 + (-7 + x3), tmp39 & xmask, other=0.0)
    tmp41 = tl_math.abs(tmp40)
    tmp42 = tl.full(tmp41.shape, float('-inf'), tmp41.dtype)
    tmp43 = tl.where(tmp39, tmp41, tmp42)
    tmp44 = triton_helpers.maximum(tmp43, tmp34)
    tmp45 = 2 + x0
    tmp46 = tmp45 >= tmp1
    tmp47 = tmp45 < tmp3
    tmp48 = tmp46 & tmp47
    tmp49 = tmp5 & tmp48
    tmp50 = tl.load(in_ptr0 + (-6 + x3), tmp49 & xmask, other=0.0)
    tmp51 = tl_math.abs(tmp50)
    tmp52 = tl.full(tmp51.shape, float('-inf'), tmp51.dtype)
    tmp53 = tl.where(tmp49, tmp51, tmp52)
    tmp54 = triton_helpers.maximum(tmp53, tmp44)
    tmp55 = -1 + x1
    tmp56 = tmp55 >= tmp1
    tmp57 = tmp55 < tmp3
    tmp58 = tmp56 & tmp57
    tmp59 = tmp58 & tmp9
    tmp60 = tl.load(in_ptr0 + (-6 + x3), tmp59 & xmask, other=0.0)
    tmp61 = tl_math.abs(tmp60)
    tmp62 = tl.full(tmp61.shape, float('-inf'), tmp61.dtype)
    tmp63 = tl.where(tmp59, tmp61, tmp62)
    tmp64 = triton_helpers.maximum(tmp63, tmp54)
    tmp65 = tmp58 & tmp18
    tmp66 = tl.load(in_ptr0 + (-5 + x3), tmp65 & xmask, other=0.0)
    tmp67 = tl_math.abs(tmp66)
    tmp68 = tl.full(tmp67.shape, float('-inf'), tmp67.dtype)
    tmp69 = tl.where(tmp65, tmp67, tmp68)
    tmp70 = triton_helpers.maximum(tmp69, tmp64)
    tmp71 = tmp58 & tmp28
    tmp72 = tl.load(in_ptr0 + (-4 + x3), tmp71 & xmask, other=0.0)
    tmp73 = tl_math.abs(tmp72)
    tmp74 = tl.full(tmp73.shape, float('-inf'), tmp73.dtype)
    tmp75 = tl.where(tmp71, tmp73, tmp74)
    tmp76 = triton_helpers.maximum(tmp75, tmp70)
    tmp77 = tmp58 & tmp38
    tmp78 = tl.load(in_ptr0 + (-3 + x3), tmp77 & xmask, other=0.0)
    tmp79 = tl_math.abs(tmp78)
    tmp80 = tl.full(tmp79.shape, float('-inf'), tmp79.dtype)
    tmp81 = tl.where(tmp77, tmp79, tmp80)
    tmp82 = triton_helpers.maximum(tmp81, tmp76)
    tmp83 = tmp58 & tmp48
    tmp84 = tl.load(in_ptr0 + (-2 + x3), tmp83 & xmask, other=0.0)
    tmp85 = tl_math.abs(tmp84)
    tmp86 = tl.full(tmp85.shape, float('-inf'), tmp85.dtype)
    tmp87 = tl.where(tmp83, tmp85, tmp86)
    tmp88 = triton_helpers.maximum(tmp87, tmp82)
    tmp89 = x1
    tmp90 = tmp89 >= tmp1
    tmp91 = tmp89 < tmp3
    tmp92 = tmp90 & tmp91
    tmp93 = tmp92 & tmp9
    tmp94 = tl.load(in_ptr0 + (-2 + x3), tmp93 & xmask, other=0.0)
    tmp95 = tl_math.abs(tmp94)
    tmp96 = tl.full(tmp95.shape, float('-inf'), tmp95.dtype)
    tmp97 = tl.where(tmp93, tmp95, tmp96)
    tmp98 = triton_helpers.maximum(tmp97, tmp88)
    tmp99 = tmp92 & tmp18
    tmp100 = tl.load(in_ptr0 + (-1 + x3), tmp99 & xmask, other=0.0)
    tmp101 = tl_math.abs(tmp100)
    tmp102 = tl.full(tmp101.shape, float('-inf'), tmp101.dtype)
    tmp103 = tl.where(tmp99, tmp101, tmp102)
    tmp104 = triton_helpers.maximum(tmp103, tmp98)
    tmp105 = tmp92 & tmp28
    tmp106 = tl.load(in_ptr0 + x3, tmp105 & xmask, other=0.0)
    tmp107 = tl_math.abs(tmp106)
    tmp108 = tl.full(tmp107.shape, float('-inf'), tmp107.dtype)
    tmp109 = tl.where(tmp105, tmp107, tmp108)
    tmp110 = triton_helpers.maximum(tmp109, tmp104)
    tmp111 = tmp92 & tmp38
    tmp112 = tl.load(in_ptr0 + (1 + x3), tmp111 & xmask, other=0.0)
    tmp113 = tl_math.abs(tmp112)
    tmp114 = tl.full(tmp113.shape, float('-inf'), tmp113.dtype)
    tmp115 = tl.where(tmp111, tmp113, tmp114)
    tmp116 = triton_helpers.maximum(tmp115, tmp110)
    tmp117 = tmp92 & tmp48
    tmp118 = tl.load(in_ptr0 + (2 + x3), tmp117 & xmask, other=0.0)
    tmp119 = tl_math.abs(tmp118)
    tmp120 = tl.full(tmp119.shape, float('-inf'), tmp119.dtype)
    tmp121 = tl.where(tmp117, tmp119, tmp120)
    tmp122 = triton_helpers.maximum(tmp121, tmp116)
    tmp123 = 1 + x1
    tmp124 = tmp123 >= tmp1
    tmp125 = tmp123 < tmp3
    tmp126 = tmp124 & tmp125
    tmp127 = tmp126 & tmp9
    tmp128 = tl.load(in_ptr0 + (2 + x3), tmp127 & xmask, other=0.0)
    tmp129 = tl_math.abs(tmp128)
    tmp130 = tl.full(tmp129.shape, float('-inf'), tmp129.dtype)
    tmp131 = tl.where(tmp127, tmp129, tmp130)
    tmp132 = triton_helpers.maximum(tmp131, tmp122)
    tmp133 = tmp126 & tmp18
    tmp134 = tl.load(in_ptr0 + (3 + x3), tmp133 & xmask, other=0.0)
    tmp135 = tl_math.abs(tmp134)
    tmp136 = tl.full(tmp135.shape, float('-inf'), tmp135.dtype)
    tmp137 = tl.where(tmp133, tmp135, tmp136)
    tmp138 = triton_helpers.maximum(tmp137, tmp132)
    tmp139 = tmp126 & tmp28
    tmp140 = tl.load(in_ptr0 + (4 + x3), tmp139 & xmask, other=0.0)
    tmp141 = tl_math.abs(tmp140)
    tmp142 = tl.full(tmp141.shape, float('-inf'), tmp141.dtype)
    tmp143 = tl.where(tmp139, tmp141, tmp142)
    tmp144 = triton_helpers.maximum(tmp143, tmp138)
    tmp145 = tmp126 & tmp38
    tmp146 = tl.load(in_ptr0 + (5 + x3), tmp145 & xmask, other=0.0)
    tmp147 = tl_math.abs(tmp146)
    tmp148 = tl.full(tmp147.shape, float('-inf'), tmp147.dtype)
    tmp149 = tl.where(tmp145, tmp147, tmp148)
    tmp150 = triton_helpers.maximum(tmp149, tmp144)
    tmp151 = tmp126 & tmp48
    tmp152 = tl.load(in_ptr0 + (6 + x3), tmp151 & xmask, other=0.0)
    tmp153 = tl_math.abs(tmp152)
    tmp154 = tl.full(tmp153.shape, float('-inf'), tmp153.dtype)
    tmp155 = tl.where(tmp151, tmp153, tmp154)
    tmp156 = triton_helpers.maximum(tmp155, tmp150)
    tmp157 = 2 + x1
    tmp158 = tmp157 >= tmp1
    tmp159 = tmp157 < tmp3
    tmp160 = tmp158 & tmp159
    tmp161 = tmp160 & tmp9
    tmp162 = tl.load(in_ptr0 + (6 + x3), tmp161 & xmask, other=0.0)
    tmp163 = tl_math.abs(tmp162)
    tmp164 = tl.full(tmp163.shape, float('-inf'), tmp163.dtype)
    tmp165 = tl.where(tmp161, tmp163, tmp164)
    tmp166 = triton_helpers.maximum(tmp165, tmp156)
    tmp167 = tmp160 & tmp18
    tmp168 = tl.load(in_ptr0 + (7 + x3), tmp167 & xmask, other=0.0)
    tmp169 = tl_math.abs(tmp168)
    tmp170 = tl.full(tmp169.shape, float('-inf'), tmp169.dtype)
    tmp171 = tl.where(tmp167, tmp169, tmp170)
    tmp172 = triton_helpers.maximum(tmp171, tmp166)
    tmp173 = tmp160 & tmp28
    tmp174 = tl.load(in_ptr0 + (8 + x3), tmp173 & xmask, other=0.0)
    tmp175 = tl_math.abs(tmp174)
    tmp176 = tl.full(tmp175.shape, float('-inf'), tmp175.dtype)
    tmp177 = tl.where(tmp173, tmp175, tmp176)
    tmp178 = triton_helpers.maximum(tmp177, tmp172)
    tmp179 = tmp160 & tmp38
    tmp180 = tl.load(in_ptr0 + (9 + x3), tmp179 & xmask, other=0.0)
    tmp181 = tl_math.abs(tmp180)
    tmp182 = tl.full(tmp181.shape, float('-inf'), tmp181.dtype)
    tmp183 = tl.where(tmp179, tmp181, tmp182)
    tmp184 = triton_helpers.maximum(tmp183, tmp178)
    tmp185 = tmp160 & tmp48
    tmp186 = tl.load(in_ptr0 + (10 + x3), tmp185 & xmask, other=0.0)
    tmp187 = tl_math.abs(tmp186)
    tmp188 = tl.full(tmp187.shape, float('-inf'), tmp187.dtype)
    tmp189 = tl.where(tmp185, tmp187, tmp188)
    tmp190 = triton_helpers.maximum(tmp189, tmp184)
    tmp192 = 1.0
    tmp193 = tmp190 + tmp192
    tmp194 = tmp191 / tmp193
    tl.store(in_out_ptr0 + x3, tmp194, xmask)


def call(args):
    arg0_1, = args
    args.clear()
    assert_size_stride(arg0_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)
        buf1 = buf0
        del buf0
        get_raw_stream(0)
        triton_poi_fused_abs_add_div_max_pool2d_with_indices_0[grid(256)](buf1,
            arg0_1, 256, XBLOCK=128, num_warps=4, num_stages=1)
        del arg0_1
    return buf1,


class DivisiveNormalization2dNew(Module):
    """Applies a 2D divisive normalization over an input signal composed of several input
    planes.

    In the simplest case, the output value of the layer with input size :math:`(N, C, H, W)`
    and output :math:`(N, C, H, W)`.

    Args:
        b_type: Type of suppressin field, must be one of (`linf`, `l1`, `l2`).
        b_size: The size of the suppression field, must be > 0.
        sigma: Constant added to suppression field, must be > 0.

    Shape:
        - Input: :math:`(N, C, H, W)`
        - Output: :math:`(N, C, H, W)`

    Examples::

        >>> # suppression of size=3, sigma=1
        >>> d = DivisiveNormalization2d(b_size=3, sigma=1)
        >>> input = torch.randn(20, 16, 50, 50)
        >>> output = d(input)
    """

    def __init__(self, b_type: 'str'='linf', b_size:
        'Union[int, Tuple[int, int]]'=(5, 5), sigma: 'float'=1.0) ->None:
        super(DivisiveNormalization2dNew, self).__init__()
        self.sigma = sigma
        if isinstance(b_size, int):
            self.b_size = b_size, b_size
        else:
            self.b_size = b_size
        self.padding = self.b_size[0] // 2, self.b_size[1] // 2
        self.b_type = b_type

    def __repr__(self) ->str:
        s = 'DivisiveNormalization2d('
        s += f'b_type={self.b_type}, b_size={self.b_size}, sigma={self.sigma}'
        s += ')'
        return s.format(**self.__dict__)

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