import torch
import numpy as np
import torch.nn as nn


class ConvLayer(torch.nn.Module):

    def __init__(self, in_channels, out_channels, kernel_size, stride):
        super(ConvLayer, self).__init__()
        reflection_padding = int(np.floor(kernel_size / 2))
        self.reflection_pad = nn.ReflectionPad2d(reflection_padding)
        self.conv2d = nn.Conv2d(in_channels, out_channels, kernel_size, stride)

    def forward(self, x):
        out = self.reflection_pad(x)
        out = self.conv2d(out)
        return out


class InstanceNormalization(torch.nn.Module):
    """InstanceNormalization
    Improves convergence of neural-style.
    ref: https://arxiv.org/pdf/1607.08022.pdf
    """

    def __init__(self, dim, eps=1e-09):
        super(InstanceNormalization, self).__init__()
        self.scale = nn.Parameter(torch.FloatTensor(dim))
        self.shift = nn.Parameter(torch.FloatTensor(dim))
        self.eps = eps
        self._reset_parameters()

    def _reset_parameters(self):
        self.scale.data.uniform_()
        self.shift.data.zero_()

    def forward(self, x):
        n = x.size(2) * x.size(3)
        t = x.view(x.size(0), x.size(1), n)
        mean = torch.mean(t, 2).unsqueeze(2).unsqueeze(3).expand_as(x)
        var = torch.var(t, 2).unsqueeze(2).unsqueeze(3).expand_as(x) * ((n -
            1) / float(n))
        scale_broadcast = self.scale.unsqueeze(1).unsqueeze(1).unsqueeze(0)
        scale_broadcast = scale_broadcast.expand_as(x)
        shift_broadcast = self.shift.unsqueeze(1).unsqueeze(1).unsqueeze(0)
        shift_broadcast = shift_broadcast.expand_as(x)
        out = (x - mean) / torch.sqrt(var + self.eps)
        out = out * scale_broadcast + shift_broadcast
        return out


class ResidualBlock(torch.nn.Module):
    """ResidualBlock
    introduced in: https://arxiv.org/abs/1512.03385
    recommended architecture: http://torch.ch/blog/2016/02/04/resnets.html
    """

    def __init__(self, channels):
        super(ResidualBlock, self).__init__()
        self.conv1 = ConvLayer(channels, channels, kernel_size=3, stride=1)
        self.in1 = InstanceNormalization(channels)
        self.conv2 = ConvLayer(channels, channels, kernel_size=3, stride=1)
        self.in2 = InstanceNormalization(channels)
        self.relu = nn.ReLU()

    def forward(self, x):
        residual = x
        out = self.relu(self.in1(self.conv1(x)))
        out = self.in2(self.conv2(out))
        out = out + residual
        return out


class UpsampleConvLayer(torch.nn.Module):
    """UpsampleConvLayer
    Upsamples the input and then does a convolution. This method gives better results
    compared to ConvTranspose2d.
    ref: http://distill.pub/2016/deconv-checkerboard/
    """

    def __init__(self, in_channels, out_channels, kernel_size, stride,
        upsample=None):
        super(UpsampleConvLayer, self).__init__()
        self.upsample = upsample
        if upsample:
            self.upsample_layer = torch.nn.Upsample(scale_factor=upsample)
        reflection_padding = int(np.floor(kernel_size / 2))
        self.reflection_pad = nn.ReflectionPad2d(reflection_padding)
        self.conv2d = nn.Conv2d(in_channels, out_channels, kernel_size, stride)

    def forward(self, x):
        x_in = x
        if self.upsample:
            x_in = self.upsample_layer(x_in)
        out = self.reflection_pad(x_in)
        out = self.conv2d(out)
        return out


class TransformerNet(torch.nn.Module):

    def __init__(self):
        super(TransformerNet, self).__init__()
        self.conv1 = ConvLayer(3, 32, kernel_size=9, stride=1)
        self.in1 = InstanceNormalization(32)
        self.conv2 = ConvLayer(32, 64, kernel_size=3, stride=2)
        self.in2 = InstanceNormalization(64)
        self.conv3 = ConvLayer(64, 128, kernel_size=3, stride=2)
        self.in3 = InstanceNormalization(128)
        self.res1 = ResidualBlock(128)
        self.res2 = ResidualBlock(128)
        self.res3 = ResidualBlock(128)
        self.res4 = ResidualBlock(128)
        self.res5 = ResidualBlock(128)
        self.deconv1 = UpsampleConvLayer(128, 64, kernel_size=3, stride=1,
            upsample=2)
        self.in4 = InstanceNormalization(64)
        self.deconv2 = UpsampleConvLayer(64, 32, kernel_size=3, stride=1,
            upsample=2)
        self.in5 = InstanceNormalization(32)
        self.deconv3 = ConvLayer(32, 3, kernel_size=9, stride=1)
        self.relu = nn.ReLU()

    def forward(self, X):
        in_X = X
        y = self.relu(self.in1(self.conv1(in_X)))
        y = self.relu(self.in2(self.conv2(y)))
        y = self.relu(self.in3(self.conv3(y)))
        y = self.res1(y)
        y = self.res2(y)
        y = self.res3(y)
        y = self.res4(y)
        y = self.res5(y)
        y = self.relu(self.in4(self.deconv1(y)))
        y = self.relu(self.in5(self.deconv2(y)))
        y = self.deconv3(y)
        return y


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


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

import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch._inductor.runtime.triton_helpers import libdevice, math as tl_math
import numpy as np
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
reinterpret_tensor = torch._C._dynamo.guards._reinterpret_tensor


@triton.jit
def triton_poi_fused_reflection_pad2d_0(in_ptr0, out_ptr0, xnumel, XBLOCK:
    tl.constexpr):
    xnumel = 62208
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x0 = xindex % 72
    x1 = xindex // 72 % 72
    x2 = xindex // 5184
    x3 = xindex
    tmp0 = tl.load(in_ptr0 + (4095 + -1 * tl_math.abs(-63 + tl_math.abs(-4 +
        x0)) + -64 * tl_math.abs(-63 + tl_math.abs(-4 + x1)) + 4096 * x2),
        xmask, eviction_policy='evict_last')
    tl.store(out_ptr0 + x3, tmp0, xmask)


@triton.jit
def triton_red_fused_convolution_mean_var_1(in_out_ptr0, in_out_ptr1,
    in_out_ptr2, in_ptr0, xnumel, rnumel, XBLOCK: tl.constexpr, RBLOCK: tl.
    constexpr):
    xnumel = 128
    rnumel = 4096
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:, None]
    xmask = xindex < xnumel
    rbase = tl.arange(0, RBLOCK)[None, :]
    x3 = xindex
    x0 = xindex % 32
    tmp1 = tl.load(in_ptr0 + x0, xmask, eviction_policy='evict_last')
    _tmp4 = tl.full([XBLOCK, RBLOCK], 0, tl.float32)
    tmp6_mean = tl.zeros([XBLOCK, RBLOCK], tl.float32)
    tmp6_m2 = tl.zeros([XBLOCK, RBLOCK], tl.float32)
    tmp6_weight = tl.zeros([XBLOCK, RBLOCK], tl.float32)
    for roffset in range(0, rnumel, RBLOCK):
        rindex = roffset + rbase
        rmask = rindex < rnumel
        r2 = rindex
        tmp0 = tl.load(in_out_ptr0 + (r2 + 4096 * x3), rmask & xmask,
            eviction_policy='evict_first', other=0.0)
        tmp2 = tmp0 + tmp1
        tmp3 = tl.broadcast_to(tmp2, [XBLOCK, RBLOCK])
        tmp5 = _tmp4 + tmp3
        _tmp4 = tl.where(rmask & xmask, tmp5, _tmp4)
        tmp6_mean_next, tmp6_m2_next, tmp6_weight_next = (triton_helpers.
            welford_reduce(tmp3, tmp6_mean, tmp6_m2, tmp6_weight, roffset == 0)
            )
        tmp6_mean = tl.where(rmask & xmask, tmp6_mean_next, tmp6_mean)
        tmp6_m2 = tl.where(rmask & xmask, tmp6_m2_next, tmp6_m2)
        tmp6_weight = tl.where(rmask & xmask, tmp6_weight_next, tmp6_weight)
        tl.store(in_out_ptr0 + (r2 + 4096 * x3), tmp2, rmask & xmask)
    tmp4 = tl.sum(_tmp4, 1)[:, None]
    tmp6_tmp, tmp7_tmp, tmp8_tmp = triton_helpers.welford(tmp6_mean,
        tmp6_m2, tmp6_weight, 1)
    tmp6_tmp[:, None]
    tmp7 = tmp7_tmp[:, None]
    tmp8_tmp[:, None]
    tmp9 = 4096.0
    tmp10 = tmp4 / tmp9
    tmp11 = 4095.0
    tmp12 = tmp7 / tmp11
    tl.debug_barrier()
    tl.store(in_out_ptr1 + x3, tmp10, xmask)
    tl.debug_barrier()
    tl.store(in_out_ptr2 + x3, tmp12, xmask)


@triton.jit
def triton_poi_fused_add_div_mul_reflection_pad2d_relu_sqrt_sub_2(in_ptr0,
    in_ptr1, in_ptr2, in_ptr3, in_ptr4, out_ptr0, xnumel, XBLOCK: tl.constexpr
    ):
    xnumel = 557568
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x0 = xindex % 66
    x1 = xindex // 66 % 66
    x4 = xindex // 4356
    x2 = xindex // 4356 % 32
    x6 = xindex
    tmp0 = tl.load(in_ptr0 + (4095 + -1 * tl_math.abs(-63 + tl_math.abs(-1 +
        x0)) + -64 * tl_math.abs(-63 + tl_math.abs(-1 + x1)) + 4096 * x4),
        xmask, eviction_policy='evict_last')
    tmp1 = tl.load(in_ptr1 + x4, xmask, eviction_policy='evict_last')
    tmp3 = tl.load(in_ptr2 + x4, xmask, eviction_policy='evict_last')
    tmp10 = tl.load(in_ptr3 + x2, xmask, eviction_policy='evict_last')
    tmp12 = tl.load(in_ptr4 + x2, xmask, eviction_policy='evict_last')
    tmp2 = tmp0 - tmp1
    tmp4 = 0.999755859375
    tmp5 = tmp3 * tmp4
    tmp6 = 1e-09
    tmp7 = tmp5 + tmp6
    tmp8 = libdevice.sqrt(tmp7)
    tmp9 = tmp2 / tmp8
    tmp11 = tmp9 * tmp10
    tmp13 = tmp11 + tmp12
    tmp14 = tl.full([1], 0, tl.int32)
    tmp15 = triton_helpers.maximum(tmp14, tmp13)
    tl.store(out_ptr0 + x6, tmp15, xmask)


@triton.jit
def triton_per_fused_convolution_mean_var_3(in_out_ptr0, in_out_ptr1,
    in_out_ptr2, in_ptr0, xnumel, rnumel):
    XBLOCK: tl.constexpr = 1
    RBLOCK: tl.constexpr = 1024
    xoffset = tl.program_id(0) * XBLOCK
    xindex = tl.full([1], xoffset, tl.int32)
    tl.full([RBLOCK], True, tl.int1)
    rindex = tl.arange(0, RBLOCK)[:]
    tl.full([RBLOCK], True, tl.int1)
    r2 = rindex
    x3 = xindex
    x0 = xindex % 64
    tmp0 = tl.load(in_out_ptr0 + (r2 + 1024 * x3), None)
    tmp1 = tl.load(in_ptr0 + x0, None, eviction_policy='evict_last')
    tmp2 = tmp0 + tmp1
    tmp3 = tl.broadcast_to(tmp2, [RBLOCK])
    tmp5 = triton_helpers.promote_to_tensor(tl.sum(tmp3, 0))
    tmp7 = tl.broadcast_to(tmp3, [RBLOCK])
    tmp9 = triton_helpers.promote_to_tensor(tl.sum(tmp7, 0))
    tmp10 = tl.full([1], 1024, tl.int32)
    tmp11 = tmp10.to(tl.float32)
    tmp12 = tmp9 / tmp11
    tmp13 = tmp3 - tmp12
    tmp14 = tmp13 * tmp13
    tmp15 = tl.broadcast_to(tmp14, [RBLOCK])
    tmp17 = triton_helpers.promote_to_tensor(tl.sum(tmp15, 0))
    tmp18 = 1024.0
    tmp19 = tmp5 / tmp18
    tmp20 = 1023.0
    tmp21 = tmp17 / tmp20
    tl.store(in_out_ptr0 + (r2 + 1024 * x3), tmp2, None)
    tl.debug_barrier()
    tl.store(in_out_ptr1 + x3, tmp19, None)
    tl.debug_barrier()
    tl.store(in_out_ptr2 + x3, tmp21, None)


@triton.jit
def triton_poi_fused_add_div_mul_reflection_pad2d_relu_sqrt_sub_4(in_ptr0,
    in_ptr1, in_ptr2, in_ptr3, in_ptr4, out_ptr0, xnumel, XBLOCK: tl.constexpr
    ):
    xnumel = 295936
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x0 = xindex % 34
    x1 = xindex // 34 % 34
    x4 = xindex // 1156
    x2 = xindex // 1156 % 64
    x6 = xindex
    tmp0 = tl.load(in_ptr0 + (1023 + -1 * tl_math.abs(-31 + tl_math.abs(-1 +
        x0)) + -32 * tl_math.abs(-31 + tl_math.abs(-1 + x1)) + 1024 * x4),
        xmask, eviction_policy='evict_last')
    tmp1 = tl.load(in_ptr1 + x4, xmask, eviction_policy='evict_last')
    tmp3 = tl.load(in_ptr2 + x4, xmask, eviction_policy='evict_last')
    tmp10 = tl.load(in_ptr3 + x2, xmask, eviction_policy='evict_last')
    tmp12 = tl.load(in_ptr4 + x2, xmask, eviction_policy='evict_last')
    tmp2 = tmp0 - tmp1
    tmp4 = 0.9990234375
    tmp5 = tmp3 * tmp4
    tmp6 = 1e-09
    tmp7 = tmp5 + tmp6
    tmp8 = libdevice.sqrt(tmp7)
    tmp9 = tmp2 / tmp8
    tmp11 = tmp9 * tmp10
    tmp13 = tmp11 + tmp12
    tmp14 = tl.full([1], 0, tl.int32)
    tmp15 = triton_helpers.maximum(tmp14, tmp13)
    tl.store(out_ptr0 + x6, tmp15, xmask)


@triton.jit
def triton_per_fused_add_convolution_div_mean_mul_relu_sqrt_sub_var_5(
    in_out_ptr0, in_out_ptr1, in_out_ptr2, in_ptr0, in_ptr1, in_ptr2,
    out_ptr0, xnumel, rnumel):
    XBLOCK: tl.constexpr = 1
    RBLOCK: tl.constexpr = 256
    xoffset = tl.program_id(0) * XBLOCK
    xindex = tl.full([1], xoffset, tl.int32)
    tl.full([RBLOCK], True, tl.int1)
    rindex = tl.arange(0, RBLOCK)[:]
    tl.full([RBLOCK], True, tl.int1)
    r2 = rindex
    x3 = xindex
    x0 = xindex % 128
    tmp0 = tl.load(in_out_ptr0 + (r2 + 256 * x3), None)
    tmp1 = tl.load(in_ptr0 + x0, None, eviction_policy='evict_last')
    tmp29 = tl.load(in_ptr1 + x0, None, eviction_policy='evict_last')
    tmp31 = tl.load(in_ptr2 + x0, None, eviction_policy='evict_last')
    tmp2 = tmp0 + tmp1
    tmp3 = tl.broadcast_to(tmp2, [RBLOCK])
    tmp5 = triton_helpers.promote_to_tensor(tl.sum(tmp3, 0))
    tmp7 = tl.broadcast_to(tmp3, [RBLOCK])
    tmp9 = triton_helpers.promote_to_tensor(tl.sum(tmp7, 0))
    tmp10 = tl.full([1], 256, tl.int32)
    tmp11 = tmp10.to(tl.float32)
    tmp12 = tmp9 / tmp11
    tmp13 = tmp3 - tmp12
    tmp14 = tmp13 * tmp13
    tmp15 = tl.broadcast_to(tmp14, [RBLOCK])
    tmp17 = triton_helpers.promote_to_tensor(tl.sum(tmp15, 0))
    tmp18 = 256.0
    tmp19 = tmp5 / tmp18
    tmp20 = 255.0
    tmp21 = tmp17 / tmp20
    tmp22 = tmp2 - tmp19
    tmp23 = 0.99609375
    tmp24 = tmp21 * tmp23
    tmp25 = 1e-09
    tmp26 = tmp24 + tmp25
    tmp27 = libdevice.sqrt(tmp26)
    tmp28 = tmp22 / tmp27
    tmp30 = tmp28 * tmp29
    tmp32 = tmp30 + tmp31
    tmp33 = tl.full([1], 0, tl.int32)
    tmp34 = triton_helpers.maximum(tmp33, tmp32)
    tl.store(in_out_ptr0 + (r2 + 256 * x3), tmp2, None)
    tl.debug_barrier()
    tl.store(in_out_ptr1 + x3, tmp19, None)
    tl.debug_barrier()
    tl.store(in_out_ptr2 + x3, tmp21, None)
    tl.store(out_ptr0 + (r2 + 256 * x3), tmp34, None)


@triton.jit
def triton_poi_fused_reflection_pad2d_6(in_ptr0, out_ptr0, xnumel, XBLOCK:
    tl.constexpr):
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    tl.full([XBLOCK], True, tl.int1)
    x0 = xindex % 18
    x1 = xindex // 18 % 18
    x2 = xindex // 324
    x3 = xindex
    tmp0 = tl.load(in_ptr0 + (255 + -1 * tl_math.abs(-15 + tl_math.abs(-1 +
        x0)) + -16 * tl_math.abs(-15 + tl_math.abs(-1 + x1)) + 256 * x2),
        None, eviction_policy='evict_last')
    tl.store(out_ptr0 + x3, tmp0, None)


@triton.jit
def triton_per_fused_convolution_mean_var_7(in_out_ptr0, in_out_ptr1,
    in_out_ptr2, in_ptr0, xnumel, rnumel):
    XBLOCK: tl.constexpr = 1
    RBLOCK: tl.constexpr = 256
    xoffset = tl.program_id(0) * XBLOCK
    xindex = tl.full([1], xoffset, tl.int32)
    tl.full([RBLOCK], True, tl.int1)
    rindex = tl.arange(0, RBLOCK)[:]
    tl.full([RBLOCK], True, tl.int1)
    r2 = rindex
    x3 = xindex
    x0 = xindex % 128
    tmp0 = tl.load(in_out_ptr0 + (r2 + 256 * x3), None)
    tmp1 = tl.load(in_ptr0 + x0, None, eviction_policy='evict_last')
    tmp2 = tmp0 + tmp1
    tmp3 = tl.broadcast_to(tmp2, [RBLOCK])
    tmp5 = triton_helpers.promote_to_tensor(tl.sum(tmp3, 0))
    tmp7 = tl.broadcast_to(tmp3, [RBLOCK])
    tmp9 = triton_helpers.promote_to_tensor(tl.sum(tmp7, 0))
    tmp10 = tl.full([1], 256, tl.int32)
    tmp11 = tmp10.to(tl.float32)
    tmp12 = tmp9 / tmp11
    tmp13 = tmp3 - tmp12
    tmp14 = tmp13 * tmp13
    tmp15 = tl.broadcast_to(tmp14, [RBLOCK])
    tmp17 = triton_helpers.promote_to_tensor(tl.sum(tmp15, 0))
    tmp18 = 256.0
    tmp19 = tmp5 / tmp18
    tmp20 = 255.0
    tmp21 = tmp17 / tmp20
    tl.store(in_out_ptr0 + (r2 + 256 * x3), tmp2, None)
    tl.debug_barrier()
    tl.store(in_out_ptr1 + x3, tmp19, None)
    tl.debug_barrier()
    tl.store(in_out_ptr2 + x3, tmp21, None)


@triton.jit
def triton_poi_fused_add_div_mul_reflection_pad2d_relu_sqrt_sub_8(in_ptr0,
    in_ptr1, in_ptr2, in_ptr3, in_ptr4, out_ptr0, xnumel, XBLOCK: tl.constexpr
    ):
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    tl.full([XBLOCK], True, tl.int1)
    x0 = xindex % 18
    x1 = xindex // 18 % 18
    x4 = xindex // 324
    x2 = xindex // 324 % 128
    x6 = xindex
    tmp0 = tl.load(in_ptr0 + (255 + -1 * tl_math.abs(-15 + tl_math.abs(-1 +
        x0)) + -16 * tl_math.abs(-15 + tl_math.abs(-1 + x1)) + 256 * x4),
        None, eviction_policy='evict_last')
    tmp1 = tl.load(in_ptr1 + x4, None, eviction_policy='evict_last')
    tmp3 = tl.load(in_ptr2 + x4, None, eviction_policy='evict_last')
    tmp10 = tl.load(in_ptr3 + x2, None, eviction_policy='evict_last')
    tmp12 = tl.load(in_ptr4 + x2, None, eviction_policy='evict_last')
    tmp2 = tmp0 - tmp1
    tmp4 = 0.99609375
    tmp5 = tmp3 * tmp4
    tmp6 = 1e-09
    tmp7 = tmp5 + tmp6
    tmp8 = libdevice.sqrt(tmp7)
    tmp9 = tmp2 / tmp8
    tmp11 = tmp9 * tmp10
    tmp13 = tmp11 + tmp12
    tmp14 = tl.full([1], 0, tl.int32)
    tmp15 = triton_helpers.maximum(tmp14, tmp13)
    tl.store(out_ptr0 + x6, tmp15, None)


@triton.jit
def triton_per_fused_add_convolution_div_mean_mul_sqrt_sub_var_9(in_out_ptr0,
    in_out_ptr1, in_out_ptr2, in_out_ptr3, in_ptr0, in_ptr1, in_ptr2,
    xnumel, rnumel):
    XBLOCK: tl.constexpr = 1
    RBLOCK: tl.constexpr = 256
    xoffset = tl.program_id(0) * XBLOCK
    xindex = tl.full([1], xoffset, tl.int32)
    tl.full([RBLOCK], True, tl.int1)
    rindex = tl.arange(0, RBLOCK)[:]
    tl.full([RBLOCK], True, tl.int1)
    r2 = rindex
    x3 = xindex
    x0 = xindex % 128
    tmp0 = tl.load(in_out_ptr0 + (r2 + 256 * x3), None)
    tmp1 = tl.load(in_ptr0 + x0, None, eviction_policy='evict_last')
    tmp29 = tl.load(in_ptr1 + x0, None, eviction_policy='evict_last')
    tmp31 = tl.load(in_ptr2 + x0, None, eviction_policy='evict_last')
    tmp33 = tl.load(in_out_ptr3 + (r2 + 256 * x3), None)
    tmp2 = tmp0 + tmp1
    tmp3 = tl.broadcast_to(tmp2, [RBLOCK])
    tmp5 = triton_helpers.promote_to_tensor(tl.sum(tmp3, 0))
    tmp7 = tl.broadcast_to(tmp3, [RBLOCK])
    tmp9 = triton_helpers.promote_to_tensor(tl.sum(tmp7, 0))
    tmp10 = tl.full([1], 256, tl.int32)
    tmp11 = tmp10.to(tl.float32)
    tmp12 = tmp9 / tmp11
    tmp13 = tmp3 - tmp12
    tmp14 = tmp13 * tmp13
    tmp15 = tl.broadcast_to(tmp14, [RBLOCK])
    tmp17 = triton_helpers.promote_to_tensor(tl.sum(tmp15, 0))
    tmp18 = 256.0
    tmp19 = tmp5 / tmp18
    tmp20 = 255.0
    tmp21 = tmp17 / tmp20
    tmp22 = tmp2 - tmp19
    tmp23 = 0.99609375
    tmp24 = tmp21 * tmp23
    tmp25 = 1e-09
    tmp26 = tmp24 + tmp25
    tmp27 = libdevice.sqrt(tmp26)
    tmp28 = tmp22 / tmp27
    tmp30 = tmp28 * tmp29
    tmp32 = tmp30 + tmp31
    tmp34 = tmp32 + tmp33
    tl.store(in_out_ptr0 + (r2 + 256 * x3), tmp2, None)
    tl.debug_barrier()
    tl.store(in_out_ptr1 + x3, tmp19, None)
    tl.debug_barrier()
    tl.store(in_out_ptr2 + x3, tmp21, None)
    tl.store(in_out_ptr3 + (r2 + 256 * x3), tmp34, None)


@triton.jit
def triton_poi_fused_arange_10(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
    tmp0 = x0
    tl.store(out_ptr0 + x0, tmp0, xmask)


@triton.jit
def triton_poi_fused__to_copy_add_arange_mul_11(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
    tmp0 = x0
    tmp1 = tmp0.to(tl.float32)
    tmp2 = 0.5
    tmp3 = tmp1 * tmp2
    tmp4 = tmp3.to(tl.int32)
    tl.store(out_ptr0 + x0, tmp4, xmask)


@triton.jit
def triton_poi_fused__unsafe_index_add_div_mul_reflection_pad2d_sqrt_sub_12(
    in_ptr0, in_ptr1, in_ptr2, in_ptr3, in_ptr4, in_ptr5, in_ptr6, out_ptr0,
    xnumel, XBLOCK: tl.constexpr):
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    tl.full([XBLOCK], True, tl.int1)
    x1 = xindex // 34 % 34
    x0 = xindex % 34
    x4 = xindex // 1156
    x2 = xindex // 1156 % 128
    x7 = xindex
    tmp0 = tl.load(in_ptr0 + (31 + -1 * tl_math.abs(-31 + tl_math.abs(-1 +
        x1))), None, eviction_policy='evict_last')
    tmp5 = tl.load(in_ptr0 + (31 + -1 * tl_math.abs(-31 + tl_math.abs(-1 +
        x0))), None, eviction_policy='evict_last')
    tmp10 = tl.load(in_ptr2 + x4, None, eviction_policy='evict_last')
    tmp12 = tl.load(in_ptr3 + x4, None, eviction_policy='evict_last')
    tmp19 = tl.load(in_ptr4 + x2, None, eviction_policy='evict_last')
    tmp21 = tl.load(in_ptr5 + x2, None, eviction_policy='evict_last')
    tmp1 = tl.full([XBLOCK], 16, tl.int32)
    tmp2 = tmp0 + tmp1
    tmp3 = tmp0 < 0
    tmp4 = tl.where(tmp3, tmp2, tmp0)
    tmp6 = tmp5 + tmp1
    tmp7 = tmp5 < 0
    tmp8 = tl.where(tmp7, tmp6, tmp5)
    tmp9 = tl.load(in_ptr1 + (tmp8 + 16 * tmp4 + 256 * x4), None,
        eviction_policy='evict_last')
    tmp11 = tmp9 - tmp10
    tmp13 = 0.99609375
    tmp14 = tmp12 * tmp13
    tmp15 = 1e-09
    tmp16 = tmp14 + tmp15
    tmp17 = libdevice.sqrt(tmp16)
    tmp18 = tmp11 / tmp17
    tmp20 = tmp18 * tmp19
    tmp22 = tmp20 + tmp21
    tmp23 = tl.load(in_ptr6 + (tmp8 + 16 * tmp4 + 256 * x4), None,
        eviction_policy='evict_last')
    tmp24 = tmp22 + tmp23
    tl.store(out_ptr0 + x7, tmp24, None)


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


@triton.jit
def triton_poi_fused__to_copy_add_arange_mul_14(out_ptr0, xnumel, XBLOCK:
    tl.constexpr):
    xnumel = 64
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x0 = xindex
    tmp0 = x0
    tmp1 = tmp0.to(tl.float32)
    tmp2 = 0.5
    tmp3 = tmp1 * tmp2
    tmp4 = tmp3.to(tl.int32)
    tl.store(out_ptr0 + x0, tmp4, xmask)


@triton.jit
def triton_poi_fused__unsafe_index_add_div_mul_reflection_pad2d_relu_sqrt_sub_15(
    in_ptr0, in_ptr1, in_ptr2, in_ptr3, in_ptr4, in_ptr5, out_ptr0, xnumel,
    XBLOCK: tl.constexpr):
    xnumel = 1115136
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x1 = xindex // 66 % 66
    x0 = xindex % 66
    x4 = xindex // 4356
    x2 = xindex // 4356 % 64
    x7 = xindex
    tmp0 = tl.load(in_ptr0 + (63 + -1 * tl_math.abs(-63 + tl_math.abs(-1 +
        x1))), xmask, eviction_policy='evict_last')
    tmp5 = tl.load(in_ptr0 + (63 + -1 * tl_math.abs(-63 + tl_math.abs(-1 +
        x0))), xmask, eviction_policy='evict_last')
    tmp10 = tl.load(in_ptr2 + x4, xmask, eviction_policy='evict_last')
    tmp12 = tl.load(in_ptr3 + x4, xmask, eviction_policy='evict_last')
    tmp19 = tl.load(in_ptr4 + x2, xmask, eviction_policy='evict_last')
    tmp21 = tl.load(in_ptr5 + x2, xmask, eviction_policy='evict_last')
    tmp1 = tl.full([XBLOCK], 32, tl.int32)
    tmp2 = tmp0 + tmp1
    tmp3 = tmp0 < 0
    tmp4 = tl.where(tmp3, tmp2, tmp0)
    tmp6 = tmp5 + tmp1
    tmp7 = tmp5 < 0
    tmp8 = tl.where(tmp7, tmp6, tmp5)
    tmp9 = tl.load(in_ptr1 + (tmp8 + 32 * tmp4 + 1024 * x4), xmask,
        eviction_policy='evict_last')
    tmp11 = tmp9 - tmp10
    tmp13 = 0.9990234375
    tmp14 = tmp12 * tmp13
    tmp15 = 1e-09
    tmp16 = tmp14 + tmp15
    tmp17 = libdevice.sqrt(tmp16)
    tmp18 = tmp11 / tmp17
    tmp20 = tmp18 * tmp19
    tmp22 = tmp20 + tmp21
    tmp23 = tl.full([1], 0, tl.int32)
    tmp24 = triton_helpers.maximum(tmp23, tmp22)
    tl.store(out_ptr0 + x7, tmp24, xmask)


@triton.jit
def triton_poi_fused_add_div_mul_reflection_pad2d_relu_sqrt_sub_16(in_ptr0,
    in_ptr1, in_ptr2, in_ptr3, in_ptr4, out_ptr0, xnumel, XBLOCK: tl.constexpr
    ):
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    tl.full([XBLOCK], True, tl.int1)
    x0 = xindex % 72
    x1 = xindex // 72 % 72
    x4 = xindex // 5184
    x2 = xindex // 5184 % 32
    x6 = xindex
    tmp0 = tl.load(in_ptr0 + (4095 + -1 * tl_math.abs(-63 + tl_math.abs(-4 +
        x0)) + -64 * tl_math.abs(-63 + tl_math.abs(-4 + x1)) + 4096 * x4),
        None, eviction_policy='evict_last')
    tmp1 = tl.load(in_ptr1 + x4, None, eviction_policy='evict_last')
    tmp3 = tl.load(in_ptr2 + x4, None, eviction_policy='evict_last')
    tmp10 = tl.load(in_ptr3 + x2, None, eviction_policy='evict_last')
    tmp12 = tl.load(in_ptr4 + x2, None, eviction_policy='evict_last')
    tmp2 = tmp0 - tmp1
    tmp4 = 0.999755859375
    tmp5 = tmp3 * tmp4
    tmp6 = 1e-09
    tmp7 = tmp5 + tmp6
    tmp8 = libdevice.sqrt(tmp7)
    tmp9 = tmp2 / tmp8
    tmp11 = tmp9 * tmp10
    tmp13 = tmp11 + tmp12
    tmp14 = tl.full([1], 0, tl.int32)
    tmp15 = triton_helpers.maximum(tmp14, tmp13)
    tl.store(out_ptr0 + x6, tmp15, None)


@triton.jit
def triton_poi_fused_convolution_17(in_out_ptr0, in_ptr0, xnumel, XBLOCK:
    tl.constexpr):
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    tl.full([XBLOCK], True, tl.int1)
    x3 = xindex
    x1 = xindex // 4096 % 3
    tmp0 = tl.load(in_out_ptr0 + x3, None)
    tmp1 = tl.load(in_ptr0 + x1, None, eviction_policy='evict_last')
    tmp2 = tmp0 + tmp1
    tl.store(in_out_ptr0 + x3, tmp2, None)


def call(args):
    (primals_1, primals_2, primals_3, primals_4, primals_5, primals_6,
        primals_7, primals_8, primals_9, primals_10, primals_11, primals_12,
        primals_13, primals_14, primals_15, primals_16, primals_17,
        primals_18, primals_19, primals_20, primals_21, primals_22,
        primals_23, primals_24, primals_25, primals_26, primals_27,
        primals_28, primals_29, primals_30, primals_31, primals_32,
        primals_33, primals_34, primals_35, primals_36, primals_37,
        primals_38, primals_39, primals_40, primals_41, primals_42,
        primals_43, primals_44, primals_45, primals_46, primals_47,
        primals_48, primals_49, primals_50, primals_51, primals_52,
        primals_53, primals_54, primals_55, primals_56, primals_57,
        primals_58, primals_59, primals_60, primals_61, primals_62, primals_63
        ) = args
    args.clear()
    assert_size_stride(primals_1, (4, 3, 64, 64), (12288, 4096, 64, 1))
    assert_size_stride(primals_2, (32, 3, 9, 9), (243, 81, 9, 1))
    assert_size_stride(primals_3, (32,), (1,))
    assert_size_stride(primals_4, (32,), (1,))
    assert_size_stride(primals_5, (32,), (1,))
    assert_size_stride(primals_6, (64, 32, 3, 3), (288, 9, 3, 1))
    assert_size_stride(primals_7, (64,), (1,))
    assert_size_stride(primals_8, (64,), (1,))
    assert_size_stride(primals_9, (64,), (1,))
    assert_size_stride(primals_10, (128, 64, 3, 3), (576, 9, 3, 1))
    assert_size_stride(primals_11, (128,), (1,))
    assert_size_stride(primals_12, (128,), (1,))
    assert_size_stride(primals_13, (128,), (1,))
    assert_size_stride(primals_14, (128, 128, 3, 3), (1152, 9, 3, 1))
    assert_size_stride(primals_15, (128,), (1,))
    assert_size_stride(primals_16, (128,), (1,))
    assert_size_stride(primals_17, (128,), (1,))
    assert_size_stride(primals_18, (128, 128, 3, 3), (1152, 9, 3, 1))
    assert_size_stride(primals_19, (128,), (1,))
    assert_size_stride(primals_20, (128,), (1,))
    assert_size_stride(primals_21, (128,), (1,))
    assert_size_stride(primals_22, (128, 128, 3, 3), (1152, 9, 3, 1))
    assert_size_stride(primals_23, (128,), (1,))
    assert_size_stride(primals_24, (128,), (1,))
    assert_size_stride(primals_25, (128,), (1,))
    assert_size_stride(primals_26, (128, 128, 3, 3), (1152, 9, 3, 1))
    assert_size_stride(primals_27, (128,), (1,))
    assert_size_stride(primals_28, (128,), (1,))
    assert_size_stride(primals_29, (128,), (1,))
    assert_size_stride(primals_30, (128, 128, 3, 3), (1152, 9, 3, 1))
    assert_size_stride(primals_31, (128,), (1,))
    assert_size_stride(primals_32, (128,), (1,))
    assert_size_stride(primals_33, (128,), (1,))
    assert_size_stride(primals_34, (128, 128, 3, 3), (1152, 9, 3, 1))
    assert_size_stride(primals_35, (128,), (1,))
    assert_size_stride(primals_36, (128,), (1,))
    assert_size_stride(primals_37, (128,), (1,))
    assert_size_stride(primals_38, (128, 128, 3, 3), (1152, 9, 3, 1))
    assert_size_stride(primals_39, (128,), (1,))
    assert_size_stride(primals_40, (128,), (1,))
    assert_size_stride(primals_41, (128,), (1,))
    assert_size_stride(primals_42, (128, 128, 3, 3), (1152, 9, 3, 1))
    assert_size_stride(primals_43, (128,), (1,))
    assert_size_stride(primals_44, (128,), (1,))
    assert_size_stride(primals_45, (128,), (1,))
    assert_size_stride(primals_46, (128, 128, 3, 3), (1152, 9, 3, 1))
    assert_size_stride(primals_47, (128,), (1,))
    assert_size_stride(primals_48, (128,), (1,))
    assert_size_stride(primals_49, (128,), (1,))
    assert_size_stride(primals_50, (128, 128, 3, 3), (1152, 9, 3, 1))
    assert_size_stride(primals_51, (128,), (1,))
    assert_size_stride(primals_52, (128,), (1,))
    assert_size_stride(primals_53, (128,), (1,))
    assert_size_stride(primals_54, (64, 128, 3, 3), (1152, 9, 3, 1))
    assert_size_stride(primals_55, (64,), (1,))
    assert_size_stride(primals_56, (64,), (1,))
    assert_size_stride(primals_57, (64,), (1,))
    assert_size_stride(primals_58, (32, 64, 3, 3), (576, 9, 3, 1))
    assert_size_stride(primals_59, (32,), (1,))
    assert_size_stride(primals_60, (32,), (1,))
    assert_size_stride(primals_61, (32,), (1,))
    assert_size_stride(primals_62, (3, 32, 9, 9), (2592, 81, 9, 1))
    assert_size_stride(primals_63, (3,), (1,))
    with torch.cuda._DeviceGuard(0):
        torch.cuda.set_device(0)
        buf0 = empty_strided_cuda((4, 3, 72, 72), (15552, 5184, 72, 1),
            torch.float32)
        get_raw_stream(0)
        triton_poi_fused_reflection_pad2d_0[grid(62208)](primals_1, buf0, 
            62208, XBLOCK=256, num_warps=4, num_stages=1)
        del primals_1
        buf1 = extern_kernels.convolution(buf0, primals_2, stride=(1, 1),
            padding=(0, 0), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf1, (4, 32, 64, 64), (131072, 4096, 64, 1))
        buf2 = buf1
        del buf1
        buf3 = empty_strided_cuda((4, 32), (32, 1), torch.float32)
        buf6 = empty_strided_cuda((4, 32), (32, 1), torch.float32)
        buf4 = buf3
        del buf3
        buf8 = buf6
        del buf6
        triton_red_fused_convolution_mean_var_1[grid(128)](buf2, buf4, buf8,
            primals_3, 128, 4096, XBLOCK=1, RBLOCK=2048, num_warps=16,
            num_stages=1)
        del primals_3
        buf9 = empty_strided_cuda((4, 32, 66, 66), (139392, 4356, 66, 1),
            torch.float32)
        triton_poi_fused_add_div_mul_reflection_pad2d_relu_sqrt_sub_2[grid(
            557568)](buf2, buf4, buf8, primals_4, primals_5, buf9, 557568,
            XBLOCK=512, num_warps=8, num_stages=1)
        buf10 = extern_kernels.convolution(buf9, primals_6, stride=(2, 2),
            padding=(0, 0), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf10, (4, 64, 32, 32), (65536, 1024, 32, 1))
        buf11 = buf10
        del buf10
        buf12 = empty_strided_cuda((4, 64), (64, 1), torch.float32)
        buf15 = empty_strided_cuda((4, 64), (64, 1), torch.float32)
        buf13 = buf12
        del buf12
        buf17 = buf15
        del buf15
        triton_per_fused_convolution_mean_var_3[grid(256)](buf11, buf13,
            buf17, primals_7, 256, 1024, num_warps=8, num_stages=1)
        del primals_7
        buf18 = empty_strided_cuda((4, 64, 34, 34), (73984, 1156, 34, 1),
            torch.float32)
        triton_poi_fused_add_div_mul_reflection_pad2d_relu_sqrt_sub_4[grid(
            295936)](buf11, buf13, buf17, primals_8, primals_9, buf18, 
            295936, XBLOCK=1024, num_warps=4, num_stages=1)
        buf19 = extern_kernels.convolution(buf18, primals_10, stride=(2, 2),
            padding=(0, 0), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf19, (4, 128, 16, 16), (32768, 256, 16, 1))
        buf20 = buf19
        del buf19
        buf21 = empty_strided_cuda((4, 128), (128, 1), torch.float32)
        buf24 = empty_strided_cuda((4, 128), (128, 1), torch.float32)
        buf22 = buf21
        del buf21
        buf26 = buf24
        del buf24
        buf27 = empty_strided_cuda((4, 128, 16, 16), (32768, 256, 16, 1),
            torch.float32)
        triton_per_fused_add_convolution_div_mean_mul_relu_sqrt_sub_var_5[grid
            (512)](buf20, buf22, buf26, primals_11, primals_12, primals_13,
            buf27, 512, 256, num_warps=2, num_stages=1)
        del primals_11
        buf28 = empty_strided_cuda((4, 128, 18, 18), (41472, 324, 18, 1),
            torch.float32)
        triton_poi_fused_reflection_pad2d_6[grid(165888)](buf27, buf28, 
            165888, XBLOCK=512, num_warps=8, num_stages=1)
        buf29 = extern_kernels.convolution(buf28, primals_14, stride=(1, 1),
            padding=(0, 0), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf29, (4, 128, 16, 16), (32768, 256, 16, 1))
        buf30 = buf29
        del buf29
        buf31 = empty_strided_cuda((4, 128), (128, 1), torch.float32)
        buf34 = empty_strided_cuda((4, 128), (128, 1), torch.float32)
        buf32 = buf31
        del buf31
        buf36 = buf34
        del buf34
        triton_per_fused_convolution_mean_var_7[grid(512)](buf30, buf32,
            buf36, primals_15, 512, 256, num_warps=2, num_stages=1)
        del primals_15
        buf37 = empty_strided_cuda((4, 128, 18, 18), (41472, 324, 18, 1),
            torch.float32)
        triton_poi_fused_add_div_mul_reflection_pad2d_relu_sqrt_sub_8[grid(
            165888)](buf30, buf32, buf36, primals_16, primals_17, buf37, 
            165888, XBLOCK=512, num_warps=8, num_stages=1)
        buf38 = extern_kernels.convolution(buf37, primals_18, stride=(1, 1),
            padding=(0, 0), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf38, (4, 128, 16, 16), (32768, 256, 16, 1))
        buf39 = buf38
        del buf38
        buf40 = empty_strided_cuda((4, 128), (128, 1), torch.float32)
        buf43 = empty_strided_cuda((4, 128), (128, 1), torch.float32)
        buf41 = buf40
        del buf40
        buf45 = buf43
        del buf43
        buf46 = buf27
        del buf27
        triton_per_fused_add_convolution_div_mean_mul_sqrt_sub_var_9[grid(512)
            ](buf39, buf41, buf45, buf46, primals_19, primals_20,
            primals_21, 512, 256, num_warps=2, num_stages=1)
        del primals_19
        del primals_21
        buf47 = empty_strided_cuda((4, 128, 18, 18), (41472, 324, 18, 1),
            torch.float32)
        triton_poi_fused_reflection_pad2d_6[grid(165888)](buf46, buf47, 
            165888, XBLOCK=512, num_warps=8, num_stages=1)
        buf48 = extern_kernels.convolution(buf47, primals_22, stride=(1, 1),
            padding=(0, 0), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf48, (4, 128, 16, 16), (32768, 256, 16, 1))
        buf49 = buf48
        del buf48
        buf50 = empty_strided_cuda((4, 128), (128, 1), torch.float32)
        buf53 = empty_strided_cuda((4, 128), (128, 1), torch.float32)
        buf51 = buf50
        del buf50
        buf55 = buf53
        del buf53
        triton_per_fused_convolution_mean_var_7[grid(512)](buf49, buf51,
            buf55, primals_23, 512, 256, num_warps=2, num_stages=1)
        del primals_23
        buf56 = empty_strided_cuda((4, 128, 18, 18), (41472, 324, 18, 1),
            torch.float32)
        triton_poi_fused_add_div_mul_reflection_pad2d_relu_sqrt_sub_8[grid(
            165888)](buf49, buf51, buf55, primals_24, primals_25, buf56, 
            165888, XBLOCK=512, num_warps=8, num_stages=1)
        buf57 = extern_kernels.convolution(buf56, primals_26, stride=(1, 1),
            padding=(0, 0), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf57, (4, 128, 16, 16), (32768, 256, 16, 1))
        buf58 = buf57
        del buf57
        buf59 = empty_strided_cuda((4, 128), (128, 1), torch.float32)
        buf62 = empty_strided_cuda((4, 128), (128, 1), torch.float32)
        buf60 = buf59
        del buf59
        buf64 = buf62
        del buf62
        buf65 = buf46
        del buf46
        triton_per_fused_add_convolution_div_mean_mul_sqrt_sub_var_9[grid(512)
            ](buf58, buf60, buf64, buf65, primals_27, primals_28,
            primals_29, 512, 256, num_warps=2, num_stages=1)
        del primals_27
        del primals_29
        buf66 = empty_strided_cuda((4, 128, 18, 18), (41472, 324, 18, 1),
            torch.float32)
        triton_poi_fused_reflection_pad2d_6[grid(165888)](buf65, buf66, 
            165888, XBLOCK=512, num_warps=8, num_stages=1)
        buf67 = extern_kernels.convolution(buf66, primals_30, stride=(1, 1),
            padding=(0, 0), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf67, (4, 128, 16, 16), (32768, 256, 16, 1))
        buf68 = buf67
        del buf67
        buf69 = empty_strided_cuda((4, 128), (128, 1), torch.float32)
        buf72 = empty_strided_cuda((4, 128), (128, 1), torch.float32)
        buf70 = buf69
        del buf69
        buf74 = buf72
        del buf72
        triton_per_fused_convolution_mean_var_7[grid(512)](buf68, buf70,
            buf74, primals_31, 512, 256, num_warps=2, num_stages=1)
        del primals_31
        buf75 = empty_strided_cuda((4, 128, 18, 18), (41472, 324, 18, 1),
            torch.float32)
        triton_poi_fused_add_div_mul_reflection_pad2d_relu_sqrt_sub_8[grid(
            165888)](buf68, buf70, buf74, primals_32, primals_33, buf75, 
            165888, XBLOCK=512, num_warps=8, num_stages=1)
        buf76 = extern_kernels.convolution(buf75, primals_34, stride=(1, 1),
            padding=(0, 0), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf76, (4, 128, 16, 16), (32768, 256, 16, 1))
        buf77 = buf76
        del buf76
        buf78 = empty_strided_cuda((4, 128), (128, 1), torch.float32)
        buf81 = empty_strided_cuda((4, 128), (128, 1), torch.float32)
        buf79 = buf78
        del buf78
        buf83 = buf81
        del buf81
        buf84 = buf65
        del buf65
        triton_per_fused_add_convolution_div_mean_mul_sqrt_sub_var_9[grid(512)
            ](buf77, buf79, buf83, buf84, primals_35, primals_36,
            primals_37, 512, 256, num_warps=2, num_stages=1)
        del primals_35
        del primals_37
        buf85 = empty_strided_cuda((4, 128, 18, 18), (41472, 324, 18, 1),
            torch.float32)
        triton_poi_fused_reflection_pad2d_6[grid(165888)](buf84, buf85, 
            165888, XBLOCK=512, num_warps=8, num_stages=1)
        buf86 = extern_kernels.convolution(buf85, primals_38, stride=(1, 1),
            padding=(0, 0), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf86, (4, 128, 16, 16), (32768, 256, 16, 1))
        buf87 = buf86
        del buf86
        buf88 = empty_strided_cuda((4, 128), (128, 1), torch.float32)
        buf91 = empty_strided_cuda((4, 128), (128, 1), torch.float32)
        buf89 = buf88
        del buf88
        buf93 = buf91
        del buf91
        triton_per_fused_convolution_mean_var_7[grid(512)](buf87, buf89,
            buf93, primals_39, 512, 256, num_warps=2, num_stages=1)
        del primals_39
        buf94 = empty_strided_cuda((4, 128, 18, 18), (41472, 324, 18, 1),
            torch.float32)
        triton_poi_fused_add_div_mul_reflection_pad2d_relu_sqrt_sub_8[grid(
            165888)](buf87, buf89, buf93, primals_40, primals_41, buf94, 
            165888, XBLOCK=512, num_warps=8, num_stages=1)
        buf95 = extern_kernels.convolution(buf94, primals_42, stride=(1, 1),
            padding=(0, 0), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf95, (4, 128, 16, 16), (32768, 256, 16, 1))
        buf96 = buf95
        del buf95
        buf97 = empty_strided_cuda((4, 128), (128, 1), torch.float32)
        buf100 = empty_strided_cuda((4, 128), (128, 1), torch.float32)
        buf98 = buf97
        del buf97
        buf102 = buf100
        del buf100
        buf103 = buf84
        del buf84
        triton_per_fused_add_convolution_div_mean_mul_sqrt_sub_var_9[grid(512)
            ](buf96, buf98, buf102, buf103, primals_43, primals_44,
            primals_45, 512, 256, num_warps=2, num_stages=1)
        del primals_43
        del primals_45
        buf104 = empty_strided_cuda((4, 128, 18, 18), (41472, 324, 18, 1),
            torch.float32)
        triton_poi_fused_reflection_pad2d_6[grid(165888)](buf103, buf104, 
            165888, XBLOCK=512, num_warps=8, num_stages=1)
        buf105 = extern_kernels.convolution(buf104, primals_46, stride=(1, 
            1), padding=(0, 0), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf105, (4, 128, 16, 16), (32768, 256, 16, 1))
        buf106 = buf105
        del buf105
        buf107 = empty_strided_cuda((4, 128), (128, 1), torch.float32)
        buf110 = empty_strided_cuda((4, 128), (128, 1), torch.float32)
        buf108 = buf107
        del buf107
        buf112 = buf110
        del buf110
        triton_per_fused_convolution_mean_var_7[grid(512)](buf106, buf108,
            buf112, primals_47, 512, 256, num_warps=2, num_stages=1)
        del primals_47
        buf113 = empty_strided_cuda((4, 128, 18, 18), (41472, 324, 18, 1),
            torch.float32)
        triton_poi_fused_add_div_mul_reflection_pad2d_relu_sqrt_sub_8[grid(
            165888)](buf106, buf108, buf112, primals_48, primals_49, buf113,
            165888, XBLOCK=512, num_warps=8, num_stages=1)
        buf114 = extern_kernels.convolution(buf113, primals_50, stride=(1, 
            1), padding=(0, 0), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf114, (4, 128, 16, 16), (32768, 256, 16, 1))
        buf115 = buf114
        del buf114
        buf116 = empty_strided_cuda((4, 128), (128, 1), torch.float32)
        buf119 = empty_strided_cuda((4, 128), (128, 1), torch.float32)
        buf117 = buf116
        del buf116
        buf121 = buf119
        del buf119
        triton_per_fused_convolution_mean_var_7[grid(512)](buf115, buf117,
            buf121, primals_51, 512, 256, num_warps=2, num_stages=1)
        del primals_51
        buf122 = empty_strided_cuda((32,), (1,), torch.int64)
        triton_poi_fused_arange_10[grid(32)](buf122, 32, XBLOCK=32,
            num_warps=1, num_stages=1)
        buf123 = empty_strided_cuda((32,), (1,), torch.int64)
        triton_poi_fused__to_copy_add_arange_mul_11[grid(32)](buf123, 32,
            XBLOCK=32, num_warps=1, num_stages=1)
        buf124 = empty_strided_cuda((4, 128, 34, 34), (147968, 1156, 34, 1),
            torch.float32)
        triton_poi_fused__unsafe_index_add_div_mul_reflection_pad2d_sqrt_sub_12[
            grid(591872)](buf123, buf115, buf117, buf121, primals_52,
            primals_53, buf103, buf124, 591872, XBLOCK=512, num_warps=8,
            num_stages=1)
        del buf103
        del primals_53
        buf125 = extern_kernels.convolution(buf124, primals_54, stride=(1, 
            1), padding=(0, 0), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf125, (4, 64, 32, 32), (65536, 1024, 32, 1))
        buf126 = buf125
        del buf125
        buf127 = empty_strided_cuda((4, 64), (64, 1), torch.float32)
        buf130 = empty_strided_cuda((4, 64), (64, 1), torch.float32)
        buf128 = buf127
        del buf127
        buf132 = buf130
        del buf130
        triton_per_fused_convolution_mean_var_3[grid(256)](buf126, buf128,
            buf132, primals_55, 256, 1024, num_warps=8, num_stages=1)
        del primals_55
        buf133 = empty_strided_cuda((64,), (1,), torch.int64)
        triton_poi_fused_arange_13[grid(64)](buf133, 64, XBLOCK=64,
            num_warps=1, num_stages=1)
        buf134 = empty_strided_cuda((64,), (1,), torch.int64)
        triton_poi_fused__to_copy_add_arange_mul_14[grid(64)](buf134, 64,
            XBLOCK=64, num_warps=1, num_stages=1)
        buf135 = empty_strided_cuda((4, 64, 66, 66), (278784, 4356, 66, 1),
            torch.float32)
        triton_poi_fused__unsafe_index_add_div_mul_reflection_pad2d_relu_sqrt_sub_15[
            grid(1115136)](buf134, buf126, buf128, buf132, primals_56,
            primals_57, buf135, 1115136, XBLOCK=512, num_warps=8, num_stages=1)
        buf136 = extern_kernels.convolution(buf135, primals_58, stride=(1, 
            1), padding=(0, 0), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf136, (4, 32, 64, 64), (131072, 4096, 64, 1))
        buf137 = buf136
        del buf136
        buf138 = empty_strided_cuda((4, 32), (32, 1), torch.float32)
        buf141 = empty_strided_cuda((4, 32), (32, 1), torch.float32)
        buf139 = buf138
        del buf138
        buf143 = buf141
        del buf141
        triton_red_fused_convolution_mean_var_1[grid(128)](buf137, buf139,
            buf143, primals_59, 128, 4096, XBLOCK=1, RBLOCK=2048, num_warps
            =16, num_stages=1)
        del primals_59
        buf144 = empty_strided_cuda((4, 32, 72, 72), (165888, 5184, 72, 1),
            torch.float32)
        triton_poi_fused_add_div_mul_reflection_pad2d_relu_sqrt_sub_16[grid
            (663552)](buf137, buf139, buf143, primals_60, primals_61,
            buf144, 663552, XBLOCK=512, num_warps=8, num_stages=1)
        buf145 = extern_kernels.convolution(buf144, primals_62, stride=(1, 
            1), padding=(0, 0), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf145, (4, 3, 64, 64), (12288, 4096, 64, 1))
        buf146 = buf145
        del buf145
        triton_poi_fused_convolution_17[grid(49152)](buf146, primals_63, 
            49152, XBLOCK=256, num_warps=4, num_stages=1)
        del primals_63
    return (buf146, primals_2, primals_4, primals_5, primals_6, primals_8,
        primals_9, primals_10, primals_12, primals_13, primals_14,
        primals_16, primals_17, primals_18, primals_20, primals_22,
        primals_24, primals_25, primals_26, primals_28, primals_30,
        primals_32, primals_33, primals_34, primals_36, primals_38,
        primals_40, primals_41, primals_42, primals_44, primals_46,
        primals_48, primals_49, primals_50, primals_52, primals_54,
        primals_56, primals_57, primals_58, primals_60, primals_61,
        primals_62, buf0, buf2, reinterpret_tensor(buf4, (4, 32, 1, 1), (32,
        1, 1, 1), 0), reinterpret_tensor(buf8, (4, 32, 1, 1), (32, 1, 1, 1),
        0), buf9, buf11, reinterpret_tensor(buf13, (4, 64, 1, 1), (64, 1, 1,
        1), 0), reinterpret_tensor(buf17, (4, 64, 1, 1), (64, 1, 1, 1), 0),
        buf18, buf20, reinterpret_tensor(buf22, (4, 128, 1, 1), (128, 1, 1,
        1), 0), reinterpret_tensor(buf26, (4, 128, 1, 1), (128, 1, 1, 1), 0
        ), buf28, buf30, reinterpret_tensor(buf32, (4, 128, 1, 1), (128, 1,
        1, 1), 0), reinterpret_tensor(buf36, (4, 128, 1, 1), (128, 1, 1, 1),
        0), buf37, buf39, reinterpret_tensor(buf41, (4, 128, 1, 1), (128, 1,
        1, 1), 0), reinterpret_tensor(buf45, (4, 128, 1, 1), (128, 1, 1, 1),
        0), buf47, buf49, reinterpret_tensor(buf51, (4, 128, 1, 1), (128, 1,
        1, 1), 0), reinterpret_tensor(buf55, (4, 128, 1, 1), (128, 1, 1, 1),
        0), buf56, buf58, reinterpret_tensor(buf60, (4, 128, 1, 1), (128, 1,
        1, 1), 0), reinterpret_tensor(buf64, (4, 128, 1, 1), (128, 1, 1, 1),
        0), buf66, buf68, reinterpret_tensor(buf70, (4, 128, 1, 1), (128, 1,
        1, 1), 0), reinterpret_tensor(buf74, (4, 128, 1, 1), (128, 1, 1, 1),
        0), buf75, buf77, reinterpret_tensor(buf79, (4, 128, 1, 1), (128, 1,
        1, 1), 0), reinterpret_tensor(buf83, (4, 128, 1, 1), (128, 1, 1, 1),
        0), buf85, buf87, reinterpret_tensor(buf89, (4, 128, 1, 1), (128, 1,
        1, 1), 0), reinterpret_tensor(buf93, (4, 128, 1, 1), (128, 1, 1, 1),
        0), buf94, buf96, reinterpret_tensor(buf98, (4, 128, 1, 1), (128, 1,
        1, 1), 0), reinterpret_tensor(buf102, (4, 128, 1, 1), (128, 1, 1, 1
        ), 0), buf104, buf106, reinterpret_tensor(buf108, (4, 128, 1, 1), (
        128, 1, 1, 1), 0), reinterpret_tensor(buf112, (4, 128, 1, 1), (128,
        1, 1, 1), 0), buf113, buf115, reinterpret_tensor(buf117, (4, 128, 1,
        1), (128, 1, 1, 1), 0), reinterpret_tensor(buf121, (4, 128, 1, 1),
        (128, 1, 1, 1), 0), buf122, buf123, buf124, buf126,
        reinterpret_tensor(buf128, (4, 64, 1, 1), (64, 1, 1, 1), 0),
        reinterpret_tensor(buf132, (4, 64, 1, 1), (64, 1, 1, 1), 0), buf133,
        buf134, buf135, buf137, reinterpret_tensor(buf139, (4, 32, 1, 1), (
        32, 1, 1, 1), 0), reinterpret_tensor(buf143, (4, 32, 1, 1), (32, 1,
        1, 1), 0), buf144)


class ConvLayer(torch.nn.Module):

    def __init__(self, in_channels, out_channels, kernel_size, stride):
        super(ConvLayer, self).__init__()
        reflection_padding = int(np.floor(kernel_size / 2))
        self.reflection_pad = nn.ReflectionPad2d(reflection_padding)
        self.conv2d = nn.Conv2d(in_channels, out_channels, kernel_size, stride)

    def forward(self, x):
        out = self.reflection_pad(x)
        out = self.conv2d(out)
        return out


class InstanceNormalization(torch.nn.Module):
    """InstanceNormalization
    Improves convergence of neural-style.
    ref: https://arxiv.org/pdf/1607.08022.pdf
    """

    def __init__(self, dim, eps=1e-09):
        super(InstanceNormalization, self).__init__()
        self.scale = nn.Parameter(torch.FloatTensor(dim))
        self.shift = nn.Parameter(torch.FloatTensor(dim))
        self.eps = eps
        self._reset_parameters()

    def _reset_parameters(self):
        self.scale.data.uniform_()
        self.shift.data.zero_()

    def forward(self, x):
        n = x.size(2) * x.size(3)
        t = x.view(x.size(0), x.size(1), n)
        mean = torch.mean(t, 2).unsqueeze(2).unsqueeze(3).expand_as(x)
        var = torch.var(t, 2).unsqueeze(2).unsqueeze(3).expand_as(x) * ((n -
            1) / float(n))
        scale_broadcast = self.scale.unsqueeze(1).unsqueeze(1).unsqueeze(0)
        scale_broadcast = scale_broadcast.expand_as(x)
        shift_broadcast = self.shift.unsqueeze(1).unsqueeze(1).unsqueeze(0)
        shift_broadcast = shift_broadcast.expand_as(x)
        out = (x - mean) / torch.sqrt(var + self.eps)
        out = out * scale_broadcast + shift_broadcast
        return out


class ResidualBlock(torch.nn.Module):
    """ResidualBlock
    introduced in: https://arxiv.org/abs/1512.03385
    recommended architecture: http://torch.ch/blog/2016/02/04/resnets.html
    """

    def __init__(self, channels):
        super(ResidualBlock, self).__init__()
        self.conv1 = ConvLayer(channels, channels, kernel_size=3, stride=1)
        self.in1 = InstanceNormalization(channels)
        self.conv2 = ConvLayer(channels, channels, kernel_size=3, stride=1)
        self.in2 = InstanceNormalization(channels)
        self.relu = nn.ReLU()

    def forward(self, x):
        residual = x
        out = self.relu(self.in1(self.conv1(x)))
        out = self.in2(self.conv2(out))
        out = out + residual
        return out


class UpsampleConvLayer(torch.nn.Module):
    """UpsampleConvLayer
    Upsamples the input and then does a convolution. This method gives better results
    compared to ConvTranspose2d.
    ref: http://distill.pub/2016/deconv-checkerboard/
    """

    def __init__(self, in_channels, out_channels, kernel_size, stride,
        upsample=None):
        super(UpsampleConvLayer, self).__init__()
        self.upsample = upsample
        if upsample:
            self.upsample_layer = torch.nn.Upsample(scale_factor=upsample)
        reflection_padding = int(np.floor(kernel_size / 2))
        self.reflection_pad = nn.ReflectionPad2d(reflection_padding)
        self.conv2d = nn.Conv2d(in_channels, out_channels, kernel_size, stride)

    def forward(self, x):
        x_in = x
        if self.upsample:
            x_in = self.upsample_layer(x_in)
        out = self.reflection_pad(x_in)
        out = self.conv2d(out)
        return out


class TransformerNetNew(torch.nn.Module):

    def __init__(self):
        super(TransformerNetNew, self).__init__()
        self.conv1 = ConvLayer(3, 32, kernel_size=9, stride=1)
        self.in1 = InstanceNormalization(32)
        self.conv2 = ConvLayer(32, 64, kernel_size=3, stride=2)
        self.in2 = InstanceNormalization(64)
        self.conv3 = ConvLayer(64, 128, kernel_size=3, stride=2)
        self.in3 = InstanceNormalization(128)
        self.res1 = ResidualBlock(128)
        self.res2 = ResidualBlock(128)
        self.res3 = ResidualBlock(128)
        self.res4 = ResidualBlock(128)
        self.res5 = ResidualBlock(128)
        self.deconv1 = UpsampleConvLayer(128, 64, kernel_size=3, stride=1,
            upsample=2)
        self.in4 = InstanceNormalization(64)
        self.deconv2 = UpsampleConvLayer(64, 32, kernel_size=3, stride=1,
            upsample=2)
        self.in5 = InstanceNormalization(32)
        self.deconv3 = ConvLayer(32, 3, kernel_size=9, stride=1)
        self.relu = nn.ReLU()

    def forward(self, input_0):
        primals_2 = self.conv1.conv2d.weight
        primals_3 = self.conv1.conv2d.bias
        primals_4 = self.in1.scale
        primals_5 = self.in1.shift
        primals_6 = self.conv2.conv2d.weight
        primals_7 = self.conv2.conv2d.bias
        primals_8 = self.in2.scale
        primals_9 = self.in2.shift
        primals_10 = self.conv3.conv2d.weight
        primals_11 = self.conv3.conv2d.bias
        primals_12 = self.in3.scale
        primals_13 = self.in3.shift
        primals_14 = self.res1.conv1.conv2d.weight
        primals_15 = self.res1.conv1.conv2d.bias
        primals_16 = self.res1.in1.scale
        primals_17 = self.res1.in1.shift
        primals_18 = self.res1.conv2.conv2d.weight
        primals_19 = self.res1.conv2.conv2d.bias
        primals_20 = self.res1.in2.scale
        primals_21 = self.res1.in2.shift
        primals_22 = self.res2.conv1.conv2d.weight
        primals_23 = self.res2.conv1.conv2d.bias
        primals_24 = self.res2.in1.scale
        primals_25 = self.res2.in1.shift
        primals_26 = self.res2.conv2.conv2d.weight
        primals_27 = self.res2.conv2.conv2d.bias
        primals_28 = self.res2.in2.scale
        primals_29 = self.res2.in2.shift
        primals_30 = self.res3.conv1.conv2d.weight
        primals_31 = self.res3.conv1.conv2d.bias
        primals_32 = self.res3.in1.scale
        primals_33 = self.res3.in1.shift
        primals_34 = self.res3.conv2.conv2d.weight
        primals_35 = self.res3.conv2.conv2d.bias
        primals_36 = self.res3.in2.scale
        primals_37 = self.res3.in2.shift
        primals_38 = self.res4.conv1.conv2d.weight
        primals_39 = self.res4.conv1.conv2d.bias
        primals_40 = self.res4.in1.scale
        primals_41 = self.res4.in1.shift
        primals_42 = self.res4.conv2.conv2d.weight
        primals_43 = self.res4.conv2.conv2d.bias
        primals_44 = self.res4.in2.scale
        primals_45 = self.res4.in2.shift
        primals_46 = self.res5.conv1.conv2d.weight
        primals_47 = self.res5.conv1.conv2d.bias
        primals_48 = self.res5.in1.scale
        primals_49 = self.res5.in1.shift
        primals_50 = self.res5.conv2.conv2d.weight
        primals_51 = self.res5.conv2.conv2d.bias
        primals_52 = self.res5.in2.scale
        primals_53 = self.res5.in2.shift
        primals_54 = self.deconv1.conv2d.weight
        primals_55 = self.deconv1.conv2d.bias
        primals_56 = self.in4.scale
        primals_57 = self.in4.shift
        primals_58 = self.deconv2.conv2d.weight
        primals_59 = self.deconv2.conv2d.bias
        primals_60 = self.in5.scale
        primals_61 = self.in5.shift
        primals_62 = self.deconv3.conv2d.weight
        primals_63 = self.deconv3.conv2d.bias
        primals_1 = input_0
        output = call([primals_1, primals_2, primals_3, primals_4,
            primals_5, primals_6, primals_7, primals_8, primals_9,
            primals_10, primals_11, primals_12, primals_13, primals_14,
            primals_15, primals_16, primals_17, primals_18, primals_19,
            primals_20, primals_21, primals_22, primals_23, primals_24,
            primals_25, primals_26, primals_27, primals_28, primals_29,
            primals_30, primals_31, primals_32, primals_33, primals_34,
            primals_35, primals_36, primals_37, primals_38, primals_39,
            primals_40, primals_41, primals_42, primals_43, primals_44,
            primals_45, primals_46, primals_47, primals_48, primals_49,
            primals_50, primals_51, primals_52, primals_53, primals_54,
            primals_55, primals_56, primals_57, primals_58, primals_59,
            primals_60, primals_61, primals_62, primals_63])
        return output[0]
