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.triton_helpers import math as tl_math
import torch.nn as nn
import torch.nn.functional as F
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_cat_0(in_ptr0, in_ptr1, in_ptr2, out_ptr0, xnumel,
    XBLOCK: tl.constexpr):
    xnumel = 96
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x0 = xindex % 6
    x1 = xindex // 6
    x2 = xindex
    tmp0 = x0
    tl.full([1], 0, tl.int64)
    tmp3 = tl.full([1], 5, tl.int64)
    tmp4 = tmp0 < tmp3
    tmp5 = tl.full([1], 4, tl.int64)
    tmp6 = tmp0 < tmp5
    tmp7 = tmp6 & tmp4
    tmp8 = tl.load(in_ptr0 + (4 * (x1 // 4) + x0), tmp7 & xmask,
        eviction_policy='evict_last', other=0.0)
    tmp9 = 0.0
    tmp10 = tmp8 > tmp9
    tmp11 = 0.01
    tmp12 = tmp8 * tmp11
    tmp13 = tl.where(tmp10, tmp8, tmp12)
    tmp14 = tl.full(tmp13.shape, 0.0, tmp13.dtype)
    tmp15 = tl.where(tmp7, tmp13, tmp14)
    tmp16 = tmp0 >= tmp5
    tmp17 = tmp16 & tmp4
    tmp18 = tl.load(in_ptr1 + x1, tmp17 & xmask, eviction_policy=
        'evict_last', other=0.0)
    tmp19 = tl.where(tmp6, tmp15, tmp18)
    tmp20 = tl.full(tmp19.shape, 0.0, tmp19.dtype)
    tmp21 = tl.where(tmp4, tmp19, tmp20)
    tmp22 = tmp0 >= tmp3
    tl.full([1], 6, tl.int64)
    tmp25 = tl.load(in_ptr2 + x1, tmp22 & xmask, eviction_policy=
        'evict_last', other=0.0)
    tmp26 = tl.where(tmp4, tmp21, tmp25)
    tl.store(out_ptr0 + x2, tmp26, xmask)


@triton.jit
def triton_poi_fused_leaky_relu_1(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)
    x2 = xindex
    x0 = xindex % 512
    tmp0 = tl.load(in_out_ptr0 + x2, None)
    tmp1 = tl.load(in_ptr0 + x0, None, eviction_policy='evict_last')
    tmp2 = tmp0 + tmp1
    tmp3 = 0.0
    tmp4 = tmp2 > tmp3
    tmp5 = 0.01
    tmp6 = tmp2 * tmp5
    tmp7 = tl.where(tmp4, tmp2, tmp6)
    tl.store(in_out_ptr0 + x2, tmp7, None)


@triton.jit
def triton_poi_fused_cos_2(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
    tmp0 = tl.load(in_ptr0 + x0, None)
    tmp1 = tl_math.cos(tmp0)
    tl.store(out_ptr0 + x0, tmp1, None)


@triton.jit
def triton_poi_fused_leaky_relu_3(in_ptr0, out_ptr1, xnumel, XBLOCK: tl.
    constexpr):
    xnumel = 16
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x0 = xindex
    tmp0 = tl.load(in_ptr0 + x0, xmask)
    tmp1 = 0.0
    tmp2 = tmp0 > tmp1
    tmp3 = 0.01
    tmp4 = tmp0 * tmp3
    tmp5 = tl.where(tmp2, tmp0, tmp4)
    tl.store(out_ptr1 + x0, tmp5, xmask)


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) = args
    args.clear()
    assert_size_stride(primals_1, (4, 4), (4, 1))
    assert_size_stride(primals_2, (4, 4), (4, 1))
    assert_size_stride(primals_3, (4, 4), (4, 1))
    assert_size_stride(primals_4, (512, 6), (6, 1))
    assert_size_stride(primals_5, (512,), (1,))
    assert_size_stride(primals_6, (512, 512), (512, 1))
    assert_size_stride(primals_7, (512,), (1,))
    assert_size_stride(primals_8, (512, 512), (512, 1))
    assert_size_stride(primals_9, (512,), (1,))
    assert_size_stride(primals_10, (256, 512), (512, 1))
    assert_size_stride(primals_11, (256,), (1,))
    assert_size_stride(primals_12, (4, 256), (256, 1))
    assert_size_stride(primals_13, (4,), (1,))
    with torch.cuda._DeviceGuard(0):
        torch.cuda.set_device(0)
        buf0 = empty_strided_cuda((16, 6), (6, 1), torch.float32)
        get_raw_stream(0)
        triton_poi_fused_cat_0[grid(96)](primals_1, primals_3, primals_2,
            buf0, 96, XBLOCK=128, num_warps=4, num_stages=1)
        del primals_2
        del primals_3
        buf1 = empty_strided_cuda((16, 512), (512, 1), torch.float32)
        extern_kernels.mm(buf0, reinterpret_tensor(primals_4, (6, 512), (1,
            6), 0), out=buf1)
        del primals_4
        buf2 = buf1
        del buf1
        triton_poi_fused_leaky_relu_1[grid(8192)](buf2, primals_5, 8192,
            XBLOCK=128, num_warps=4, num_stages=1)
        del primals_5
        buf3 = empty_strided_cuda((16, 512), (512, 1), torch.float32)
        extern_kernels.mm(buf2, reinterpret_tensor(primals_6, (512, 512), (
            1, 512), 0), out=buf3)
        buf4 = buf3
        del buf3
        triton_poi_fused_leaky_relu_1[grid(8192)](buf4, primals_7, 8192,
            XBLOCK=128, num_warps=4, num_stages=1)
        del primals_7
        buf5 = empty_strided_cuda((16, 512), (512, 1), torch.float32)
        extern_kernels.mm(buf4, reinterpret_tensor(primals_8, (512, 512), (
            1, 512), 0), out=buf5)
        buf6 = buf5
        del buf5
        triton_poi_fused_leaky_relu_1[grid(8192)](buf6, primals_9, 8192,
            XBLOCK=128, num_warps=4, num_stages=1)
        del primals_9
        buf7 = empty_strided_cuda((16, 256), (256, 1), torch.float32)
        extern_kernels.addmm(primals_11, buf6, reinterpret_tensor(
            primals_10, (512, 256), (1, 512), 0), alpha=1, beta=1, out=buf7)
        del primals_11
        buf8 = empty_strided_cuda((16, 256), (256, 1), torch.float32)
        triton_poi_fused_cos_2[grid(4096)](buf7, buf8, 4096, XBLOCK=128,
            num_warps=4, num_stages=1)
        buf9 = empty_strided_cuda((16, 4), (4, 1), torch.float32)
        extern_kernels.addmm(primals_13, buf8, reinterpret_tensor(
            primals_12, (256, 4), (1, 256), 0), alpha=1, beta=1, out=buf9)
        del primals_13
        triton_poi_fused_leaky_relu_3[grid(16)](primals_1, primals_1, 16,
            XBLOCK=16, num_warps=1, num_stages=1)
        del primals_1
    return (reinterpret_tensor(buf9, (16, 2), (4, 1), 0),
        reinterpret_tensor(buf9, (16, 2), (4, 1), 2), buf9, buf0, buf2,
        buf4, buf6, buf7, buf8, primals_12, primals_10, primals_8, primals_6)


def weights_init(m):
    if isinstance(m, nn.Conv2d):
        nn.init.kaiming_uniform_(m.weight, a=0, mode='fan_in', nonlinearity
            ='leaky_relu')
        try:
            nn.init.constant_(m.bias, 0.01)
        except:
            pass
    if isinstance(m, nn.Linear):
        nn.init.kaiming_uniform_(m.weight, a=0, mode='fan_in', nonlinearity
            ='leaky_relu')
        nn.init.constant_(m.bias, 0.01)


class Generator(nn.Module):

    def __init__(self, input_dim=8, output_dim=2):
        super(Generator, self).__init__()
        self.linear1 = nn.Linear(input_dim, 512)
        self.linear2 = nn.Linear(512, 512)
        self.linear3 = nn.Linear(512, 512)
        self.linear4 = nn.Linear(512, 256)
        self.linear5 = nn.Linear(256, output_dim)
        self.apply(weights_init)

    def forward(self, condition, v0, t):
        x = torch.cat([condition, v0], dim=1)
        x = torch.cat([x, t], dim=1)
        x = self.linear1(x)
        x = F.leaky_relu(x, inplace=True)
        x = self.linear2(x)
        x = F.leaky_relu(x, inplace=True)
        x = self.linear3(x)
        x = F.leaky_relu(x, inplace=True)
        x = self.linear4(x)
        x = torch.cos(x)
        x = self.linear5(x)
        return x


class qyNew(nn.Module):

    def __init__(self, zy_dim):
        super(qyNew, self).__init__()
        self.trajectory_generation = Generator(input_dim=1 + 1 + zy_dim,
            output_dim=4)

    def forward(self, input_0, input_1, input_2):
        primals_4 = self.trajectory_generation.linear1.weight
        primals_5 = self.trajectory_generation.linear1.bias
        primals_6 = self.trajectory_generation.linear2.weight
        primals_7 = self.trajectory_generation.linear2.bias
        primals_8 = self.trajectory_generation.linear3.weight
        primals_9 = self.trajectory_generation.linear3.bias
        primals_10 = self.trajectory_generation.linear4.weight
        primals_11 = self.trajectory_generation.linear4.bias
        primals_12 = self.trajectory_generation.linear5.weight
        primals_13 = self.trajectory_generation.linear5.bias
        primals_1 = input_0
        primals_2 = input_1
        primals_3 = input_2
        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])
        return output[0], output[1]


Measured latency_ms: 0.11905