import torch
from torch import device
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.triton_helpers import libdevice
import torch.nn as nn
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
empty_strided_cuda = torch._C._dynamo.guards._empty_strided_cuda


@triton.jit
def triton_poi_fused_cat_0(out_ptr0, xnumel, XBLOCK: tl.constexpr):
    xnumel = 32
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x0 = xindex % 2
    x1 = xindex // 2 % 4
    x2 = xindex // 8
    x4 = xindex
    tmp0 = x0
    tl.full([1], 0, tl.int64)
    tmp3 = tl.full([1], 1, tl.int64)
    tmp4 = tmp0 < tmp3
    tmp5 = x1
    tmp6 = tmp5.to(tl.float32)
    tmp7 = 6.0
    tmp8 = tmp6 < tmp7
    tmp9 = 0.16666666666666666
    tmp10 = tmp6 * tmp9
    tmp11 = -0.9166666666666666
    tmp12 = tmp10 + tmp11
    tmp13 = 11 + -1 * x1
    tmp14 = tmp13.to(tl.float32)
    tmp15 = tmp14 * tmp9
    tmp16 = 0.9166666666666666
    tmp17 = tmp16 - tmp15
    tmp18 = tl.where(tmp8, tmp12, tmp17)
    tmp19 = tl.full(tmp18.shape, 0.0, tmp18.dtype)
    tmp20 = tl.where(tmp4, tmp18, tmp19)
    tmp21 = tmp0 >= tmp3
    tl.full([1], 2, tl.int64)
    tmp24 = x2
    tmp25 = tmp24.to(tl.float32)
    tmp26 = tmp25 < tmp7
    tmp27 = tmp25 * tmp9
    tmp28 = tmp27 + tmp11
    tmp29 = 11 + -1 * x2
    tmp30 = tmp29.to(tl.float32)
    tmp31 = tmp30 * tmp9
    tmp32 = tmp16 - tmp31
    tmp33 = tl.where(tmp26, tmp28, tmp32)
    tmp34 = tl.full(tmp33.shape, 0.0, tmp33.dtype)
    tmp35 = tl.where(tmp21, tmp33, tmp34)
    tmp36 = tl.where(tmp4, tmp20, tmp35)
    tl.store(out_ptr0 + x4, tmp36, xmask)


@triton.jit
def triton_poi_fused_grid_sampler_2d_replication_pad2d_1(in_out_ptr0,
    in_ptr0, in_ptr1, in_ptr2, xnumel, XBLOCK: tl.constexpr):
    xnumel = 256
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x0 = xindex % 16
    x2 = xindex // 64
    x5 = xindex
    x3 = xindex // 16
    tmp0 = tl.load(in_ptr0 + 2 * x0, xmask, eviction_policy='evict_last')
    tmp1 = tl.load(in_ptr1 + 2 * x2, xmask, eviction_policy='evict_last')
    tmp14 = tl.load(in_ptr0 + (1 + 2 * x0), xmask, eviction_policy='evict_last'
        )
    tmp15 = tl.load(in_ptr1 + (1 + 2 * x2), xmask, eviction_policy='evict_last'
        )
    tmp2 = 0.16666666666666666
    tmp3 = tmp1 * tmp2
    tmp4 = tmp0 + tmp3
    tmp5 = 6.0
    tmp6 = tmp4 * tmp5
    tmp7 = 5.5
    tmp8 = tmp6 + tmp7
    tmp9 = libdevice.floor(tmp8)
    tmp10 = 0.0
    tmp11 = tmp9 >= tmp10
    tmp12 = 12.0
    tmp13 = tmp9 < tmp12
    tmp16 = tmp15 * tmp2
    tmp17 = tmp14 + tmp16
    tmp18 = tmp17 * tmp5
    tmp19 = tmp18 + tmp7
    tmp20 = libdevice.floor(tmp19)
    tmp21 = tmp20 >= tmp10
    tmp22 = tmp20 < tmp12
    tmp23 = tmp21 & tmp22
    tmp24 = tmp13 & tmp23
    tmp25 = tmp11 & tmp24
    tmp26 = 1.0
    tmp27 = tmp9 + tmp26
    tmp28 = tmp27 - tmp8
    tmp29 = tmp20 + tmp26
    tmp30 = tmp29 - tmp19
    tmp31 = tmp28 * tmp30
    tmp32 = tl.where(tmp25, tmp31, tmp10)
    tmp33 = tmp27 >= tmp10
    tmp34 = tmp27 < tmp12
    tmp35 = tmp34 & tmp23
    tmp36 = tmp33 & tmp35
    tmp37 = tmp8 - tmp9
    tmp38 = tmp37 * tmp30
    tmp39 = tl.where(tmp36, tmp38, tmp10)
    tmp40 = tmp29 >= tmp10
    tmp41 = tmp29 < tmp12
    tmp42 = tmp40 & tmp41
    tmp43 = tmp34 & tmp42
    tmp44 = tmp33 & tmp43
    tmp45 = tmp19 - tmp20
    tmp46 = tmp37 * tmp45
    tmp47 = tl.where(tmp44, tmp46, tmp10)
    tmp48 = tmp13 & tmp42
    tmp49 = tmp11 & tmp48
    tmp50 = tmp28 * tmp45
    tmp51 = tl.where(tmp49, tmp50, tmp10)
    tmp52 = tmp20.to(tl.int64)
    tmp53 = tl.full([1], 0, tl.int64)
    tmp54 = tl.where(tmp25, tmp52, tmp53)
    tmp55 = tl.full([XBLOCK], 12, tl.int32)
    tmp56 = tmp54 + tmp55
    tmp57 = tmp54 < 0
    tmp58 = tl.where(tmp57, tmp56, tmp54)
    tl.device_assert((0 <= tmp58) & (tmp58 < 12) | ~xmask,
        'index out of bounds: 0 <= tmp58 < 12')
    tmp60 = tmp9.to(tl.int64)
    tmp61 = tl.where(tmp25, tmp60, tmp53)
    tmp62 = tmp61 + tmp55
    tmp63 = tmp61 < 0
    tmp64 = tl.where(tmp63, tmp62, tmp61)
    tl.device_assert((0 <= tmp64) & (tmp64 < 12) | ~xmask,
        'index out of bounds: 0 <= tmp64 < 12')
    tmp66 = tl.load(in_ptr2 + (4 * (3 * (3 <= 0 * (0 >= -4 + tmp58) + (-4 +
        tmp58) * (-4 + tmp58 > 0)) + (0 * (0 >= -4 + tmp58) + (-4 + tmp58) *
        (-4 + tmp58 > 0)) * (0 * (0 >= -4 + tmp58) + (-4 + tmp58) * (-4 +
        tmp58 > 0) < 3)) + 16 * x3 + (3 * (3 <= 0 * (0 >= -4 + tmp64) + (-4 +
        tmp64) * (-4 + tmp64 > 0)) + (0 * (0 >= -4 + tmp64) + (-4 + tmp64) *
        (-4 + tmp64 > 0)) * (0 * (0 >= -4 + tmp64) + (-4 + tmp64) * (-4 +
        tmp64 > 0) < 3))), xmask, eviction_policy='evict_last')
    tmp67 = tl.where(tmp36, tmp52, tmp53)
    tmp68 = tmp27.to(tl.int64)
    tmp69 = tl.where(tmp36, tmp68, tmp53)
    tmp70 = tmp29.to(tl.int64)
    tmp71 = tl.where(tmp49, tmp70, tmp53)
    tmp72 = tl.where(tmp49, tmp60, tmp53)
    tmp73 = tmp66 * tmp32
    tmp74 = tmp67 + tmp55
    tmp75 = tmp67 < 0
    tmp76 = tl.where(tmp75, tmp74, tmp67)
    tl.device_assert((0 <= tmp76) & (tmp76 < 12) | ~xmask,
        'index out of bounds: 0 <= tmp76 < 12')
    tmp78 = tmp69 + tmp55
    tmp79 = tmp69 < 0
    tmp80 = tl.where(tmp79, tmp78, tmp69)
    tl.device_assert((0 <= tmp80) & (tmp80 < 12) | ~xmask,
        'index out of bounds: 0 <= tmp80 < 12')
    tmp82 = tl.load(in_ptr2 + (4 * (3 * (3 <= 0 * (0 >= -4 + tmp76) + (-4 +
        tmp76) * (-4 + tmp76 > 0)) + (0 * (0 >= -4 + tmp76) + (-4 + tmp76) *
        (-4 + tmp76 > 0)) * (0 * (0 >= -4 + tmp76) + (-4 + tmp76) * (-4 +
        tmp76 > 0) < 3)) + 16 * x3 + (3 * (3 <= 0 * (0 >= -4 + tmp80) + (-4 +
        tmp80) * (-4 + tmp80 > 0)) + (0 * (0 >= -4 + tmp80) + (-4 + tmp80) *
        (-4 + tmp80 > 0)) * (0 * (0 >= -4 + tmp80) + (-4 + tmp80) * (-4 +
        tmp80 > 0) < 3))), xmask, eviction_policy='evict_last')
    tmp83 = tmp82 * tmp39
    tmp84 = tmp73 + tmp83
    tmp85 = tmp71 + tmp55
    tmp86 = tmp71 < 0
    tmp87 = tl.where(tmp86, tmp85, tmp71)
    tl.device_assert((0 <= tmp87) & (tmp87 < 12) | ~xmask,
        'index out of bounds: 0 <= tmp87 < 12')
    tmp89 = tmp72 + tmp55
    tmp90 = tmp72 < 0
    tmp91 = tl.where(tmp90, tmp89, tmp72)
    tl.device_assert((0 <= tmp91) & (tmp91 < 12) | ~xmask,
        'index out of bounds: 0 <= tmp91 < 12')
    tmp93 = tl.load(in_ptr2 + (4 * (3 * (3 <= 0 * (0 >= -4 + tmp87) + (-4 +
        tmp87) * (-4 + tmp87 > 0)) + (0 * (0 >= -4 + tmp87) + (-4 + tmp87) *
        (-4 + tmp87 > 0)) * (0 * (0 >= -4 + tmp87) + (-4 + tmp87) * (-4 +
        tmp87 > 0) < 3)) + 16 * x3 + (3 * (3 <= 0 * (0 >= -4 + tmp91) + (-4 +
        tmp91) * (-4 + tmp91 > 0)) + (0 * (0 >= -4 + tmp91) + (-4 + tmp91) *
        (-4 + tmp91 > 0)) * (0 * (0 >= -4 + tmp91) + (-4 + tmp91) * (-4 +
        tmp91 > 0) < 3))), xmask, eviction_policy='evict_last')
    tmp94 = tmp93 * tmp51
    tmp95 = tmp84 + tmp94
    tmp96 = tl.where(tmp44, tmp70, tmp53)
    tmp97 = tl.where(tmp44, tmp68, tmp53)
    tmp98 = tmp96 + tmp55
    tmp99 = tmp96 < 0
    tmp100 = tl.where(tmp99, tmp98, tmp96)
    tl.device_assert((0 <= tmp100) & (tmp100 < 12) | ~xmask,
        'index out of bounds: 0 <= tmp100 < 12')
    tmp102 = tmp97 + tmp55
    tmp103 = tmp97 < 0
    tmp104 = tl.where(tmp103, tmp102, tmp97)
    tl.device_assert((0 <= tmp104) & (tmp104 < 12) | ~xmask,
        'index out of bounds: 0 <= tmp104 < 12')
    tmp106 = tl.load(in_ptr2 + (4 * (3 * (3 <= 0 * (0 >= -4 + tmp100) + (-4 +
        tmp100) * (-4 + tmp100 > 0)) + (0 * (0 >= -4 + tmp100) + (-4 +
        tmp100) * (-4 + tmp100 > 0)) * (0 * (0 >= -4 + tmp100) + (-4 +
        tmp100) * (-4 + tmp100 > 0) < 3)) + 16 * x3 + (3 * (3 <= 0 * (0 >= 
        -4 + tmp104) + (-4 + tmp104) * (-4 + tmp104 > 0)) + (0 * (0 >= -4 +
        tmp104) + (-4 + tmp104) * (-4 + tmp104 > 0)) * (0 * (0 >= -4 +
        tmp104) + (-4 + tmp104) * (-4 + tmp104 > 0) < 3))), xmask,
        eviction_policy='evict_last')
    tmp107 = tmp106 * tmp47
    tmp108 = tmp95 + tmp107
    tl.store(in_out_ptr0 + x5, tmp108, 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, 2), (8, 2, 1), torch.float32)
        get_raw_stream(0)
        triton_poi_fused_cat_0[grid(32)](buf0, 32, XBLOCK=32, num_warps=1,
            num_stages=1)
        buf1 = torch.ops.aten.randint.low(0, 9, [4, 1, 1, 2], dtype=torch.
            float32, device=device(type='cuda', index=0), pin_memory=False)
        buf2 = buf1
        del buf1
        buf10 = empty_strided_cuda((4, 4, 4, 4), (64, 16, 4, 1), torch.float32)
        buf11 = buf10
        del buf10
        buf15 = buf11
        del buf11
        triton_poi_fused_grid_sampler_2d_replication_pad2d_1[grid(256)](buf15,
            buf0, buf2, arg0_1, 256, XBLOCK=128, num_warps=4, num_stages=1)
        del arg0_1
        del buf0
        del buf2
    return buf15,


class RandomShiftsAugNew(nn.Module):

    def __init__(self, pad):
        super().__init__()
        self.pad = pad

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


Measured latency_ms: 0.037558