import torch
import torch.nn as nn
import torch.nn.functional as F


class InnerProductDecoder(nn.Module):

    def __init__(self, activation=torch.sigmoid, dropout=0.1):
        super(InnerProductDecoder, self).__init__()
        self.dropout = dropout
        self.activation = activation

    def forward(self, z):
        z = F.dropout(z, self.dropout)
        adj = self.activation(torch.mm(z, z.t()))
        return adj


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


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
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_sigmoid_0(in_out_ptr0, 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_out_ptr0 + x0, xmask)
    tmp1 = tl.sigmoid(tmp0)
    tl.store(in_out_ptr0 + x0, tmp1, xmask)


def call(args):
    arg0_1, = args
    args.clear()
    assert_size_stride(arg0_1, (4, 4), (4, 1))
    with torch.cuda._DeviceGuard(0):
        torch.cuda.set_device(0)
        buf0 = torch.ops.aten.native_dropout.default(arg0_1, 0.1, True)
        del arg0_1
        buf1 = buf0[0]
        del buf0
        buf3 = empty_strided_cuda((4, 4), (4, 1), torch.float32)
        extern_kernels.mm(buf1, reinterpret_tensor(buf1, (4, 4), (1, 4), 0),
            out=buf3)
        del buf1
        buf4 = buf3
        del buf3
        get_raw_stream(0)
        triton_poi_fused_sigmoid_0[grid(16)](buf4, 16, XBLOCK=16, num_warps
            =1, num_stages=1)
    return buf4,


class InnerProductDecoderNew(nn.Module):

    def __init__(self, activation=torch.sigmoid, dropout=0.1):
        super(InnerProductDecoderNew, self).__init__()
        self.dropout = dropout
        self.activation = activation

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