# AOT ID: ['0_inference']
from ctypes import c_void_p, c_long, c_int
import torch
import math
import random
import os
import tempfile
from math import inf, nan
from torch._inductor.hooks import run_intermediate_hooks
from torch._inductor.utils import maybe_profile
from torch._inductor.codegen.memory_planning import _align as align
from torch import device, empty_strided
from torch._inductor.async_compile import AsyncCompile
from torch._inductor.select_algorithm import extern_kernels
from torch._inductor.codegen.multi_kernel import MultiKernelCall
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid, split_scan_grid, grid_combo_kernels, start_graph, end_graph
from torch._C import _cuda_getCurrentRawStream as get_raw_stream

aten = torch.ops.aten
inductor_ops = torch.ops.inductor
_quantized = torch.ops._quantized
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
empty_strided_cpu = torch._C._dynamo.guards._empty_strided_cpu
empty_strided_cuda = torch._C._dynamo.guards._empty_strided_cuda
empty_strided_xpu = torch._C._dynamo.guards._empty_strided_xpu
reinterpret_tensor = torch._C._dynamo.guards._reinterpret_tensor
alloc_from_pool = torch.ops.inductor._alloc_from_pool
async_compile = AsyncCompile()


# kernel path: runs/run_shard_1/inductor_cache/fk/cfkf6enhrdxuolzpcw3wzgmkvdxbf2yeamw6dswhcd7tiorzwjps.py
# Topologically Sorted Source Nodes: [x, mean, log, log_1, mean_1, s, sub_2, s3, pow_1, mul, add_1, rt, nm, dn, truediv, k], Original ATen: [aten.add, aten.mean, aten.log, aten.sub, aten.rsub, aten.pow, aten.mul, aten.sqrt, aten.div]
# Source node to ATen node mapping:
#   add_1 => add_1
#   dn => mul_1
#   k => add_3
#   log => log
#   log_1 => log_1
#   mean => mean
#   mean_1 => mean_1
#   mul => mul
#   nm => add_2
#   pow_1 => pow_1
#   rt => sqrt
#   s => sub
#   s3 => sub_1
#   sub_2 => sub_2
#   truediv => div
#   x => add
# Graph fragment:
#   %add : [num_users=3] = call_function[target=torch.ops.aten.add.Tensor](args = (%arg0_1, 1e-07), kwargs = {})
#   %mean : [num_users=1] = call_function[target=torch.ops.aten.mean.dim](args = (%add, [1]), kwargs = {})
#   %log : [num_users=1] = call_function[target=torch.ops.aten.log.default](args = (%mean,), kwargs = {})
#   %log_1 : [num_users=1] = call_function[target=torch.ops.aten.log.default](args = (%add,), kwargs = {})
#   %mean_1 : [num_users=1] = call_function[target=torch.ops.aten.mean.dim](args = (%log_1, [1]), kwargs = {})
#   %sub : [num_users=14] = call_function[target=torch.ops.aten.sub.Tensor](args = (%log, %mean_1), kwargs = {})
#   %sub_2 : [num_users=1] = call_function[target=torch.ops.aten.sub.Tensor](args = (3.0, %sub), kwargs = {})
#   %sub_1 : [num_users=1] = call_function[target=torch.ops.aten.sub.Tensor](args = (%sub, 3.0), kwargs = {})
#   %pow_1 : [num_users=1] = call_function[target=torch.ops.aten.pow.Tensor_Scalar](args = (%sub_1, 2), kwargs = {})
#   %mul : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%sub, 24.0), kwargs = {})
#   %add_1 : [num_users=1] = call_function[target=torch.ops.aten.add.Tensor](args = (%pow_1, %mul), kwargs = {})
#   %sqrt : [num_users=1] = call_function[target=torch.ops.aten.sqrt.default](args = (%add_1,), kwargs = {})
#   %add_2 : [num_users=1] = call_function[target=torch.ops.aten.add.Tensor](args = (%sub_2, %sqrt), kwargs = {})
#   %mul_1 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%sub, 12.0), kwargs = {})
#   %div : [num_users=1] = call_function[target=torch.ops.aten.div.Tensor](args = (%add_2, %mul_1), kwargs = {})
#   %add_3 : [num_users=6] = call_function[target=torch.ops.aten.add.Tensor](args = (%div, 1e-07), kwargs = {})
triton_poi_fused_add_div_log_mean_mul_pow_rsub_sqrt_sub_0 = async_compile.triton('triton_poi_fused_add_div_log_mean_mul_pow_rsub_sqrt_sub_0', '''
import triton
import triton.language as tl
from triton.compiler.compiler import AttrsDescriptor

from torch._inductor.runtime import triton_helpers, triton_heuristics
from torch._inductor.runtime.triton_helpers import libdevice, math as tl_math
from torch._inductor.runtime.hints import AutotuneHint, ReductionHint, TileHint, instance_descriptor, DeviceProperties

@triton_heuristics.pointwise(
    size_hints=[64], 
    filename=__file__,
    triton_meta={'signature': {0: '*fp32', 1: '*fp32', 2: '*fp32', 3: 'i32'}, 'device': DeviceProperties(type='cuda', index=0, cc=90, major=9, regs_per_multiprocessor=65536, max_threads_per_multi_processor=2048, multi_processor_count=132), 'constants': {}, 'configs': [AttrsDescriptor(divisible_by_16=(0, 1, 2, 3), equal_to_1=())]},
    inductor_meta={'autotune_hints': set(), 'kernel_name': 'triton_poi_fused_add_div_log_mean_mul_pow_rsub_sqrt_sub_0', 'mutated_arg_names': ['in_out_ptr0'], 'no_x_dim': False, 'num_load': 4, 'num_reduction': 0, 'backend_hash': 'B098E03CDA7B8ADC90DAFFDF24A2956451D1B13F297756A5DCC209498AA53705', 'are_deterministic_algorithms_enabled': False, 'assert_indirect_indexing': True, 'autotune_local_cache': True, 'autotune_pointwise': True, 'autotune_remote_cache': None, 'force_disable_caches': False, 'dynamic_scale_rblock': True, 'max_autotune': False, 'max_autotune_pointwise': False, 'min_split_scan_rblock': 256, 'spill_threshold': 16, 'store_cubin': False},
    min_elem_per_thread=0
)
@triton.jit
def triton_poi_fused_add_div_log_mean_mul_pow_rsub_sqrt_sub_0(in_out_ptr0, in_ptr0, 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 % 16
    x1 = (xindex // 16)
    x2 = xindex
    tmp0 = tl.load(in_ptr0 + (x0 + (64*x1)), xmask)
    tmp3 = tl.load(in_ptr0 + (16 + x0 + (64*x1)), xmask)
    tmp6 = tl.load(in_ptr0 + (32 + x0 + (64*x1)), xmask)
    tmp9 = tl.load(in_ptr0 + (48 + x0 + (64*x1)), xmask)
    tmp1 = 1e-07
    tmp2 = tmp0 + tmp1
    tmp4 = tmp3 + tmp1
    tmp5 = tmp2 + tmp4
    tmp7 = tmp6 + tmp1
    tmp8 = tmp5 + tmp7
    tmp10 = tmp9 + tmp1
    tmp11 = tmp8 + tmp10
    tmp12 = 4.0
    tmp13 = tmp11 / tmp12
    tmp14 = tl_math.log(tmp13)
    tmp15 = tl_math.log(tmp2)
    tmp16 = tl_math.log(tmp4)
    tmp17 = tmp15 + tmp16
    tmp18 = tl_math.log(tmp7)
    tmp19 = tmp17 + tmp18
    tmp20 = tl_math.log(tmp10)
    tmp21 = tmp19 + tmp20
    tmp22 = tmp21 / tmp12
    tmp23 = tmp14 - tmp22
    tmp24 = 3.0
    tmp25 = tmp23 - tmp24
    tmp26 = tmp25 * tmp25
    tmp27 = 24.0
    tmp28 = tmp23 * tmp27
    tmp29 = tmp26 + tmp28
    tmp30 = libdevice.sqrt(tmp29)
    tmp31 = tmp24 - tmp23
    tmp32 = tmp31 + tmp30
    tmp33 = 12.0
    tmp34 = tmp23 * tmp33
    tmp35 = tmp32 / tmp34
    tmp36 = tmp35 + tmp1
    tl.store(in_out_ptr0 + (x2), tmp35, xmask)
    tl.store(out_ptr0 + (x2), tmp36, xmask)
''', device_str='cuda')


# kernel path: runs/run_shard_1/inductor_cache/cp/ccpzc7bnwy5ex77gkagui54sgmgom2lohbjngjpoztrk3ogip5hv.py
# Topologically Sorted Source Nodes: [x, mean, log, log_1, mean_1, s, k, log_2, sub_3, nm_1, reciprocal, z, zz, mul_2, reciprocal_1, a, truediv_1, b, mul_3, truediv_2, c, mul_4, truediv_3, d, e, pow_3, reciprocal_2, e_1, dn_1, truediv_5, k2], Original ATen: [aten.add, aten.mean, aten.log, aten.sub, aten.reciprocal, aten.pow, aten.mul, aten.rsub, aten.div]
# Source node to ATen node mapping:
#   a => sub_5
#   b => sub_6
#   c => add_5
#   d => add_6
#   dn_1 => sub_7
#   e => div_4
#   e_1 => add_7
#   k => add_3
#   k2 => sub_8
#   log => log
#   log_1 => log_1
#   log_2 => log_2
#   mean => mean
#   mean_1 => mean_1
#   mul_2 => mul_2
#   mul_3 => mul_3
#   mul_4 => mul_4
#   nm_1 => sub_4
#   pow_3 => pow_3
#   reciprocal => reciprocal
#   reciprocal_1 => reciprocal_1
#   reciprocal_2 => reciprocal_2
#   s => sub
#   sub_3 => sub_3
#   truediv_1 => div_1
#   truediv_2 => div_2
#   truediv_3 => div_3
#   truediv_5 => div_5
#   x => add
#   z => add_4
#   zz => pow_2
# Graph fragment:
#   %add : [num_users=3] = call_function[target=torch.ops.aten.add.Tensor](args = (%arg0_1, 1e-07), kwargs = {})
#   %mean : [num_users=1] = call_function[target=torch.ops.aten.mean.dim](args = (%add, [1]), kwargs = {})
#   %log : [num_users=1] = call_function[target=torch.ops.aten.log.default](args = (%mean,), kwargs = {})
#   %log_1 : [num_users=1] = call_function[target=torch.ops.aten.log.default](args = (%add,), kwargs = {})
#   %mean_1 : [num_users=1] = call_function[target=torch.ops.aten.mean.dim](args = (%log_1, [1]), kwargs = {})
#   %sub : [num_users=14] = call_function[target=torch.ops.aten.sub.Tensor](args = (%log, %mean_1), kwargs = {})
#   %add_3 : [num_users=6] = call_function[target=torch.ops.aten.add.Tensor](args = (%div, 1e-07), kwargs = {})
#   %log_2 : [num_users=1] = call_function[target=torch.ops.aten.log.default](args = (%add_3,), kwargs = {})
#   %sub_3 : [num_users=1] = call_function[target=torch.ops.aten.sub.Tensor](args = (%log_2, %digamma), kwargs = {})
#   %sub_4 : [num_users=1] = call_function[target=torch.ops.aten.sub.Tensor](args = (%sub_3, %sub), kwargs = {})
#   %reciprocal : [num_users=1] = call_function[target=torch.ops.aten.reciprocal.default](args = (%add_3,), kwargs = {})
#   %add_4 : [num_users=4] = call_function[target=torch.ops.aten.add.Tensor](args = (%add_3, 1.0), kwargs = {})
#   %pow_2 : [num_users=2] = call_function[target=torch.ops.aten.pow.Tensor_Scalar](args = (%add_4, 2), kwargs = {})
#   %mul_2 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%pow_2, 7.0), kwargs = {})
#   %reciprocal_1 : [num_users=1] = call_function[target=torch.ops.aten.reciprocal.default](args = (%mul_2,), kwargs = {})
#   %sub_5 : [num_users=1] = call_function[target=torch.ops.aten.sub.Tensor](args = (0.2, %reciprocal_1), kwargs = {})
#   %div_1 : [num_users=1] = call_function[target=torch.ops.aten.div.Tensor](args = (%sub_5, %pow_2), kwargs = {})
#   %sub_6 : [num_users=1] = call_function[target=torch.ops.aten.sub.Tensor](args = (1.0, %div_1), kwargs = {})
#   %mul_3 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%add_4, 3.0), kwargs = {})
#   %div_2 : [num_users=1] = call_function[target=torch.ops.aten.div.Tensor](args = (%sub_6, %mul_3), kwargs = {})
#   %add_5 : [num_users=1] = call_function[target=torch.ops.aten.add.Tensor](args = (%div_2, 1.0), kwargs = {})
#   %mul_4 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%add_4, 2.0), kwargs = {})
#   %div_3 : [num_users=1] = call_function[target=torch.ops.aten.div.Tensor](args = (%add_5, %mul_4), kwargs = {})
#   %add_6 : [num_users=1] = call_function[target=torch.ops.aten.add.Tensor](args = (%div_3, 1.0), kwargs = {})
#   %div_4 : [num_users=1] = call_function[target=torch.ops.aten.div.Tensor](args = (%add_6, %add_4), kwargs = {})
#   %pow_3 : [num_users=1] = call_function[target=torch.ops.aten.pow.Tensor_Scalar](args = (%add_3, 2.0), kwargs = {})
#   %reciprocal_2 : [num_users=1] = call_function[target=torch.ops.aten.reciprocal.default](args = (%pow_3,), kwargs = {})
#   %add_7 : [num_users=1] = call_function[target=torch.ops.aten.add.Tensor](args = (%div_4, %reciprocal_2), kwargs = {})
#   %sub_7 : [num_users=1] = call_function[target=torch.ops.aten.sub.Tensor](args = (%reciprocal, %add_7), kwargs = {})
#   %div_5 : [num_users=1] = call_function[target=torch.ops.aten.div.Tensor](args = (%sub_4, %sub_7), kwargs = {})
#   %sub_8 : [num_users=6] = call_function[target=torch.ops.aten.sub.Tensor](args = (%add_3, %div_5), kwargs = {})
triton_poi_fused_add_div_log_mean_mul_pow_reciprocal_rsub_sub_1 = async_compile.triton('triton_poi_fused_add_div_log_mean_mul_pow_reciprocal_rsub_sub_1', '''
import triton
import triton.language as tl
from triton.compiler.compiler import AttrsDescriptor

from torch._inductor.runtime import triton_helpers, triton_heuristics
from torch._inductor.runtime.triton_helpers import libdevice, math as tl_math
from torch._inductor.runtime.hints import AutotuneHint, ReductionHint, TileHint, instance_descriptor, DeviceProperties

@triton_heuristics.pointwise(
    size_hints=[64], 
    filename=__file__,
    triton_meta={'signature': {0: '*fp32', 1: '*fp32', 2: '*fp32', 3: '*fp32', 4: '*fp32', 5: 'i32'}, 'device': DeviceProperties(type='cuda', index=0, cc=90, major=9, regs_per_multiprocessor=65536, max_threads_per_multi_processor=2048, multi_processor_count=132), 'constants': {}, 'configs': [AttrsDescriptor(divisible_by_16=(0, 1, 2, 3, 4, 5), equal_to_1=())]},
    inductor_meta={'autotune_hints': set(), 'kernel_name': 'triton_poi_fused_add_div_log_mean_mul_pow_reciprocal_rsub_sub_1', 'mutated_arg_names': ['in_out_ptr0'], 'no_x_dim': False, 'num_load': 7, 'num_reduction': 0, 'backend_hash': 'B098E03CDA7B8ADC90DAFFDF24A2956451D1B13F297756A5DCC209498AA53705', 'are_deterministic_algorithms_enabled': False, 'assert_indirect_indexing': True, 'autotune_local_cache': True, 'autotune_pointwise': True, 'autotune_remote_cache': None, 'force_disable_caches': False, 'dynamic_scale_rblock': True, 'max_autotune': False, 'max_autotune_pointwise': False, 'min_split_scan_rblock': 256, 'spill_threshold': 16, 'store_cubin': False},
    min_elem_per_thread=0
)
@triton.jit
def triton_poi_fused_add_div_log_mean_mul_pow_reciprocal_rsub_sub_1(in_out_ptr0, in_ptr0, in_ptr1, in_ptr2, out_ptr0, xnumel, XBLOCK : tl.constexpr):
    xnumel = 64
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x2 = xindex
    x0 = xindex % 16
    x1 = (xindex // 16)
    tmp0 = tl.load(in_out_ptr0 + (x2), xmask)
    tmp4 = tl.load(in_ptr0 + (x2), xmask)
    tmp6 = tl.load(in_ptr1 + (x0 + (64*x1)), xmask)
    tmp8 = tl.load(in_ptr1 + (16 + x0 + (64*x1)), xmask)
    tmp11 = tl.load(in_ptr1 + (32 + x0 + (64*x1)), xmask)
    tmp14 = tl.load(in_ptr1 + (48 + x0 + (64*x1)), xmask)
    tmp30 = tl.load(in_ptr2 + (x2), xmask)
    tmp1 = 1e-07
    tmp2 = tmp0 + tmp1
    tmp3 = tl_math.log(tmp2)
    tmp5 = tmp3 - tmp4
    tmp7 = tmp6 + tmp1
    tmp9 = tmp8 + tmp1
    tmp10 = tmp7 + tmp9
    tmp12 = tmp11 + tmp1
    tmp13 = tmp10 + tmp12
    tmp15 = tmp14 + tmp1
    tmp16 = tmp13 + tmp15
    tmp17 = 4.0
    tmp18 = tmp16 / tmp17
    tmp19 = tl_math.log(tmp18)
    tmp20 = tl_math.log(tmp7)
    tmp21 = tl_math.log(tmp9)
    tmp22 = tmp20 + tmp21
    tmp23 = tl_math.log(tmp12)
    tmp24 = tmp22 + tmp23
    tmp25 = tl_math.log(tmp15)
    tmp26 = tmp24 + tmp25
    tmp27 = tmp26 / tmp17
    tmp28 = tmp19 - tmp27
    tmp29 = tmp5 - tmp28
    tmp31 = tl.full([1], 1, tl.int32)
    tmp32 = tmp31 / tmp30
    tmp33 = 1.0
    tmp34 = tmp30 + tmp33
    tmp35 = tmp34 * tmp34
    tmp36 = 7.0
    tmp37 = tmp35 * tmp36
    tmp38 = tmp31 / tmp37
    tmp39 = 0.2
    tmp40 = tmp39 - tmp38
    tmp41 = tmp40 / tmp35
    tmp42 = tmp33 - tmp41
    tmp43 = 3.0
    tmp44 = tmp34 * tmp43
    tmp45 = tmp42 / tmp44
    tmp46 = tmp45 + tmp33
    tmp47 = 2.0
    tmp48 = tmp34 * tmp47
    tmp49 = tmp46 / tmp48
    tmp50 = tmp49 + tmp33
    tmp51 = tmp50 / tmp34
    tmp52 = tmp30 * tmp30
    tmp53 = tmp31 / tmp52
    tmp54 = tmp51 + tmp53
    tmp55 = tmp32 - tmp54
    tmp56 = tmp29 / tmp55
    tmp57 = tmp30 - tmp56
    tl.store(in_out_ptr0 + (x2), tmp56, xmask)
    tl.store(out_ptr0 + (x2), tmp57, xmask)
''', device_str='cuda')


# kernel path: runs/run_shard_1/inductor_cache/ac/cacnwf5nwa2gxch4csd5vbrr53xvpaxk2jshkrqlyka4taohph4n.py
# Topologically Sorted Source Nodes: [x, mean, log, log_1, mean_1, s, k2, log_3, sub_9, nm_2, reciprocal_3, z_1, zz_1, mul_5, reciprocal_4, a_1, truediv_6, b_1, mul_6, truediv_7, c_1, mul_7, truediv_8, d_1, e_2, pow_5, reciprocal_5, e_3, dn_2, truediv_10, k2_1], Original ATen: [aten.add, aten.mean, aten.log, aten.sub, aten.reciprocal, aten.pow, aten.mul, aten.rsub, aten.div]
# Source node to ATen node mapping:
#   a_1 => sub_11
#   b_1 => sub_12
#   c_1 => add_9
#   d_1 => add_10
#   dn_2 => sub_13
#   e_2 => div_9
#   e_3 => add_11
#   k2 => sub_8
#   k2_1 => sub_14
#   log => log
#   log_1 => log_1
#   log_3 => log_3
#   mean => mean
#   mean_1 => mean_1
#   mul_5 => mul_5
#   mul_6 => mul_6
#   mul_7 => mul_7
#   nm_2 => sub_10
#   pow_5 => pow_5
#   reciprocal_3 => reciprocal_3
#   reciprocal_4 => reciprocal_4
#   reciprocal_5 => reciprocal_5
#   s => sub
#   sub_9 => sub_9
#   truediv_10 => div_10
#   truediv_6 => div_6
#   truediv_7 => div_7
#   truediv_8 => div_8
#   x => add
#   z_1 => add_8
#   zz_1 => pow_4
# Graph fragment:
#   %add : [num_users=3] = call_function[target=torch.ops.aten.add.Tensor](args = (%arg0_1, 1e-07), kwargs = {})
#   %mean : [num_users=1] = call_function[target=torch.ops.aten.mean.dim](args = (%add, [1]), kwargs = {})
#   %log : [num_users=1] = call_function[target=torch.ops.aten.log.default](args = (%mean,), kwargs = {})
#   %log_1 : [num_users=1] = call_function[target=torch.ops.aten.log.default](args = (%add,), kwargs = {})
#   %mean_1 : [num_users=1] = call_function[target=torch.ops.aten.mean.dim](args = (%log_1, [1]), kwargs = {})
#   %sub : [num_users=14] = call_function[target=torch.ops.aten.sub.Tensor](args = (%log, %mean_1), kwargs = {})
#   %sub_8 : [num_users=6] = call_function[target=torch.ops.aten.sub.Tensor](args = (%add_3, %div_5), kwargs = {})
#   %log_3 : [num_users=1] = call_function[target=torch.ops.aten.log.default](args = (%sub_8,), kwargs = {})
#   %sub_9 : [num_users=1] = call_function[target=torch.ops.aten.sub.Tensor](args = (%log_3, %digamma_1), kwargs = {})
#   %sub_10 : [num_users=1] = call_function[target=torch.ops.aten.sub.Tensor](args = (%sub_9, %sub), kwargs = {})
#   %reciprocal_3 : [num_users=1] = call_function[target=torch.ops.aten.reciprocal.default](args = (%sub_8,), kwargs = {})
#   %add_8 : [num_users=4] = call_function[target=torch.ops.aten.add.Tensor](args = (%sub_8, 1.0), kwargs = {})
#   %pow_4 : [num_users=2] = call_function[target=torch.ops.aten.pow.Tensor_Scalar](args = (%add_8, 2), kwargs = {})
#   %mul_5 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%pow_4, 7.0), kwargs = {})
#   %reciprocal_4 : [num_users=1] = call_function[target=torch.ops.aten.reciprocal.default](args = (%mul_5,), kwargs = {})
#   %sub_11 : [num_users=1] = call_function[target=torch.ops.aten.sub.Tensor](args = (0.2, %reciprocal_4), kwargs = {})
#   %div_6 : [num_users=1] = call_function[target=torch.ops.aten.div.Tensor](args = (%sub_11, %pow_4), kwargs = {})
#   %sub_12 : [num_users=1] = call_function[target=torch.ops.aten.sub.Tensor](args = (1.0, %div_6), kwargs = {})
#   %mul_6 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%add_8, 3.0), kwargs = {})
#   %div_7 : [num_users=1] = call_function[target=torch.ops.aten.div.Tensor](args = (%sub_12, %mul_6), kwargs = {})
#   %add_9 : [num_users=1] = call_function[target=torch.ops.aten.add.Tensor](args = (%div_7, 1.0), kwargs = {})
#   %mul_7 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%add_8, 2.0), kwargs = {})
#   %div_8 : [num_users=1] = call_function[target=torch.ops.aten.div.Tensor](args = (%add_9, %mul_7), kwargs = {})
#   %add_10 : [num_users=1] = call_function[target=torch.ops.aten.add.Tensor](args = (%div_8, 1.0), kwargs = {})
#   %div_9 : [num_users=1] = call_function[target=torch.ops.aten.div.Tensor](args = (%add_10, %add_8), kwargs = {})
#   %pow_5 : [num_users=1] = call_function[target=torch.ops.aten.pow.Tensor_Scalar](args = (%sub_8, 2.0), kwargs = {})
#   %reciprocal_5 : [num_users=1] = call_function[target=torch.ops.aten.reciprocal.default](args = (%pow_5,), kwargs = {})
#   %add_11 : [num_users=1] = call_function[target=torch.ops.aten.add.Tensor](args = (%div_9, %reciprocal_5), kwargs = {})
#   %sub_13 : [num_users=1] = call_function[target=torch.ops.aten.sub.Tensor](args = (%reciprocal_3, %add_11), kwargs = {})
#   %div_10 : [num_users=1] = call_function[target=torch.ops.aten.div.Tensor](args = (%sub_10, %sub_13), kwargs = {})
#   %sub_14 : [num_users=6] = call_function[target=torch.ops.aten.sub.Tensor](args = (%sub_8, %div_10), kwargs = {})
triton_poi_fused_add_div_log_mean_mul_pow_reciprocal_rsub_sub_2 = async_compile.triton('triton_poi_fused_add_div_log_mean_mul_pow_reciprocal_rsub_sub_2', '''
import triton
import triton.language as tl
from triton.compiler.compiler import AttrsDescriptor

from torch._inductor.runtime import triton_helpers, triton_heuristics
from torch._inductor.runtime.triton_helpers import libdevice, math as tl_math
from torch._inductor.runtime.hints import AutotuneHint, ReductionHint, TileHint, instance_descriptor, DeviceProperties

@triton_heuristics.pointwise(
    size_hints=[64], 
    filename=__file__,
    triton_meta={'signature': {0: '*fp32', 1: '*fp32', 2: '*fp32', 3: '*fp32', 4: '*fp32', 5: '*fp32', 6: 'i32'}, 'device': DeviceProperties(type='cuda', index=0, cc=90, major=9, regs_per_multiprocessor=65536, max_threads_per_multi_processor=2048, multi_processor_count=132), 'constants': {}, 'configs': [AttrsDescriptor(divisible_by_16=(0, 1, 2, 3, 4, 5, 6), equal_to_1=())]},
    inductor_meta={'autotune_hints': set(), 'kernel_name': 'triton_poi_fused_add_div_log_mean_mul_pow_reciprocal_rsub_sub_2', 'mutated_arg_names': ['in_out_ptr0'], 'no_x_dim': False, 'num_load': 8, 'num_reduction': 0, 'backend_hash': 'B098E03CDA7B8ADC90DAFFDF24A2956451D1B13F297756A5DCC209498AA53705', 'are_deterministic_algorithms_enabled': False, 'assert_indirect_indexing': True, 'autotune_local_cache': True, 'autotune_pointwise': True, 'autotune_remote_cache': None, 'force_disable_caches': False, 'dynamic_scale_rblock': True, 'max_autotune': False, 'max_autotune_pointwise': False, 'min_split_scan_rblock': 256, 'spill_threshold': 16, 'store_cubin': False},
    min_elem_per_thread=0
)
@triton.jit
def triton_poi_fused_add_div_log_mean_mul_pow_reciprocal_rsub_sub_2(in_out_ptr0, in_ptr0, in_ptr1, in_ptr2, in_ptr3, out_ptr0, xnumel, XBLOCK : tl.constexpr):
    xnumel = 64
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x2 = xindex
    x0 = xindex % 16
    x1 = (xindex // 16)
    tmp0 = tl.load(in_out_ptr0 + (x2), xmask)
    tmp1 = tl.load(in_ptr0 + (x2), xmask)
    tmp4 = tl.load(in_ptr1 + (x2), xmask)
    tmp6 = tl.load(in_ptr2 + (x0 + (64*x1)), xmask)
    tmp9 = tl.load(in_ptr2 + (16 + x0 + (64*x1)), xmask)
    tmp12 = tl.load(in_ptr2 + (32 + x0 + (64*x1)), xmask)
    tmp15 = tl.load(in_ptr2 + (48 + x0 + (64*x1)), xmask)
    tmp31 = tl.load(in_ptr3 + (x2), xmask)
    tmp2 = tmp0 - tmp1
    tmp3 = tl_math.log(tmp2)
    tmp5 = tmp3 - tmp4
    tmp7 = 1e-07
    tmp8 = tmp6 + tmp7
    tmp10 = tmp9 + tmp7
    tmp11 = tmp8 + tmp10
    tmp13 = tmp12 + tmp7
    tmp14 = tmp11 + tmp13
    tmp16 = tmp15 + tmp7
    tmp17 = tmp14 + tmp16
    tmp18 = 4.0
    tmp19 = tmp17 / tmp18
    tmp20 = tl_math.log(tmp19)
    tmp21 = tl_math.log(tmp8)
    tmp22 = tl_math.log(tmp10)
    tmp23 = tmp21 + tmp22
    tmp24 = tl_math.log(tmp13)
    tmp25 = tmp23 + tmp24
    tmp26 = tl_math.log(tmp16)
    tmp27 = tmp25 + tmp26
    tmp28 = tmp27 / tmp18
    tmp29 = tmp20 - tmp28
    tmp30 = tmp5 - tmp29
    tmp32 = tl.full([1], 1, tl.int32)
    tmp33 = tmp32 / tmp31
    tmp34 = 1.0
    tmp35 = tmp31 + tmp34
    tmp36 = tmp35 * tmp35
    tmp37 = 7.0
    tmp38 = tmp36 * tmp37
    tmp39 = tmp32 / tmp38
    tmp40 = 0.2
    tmp41 = tmp40 - tmp39
    tmp42 = tmp41 / tmp36
    tmp43 = tmp34 - tmp42
    tmp44 = 3.0
    tmp45 = tmp35 * tmp44
    tmp46 = tmp43 / tmp45
    tmp47 = tmp46 + tmp34
    tmp48 = 2.0
    tmp49 = tmp35 * tmp48
    tmp50 = tmp47 / tmp49
    tmp51 = tmp50 + tmp34
    tmp52 = tmp51 / tmp35
    tmp53 = tmp31 * tmp31
    tmp54 = tmp32 / tmp53
    tmp55 = tmp52 + tmp54
    tmp56 = tmp33 - tmp55
    tmp57 = tmp30 / tmp56
    tmp58 = tmp31 - tmp57
    tl.store(in_out_ptr0 + (x2), tmp30, xmask)
    tl.store(out_ptr0 + (x2), tmp58, xmask)
''', device_str='cuda')


# kernel path: runs/run_shard_1/inductor_cache/23/c23dnslt4c2jdgtblpo22kyagp5vbtmqmmwxvvvgu7zpxpjojrbb.py
# Topologically Sorted Source Nodes: [x, mean, log, log_1, mean_1, s, reciprocal_3, z_1, zz_1, mul_5, reciprocal_4, a_1, truediv_6, b_1, mul_6, truediv_7, c_1, mul_7, truediv_8, d_1, e_2, pow_5, reciprocal_5, e_3, dn_2, truediv_10, k2_1, log_4, sub_15, nm_3, reciprocal_6, z_2, zz_2, mul_8, reciprocal_7, a_2, truediv_11, b_2, mul_9, truediv_12, c_2, mul_10, truediv_13, d_2, e_4, pow_7, reciprocal_8, e_5, dn_3, truediv_15, k2_2], Original ATen: [aten.add, aten.mean, aten.log, aten.sub, aten.reciprocal, aten.pow, aten.mul, aten.rsub, aten.div]
# Source node to ATen node mapping:
#   a_1 => sub_11
#   a_2 => sub_17
#   b_1 => sub_12
#   b_2 => sub_18
#   c_1 => add_9
#   c_2 => add_13
#   d_1 => add_10
#   d_2 => add_14
#   dn_2 => sub_13
#   dn_3 => sub_19
#   e_2 => div_9
#   e_3 => add_11
#   e_4 => div_14
#   e_5 => add_15
#   k2_1 => sub_14
#   k2_2 => sub_20
#   log => log
#   log_1 => log_1
#   log_4 => log_4
#   mean => mean
#   mean_1 => mean_1
#   mul_10 => mul_10
#   mul_5 => mul_5
#   mul_6 => mul_6
#   mul_7 => mul_7
#   mul_8 => mul_8
#   mul_9 => mul_9
#   nm_3 => sub_16
#   pow_5 => pow_5
#   pow_7 => pow_7
#   reciprocal_3 => reciprocal_3
#   reciprocal_4 => reciprocal_4
#   reciprocal_5 => reciprocal_5
#   reciprocal_6 => reciprocal_6
#   reciprocal_7 => reciprocal_7
#   reciprocal_8 => reciprocal_8
#   s => sub
#   sub_15 => sub_15
#   truediv_10 => div_10
#   truediv_11 => div_11
#   truediv_12 => div_12
#   truediv_13 => div_13
#   truediv_15 => div_15
#   truediv_6 => div_6
#   truediv_7 => div_7
#   truediv_8 => div_8
#   x => add
#   z_1 => add_8
#   z_2 => add_12
#   zz_1 => pow_4
#   zz_2 => pow_6
# Graph fragment:
#   %add : [num_users=3] = call_function[target=torch.ops.aten.add.Tensor](args = (%arg0_1, 1e-07), kwargs = {})
#   %mean : [num_users=1] = call_function[target=torch.ops.aten.mean.dim](args = (%add, [1]), kwargs = {})
#   %log : [num_users=1] = call_function[target=torch.ops.aten.log.default](args = (%mean,), kwargs = {})
#   %log_1 : [num_users=1] = call_function[target=torch.ops.aten.log.default](args = (%add,), kwargs = {})
#   %mean_1 : [num_users=1] = call_function[target=torch.ops.aten.mean.dim](args = (%log_1, [1]), kwargs = {})
#   %sub : [num_users=14] = call_function[target=torch.ops.aten.sub.Tensor](args = (%log, %mean_1), kwargs = {})
#   %reciprocal_3 : [num_users=1] = call_function[target=torch.ops.aten.reciprocal.default](args = (%sub_8,), kwargs = {})
#   %add_8 : [num_users=4] = call_function[target=torch.ops.aten.add.Tensor](args = (%sub_8, 1.0), kwargs = {})
#   %pow_4 : [num_users=2] = call_function[target=torch.ops.aten.pow.Tensor_Scalar](args = (%add_8, 2), kwargs = {})
#   %mul_5 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%pow_4, 7.0), kwargs = {})
#   %reciprocal_4 : [num_users=1] = call_function[target=torch.ops.aten.reciprocal.default](args = (%mul_5,), kwargs = {})
#   %sub_11 : [num_users=1] = call_function[target=torch.ops.aten.sub.Tensor](args = (0.2, %reciprocal_4), kwargs = {})
#   %div_6 : [num_users=1] = call_function[target=torch.ops.aten.div.Tensor](args = (%sub_11, %pow_4), kwargs = {})
#   %sub_12 : [num_users=1] = call_function[target=torch.ops.aten.sub.Tensor](args = (1.0, %div_6), kwargs = {})
#   %mul_6 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%add_8, 3.0), kwargs = {})
#   %div_7 : [num_users=1] = call_function[target=torch.ops.aten.div.Tensor](args = (%sub_12, %mul_6), kwargs = {})
#   %add_9 : [num_users=1] = call_function[target=torch.ops.aten.add.Tensor](args = (%div_7, 1.0), kwargs = {})
#   %mul_7 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%add_8, 2.0), kwargs = {})
#   %div_8 : [num_users=1] = call_function[target=torch.ops.aten.div.Tensor](args = (%add_9, %mul_7), kwargs = {})
#   %add_10 : [num_users=1] = call_function[target=torch.ops.aten.add.Tensor](args = (%div_8, 1.0), kwargs = {})
#   %div_9 : [num_users=1] = call_function[target=torch.ops.aten.div.Tensor](args = (%add_10, %add_8), kwargs = {})
#   %pow_5 : [num_users=1] = call_function[target=torch.ops.aten.pow.Tensor_Scalar](args = (%sub_8, 2.0), kwargs = {})
#   %reciprocal_5 : [num_users=1] = call_function[target=torch.ops.aten.reciprocal.default](args = (%pow_5,), kwargs = {})
#   %add_11 : [num_users=1] = call_function[target=torch.ops.aten.add.Tensor](args = (%div_9, %reciprocal_5), kwargs = {})
#   %sub_13 : [num_users=1] = call_function[target=torch.ops.aten.sub.Tensor](args = (%reciprocal_3, %add_11), kwargs = {})
#   %div_10 : [num_users=1] = call_function[target=torch.ops.aten.div.Tensor](args = (%sub_10, %sub_13), kwargs = {})
#   %sub_14 : [num_users=6] = call_function[target=torch.ops.aten.sub.Tensor](args = (%sub_8, %div_10), kwargs = {})
#   %log_4 : [num_users=1] = call_function[target=torch.ops.aten.log.default](args = (%sub_14,), kwargs = {})
#   %sub_15 : [num_users=1] = call_function[target=torch.ops.aten.sub.Tensor](args = (%log_4, %digamma_2), kwargs = {})
#   %sub_16 : [num_users=1] = call_function[target=torch.ops.aten.sub.Tensor](args = (%sub_15, %sub), kwargs = {})
#   %reciprocal_6 : [num_users=1] = call_function[target=torch.ops.aten.reciprocal.default](args = (%sub_14,), kwargs = {})
#   %add_12 : [num_users=4] = call_function[target=torch.ops.aten.add.Tensor](args = (%sub_14, 1.0), kwargs = {})
#   %pow_6 : [num_users=2] = call_function[target=torch.ops.aten.pow.Tensor_Scalar](args = (%add_12, 2), kwargs = {})
#   %mul_8 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%pow_6, 7.0), kwargs = {})
#   %reciprocal_7 : [num_users=1] = call_function[target=torch.ops.aten.reciprocal.default](args = (%mul_8,), kwargs = {})
#   %sub_17 : [num_users=1] = call_function[target=torch.ops.aten.sub.Tensor](args = (0.2, %reciprocal_7), kwargs = {})
#   %div_11 : [num_users=1] = call_function[target=torch.ops.aten.div.Tensor](args = (%sub_17, %pow_6), kwargs = {})
#   %sub_18 : [num_users=1] = call_function[target=torch.ops.aten.sub.Tensor](args = (1.0, %div_11), kwargs = {})
#   %mul_9 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%add_12, 3.0), kwargs = {})
#   %div_12 : [num_users=1] = call_function[target=torch.ops.aten.div.Tensor](args = (%sub_18, %mul_9), kwargs = {})
#   %add_13 : [num_users=1] = call_function[target=torch.ops.aten.add.Tensor](args = (%div_12, 1.0), kwargs = {})
#   %mul_10 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%add_12, 2.0), kwargs = {})
#   %div_13 : [num_users=1] = call_function[target=torch.ops.aten.div.Tensor](args = (%add_13, %mul_10), kwargs = {})
#   %add_14 : [num_users=1] = call_function[target=torch.ops.aten.add.Tensor](args = (%div_13, 1.0), kwargs = {})
#   %div_14 : [num_users=1] = call_function[target=torch.ops.aten.div.Tensor](args = (%add_14, %add_12), kwargs = {})
#   %pow_7 : [num_users=1] = call_function[target=torch.ops.aten.pow.Tensor_Scalar](args = (%sub_14, 2.0), kwargs = {})
#   %reciprocal_8 : [num_users=1] = call_function[target=torch.ops.aten.reciprocal.default](args = (%pow_7,), kwargs = {})
#   %add_15 : [num_users=1] = call_function[target=torch.ops.aten.add.Tensor](args = (%div_14, %reciprocal_8), kwargs = {})
#   %sub_19 : [num_users=1] = call_function[target=torch.ops.aten.sub.Tensor](args = (%reciprocal_6, %add_15), kwargs = {})
#   %div_15 : [num_users=1] = call_function[target=torch.ops.aten.div.Tensor](args = (%sub_16, %sub_19), kwargs = {})
#   %sub_20 : [num_users=6] = call_function[target=torch.ops.aten.sub.Tensor](args = (%sub_14, %div_15), kwargs = {})
triton_poi_fused_add_div_log_mean_mul_pow_reciprocal_rsub_sub_3 = async_compile.triton('triton_poi_fused_add_div_log_mean_mul_pow_reciprocal_rsub_sub_3', '''
import triton
import triton.language as tl
from triton.compiler.compiler import AttrsDescriptor

from torch._inductor.runtime import triton_helpers, triton_heuristics
from torch._inductor.runtime.triton_helpers import libdevice, math as tl_math
from torch._inductor.runtime.hints import AutotuneHint, ReductionHint, TileHint, instance_descriptor, DeviceProperties

@triton_heuristics.pointwise(
    size_hints=[64], 
    filename=__file__,
    triton_meta={'signature': {0: '*fp32', 1: '*fp32', 2: '*fp32', 3: '*fp32', 4: '*fp32', 5: '*fp32', 6: 'i32'}, 'device': DeviceProperties(type='cuda', index=0, cc=90, major=9, regs_per_multiprocessor=65536, max_threads_per_multi_processor=2048, multi_processor_count=132), 'constants': {}, 'configs': [AttrsDescriptor(divisible_by_16=(0, 1, 2, 3, 4, 5, 6), equal_to_1=())]},
    inductor_meta={'autotune_hints': set(), 'kernel_name': 'triton_poi_fused_add_div_log_mean_mul_pow_reciprocal_rsub_sub_3', 'mutated_arg_names': ['in_out_ptr0'], 'no_x_dim': False, 'num_load': 8, 'num_reduction': 0, 'backend_hash': 'B098E03CDA7B8ADC90DAFFDF24A2956451D1B13F297756A5DCC209498AA53705', 'are_deterministic_algorithms_enabled': False, 'assert_indirect_indexing': True, 'autotune_local_cache': True, 'autotune_pointwise': True, 'autotune_remote_cache': None, 'force_disable_caches': False, 'dynamic_scale_rblock': True, 'max_autotune': False, 'max_autotune_pointwise': False, 'min_split_scan_rblock': 256, 'spill_threshold': 16, 'store_cubin': False},
    min_elem_per_thread=0
)
@triton.jit
def triton_poi_fused_add_div_log_mean_mul_pow_reciprocal_rsub_sub_3(in_out_ptr0, in_ptr0, in_ptr1, in_ptr2, in_ptr3, 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
    x1 = xindex % 16
    x2 = (xindex // 16)
    tmp0 = tl.load(in_ptr0 + (x0), xmask)
    tmp1 = tl.load(in_ptr1 + (x0), xmask)
    tmp30 = tl.load(in_out_ptr0 + (x0), xmask)
    tmp32 = tl.load(in_ptr2 + (x1 + (64*x2)), xmask)
    tmp35 = tl.load(in_ptr2 + (16 + x1 + (64*x2)), xmask)
    tmp38 = tl.load(in_ptr2 + (32 + x1 + (64*x2)), xmask)
    tmp41 = tl.load(in_ptr2 + (48 + x1 + (64*x2)), xmask)
    tmp57 = tl.load(in_ptr3 + (x0), xmask)
    tmp2 = tl.full([1], 1, tl.int32)
    tmp3 = tmp2 / tmp0
    tmp4 = 1.0
    tmp5 = tmp0 + tmp4
    tmp6 = tmp5 * tmp5
    tmp7 = 7.0
    tmp8 = tmp6 * tmp7
    tmp9 = tmp2 / tmp8
    tmp10 = 0.2
    tmp11 = tmp10 - tmp9
    tmp12 = tmp11 / tmp6
    tmp13 = tmp4 - tmp12
    tmp14 = 3.0
    tmp15 = tmp5 * tmp14
    tmp16 = tmp13 / tmp15
    tmp17 = tmp16 + tmp4
    tmp18 = 2.0
    tmp19 = tmp5 * tmp18
    tmp20 = tmp17 / tmp19
    tmp21 = tmp20 + tmp4
    tmp22 = tmp21 / tmp5
    tmp23 = tmp0 * tmp0
    tmp24 = tmp2 / tmp23
    tmp25 = tmp22 + tmp24
    tmp26 = tmp3 - tmp25
    tmp27 = tmp1 / tmp26
    tmp28 = tmp0 - tmp27
    tmp29 = tl_math.log(tmp28)
    tmp31 = tmp29 - tmp30
    tmp33 = 1e-07
    tmp34 = tmp32 + tmp33
    tmp36 = tmp35 + tmp33
    tmp37 = tmp34 + tmp36
    tmp39 = tmp38 + tmp33
    tmp40 = tmp37 + tmp39
    tmp42 = tmp41 + tmp33
    tmp43 = tmp40 + tmp42
    tmp44 = 4.0
    tmp45 = tmp43 / tmp44
    tmp46 = tl_math.log(tmp45)
    tmp47 = tl_math.log(tmp34)
    tmp48 = tl_math.log(tmp36)
    tmp49 = tmp47 + tmp48
    tmp50 = tl_math.log(tmp39)
    tmp51 = tmp49 + tmp50
    tmp52 = tl_math.log(tmp42)
    tmp53 = tmp51 + tmp52
    tmp54 = tmp53 / tmp44
    tmp55 = tmp46 - tmp54
    tmp56 = tmp31 - tmp55
    tmp58 = tmp2 / tmp57
    tmp59 = tmp57 + tmp4
    tmp60 = tmp59 * tmp59
    tmp61 = tmp60 * tmp7
    tmp62 = tmp2 / tmp61
    tmp63 = tmp10 - tmp62
    tmp64 = tmp63 / tmp60
    tmp65 = tmp4 - tmp64
    tmp66 = tmp59 * tmp14
    tmp67 = tmp65 / tmp66
    tmp68 = tmp67 + tmp4
    tmp69 = tmp59 * tmp18
    tmp70 = tmp68 / tmp69
    tmp71 = tmp70 + tmp4
    tmp72 = tmp71 / tmp59
    tmp73 = tmp57 * tmp57
    tmp74 = tmp2 / tmp73
    tmp75 = tmp72 + tmp74
    tmp76 = tmp58 - tmp75
    tmp77 = tmp56 / tmp76
    tmp78 = tmp57 - tmp77
    tl.store(in_out_ptr0 + (x0), tmp77, xmask)
    tl.store(out_ptr0 + (x0), tmp78, xmask)
''', device_str='cuda')


# kernel path: runs/run_shard_1/inductor_cache/5r/c5ravvqqldt4ehwikip7iu66obt35uy2ozmkhn7zqdu2h6ttu5as.py
# Topologically Sorted Source Nodes: [x, mean, log, log_1, mean_1, s, reciprocal_9, z_3, zz_3, mul_11, reciprocal_10, a_3, truediv_16, b_3, mul_12, truediv_17, c_3, mul_13, truediv_18, d_3, e_6, pow_9, reciprocal_11, e_7, dn_4, truediv_20, k2_3, log_6, sub_27, nm_5, reciprocal_12, z_4, zz_4, mul_14, reciprocal_13, a_4, truediv_21, b_4, mul_15, truediv_22, c_4, mul_16, truediv_23, d_4, e_8, pow_11, reciprocal_14, e_9, dn_5, truediv_25, k2_4], Original ATen: [aten.add, aten.mean, aten.log, aten.sub, aten.reciprocal, aten.pow, aten.mul, aten.rsub, aten.div]
# Source node to ATen node mapping:
#   a_3 => sub_23
#   a_4 => sub_29
#   b_3 => sub_24
#   b_4 => sub_30
#   c_3 => add_17
#   c_4 => add_21
#   d_3 => add_18
#   d_4 => add_22
#   dn_4 => sub_25
#   dn_5 => sub_31
#   e_6 => div_19
#   e_7 => add_19
#   e_8 => div_24
#   e_9 => add_23
#   k2_3 => sub_26
#   k2_4 => sub_32
#   log => log
#   log_1 => log_1
#   log_6 => log_6
#   mean => mean
#   mean_1 => mean_1
#   mul_11 => mul_11
#   mul_12 => mul_12
#   mul_13 => mul_13
#   mul_14 => mul_14
#   mul_15 => mul_15
#   mul_16 => mul_16
#   nm_5 => sub_28
#   pow_11 => pow_11
#   pow_9 => pow_9
#   reciprocal_10 => reciprocal_10
#   reciprocal_11 => reciprocal_11
#   reciprocal_12 => reciprocal_12
#   reciprocal_13 => reciprocal_13
#   reciprocal_14 => reciprocal_14
#   reciprocal_9 => reciprocal_9
#   s => sub
#   sub_27 => sub_27
#   truediv_16 => div_16
#   truediv_17 => div_17
#   truediv_18 => div_18
#   truediv_20 => div_20
#   truediv_21 => div_21
#   truediv_22 => div_22
#   truediv_23 => div_23
#   truediv_25 => div_25
#   x => add
#   z_3 => add_16
#   z_4 => add_20
#   zz_3 => pow_8
#   zz_4 => pow_10
# Graph fragment:
#   %add : [num_users=3] = call_function[target=torch.ops.aten.add.Tensor](args = (%arg0_1, 1e-07), kwargs = {})
#   %mean : [num_users=1] = call_function[target=torch.ops.aten.mean.dim](args = (%add, [1]), kwargs = {})
#   %log : [num_users=1] = call_function[target=torch.ops.aten.log.default](args = (%mean,), kwargs = {})
#   %log_1 : [num_users=1] = call_function[target=torch.ops.aten.log.default](args = (%add,), kwargs = {})
#   %mean_1 : [num_users=1] = call_function[target=torch.ops.aten.mean.dim](args = (%log_1, [1]), kwargs = {})
#   %sub : [num_users=14] = call_function[target=torch.ops.aten.sub.Tensor](args = (%log, %mean_1), kwargs = {})
#   %reciprocal_9 : [num_users=1] = call_function[target=torch.ops.aten.reciprocal.default](args = (%sub_20,), kwargs = {})
#   %add_16 : [num_users=4] = call_function[target=torch.ops.aten.add.Tensor](args = (%sub_20, 1.0), kwargs = {})
#   %pow_8 : [num_users=2] = call_function[target=torch.ops.aten.pow.Tensor_Scalar](args = (%add_16, 2), kwargs = {})
#   %mul_11 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%pow_8, 7.0), kwargs = {})
#   %reciprocal_10 : [num_users=1] = call_function[target=torch.ops.aten.reciprocal.default](args = (%mul_11,), kwargs = {})
#   %sub_23 : [num_users=1] = call_function[target=torch.ops.aten.sub.Tensor](args = (0.2, %reciprocal_10), kwargs = {})
#   %div_16 : [num_users=1] = call_function[target=torch.ops.aten.div.Tensor](args = (%sub_23, %pow_8), kwargs = {})
#   %sub_24 : [num_users=1] = call_function[target=torch.ops.aten.sub.Tensor](args = (1.0, %div_16), kwargs = {})
#   %mul_12 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%add_16, 3.0), kwargs = {})
#   %div_17 : [num_users=1] = call_function[target=torch.ops.aten.div.Tensor](args = (%sub_24, %mul_12), kwargs = {})
#   %add_17 : [num_users=1] = call_function[target=torch.ops.aten.add.Tensor](args = (%div_17, 1.0), kwargs = {})
#   %mul_13 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%add_16, 2.0), kwargs = {})
#   %div_18 : [num_users=1] = call_function[target=torch.ops.aten.div.Tensor](args = (%add_17, %mul_13), kwargs = {})
#   %add_18 : [num_users=1] = call_function[target=torch.ops.aten.add.Tensor](args = (%div_18, 1.0), kwargs = {})
#   %div_19 : [num_users=1] = call_function[target=torch.ops.aten.div.Tensor](args = (%add_18, %add_16), kwargs = {})
#   %pow_9 : [num_users=1] = call_function[target=torch.ops.aten.pow.Tensor_Scalar](args = (%sub_20, 2.0), kwargs = {})
#   %reciprocal_11 : [num_users=1] = call_function[target=torch.ops.aten.reciprocal.default](args = (%pow_9,), kwargs = {})
#   %add_19 : [num_users=1] = call_function[target=torch.ops.aten.add.Tensor](args = (%div_19, %reciprocal_11), kwargs = {})
#   %sub_25 : [num_users=1] = call_function[target=torch.ops.aten.sub.Tensor](args = (%reciprocal_9, %add_19), kwargs = {})
#   %div_20 : [num_users=1] = call_function[target=torch.ops.aten.div.Tensor](args = (%sub_22, %sub_25), kwargs = {})
#   %sub_26 : [num_users=6] = call_function[target=torch.ops.aten.sub.Tensor](args = (%sub_20, %div_20), kwargs = {})
#   %log_6 : [num_users=1] = call_function[target=torch.ops.aten.log.default](args = (%sub_26,), kwargs = {})
#   %sub_27 : [num_users=1] = call_function[target=torch.ops.aten.sub.Tensor](args = (%log_6, %digamma_4), kwargs = {})
#   %sub_28 : [num_users=1] = call_function[target=torch.ops.aten.sub.Tensor](args = (%sub_27, %sub), kwargs = {})
#   %reciprocal_12 : [num_users=1] = call_function[target=torch.ops.aten.reciprocal.default](args = (%sub_26,), kwargs = {})
#   %add_20 : [num_users=4] = call_function[target=torch.ops.aten.add.Tensor](args = (%sub_26, 1.0), kwargs = {})
#   %pow_10 : [num_users=2] = call_function[target=torch.ops.aten.pow.Tensor_Scalar](args = (%add_20, 2), kwargs = {})
#   %mul_14 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%pow_10, 7.0), kwargs = {})
#   %reciprocal_13 : [num_users=1] = call_function[target=torch.ops.aten.reciprocal.default](args = (%mul_14,), kwargs = {})
#   %sub_29 : [num_users=1] = call_function[target=torch.ops.aten.sub.Tensor](args = (0.2, %reciprocal_13), kwargs = {})
#   %div_21 : [num_users=1] = call_function[target=torch.ops.aten.div.Tensor](args = (%sub_29, %pow_10), kwargs = {})
#   %sub_30 : [num_users=1] = call_function[target=torch.ops.aten.sub.Tensor](args = (1.0, %div_21), kwargs = {})
#   %mul_15 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%add_20, 3.0), kwargs = {})
#   %div_22 : [num_users=1] = call_function[target=torch.ops.aten.div.Tensor](args = (%sub_30, %mul_15), kwargs = {})
#   %add_21 : [num_users=1] = call_function[target=torch.ops.aten.add.Tensor](args = (%div_22, 1.0), kwargs = {})
#   %mul_16 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%add_20, 2.0), kwargs = {})
#   %div_23 : [num_users=1] = call_function[target=torch.ops.aten.div.Tensor](args = (%add_21, %mul_16), kwargs = {})
#   %add_22 : [num_users=1] = call_function[target=torch.ops.aten.add.Tensor](args = (%div_23, 1.0), kwargs = {})
#   %div_24 : [num_users=1] = call_function[target=torch.ops.aten.div.Tensor](args = (%add_22, %add_20), kwargs = {})
#   %pow_11 : [num_users=1] = call_function[target=torch.ops.aten.pow.Tensor_Scalar](args = (%sub_26, 2.0), kwargs = {})
#   %reciprocal_14 : [num_users=1] = call_function[target=torch.ops.aten.reciprocal.default](args = (%pow_11,), kwargs = {})
#   %add_23 : [num_users=1] = call_function[target=torch.ops.aten.add.Tensor](args = (%div_24, %reciprocal_14), kwargs = {})
#   %sub_31 : [num_users=1] = call_function[target=torch.ops.aten.sub.Tensor](args = (%reciprocal_12, %add_23), kwargs = {})
#   %div_25 : [num_users=1] = call_function[target=torch.ops.aten.div.Tensor](args = (%sub_28, %sub_31), kwargs = {})
#   %sub_32 : [num_users=6] = call_function[target=torch.ops.aten.sub.Tensor](args = (%sub_26, %div_25), kwargs = {})
triton_poi_fused_add_div_log_mean_mul_pow_reciprocal_rsub_sub_4 = async_compile.triton('triton_poi_fused_add_div_log_mean_mul_pow_reciprocal_rsub_sub_4', '''
import triton
import triton.language as tl
from triton.compiler.compiler import AttrsDescriptor

from torch._inductor.runtime import triton_helpers, triton_heuristics
from torch._inductor.runtime.triton_helpers import libdevice, math as tl_math
from torch._inductor.runtime.hints import AutotuneHint, ReductionHint, TileHint, instance_descriptor, DeviceProperties

@triton_heuristics.pointwise(
    size_hints=[64], 
    filename=__file__,
    triton_meta={'signature': {0: '*fp32', 1: '*fp32', 2: '*fp32', 3: '*fp32', 4: '*fp32', 5: '*fp32', 6: 'i32'}, 'device': DeviceProperties(type='cuda', index=0, cc=90, major=9, regs_per_multiprocessor=65536, max_threads_per_multi_processor=2048, multi_processor_count=132), 'constants': {}, 'configs': [AttrsDescriptor(divisible_by_16=(0, 1, 2, 3, 4, 5, 6), equal_to_1=())]},
    inductor_meta={'autotune_hints': set(), 'kernel_name': 'triton_poi_fused_add_div_log_mean_mul_pow_reciprocal_rsub_sub_4', 'mutated_arg_names': ['in_out_ptr0'], 'no_x_dim': False, 'num_load': 8, 'num_reduction': 0, 'backend_hash': 'B098E03CDA7B8ADC90DAFFDF24A2956451D1B13F297756A5DCC209498AA53705', 'are_deterministic_algorithms_enabled': False, 'assert_indirect_indexing': True, 'autotune_local_cache': True, 'autotune_pointwise': True, 'autotune_remote_cache': None, 'force_disable_caches': False, 'dynamic_scale_rblock': True, 'max_autotune': False, 'max_autotune_pointwise': False, 'min_split_scan_rblock': 256, 'spill_threshold': 16, 'store_cubin': False},
    min_elem_per_thread=0
)
@triton.jit
def triton_poi_fused_add_div_log_mean_mul_pow_reciprocal_rsub_sub_4(in_out_ptr0, in_ptr0, in_ptr1, in_ptr2, in_ptr3, 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
    x1 = xindex % 16
    x2 = (xindex // 16)
    tmp0 = tl.load(in_out_ptr0 + (x0), xmask)
    tmp1 = tl.load(in_ptr0 + (x0), xmask)
    tmp30 = tl.load(in_ptr1 + (x0), xmask)
    tmp32 = tl.load(in_ptr2 + (x1 + (64*x2)), xmask)
    tmp35 = tl.load(in_ptr2 + (16 + x1 + (64*x2)), xmask)
    tmp38 = tl.load(in_ptr2 + (32 + x1 + (64*x2)), xmask)
    tmp41 = tl.load(in_ptr2 + (48 + x1 + (64*x2)), xmask)
    tmp57 = tl.load(in_ptr3 + (x0), xmask)
    tmp2 = tl.full([1], 1, tl.int32)
    tmp3 = tmp2 / tmp0
    tmp4 = 1.0
    tmp5 = tmp0 + tmp4
    tmp6 = tmp5 * tmp5
    tmp7 = 7.0
    tmp8 = tmp6 * tmp7
    tmp9 = tmp2 / tmp8
    tmp10 = 0.2
    tmp11 = tmp10 - tmp9
    tmp12 = tmp11 / tmp6
    tmp13 = tmp4 - tmp12
    tmp14 = 3.0
    tmp15 = tmp5 * tmp14
    tmp16 = tmp13 / tmp15
    tmp17 = tmp16 + tmp4
    tmp18 = 2.0
    tmp19 = tmp5 * tmp18
    tmp20 = tmp17 / tmp19
    tmp21 = tmp20 + tmp4
    tmp22 = tmp21 / tmp5
    tmp23 = tmp0 * tmp0
    tmp24 = tmp2 / tmp23
    tmp25 = tmp22 + tmp24
    tmp26 = tmp3 - tmp25
    tmp27 = tmp1 / tmp26
    tmp28 = tmp0 - tmp27
    tmp29 = tl_math.log(tmp28)
    tmp31 = tmp29 - tmp30
    tmp33 = 1e-07
    tmp34 = tmp32 + tmp33
    tmp36 = tmp35 + tmp33
    tmp37 = tmp34 + tmp36
    tmp39 = tmp38 + tmp33
    tmp40 = tmp37 + tmp39
    tmp42 = tmp41 + tmp33
    tmp43 = tmp40 + tmp42
    tmp44 = 4.0
    tmp45 = tmp43 / tmp44
    tmp46 = tl_math.log(tmp45)
    tmp47 = tl_math.log(tmp34)
    tmp48 = tl_math.log(tmp36)
    tmp49 = tmp47 + tmp48
    tmp50 = tl_math.log(tmp39)
    tmp51 = tmp49 + tmp50
    tmp52 = tl_math.log(tmp42)
    tmp53 = tmp51 + tmp52
    tmp54 = tmp53 / tmp44
    tmp55 = tmp46 - tmp54
    tmp56 = tmp31 - tmp55
    tmp58 = tmp2 / tmp57
    tmp59 = tmp57 + tmp4
    tmp60 = tmp59 * tmp59
    tmp61 = tmp60 * tmp7
    tmp62 = tmp2 / tmp61
    tmp63 = tmp10 - tmp62
    tmp64 = tmp63 / tmp60
    tmp65 = tmp4 - tmp64
    tmp66 = tmp59 * tmp14
    tmp67 = tmp65 / tmp66
    tmp68 = tmp67 + tmp4
    tmp69 = tmp59 * tmp18
    tmp70 = tmp68 / tmp69
    tmp71 = tmp70 + tmp4
    tmp72 = tmp71 / tmp59
    tmp73 = tmp57 * tmp57
    tmp74 = tmp2 / tmp73
    tmp75 = tmp72 + tmp74
    tmp76 = tmp58 - tmp75
    tmp77 = tmp56 / tmp76
    tmp78 = tmp57 - tmp77
    tl.store(in_out_ptr0 + (x0), tmp77, xmask)
    tl.store(out_ptr0 + (x0), tmp78, xmask)
''', device_str='cuda')


# kernel path: runs/run_shard_1/inductor_cache/ar/carxneddoiwjpi7pqfjcyon5zit4yz2i5tujfyoqfyzxpc77xxtr.py
# Topologically Sorted Source Nodes: [x, mean, log, log_1, mean_1, s, k2_8, log_11, sub_57, nm_10, reciprocal_27, z_9, zz_9, mul_29, reciprocal_28, a_9, truediv_46, b_9, mul_30, truediv_47, c_9, mul_31, truediv_48, d_9, e_18, pow_21, reciprocal_29, e_19, dn_10, truediv_50, k2_9, reciprocal_30, mean_2, th], Original ATen: [aten.add, aten.mean, aten.log, aten.sub, aten.reciprocal, aten.pow, aten.mul, aten.rsub, aten.div]
# Source node to ATen node mapping:
#   a_9 => sub_59
#   b_9 => sub_60
#   c_9 => add_41
#   d_9 => add_42
#   dn_10 => sub_61
#   e_18 => div_49
#   e_19 => add_43
#   k2_8 => sub_56
#   k2_9 => sub_62
#   log => log
#   log_1 => log_1
#   log_11 => log_11
#   mean => mean
#   mean_1 => mean_1
#   mean_2 => mean_2
#   mul_29 => mul_29
#   mul_30 => mul_30
#   mul_31 => mul_31
#   nm_10 => sub_58
#   pow_21 => pow_21
#   reciprocal_27 => reciprocal_27
#   reciprocal_28 => reciprocal_28
#   reciprocal_29 => reciprocal_29
#   reciprocal_30 => reciprocal_30
#   s => sub
#   sub_57 => sub_57
#   th => mul_32
#   truediv_46 => div_46
#   truediv_47 => div_47
#   truediv_48 => div_48
#   truediv_50 => div_50
#   x => add
#   z_9 => add_40
#   zz_9 => pow_20
# Graph fragment:
#   %add : [num_users=3] = call_function[target=torch.ops.aten.add.Tensor](args = (%arg0_1, 1e-07), kwargs = {})
#   %mean : [num_users=1] = call_function[target=torch.ops.aten.mean.dim](args = (%add, [1]), kwargs = {})
#   %log : [num_users=1] = call_function[target=torch.ops.aten.log.default](args = (%mean,), kwargs = {})
#   %log_1 : [num_users=1] = call_function[target=torch.ops.aten.log.default](args = (%add,), kwargs = {})
#   %mean_1 : [num_users=1] = call_function[target=torch.ops.aten.mean.dim](args = (%log_1, [1]), kwargs = {})
#   %sub : [num_users=14] = call_function[target=torch.ops.aten.sub.Tensor](args = (%log, %mean_1), kwargs = {})
#   %sub_56 : [num_users=6] = call_function[target=torch.ops.aten.sub.Tensor](args = (%sub_50, %div_45), kwargs = {})
#   %log_11 : [num_users=1] = call_function[target=torch.ops.aten.log.default](args = (%sub_56,), kwargs = {})
#   %sub_57 : [num_users=1] = call_function[target=torch.ops.aten.sub.Tensor](args = (%log_11, %digamma_9), kwargs = {})
#   %sub_58 : [num_users=1] = call_function[target=torch.ops.aten.sub.Tensor](args = (%sub_57, %sub), kwargs = {})
#   %reciprocal_27 : [num_users=1] = call_function[target=torch.ops.aten.reciprocal.default](args = (%sub_56,), kwargs = {})
#   %add_40 : [num_users=4] = call_function[target=torch.ops.aten.add.Tensor](args = (%sub_56, 1.0), kwargs = {})
#   %pow_20 : [num_users=2] = call_function[target=torch.ops.aten.pow.Tensor_Scalar](args = (%add_40, 2), kwargs = {})
#   %mul_29 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%pow_20, 7.0), kwargs = {})
#   %reciprocal_28 : [num_users=1] = call_function[target=torch.ops.aten.reciprocal.default](args = (%mul_29,), kwargs = {})
#   %sub_59 : [num_users=1] = call_function[target=torch.ops.aten.sub.Tensor](args = (0.2, %reciprocal_28), kwargs = {})
#   %div_46 : [num_users=1] = call_function[target=torch.ops.aten.div.Tensor](args = (%sub_59, %pow_20), kwargs = {})
#   %sub_60 : [num_users=1] = call_function[target=torch.ops.aten.sub.Tensor](args = (1.0, %div_46), kwargs = {})
#   %mul_30 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%add_40, 3.0), kwargs = {})
#   %div_47 : [num_users=1] = call_function[target=torch.ops.aten.div.Tensor](args = (%sub_60, %mul_30), kwargs = {})
#   %add_41 : [num_users=1] = call_function[target=torch.ops.aten.add.Tensor](args = (%div_47, 1.0), kwargs = {})
#   %mul_31 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%add_40, 2.0), kwargs = {})
#   %div_48 : [num_users=1] = call_function[target=torch.ops.aten.div.Tensor](args = (%add_41, %mul_31), kwargs = {})
#   %add_42 : [num_users=1] = call_function[target=torch.ops.aten.add.Tensor](args = (%div_48, 1.0), kwargs = {})
#   %div_49 : [num_users=1] = call_function[target=torch.ops.aten.div.Tensor](args = (%add_42, %add_40), kwargs = {})
#   %pow_21 : [num_users=1] = call_function[target=torch.ops.aten.pow.Tensor_Scalar](args = (%sub_56, 2.0), kwargs = {})
#   %reciprocal_29 : [num_users=1] = call_function[target=torch.ops.aten.reciprocal.default](args = (%pow_21,), kwargs = {})
#   %add_43 : [num_users=1] = call_function[target=torch.ops.aten.add.Tensor](args = (%div_49, %reciprocal_29), kwargs = {})
#   %sub_61 : [num_users=1] = call_function[target=torch.ops.aten.sub.Tensor](args = (%reciprocal_27, %add_43), kwargs = {})
#   %div_50 : [num_users=1] = call_function[target=torch.ops.aten.div.Tensor](args = (%sub_58, %sub_61), kwargs = {})
#   %sub_62 : [num_users=1] = call_function[target=torch.ops.aten.sub.Tensor](args = (%sub_56, %div_50), kwargs = {})
#   %reciprocal_30 : [num_users=1] = call_function[target=torch.ops.aten.reciprocal.default](args = (%sub_62,), kwargs = {})
#   %mean_2 : [num_users=1] = call_function[target=torch.ops.aten.mean.dim](args = (%add, [1]), kwargs = {})
#   %mul_32 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%reciprocal_30, %mean_2), kwargs = {})
triton_poi_fused_add_div_log_mean_mul_pow_reciprocal_rsub_sub_5 = async_compile.triton('triton_poi_fused_add_div_log_mean_mul_pow_reciprocal_rsub_sub_5', '''
import triton
import triton.language as tl
from triton.compiler.compiler import AttrsDescriptor

from torch._inductor.runtime import triton_helpers, triton_heuristics
from torch._inductor.runtime.triton_helpers import libdevice, math as tl_math
from torch._inductor.runtime.hints import AutotuneHint, ReductionHint, TileHint, instance_descriptor, DeviceProperties

@triton_heuristics.pointwise(
    size_hints=[64], 
    filename=__file__,
    triton_meta={'signature': {0: '*fp32', 1: '*fp32', 2: '*fp32', 3: '*fp32', 4: '*fp32', 5: 'i32'}, 'device': DeviceProperties(type='cuda', index=0, cc=90, major=9, regs_per_multiprocessor=65536, max_threads_per_multi_processor=2048, multi_processor_count=132), 'constants': {}, 'configs': [AttrsDescriptor(divisible_by_16=(0, 1, 2, 3, 4, 5), equal_to_1=())]},
    inductor_meta={'autotune_hints': set(), 'kernel_name': 'triton_poi_fused_add_div_log_mean_mul_pow_reciprocal_rsub_sub_5', 'mutated_arg_names': ['in_out_ptr0', 'in_out_ptr1'], 'no_x_dim': False, 'num_load': 8, 'num_reduction': 0, 'backend_hash': 'B098E03CDA7B8ADC90DAFFDF24A2956451D1B13F297756A5DCC209498AA53705', 'are_deterministic_algorithms_enabled': False, 'assert_indirect_indexing': True, 'autotune_local_cache': True, 'autotune_pointwise': True, 'autotune_remote_cache': None, 'force_disable_caches': False, 'dynamic_scale_rblock': True, 'max_autotune': False, 'max_autotune_pointwise': False, 'min_split_scan_rblock': 256, 'spill_threshold': 16, 'store_cubin': False},
    min_elem_per_thread=0
)
@triton.jit
def triton_poi_fused_add_div_log_mean_mul_pow_reciprocal_rsub_sub_5(in_out_ptr0, in_out_ptr1, in_ptr0, in_ptr1, in_ptr2, xnumel, XBLOCK : tl.constexpr):
    xnumel = 64
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x2 = xindex
    x0 = xindex % 16
    x1 = (xindex // 16)
    tmp0 = tl.load(in_out_ptr0 + (x2), xmask)
    tmp1 = tl.load(in_ptr0 + (x2), xmask)
    tmp4 = tl.load(in_ptr1 + (x2), xmask)
    tmp6 = tl.load(in_ptr2 + (x0 + (64*x1)), xmask)
    tmp9 = tl.load(in_ptr2 + (16 + x0 + (64*x1)), xmask)
    tmp12 = tl.load(in_ptr2 + (32 + x0 + (64*x1)), xmask)
    tmp15 = tl.load(in_ptr2 + (48 + x0 + (64*x1)), xmask)
    tmp31 = tl.load(in_out_ptr1 + (x2), xmask)
    tmp2 = tmp0 - tmp1
    tmp3 = tl_math.log(tmp2)
    tmp5 = tmp3 - tmp4
    tmp7 = 1e-07
    tmp8 = tmp6 + tmp7
    tmp10 = tmp9 + tmp7
    tmp11 = tmp8 + tmp10
    tmp13 = tmp12 + tmp7
    tmp14 = tmp11 + tmp13
    tmp16 = tmp15 + tmp7
    tmp17 = tmp14 + tmp16
    tmp18 = 4.0
    tmp19 = tmp17 / tmp18
    tmp20 = tl_math.log(tmp19)
    tmp21 = tl_math.log(tmp8)
    tmp22 = tl_math.log(tmp10)
    tmp23 = tmp21 + tmp22
    tmp24 = tl_math.log(tmp13)
    tmp25 = tmp23 + tmp24
    tmp26 = tl_math.log(tmp16)
    tmp27 = tmp25 + tmp26
    tmp28 = tmp27 / tmp18
    tmp29 = tmp20 - tmp28
    tmp30 = tmp5 - tmp29
    tmp32 = tl.full([1], 1, tl.int32)
    tmp33 = tmp32 / tmp31
    tmp34 = 1.0
    tmp35 = tmp31 + tmp34
    tmp36 = tmp35 * tmp35
    tmp37 = 7.0
    tmp38 = tmp36 * tmp37
    tmp39 = tmp32 / tmp38
    tmp40 = 0.2
    tmp41 = tmp40 - tmp39
    tmp42 = tmp41 / tmp36
    tmp43 = tmp34 - tmp42
    tmp44 = 3.0
    tmp45 = tmp35 * tmp44
    tmp46 = tmp43 / tmp45
    tmp47 = tmp46 + tmp34
    tmp48 = 2.0
    tmp49 = tmp35 * tmp48
    tmp50 = tmp47 / tmp49
    tmp51 = tmp50 + tmp34
    tmp52 = tmp51 / tmp35
    tmp53 = tmp31 * tmp31
    tmp54 = tmp32 / tmp53
    tmp55 = tmp52 + tmp54
    tmp56 = tmp33 - tmp55
    tmp57 = tmp30 / tmp56
    tmp58 = tmp31 - tmp57
    tmp59 = tmp32 / tmp58
    tmp60 = tmp59 * tmp19
    tl.store(in_out_ptr1 + (x2), tmp60, xmask)
''', device_str='cuda')


async_compile.wait(globals())
del async_compile

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, 4), (16, 4, 1), torch.float32)
        buf1 = buf0; del buf0  # reuse
        buf2 = empty_strided_cuda((4, 4, 4), (16, 4, 1), torch.float32)
        # Topologically Sorted Source Nodes: [x, mean, log, log_1, mean_1, s, sub_2, s3, pow_1, mul, add_1, rt, nm, dn, truediv, k], Original ATen: [aten.add, aten.mean, aten.log, aten.sub, aten.rsub, aten.pow, aten.mul, aten.sqrt, aten.div]
        stream0 = get_raw_stream(0)
        triton_poi_fused_add_div_log_mean_mul_pow_rsub_sqrt_sub_0.run(buf1, arg0_1, buf2, 64, grid=grid(64), stream=stream0)
        # Topologically Sorted Source Nodes: [k, digamma], Original ATen: [aten.add, aten.digamma]
        buf3 = torch.ops.aten.digamma.default(buf2)
        buf4 = buf3
        del buf3
        buf5 = buf1; del buf1  # reuse
        buf6 = empty_strided_cuda((4, 4, 4), (16, 4, 1), torch.float32)
        # Topologically Sorted Source Nodes: [x, mean, log, log_1, mean_1, s, k, log_2, sub_3, nm_1, reciprocal, z, zz, mul_2, reciprocal_1, a, truediv_1, b, mul_3, truediv_2, c, mul_4, truediv_3, d, e, pow_3, reciprocal_2, e_1, dn_1, truediv_5, k2], Original ATen: [aten.add, aten.mean, aten.log, aten.sub, aten.reciprocal, aten.pow, aten.mul, aten.rsub, aten.div]
        triton_poi_fused_add_div_log_mean_mul_pow_reciprocal_rsub_sub_1.run(buf5, buf4, arg0_1, buf2, buf6, 64, grid=grid(64), stream=stream0)
        # Topologically Sorted Source Nodes: [k2, digamma_1], Original ATen: [aten.sub, aten.digamma]
        buf7 = torch.ops.aten.digamma.default(buf6)
        buf8 = buf7
        del buf7
        buf9 = buf2; del buf2  # reuse
        buf10 = buf4; del buf4  # reuse
        # Topologically Sorted Source Nodes: [x, mean, log, log_1, mean_1, s, k2, log_3, sub_9, nm_2, reciprocal_3, z_1, zz_1, mul_5, reciprocal_4, a_1, truediv_6, b_1, mul_6, truediv_7, c_1, mul_7, truediv_8, d_1, e_2, pow_5, reciprocal_5, e_3, dn_2, truediv_10, k2_1], Original ATen: [aten.add, aten.mean, aten.log, aten.sub, aten.reciprocal, aten.pow, aten.mul, aten.rsub, aten.div]
        triton_poi_fused_add_div_log_mean_mul_pow_reciprocal_rsub_sub_2.run(buf9, buf5, buf8, arg0_1, buf6, buf10, 64, grid=grid(64), stream=stream0)
        del buf5
        # Topologically Sorted Source Nodes: [reciprocal_3, z_1, zz_1, mul_5, reciprocal_4, a_1, truediv_6, b_1, mul_6, truediv_7, c_1, mul_7, truediv_8, d_1, e_2, pow_5, reciprocal_5, e_3, dn_2, truediv_10, k2_1, digamma_2], Original ATen: [aten.reciprocal, aten.add, aten.pow, aten.mul, aten.rsub, aten.div, aten.sub, aten.digamma]
        buf11 = torch.ops.aten.digamma.default(buf10)
        buf12 = buf11
        del buf11
        buf13 = buf12; del buf12  # reuse
        buf14 = buf13; del buf13  # reuse
        buf15 = buf8; del buf8  # reuse
        # Topologically Sorted Source Nodes: [x, mean, log, log_1, mean_1, s, reciprocal_3, z_1, zz_1, mul_5, reciprocal_4, a_1, truediv_6, b_1, mul_6, truediv_7, c_1, mul_7, truediv_8, d_1, e_2, pow_5, reciprocal_5, e_3, dn_2, truediv_10, k2_1, log_4, sub_15, nm_3, reciprocal_6, z_2, zz_2, mul_8, reciprocal_7, a_2, truediv_11, b_2, mul_9, truediv_12, c_2, mul_10, truediv_13, d_2, e_4, pow_7, reciprocal_8, e_5, dn_3, truediv_15, k2_2], Original ATen: [aten.add, aten.mean, aten.log, aten.sub, aten.reciprocal, aten.pow, aten.mul, aten.rsub, aten.div]
        triton_poi_fused_add_div_log_mean_mul_pow_reciprocal_rsub_sub_3.run(buf14, buf6, buf9, arg0_1, buf10, buf15, 64, grid=grid(64), stream=stream0)
        del buf6
        # Topologically Sorted Source Nodes: [k2_2, digamma_3], Original ATen: [aten.sub, aten.digamma]
        buf16 = torch.ops.aten.digamma.default(buf15)
        buf17 = buf16
        del buf16
        buf18 = buf10; del buf10  # reuse
        buf19 = buf9; del buf9  # reuse
        # Topologically Sorted Source Nodes: [x, mean, log, log_1, mean_1, s, k2_2, log_5, sub_21, nm_4, reciprocal_9, z_3, zz_3, mul_11, reciprocal_10, a_3, truediv_16, b_3, mul_12, truediv_17, c_3, mul_13, truediv_18, d_3, e_6, pow_9, reciprocal_11, e_7, dn_4, truediv_20, k2_3], Original ATen: [aten.add, aten.mean, aten.log, aten.sub, aten.reciprocal, aten.pow, aten.mul, aten.rsub, aten.div]
        triton_poi_fused_add_div_log_mean_mul_pow_reciprocal_rsub_sub_2.run(buf18, buf14, buf17, arg0_1, buf15, buf19, 64, grid=grid(64), stream=stream0)
        del buf14
        # Topologically Sorted Source Nodes: [reciprocal_9, z_3, zz_3, mul_11, reciprocal_10, a_3, truediv_16, b_3, mul_12, truediv_17, c_3, mul_13, truediv_18, d_3, e_6, pow_9, reciprocal_11, e_7, dn_4, truediv_20, k2_3, digamma_4], Original ATen: [aten.reciprocal, aten.add, aten.pow, aten.mul, aten.rsub, aten.div, aten.sub, aten.digamma]
        buf20 = torch.ops.aten.digamma.default(buf19)
        buf21 = buf20
        del buf20
        buf22 = buf15; del buf15  # reuse
        buf23 = buf22; del buf22  # reuse
        buf24 = buf17; del buf17  # reuse
        # Topologically Sorted Source Nodes: [x, mean, log, log_1, mean_1, s, reciprocal_9, z_3, zz_3, mul_11, reciprocal_10, a_3, truediv_16, b_3, mul_12, truediv_17, c_3, mul_13, truediv_18, d_3, e_6, pow_9, reciprocal_11, e_7, dn_4, truediv_20, k2_3, log_6, sub_27, nm_5, reciprocal_12, z_4, zz_4, mul_14, reciprocal_13, a_4, truediv_21, b_4, mul_15, truediv_22, c_4, mul_16, truediv_23, d_4, e_8, pow_11, reciprocal_14, e_9, dn_5, truediv_25, k2_4], Original ATen: [aten.add, aten.mean, aten.log, aten.sub, aten.reciprocal, aten.pow, aten.mul, aten.rsub, aten.div]
        triton_poi_fused_add_div_log_mean_mul_pow_reciprocal_rsub_sub_4.run(buf23, buf18, buf21, arg0_1, buf19, buf24, 64, grid=grid(64), stream=stream0)
        del buf18
        # Topologically Sorted Source Nodes: [k2_4, digamma_5], Original ATen: [aten.sub, aten.digamma]
        buf25 = torch.ops.aten.digamma.default(buf24)
        buf26 = buf25
        del buf25
        buf27 = buf19; del buf19  # reuse
        buf28 = buf21; del buf21  # reuse
        # Topologically Sorted Source Nodes: [x, mean, log, log_1, mean_1, s, k2_4, log_7, sub_33, nm_6, reciprocal_15, z_5, zz_5, mul_17, reciprocal_16, a_5, truediv_26, b_5, mul_18, truediv_27, c_5, mul_19, truediv_28, d_5, e_10, pow_13, reciprocal_17, e_11, dn_6, truediv_30, k2_5], Original ATen: [aten.add, aten.mean, aten.log, aten.sub, aten.reciprocal, aten.pow, aten.mul, aten.rsub, aten.div]
        triton_poi_fused_add_div_log_mean_mul_pow_reciprocal_rsub_sub_2.run(buf27, buf23, buf26, arg0_1, buf24, buf28, 64, grid=grid(64), stream=stream0)
        del buf23
        # Topologically Sorted Source Nodes: [reciprocal_15, z_5, zz_5, mul_17, reciprocal_16, a_5, truediv_26, b_5, mul_18, truediv_27, c_5, mul_19, truediv_28, d_5, e_10, pow_13, reciprocal_17, e_11, dn_6, truediv_30, k2_5, digamma_6], Original ATen: [aten.reciprocal, aten.add, aten.pow, aten.mul, aten.rsub, aten.div, aten.sub, aten.digamma]
        buf29 = torch.ops.aten.digamma.default(buf28)
        buf30 = buf29
        del buf29
        buf31 = buf24; del buf24  # reuse
        buf32 = buf31; del buf31  # reuse
        buf33 = buf26; del buf26  # reuse
        # Topologically Sorted Source Nodes: [x, mean, log, log_1, mean_1, s, reciprocal_15, z_5, zz_5, mul_17, reciprocal_16, a_5, truediv_26, b_5, mul_18, truediv_27, c_5, mul_19, truediv_28, d_5, e_10, pow_13, reciprocal_17, e_11, dn_6, truediv_30, k2_5, log_8, sub_39, nm_7, reciprocal_18, z_6, zz_6, mul_20, reciprocal_19, a_6, truediv_31, b_6, mul_21, truediv_32, c_6, mul_22, truediv_33, d_6, e_12, pow_15, reciprocal_20, e_13, dn_7, truediv_35, k2_6], Original ATen: [aten.add, aten.mean, aten.log, aten.sub, aten.reciprocal, aten.pow, aten.mul, aten.rsub, aten.div]
        triton_poi_fused_add_div_log_mean_mul_pow_reciprocal_rsub_sub_4.run(buf32, buf27, buf30, arg0_1, buf28, buf33, 64, grid=grid(64), stream=stream0)
        del buf27
        # Topologically Sorted Source Nodes: [k2_6, digamma_7], Original ATen: [aten.sub, aten.digamma]
        buf34 = torch.ops.aten.digamma.default(buf33)
        buf35 = buf34
        del buf34
        buf36 = buf28; del buf28  # reuse
        buf37 = buf30; del buf30  # reuse
        # Topologically Sorted Source Nodes: [x, mean, log, log_1, mean_1, s, k2_6, log_9, sub_45, nm_8, reciprocal_21, z_7, zz_7, mul_23, reciprocal_22, a_7, truediv_36, b_7, mul_24, truediv_37, c_7, mul_25, truediv_38, d_7, e_14, pow_17, reciprocal_23, e_15, dn_8, truediv_40, k2_7], Original ATen: [aten.add, aten.mean, aten.log, aten.sub, aten.reciprocal, aten.pow, aten.mul, aten.rsub, aten.div]
        triton_poi_fused_add_div_log_mean_mul_pow_reciprocal_rsub_sub_2.run(buf36, buf32, buf35, arg0_1, buf33, buf37, 64, grid=grid(64), stream=stream0)
        del buf32
        # Topologically Sorted Source Nodes: [reciprocal_21, z_7, zz_7, mul_23, reciprocal_22, a_7, truediv_36, b_7, mul_24, truediv_37, c_7, mul_25, truediv_38, d_7, e_14, pow_17, reciprocal_23, e_15, dn_8, truediv_40, k2_7, digamma_8], Original ATen: [aten.reciprocal, aten.add, aten.pow, aten.mul, aten.rsub, aten.div, aten.sub, aten.digamma]
        buf38 = torch.ops.aten.digamma.default(buf37)
        buf39 = buf38
        del buf38
        buf40 = buf33; del buf33  # reuse
        buf41 = buf40; del buf40  # reuse
        buf42 = buf35; del buf35  # reuse
        # Topologically Sorted Source Nodes: [x, mean, log, log_1, mean_1, s, reciprocal_21, z_7, zz_7, mul_23, reciprocal_22, a_7, truediv_36, b_7, mul_24, truediv_37, c_7, mul_25, truediv_38, d_7, e_14, pow_17, reciprocal_23, e_15, dn_8, truediv_40, k2_7, log_10, sub_51, nm_9, reciprocal_24, z_8, zz_8, mul_26, reciprocal_25, a_8, truediv_41, b_8, mul_27, truediv_42, c_8, mul_28, truediv_43, d_8, e_16, pow_19, reciprocal_26, e_17, dn_9, truediv_45, k2_8], Original ATen: [aten.add, aten.mean, aten.log, aten.sub, aten.reciprocal, aten.pow, aten.mul, aten.rsub, aten.div]
        triton_poi_fused_add_div_log_mean_mul_pow_reciprocal_rsub_sub_4.run(buf41, buf36, buf39, arg0_1, buf37, buf42, 64, grid=grid(64), stream=stream0)
        del buf36
        del buf39
        # Topologically Sorted Source Nodes: [k2_8, digamma_9], Original ATen: [aten.sub, aten.digamma]
        buf43 = torch.ops.aten.digamma.default(buf42)
        buf44 = buf43
        del buf43
        buf45 = buf37; del buf37  # reuse
        buf46 = buf42; del buf42  # reuse
        # Topologically Sorted Source Nodes: [x, mean, log, log_1, mean_1, s, k2_8, log_11, sub_57, nm_10, reciprocal_27, z_9, zz_9, mul_29, reciprocal_28, a_9, truediv_46, b_9, mul_30, truediv_47, c_9, mul_31, truediv_48, d_9, e_18, pow_21, reciprocal_29, e_19, dn_10, truediv_50, k2_9, reciprocal_30, mean_2, th], Original ATen: [aten.add, aten.mean, aten.log, aten.sub, aten.reciprocal, aten.pow, aten.mul, aten.rsub, aten.div]
        triton_poi_fused_add_div_log_mean_mul_pow_reciprocal_rsub_sub_5.run(buf45, buf46, buf41, buf44, arg0_1, 64, grid=grid(64), stream=stream0)
        del arg0_1
        del buf41
        del buf44
        del buf45
    return (buf46, )


def benchmark_compiled_module(times=10, repeat=10):
    from torch._dynamo.testing import rand_strided
    from torch._inductor.utils import print_performance
    arg0_1 = rand_strided((4, 4, 4, 4), (64, 16, 4, 1), device='cuda:0', dtype=torch.float32)
    fn = lambda: call([arg0_1])
    return print_performance(fn, times=times, repeat=repeat)


if __name__ == "__main__":
    from torch._inductor.wrapper_benchmark import compiled_module_main
    compiled_module_main('None', benchmark_compiled_module)

import torch
import torch.nn as nn
import torch.autograd


class GammaScaleMap(nn.Module):
    """
        Compute Gamma Scale on a 4D tensor (The hard way). This acts as a standard PyTorch layer. 
        
        Gamma Scale is computed independantly for each batch item at each location x,y
    
        Input should be:
        
        (1) A tensor of size [batch x channels x height x width] 
        (2) A tensor with only positive values. (After a ReLU)
        
        Output is a 3D tensor of size [batch x height x width] 
    """

    def __init__(self, run_relu=False):
        super(GammaScaleMap, self).__init__()
        """
            SMOE Scale must take in values > 0. Optionally, we can run a ReLU to do that.
        """
        if run_relu:
            self.relu = nn.ReLU(inplace=False)
        else:
            self.relu = None

    def _trigamma(self, x):
        """
            We need this line since recursion is not good for x < 1.0
            Note that we take + torch.reciprocal(x.pow(2)) at the end because:
        
                trigamma(z) = trigamma(z + 1) + 1/z^2
        
        """
        z = x + 1.0
        zz = z.pow(2)
        a = 0.2 - torch.reciprocal(7.0 * zz)
        b = 1.0 - a / zz
        c = 1.0 + b / (3.0 * z)
        d = 1.0 + c / (2.0 * z)
        e = d / z
        e = e + torch.reciprocal(x.pow(2.0))
        return e

    def _k_update(self, k, s):
        nm = torch.log(k) - torch.digamma(k) - s
        dn = torch.reciprocal(k) - self._trigamma(k)
        k2 = k - nm / dn
        return k2

    def _compute_k_est(self, x, i=10, dim=1):
        """
            Calculate s
        """
        s = torch.log(torch.mean(x, dim=dim)) - torch.mean(torch.log(x),
            dim=dim)
        """
            Get estimate of k to within 1.5%
        
            NOTE: K gets smaller as log variance s increases
        """
        s3 = s - 3.0
        rt = torch.sqrt(s3.pow(2) + 24.0 * s)
        nm = 3.0 - s + rt
        dn = 12.0 * s
        k = nm / dn + 1e-07
        """
            Do i Newton-Raphson steps to get closer than 1.5%
            For i=5 gets us within 4 or 5 decimal places
        """
        for _ in range(i):
            k = self._k_update(k, s)
        return k

    def forward(self, x):
        assert torch.is_tensor(x), 'input must be a Torch Tensor'
        assert len(x.size()) > 2, 'input must have at least three dims'
        """
            If we do not have a convenient ReLU to pluck from, we can do it here
        """
        if self.relu is not None:
            x = self.relu(x)
        """
            avoid log(0)
        """
        x = x + 1e-07
        k = self._compute_k_est(x)
        th = torch.reciprocal(k) * torch.mean(x, dim=1)
        return th


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


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

import torch
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, math as tl_math
import torch.nn as nn
import torch.autograd
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_add_div_log_mean_mul_pow_rsub_sqrt_sub_0(in_out_ptr0,
    in_ptr0, 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 % 16
    x1 = xindex // 16
    x2 = xindex
    tmp0 = tl.load(in_ptr0 + (x0 + 64 * x1), xmask)
    tmp3 = tl.load(in_ptr0 + (16 + x0 + 64 * x1), xmask)
    tmp6 = tl.load(in_ptr0 + (32 + x0 + 64 * x1), xmask)
    tmp9 = tl.load(in_ptr0 + (48 + x0 + 64 * x1), xmask)
    tmp1 = 1e-07
    tmp2 = tmp0 + tmp1
    tmp4 = tmp3 + tmp1
    tmp5 = tmp2 + tmp4
    tmp7 = tmp6 + tmp1
    tmp8 = tmp5 + tmp7
    tmp10 = tmp9 + tmp1
    tmp11 = tmp8 + tmp10
    tmp12 = 4.0
    tmp13 = tmp11 / tmp12
    tmp14 = tl_math.log(tmp13)
    tmp15 = tl_math.log(tmp2)
    tmp16 = tl_math.log(tmp4)
    tmp17 = tmp15 + tmp16
    tmp18 = tl_math.log(tmp7)
    tmp19 = tmp17 + tmp18
    tmp20 = tl_math.log(tmp10)
    tmp21 = tmp19 + tmp20
    tmp22 = tmp21 / tmp12
    tmp23 = tmp14 - tmp22
    tmp24 = 3.0
    tmp25 = tmp23 - tmp24
    tmp26 = tmp25 * tmp25
    tmp27 = 24.0
    tmp28 = tmp23 * tmp27
    tmp29 = tmp26 + tmp28
    tmp30 = libdevice.sqrt(tmp29)
    tmp31 = tmp24 - tmp23
    tmp32 = tmp31 + tmp30
    tmp33 = 12.0
    tmp34 = tmp23 * tmp33
    tmp35 = tmp32 / tmp34
    tmp36 = tmp35 + tmp1
    tl.store(in_out_ptr0 + x2, tmp35, xmask)
    tl.store(out_ptr0 + x2, tmp36, xmask)


@triton.jit
def triton_poi_fused_add_div_log_mean_mul_pow_reciprocal_rsub_sub_1(in_out_ptr0
    , in_ptr0, in_ptr1, in_ptr2, out_ptr0, xnumel, XBLOCK: tl.constexpr):
    xnumel = 64
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x2 = xindex
    x0 = xindex % 16
    x1 = xindex // 16
    tmp0 = tl.load(in_out_ptr0 + x2, xmask)
    tmp4 = tl.load(in_ptr0 + x2, xmask)
    tmp6 = tl.load(in_ptr1 + (x0 + 64 * x1), xmask)
    tmp8 = tl.load(in_ptr1 + (16 + x0 + 64 * x1), xmask)
    tmp11 = tl.load(in_ptr1 + (32 + x0 + 64 * x1), xmask)
    tmp14 = tl.load(in_ptr1 + (48 + x0 + 64 * x1), xmask)
    tmp30 = tl.load(in_ptr2 + x2, xmask)
    tmp1 = 1e-07
    tmp2 = tmp0 + tmp1
    tmp3 = tl_math.log(tmp2)
    tmp5 = tmp3 - tmp4
    tmp7 = tmp6 + tmp1
    tmp9 = tmp8 + tmp1
    tmp10 = tmp7 + tmp9
    tmp12 = tmp11 + tmp1
    tmp13 = tmp10 + tmp12
    tmp15 = tmp14 + tmp1
    tmp16 = tmp13 + tmp15
    tmp17 = 4.0
    tmp18 = tmp16 / tmp17
    tmp19 = tl_math.log(tmp18)
    tmp20 = tl_math.log(tmp7)
    tmp21 = tl_math.log(tmp9)
    tmp22 = tmp20 + tmp21
    tmp23 = tl_math.log(tmp12)
    tmp24 = tmp22 + tmp23
    tmp25 = tl_math.log(tmp15)
    tmp26 = tmp24 + tmp25
    tmp27 = tmp26 / tmp17
    tmp28 = tmp19 - tmp27
    tmp29 = tmp5 - tmp28
    tmp31 = tl.full([1], 1, tl.int32)
    tmp32 = tmp31 / tmp30
    tmp33 = 1.0
    tmp34 = tmp30 + tmp33
    tmp35 = tmp34 * tmp34
    tmp36 = 7.0
    tmp37 = tmp35 * tmp36
    tmp38 = tmp31 / tmp37
    tmp39 = 0.2
    tmp40 = tmp39 - tmp38
    tmp41 = tmp40 / tmp35
    tmp42 = tmp33 - tmp41
    tmp43 = 3.0
    tmp44 = tmp34 * tmp43
    tmp45 = tmp42 / tmp44
    tmp46 = tmp45 + tmp33
    tmp47 = 2.0
    tmp48 = tmp34 * tmp47
    tmp49 = tmp46 / tmp48
    tmp50 = tmp49 + tmp33
    tmp51 = tmp50 / tmp34
    tmp52 = tmp30 * tmp30
    tmp53 = tmp31 / tmp52
    tmp54 = tmp51 + tmp53
    tmp55 = tmp32 - tmp54
    tmp56 = tmp29 / tmp55
    tmp57 = tmp30 - tmp56
    tl.store(in_out_ptr0 + x2, tmp56, xmask)
    tl.store(out_ptr0 + x2, tmp57, xmask)


@triton.jit
def triton_poi_fused_add_div_log_mean_mul_pow_reciprocal_rsub_sub_2(in_out_ptr0
    , in_ptr0, in_ptr1, in_ptr2, in_ptr3, out_ptr0, xnumel, XBLOCK: tl.
    constexpr):
    xnumel = 64
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x2 = xindex
    x0 = xindex % 16
    x1 = xindex // 16
    tmp0 = tl.load(in_out_ptr0 + x2, xmask)
    tmp1 = tl.load(in_ptr0 + x2, xmask)
    tmp4 = tl.load(in_ptr1 + x2, xmask)
    tmp6 = tl.load(in_ptr2 + (x0 + 64 * x1), xmask)
    tmp9 = tl.load(in_ptr2 + (16 + x0 + 64 * x1), xmask)
    tmp12 = tl.load(in_ptr2 + (32 + x0 + 64 * x1), xmask)
    tmp15 = tl.load(in_ptr2 + (48 + x0 + 64 * x1), xmask)
    tmp31 = tl.load(in_ptr3 + x2, xmask)
    tmp2 = tmp0 - tmp1
    tmp3 = tl_math.log(tmp2)
    tmp5 = tmp3 - tmp4
    tmp7 = 1e-07
    tmp8 = tmp6 + tmp7
    tmp10 = tmp9 + tmp7
    tmp11 = tmp8 + tmp10
    tmp13 = tmp12 + tmp7
    tmp14 = tmp11 + tmp13
    tmp16 = tmp15 + tmp7
    tmp17 = tmp14 + tmp16
    tmp18 = 4.0
    tmp19 = tmp17 / tmp18
    tmp20 = tl_math.log(tmp19)
    tmp21 = tl_math.log(tmp8)
    tmp22 = tl_math.log(tmp10)
    tmp23 = tmp21 + tmp22
    tmp24 = tl_math.log(tmp13)
    tmp25 = tmp23 + tmp24
    tmp26 = tl_math.log(tmp16)
    tmp27 = tmp25 + tmp26
    tmp28 = tmp27 / tmp18
    tmp29 = tmp20 - tmp28
    tmp30 = tmp5 - tmp29
    tmp32 = tl.full([1], 1, tl.int32)
    tmp33 = tmp32 / tmp31
    tmp34 = 1.0
    tmp35 = tmp31 + tmp34
    tmp36 = tmp35 * tmp35
    tmp37 = 7.0
    tmp38 = tmp36 * tmp37
    tmp39 = tmp32 / tmp38
    tmp40 = 0.2
    tmp41 = tmp40 - tmp39
    tmp42 = tmp41 / tmp36
    tmp43 = tmp34 - tmp42
    tmp44 = 3.0
    tmp45 = tmp35 * tmp44
    tmp46 = tmp43 / tmp45
    tmp47 = tmp46 + tmp34
    tmp48 = 2.0
    tmp49 = tmp35 * tmp48
    tmp50 = tmp47 / tmp49
    tmp51 = tmp50 + tmp34
    tmp52 = tmp51 / tmp35
    tmp53 = tmp31 * tmp31
    tmp54 = tmp32 / tmp53
    tmp55 = tmp52 + tmp54
    tmp56 = tmp33 - tmp55
    tmp57 = tmp30 / tmp56
    tmp58 = tmp31 - tmp57
    tl.store(in_out_ptr0 + x2, tmp30, xmask)
    tl.store(out_ptr0 + x2, tmp58, xmask)


@triton.jit
def triton_poi_fused_add_div_log_mean_mul_pow_reciprocal_rsub_sub_3(in_out_ptr0
    , in_ptr0, in_ptr1, in_ptr2, in_ptr3, 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
    x1 = xindex % 16
    x2 = xindex // 16
    tmp0 = tl.load(in_ptr0 + x0, xmask)
    tmp1 = tl.load(in_ptr1 + x0, xmask)
    tmp30 = tl.load(in_out_ptr0 + x0, xmask)
    tmp32 = tl.load(in_ptr2 + (x1 + 64 * x2), xmask)
    tmp35 = tl.load(in_ptr2 + (16 + x1 + 64 * x2), xmask)
    tmp38 = tl.load(in_ptr2 + (32 + x1 + 64 * x2), xmask)
    tmp41 = tl.load(in_ptr2 + (48 + x1 + 64 * x2), xmask)
    tmp57 = tl.load(in_ptr3 + x0, xmask)
    tmp2 = tl.full([1], 1, tl.int32)
    tmp3 = tmp2 / tmp0
    tmp4 = 1.0
    tmp5 = tmp0 + tmp4
    tmp6 = tmp5 * tmp5
    tmp7 = 7.0
    tmp8 = tmp6 * tmp7
    tmp9 = tmp2 / tmp8
    tmp10 = 0.2
    tmp11 = tmp10 - tmp9
    tmp12 = tmp11 / tmp6
    tmp13 = tmp4 - tmp12
    tmp14 = 3.0
    tmp15 = tmp5 * tmp14
    tmp16 = tmp13 / tmp15
    tmp17 = tmp16 + tmp4
    tmp18 = 2.0
    tmp19 = tmp5 * tmp18
    tmp20 = tmp17 / tmp19
    tmp21 = tmp20 + tmp4
    tmp22 = tmp21 / tmp5
    tmp23 = tmp0 * tmp0
    tmp24 = tmp2 / tmp23
    tmp25 = tmp22 + tmp24
    tmp26 = tmp3 - tmp25
    tmp27 = tmp1 / tmp26
    tmp28 = tmp0 - tmp27
    tmp29 = tl_math.log(tmp28)
    tmp31 = tmp29 - tmp30
    tmp33 = 1e-07
    tmp34 = tmp32 + tmp33
    tmp36 = tmp35 + tmp33
    tmp37 = tmp34 + tmp36
    tmp39 = tmp38 + tmp33
    tmp40 = tmp37 + tmp39
    tmp42 = tmp41 + tmp33
    tmp43 = tmp40 + tmp42
    tmp44 = 4.0
    tmp45 = tmp43 / tmp44
    tmp46 = tl_math.log(tmp45)
    tmp47 = tl_math.log(tmp34)
    tmp48 = tl_math.log(tmp36)
    tmp49 = tmp47 + tmp48
    tmp50 = tl_math.log(tmp39)
    tmp51 = tmp49 + tmp50
    tmp52 = tl_math.log(tmp42)
    tmp53 = tmp51 + tmp52
    tmp54 = tmp53 / tmp44
    tmp55 = tmp46 - tmp54
    tmp56 = tmp31 - tmp55
    tmp58 = tmp2 / tmp57
    tmp59 = tmp57 + tmp4
    tmp60 = tmp59 * tmp59
    tmp61 = tmp60 * tmp7
    tmp62 = tmp2 / tmp61
    tmp63 = tmp10 - tmp62
    tmp64 = tmp63 / tmp60
    tmp65 = tmp4 - tmp64
    tmp66 = tmp59 * tmp14
    tmp67 = tmp65 / tmp66
    tmp68 = tmp67 + tmp4
    tmp69 = tmp59 * tmp18
    tmp70 = tmp68 / tmp69
    tmp71 = tmp70 + tmp4
    tmp72 = tmp71 / tmp59
    tmp73 = tmp57 * tmp57
    tmp74 = tmp2 / tmp73
    tmp75 = tmp72 + tmp74
    tmp76 = tmp58 - tmp75
    tmp77 = tmp56 / tmp76
    tmp78 = tmp57 - tmp77
    tl.store(in_out_ptr0 + x0, tmp77, xmask)
    tl.store(out_ptr0 + x0, tmp78, xmask)


@triton.jit
def triton_poi_fused_add_div_log_mean_mul_pow_reciprocal_rsub_sub_4(in_out_ptr0
    , in_ptr0, in_ptr1, in_ptr2, in_ptr3, 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
    x1 = xindex % 16
    x2 = xindex // 16
    tmp0 = tl.load(in_out_ptr0 + x0, xmask)
    tmp1 = tl.load(in_ptr0 + x0, xmask)
    tmp30 = tl.load(in_ptr1 + x0, xmask)
    tmp32 = tl.load(in_ptr2 + (x1 + 64 * x2), xmask)
    tmp35 = tl.load(in_ptr2 + (16 + x1 + 64 * x2), xmask)
    tmp38 = tl.load(in_ptr2 + (32 + x1 + 64 * x2), xmask)
    tmp41 = tl.load(in_ptr2 + (48 + x1 + 64 * x2), xmask)
    tmp57 = tl.load(in_ptr3 + x0, xmask)
    tmp2 = tl.full([1], 1, tl.int32)
    tmp3 = tmp2 / tmp0
    tmp4 = 1.0
    tmp5 = tmp0 + tmp4
    tmp6 = tmp5 * tmp5
    tmp7 = 7.0
    tmp8 = tmp6 * tmp7
    tmp9 = tmp2 / tmp8
    tmp10 = 0.2
    tmp11 = tmp10 - tmp9
    tmp12 = tmp11 / tmp6
    tmp13 = tmp4 - tmp12
    tmp14 = 3.0
    tmp15 = tmp5 * tmp14
    tmp16 = tmp13 / tmp15
    tmp17 = tmp16 + tmp4
    tmp18 = 2.0
    tmp19 = tmp5 * tmp18
    tmp20 = tmp17 / tmp19
    tmp21 = tmp20 + tmp4
    tmp22 = tmp21 / tmp5
    tmp23 = tmp0 * tmp0
    tmp24 = tmp2 / tmp23
    tmp25 = tmp22 + tmp24
    tmp26 = tmp3 - tmp25
    tmp27 = tmp1 / tmp26
    tmp28 = tmp0 - tmp27
    tmp29 = tl_math.log(tmp28)
    tmp31 = tmp29 - tmp30
    tmp33 = 1e-07
    tmp34 = tmp32 + tmp33
    tmp36 = tmp35 + tmp33
    tmp37 = tmp34 + tmp36
    tmp39 = tmp38 + tmp33
    tmp40 = tmp37 + tmp39
    tmp42 = tmp41 + tmp33
    tmp43 = tmp40 + tmp42
    tmp44 = 4.0
    tmp45 = tmp43 / tmp44
    tmp46 = tl_math.log(tmp45)
    tmp47 = tl_math.log(tmp34)
    tmp48 = tl_math.log(tmp36)
    tmp49 = tmp47 + tmp48
    tmp50 = tl_math.log(tmp39)
    tmp51 = tmp49 + tmp50
    tmp52 = tl_math.log(tmp42)
    tmp53 = tmp51 + tmp52
    tmp54 = tmp53 / tmp44
    tmp55 = tmp46 - tmp54
    tmp56 = tmp31 - tmp55
    tmp58 = tmp2 / tmp57
    tmp59 = tmp57 + tmp4
    tmp60 = tmp59 * tmp59
    tmp61 = tmp60 * tmp7
    tmp62 = tmp2 / tmp61
    tmp63 = tmp10 - tmp62
    tmp64 = tmp63 / tmp60
    tmp65 = tmp4 - tmp64
    tmp66 = tmp59 * tmp14
    tmp67 = tmp65 / tmp66
    tmp68 = tmp67 + tmp4
    tmp69 = tmp59 * tmp18
    tmp70 = tmp68 / tmp69
    tmp71 = tmp70 + tmp4
    tmp72 = tmp71 / tmp59
    tmp73 = tmp57 * tmp57
    tmp74 = tmp2 / tmp73
    tmp75 = tmp72 + tmp74
    tmp76 = tmp58 - tmp75
    tmp77 = tmp56 / tmp76
    tmp78 = tmp57 - tmp77
    tl.store(in_out_ptr0 + x0, tmp77, xmask)
    tl.store(out_ptr0 + x0, tmp78, xmask)


@triton.jit
def triton_poi_fused_add_div_log_mean_mul_pow_reciprocal_rsub_sub_5(in_out_ptr0
    , in_out_ptr1, in_ptr0, in_ptr1, in_ptr2, xnumel, XBLOCK: tl.constexpr):
    xnumel = 64
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x2 = xindex
    x0 = xindex % 16
    x1 = xindex // 16
    tmp0 = tl.load(in_out_ptr0 + x2, xmask)
    tmp1 = tl.load(in_ptr0 + x2, xmask)
    tmp4 = tl.load(in_ptr1 + x2, xmask)
    tmp6 = tl.load(in_ptr2 + (x0 + 64 * x1), xmask)
    tmp9 = tl.load(in_ptr2 + (16 + x0 + 64 * x1), xmask)
    tmp12 = tl.load(in_ptr2 + (32 + x0 + 64 * x1), xmask)
    tmp15 = tl.load(in_ptr2 + (48 + x0 + 64 * x1), xmask)
    tmp31 = tl.load(in_out_ptr1 + x2, xmask)
    tmp2 = tmp0 - tmp1
    tmp3 = tl_math.log(tmp2)
    tmp5 = tmp3 - tmp4
    tmp7 = 1e-07
    tmp8 = tmp6 + tmp7
    tmp10 = tmp9 + tmp7
    tmp11 = tmp8 + tmp10
    tmp13 = tmp12 + tmp7
    tmp14 = tmp11 + tmp13
    tmp16 = tmp15 + tmp7
    tmp17 = tmp14 + tmp16
    tmp18 = 4.0
    tmp19 = tmp17 / tmp18
    tmp20 = tl_math.log(tmp19)
    tmp21 = tl_math.log(tmp8)
    tmp22 = tl_math.log(tmp10)
    tmp23 = tmp21 + tmp22
    tmp24 = tl_math.log(tmp13)
    tmp25 = tmp23 + tmp24
    tmp26 = tl_math.log(tmp16)
    tmp27 = tmp25 + tmp26
    tmp28 = tmp27 / tmp18
    tmp29 = tmp20 - tmp28
    tmp30 = tmp5 - tmp29
    tmp32 = tl.full([1], 1, tl.int32)
    tmp33 = tmp32 / tmp31
    tmp34 = 1.0
    tmp35 = tmp31 + tmp34
    tmp36 = tmp35 * tmp35
    tmp37 = 7.0
    tmp38 = tmp36 * tmp37
    tmp39 = tmp32 / tmp38
    tmp40 = 0.2
    tmp41 = tmp40 - tmp39
    tmp42 = tmp41 / tmp36
    tmp43 = tmp34 - tmp42
    tmp44 = 3.0
    tmp45 = tmp35 * tmp44
    tmp46 = tmp43 / tmp45
    tmp47 = tmp46 + tmp34
    tmp48 = 2.0
    tmp49 = tmp35 * tmp48
    tmp50 = tmp47 / tmp49
    tmp51 = tmp50 + tmp34
    tmp52 = tmp51 / tmp35
    tmp53 = tmp31 * tmp31
    tmp54 = tmp32 / tmp53
    tmp55 = tmp52 + tmp54
    tmp56 = tmp33 - tmp55
    tmp57 = tmp30 / tmp56
    tmp58 = tmp31 - tmp57
    tmp59 = tmp32 / tmp58
    tmp60 = tmp59 * tmp19
    tl.store(in_out_ptr1 + x2, tmp60, 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, 4), (16, 4, 1), torch.float32)
        buf1 = buf0
        del buf0
        buf2 = empty_strided_cuda((4, 4, 4), (16, 4, 1), torch.float32)
        get_raw_stream(0)
        triton_poi_fused_add_div_log_mean_mul_pow_rsub_sqrt_sub_0[grid(64)](
            buf1, arg0_1, buf2, 64, XBLOCK=64, num_warps=1, num_stages=1)
        buf3 = torch.ops.aten.digamma.default(buf2)
        buf4 = buf3
        del buf3
        buf5 = buf1
        del buf1
        buf6 = empty_strided_cuda((4, 4, 4), (16, 4, 1), torch.float32)
        triton_poi_fused_add_div_log_mean_mul_pow_reciprocal_rsub_sub_1[grid
            (64)](buf5, buf4, arg0_1, buf2, buf6, 64, XBLOCK=64, num_warps=
            1, num_stages=1)
        buf7 = torch.ops.aten.digamma.default(buf6)
        buf8 = buf7
        del buf7
        buf9 = buf2
        del buf2
        buf10 = buf4
        del buf4
        triton_poi_fused_add_div_log_mean_mul_pow_reciprocal_rsub_sub_2[grid
            (64)](buf9, buf5, buf8, arg0_1, buf6, buf10, 64, XBLOCK=64,
            num_warps=1, num_stages=1)
        del buf5
        buf11 = torch.ops.aten.digamma.default(buf10)
        buf12 = buf11
        del buf11
        buf13 = buf12
        del buf12
        buf14 = buf13
        del buf13
        buf15 = buf8
        del buf8
        triton_poi_fused_add_div_log_mean_mul_pow_reciprocal_rsub_sub_3[grid
            (64)](buf14, buf6, buf9, arg0_1, buf10, buf15, 64, XBLOCK=64,
            num_warps=1, num_stages=1)
        del buf6
        buf16 = torch.ops.aten.digamma.default(buf15)
        buf17 = buf16
        del buf16
        buf18 = buf10
        del buf10
        buf19 = buf9
        del buf9
        triton_poi_fused_add_div_log_mean_mul_pow_reciprocal_rsub_sub_2[grid
            (64)](buf18, buf14, buf17, arg0_1, buf15, buf19, 64, XBLOCK=64,
            num_warps=1, num_stages=1)
        del buf14
        buf20 = torch.ops.aten.digamma.default(buf19)
        buf21 = buf20
        del buf20
        buf22 = buf15
        del buf15
        buf23 = buf22
        del buf22
        buf24 = buf17
        del buf17
        triton_poi_fused_add_div_log_mean_mul_pow_reciprocal_rsub_sub_4[grid
            (64)](buf23, buf18, buf21, arg0_1, buf19, buf24, 64, XBLOCK=64,
            num_warps=1, num_stages=1)
        del buf18
        buf25 = torch.ops.aten.digamma.default(buf24)
        buf26 = buf25
        del buf25
        buf27 = buf19
        del buf19
        buf28 = buf21
        del buf21
        triton_poi_fused_add_div_log_mean_mul_pow_reciprocal_rsub_sub_2[grid
            (64)](buf27, buf23, buf26, arg0_1, buf24, buf28, 64, XBLOCK=64,
            num_warps=1, num_stages=1)
        del buf23
        buf29 = torch.ops.aten.digamma.default(buf28)
        buf30 = buf29
        del buf29
        buf31 = buf24
        del buf24
        buf32 = buf31
        del buf31
        buf33 = buf26
        del buf26
        triton_poi_fused_add_div_log_mean_mul_pow_reciprocal_rsub_sub_4[grid
            (64)](buf32, buf27, buf30, arg0_1, buf28, buf33, 64, XBLOCK=64,
            num_warps=1, num_stages=1)
        del buf27
        buf34 = torch.ops.aten.digamma.default(buf33)
        buf35 = buf34
        del buf34
        buf36 = buf28
        del buf28
        buf37 = buf30
        del buf30
        triton_poi_fused_add_div_log_mean_mul_pow_reciprocal_rsub_sub_2[grid
            (64)](buf36, buf32, buf35, arg0_1, buf33, buf37, 64, XBLOCK=64,
            num_warps=1, num_stages=1)
        del buf32
        buf38 = torch.ops.aten.digamma.default(buf37)
        buf39 = buf38
        del buf38
        buf40 = buf33
        del buf33
        buf41 = buf40
        del buf40
        buf42 = buf35
        del buf35
        triton_poi_fused_add_div_log_mean_mul_pow_reciprocal_rsub_sub_4[grid
            (64)](buf41, buf36, buf39, arg0_1, buf37, buf42, 64, XBLOCK=64,
            num_warps=1, num_stages=1)
        del buf36
        del buf39
        buf43 = torch.ops.aten.digamma.default(buf42)
        buf44 = buf43
        del buf43
        buf45 = buf37
        del buf37
        buf46 = buf42
        del buf42
        triton_poi_fused_add_div_log_mean_mul_pow_reciprocal_rsub_sub_5[grid
            (64)](buf45, buf46, buf41, buf44, arg0_1, 64, XBLOCK=64,
            num_warps=1, num_stages=1)
        del arg0_1
        del buf41
        del buf44
        del buf45
    return buf46,


class GammaScaleMapNew(nn.Module):
    """
        Compute Gamma Scale on a 4D tensor (The hard way). This acts as a standard PyTorch layer. 
        
        Gamma Scale is computed independantly for each batch item at each location x,y
    
        Input should be:
        
        (1) A tensor of size [batch x channels x height x width] 
        (2) A tensor with only positive values. (After a ReLU)
        
        Output is a 3D tensor of size [batch x height x width] 
    """

    def __init__(self, run_relu=False):
        super(GammaScaleMapNew, self).__init__()
        """
            SMOE Scale must take in values > 0. Optionally, we can run a ReLU to do that.
        """
        if run_relu:
            self.relu = nn.ReLU(inplace=False)
        else:
            self.relu = None

    def _trigamma(self, x):
        """
            We need this line since recursion is not good for x < 1.0
            Note that we take + torch.reciprocal(x.pow(2)) at the end because:
        
                trigamma(z) = trigamma(z + 1) + 1/z^2
        
        """
        z = x + 1.0
        zz = z.pow(2)
        a = 0.2 - torch.reciprocal(7.0 * zz)
        b = 1.0 - a / zz
        c = 1.0 + b / (3.0 * z)
        d = 1.0 + c / (2.0 * z)
        e = d / z
        e = e + torch.reciprocal(x.pow(2.0))
        return e

    def _k_update(self, k, s):
        nm = torch.log(k) - torch.digamma(k) - s
        dn = torch.reciprocal(k) - self._trigamma(k)
        k2 = k - nm / dn
        return k2

    def _compute_k_est(self, x, i=10, dim=1):
        """
            Calculate s
        """
        s = torch.log(torch.mean(x, dim=dim)) - torch.mean(torch.log(x),
            dim=dim)
        """
            Get estimate of k to within 1.5%
        
            NOTE: K gets smaller as log variance s increases
        """
        s3 = s - 3.0
        rt = torch.sqrt(s3.pow(2) + 24.0 * s)
        nm = 3.0 - s + rt
        dn = 12.0 * s
        k = nm / dn + 1e-07
        """
            Do i Newton-Raphson steps to get closer than 1.5%
            For i=5 gets us within 4 or 5 decimal places
        """
        for _ in range(i):
            k = self._k_update(k, s)
        return k

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