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
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_per_fused_add_div_mse_loss_mul_0(in_out_ptr0, in_ptr0, in_ptr1,
    in_ptr2, in_ptr3, in_ptr4, in_ptr5, in_ptr6, in_ptr7, in_ptr8, in_ptr9,
    xnumel, rnumel):
    XBLOCK: tl.constexpr = 1
    RBLOCK: tl.constexpr = 256
    xoffset = tl.program_id(0) * XBLOCK
    tl.full([1], xoffset, tl.int32)
    tl.full([RBLOCK], True, tl.int1)
    rindex = tl.arange(0, RBLOCK)[:]
    tl.full([RBLOCK], True, tl.int1)
    r0 = rindex % 64
    r2 = rindex
    tmp0 = tl.load(in_ptr0 + (128 + r0), None, eviction_policy='evict_last')
    tmp1 = tl.load(in_ptr1 + (512 + r2), None)
    tmp7 = tl.load(in_ptr2 + r2, None)
    tmp10 = tl.load(in_ptr3 + r2, None)
    tmp17 = tl.load(in_ptr4 + r2, None)
    tmp19 = tl.load(in_ptr5 + r2, None)
    tmp26 = tl.load(in_ptr6 + r2, None)
    tmp28 = tl.load(in_ptr7 + r2, None)
    tmp35 = tl.load(in_ptr8 + r2, None)
    tmp37 = tl.load(in_ptr9 + r2, None)
    tmp2 = tmp0 - tmp1
    tmp3 = tmp2 * tmp2
    tmp4 = tl.broadcast_to(tmp3, [RBLOCK])
    tmp6 = triton_helpers.promote_to_tensor(tl.sum(tmp4, 0))
    tmp8 = 0.00390625
    tmp9 = tmp7 * tmp8
    tmp11 = tmp10 * tmp8
    tmp12 = tmp9 - tmp11
    tmp13 = tmp12 * tmp12
    tmp14 = tl.broadcast_to(tmp13, [RBLOCK])
    tmp16 = triton_helpers.promote_to_tensor(tl.sum(tmp14, 0))
    tmp18 = tmp17 * tmp8
    tmp20 = tmp19 * tmp8
    tmp21 = tmp18 - tmp20
    tmp22 = tmp21 * tmp21
    tmp23 = tl.broadcast_to(tmp22, [RBLOCK])
    tmp25 = triton_helpers.promote_to_tensor(tl.sum(tmp23, 0))
    tmp27 = tmp26 * tmp8
    tmp29 = tmp28 * tmp8
    tmp30 = tmp27 - tmp29
    tmp31 = tmp30 * tmp30
    tmp32 = tl.broadcast_to(tmp31, [RBLOCK])
    tmp34 = triton_helpers.promote_to_tensor(tl.sum(tmp32, 0))
    tmp36 = tmp35 * tmp8
    tmp38 = tmp37 * tmp8
    tmp39 = tmp36 - tmp38
    tmp40 = tmp39 * tmp39
    tmp41 = tl.broadcast_to(tmp40, [RBLOCK])
    tmp43 = triton_helpers.promote_to_tensor(tl.sum(tmp41, 0))
    tmp44 = 256.0
    tmp45 = tmp6 / tmp44
    tmp46 = tmp16 / tmp44
    tmp47 = 0.0
    tmp48 = tmp46 + tmp47
    tmp49 = tmp25 / tmp44
    tmp50 = tmp48 + tmp49
    tmp51 = tmp34 / tmp44
    tmp52 = tmp50 + tmp51
    tmp53 = tmp43 / tmp44
    tmp54 = tmp52 + tmp53
    tmp55 = 10000000.0
    tmp56 = tmp54 * tmp55
    tmp57 = tmp45 + tmp56
    tl.debug_barrier()
    tl.store(in_out_ptr0 + tl.full([1], 0, tl.int32), tmp57, None)


def call(args):
    arg0_1, arg1_1, arg2_1 = args
    args.clear()
    assert_size_stride(arg0_1, (4, 4, 4, 4), (64, 16, 4, 1))
    assert_size_stride(arg1_1, (4, 4, 4, 4, 4), (256, 64, 16, 4, 1))
    assert_size_stride(arg2_1, (4, 4, 4, 4, 4), (256, 64, 16, 4, 1))
    with torch.cuda._DeviceGuard(0):
        torch.cuda.set_device(0)
        buf1 = empty_strided_cuda((16, 16), (16, 1), torch.float32)
        extern_kernels.mm(reinterpret_tensor(arg2_1, (16, 16), (16, 1), 0),
            reinterpret_tensor(arg2_1, (16, 16), (1, 16), 0), out=buf1)
        buf10 = empty_strided_cuda((16, 16), (16, 1), torch.float32)
        extern_kernels.mm(reinterpret_tensor(arg2_1, (16, 16), (16, 1), 768
            ), reinterpret_tensor(arg2_1, (16, 16), (1, 16), 768), out=buf10)
        buf11 = empty_strided_cuda((16, 16), (16, 1), torch.float32)
        extern_kernels.mm(reinterpret_tensor(arg1_1, (16, 16), (16, 1), 768
            ), reinterpret_tensor(arg1_1, (16, 16), (1, 16), 768), out=buf11)
        buf2 = empty_strided_cuda((16, 16), (16, 1), torch.float32)
        extern_kernels.mm(reinterpret_tensor(arg1_1, (16, 16), (16, 1), 0),
            reinterpret_tensor(arg1_1, (16, 16), (1, 16), 0), out=buf2)
        buf4 = empty_strided_cuda((16, 16), (16, 1), torch.float32)
        extern_kernels.mm(reinterpret_tensor(arg2_1, (16, 16), (16, 1), 256
            ), reinterpret_tensor(arg2_1, (16, 16), (1, 16), 256), out=buf4)
        buf5 = empty_strided_cuda((16, 16), (16, 1), torch.float32)
        extern_kernels.mm(reinterpret_tensor(arg1_1, (16, 16), (16, 1), 256
            ), reinterpret_tensor(arg1_1, (16, 16), (1, 16), 256), out=buf5)
        buf7 = empty_strided_cuda((16, 16), (16, 1), torch.float32)
        extern_kernels.mm(reinterpret_tensor(arg2_1, (16, 16), (16, 1), 512
            ), reinterpret_tensor(arg2_1, (16, 16), (1, 16), 512), out=buf7)
        del arg2_1
        buf8 = empty_strided_cuda((16, 16), (16, 1), torch.float32)
        extern_kernels.mm(reinterpret_tensor(arg1_1, (16, 16), (16, 1), 512
            ), reinterpret_tensor(arg1_1, (16, 16), (1, 16), 512), out=buf8)
        buf0 = empty_strided_cuda((), (), torch.float32)
        buf13 = buf0
        del buf0
        get_raw_stream(0)
        triton_per_fused_add_div_mse_loss_mul_0[grid(1)](buf13, arg0_1,
            arg1_1, buf1, buf2, buf4, buf5, buf7, buf8, buf10, buf11, 1, 
            256, num_warps=2, num_stages=1)
        del arg0_1
        del arg1_1
        del buf1
        del buf10
        del buf11
        del buf2
        del buf4
        del buf5
        del buf7
        del buf8
    return buf13,


class PerceptualLossNew(nn.Module):

    def __init__(self):
        super().__init__()
        self.tgt_gm = None

    def gram_matrix(self, x):
        a, b, c, d = x.shape
        features = x.view(a * b, c * d)
        G = torch.mm(features, features.t())
        return G.div(a * b * c * d)

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


Measured latency_ms: 0.074145