U
    <c_Z                   @   s7 U d dl mZmZ d dlmZmZmZ d dlZd dl Z d dlZd dlZd dl	Z	d dl
Z
d dlZd dlZd dlZd dlmZmZ d dlmZmZmZmZmZ d dlmZ d dlmZmZmZmZmZm Z m!Z!m"Z"m#Z#m$Z$m%Z%m&Z&m'Z'm(Z( d dl)m*Z*m+Z+m,Z,m-Z-m.Z.m/Z/m0Z0m1Z1m2Z2m3Z3m4Z4m5Z5m6Z6 d d	l7m8Z8m9Z9m:Z:m;Z;m<Z<m=Z= d d
l>m?Z?m@Z@mAZAmBZBmCZCmDZDmEZEmFZFmGZG d dlHmIZJ d dlKZd dlLZd dlMZd dlNmOZP d dlQmRZR d dlSmTZT d dlUmVZVmWZWmXZXmYZYmZZZm[Z[m\Z\m]Z]m^Z^m_Z_m`Z`maZambZbmcZcmdZdmeZemfZfmgZgmhZhmiZimjZjmkZkmlZlmmZmmnZnmoZompZpmqZqmrZrmsZsmtZtmuZumvZvmwZwmxZxmyZymzZzm{Z{m|Z|m}Z}m~Z~mZmZmZmZmZmZmZ d dlmZmZmZmZmZmZ d dlmZmZ d dlmZ d dlmZmZmZmZmZmZmZmZmZmZ d dlmZmZmZ d dlmZ eCr,d dlmZ d dlZd dlZ
dddZdd Zdd Zdd Zdd Zd d! Zd"d# Zd$d% Zd&d' Zd(d) Zd*d+ Zd,d- Zd.d/ Zd0d1 Zd2d3 Zd4d5 Zd6d7 Zd8d9 Zd:d; Zd<d= Zd>d? Zd@dA ZdBdC ZdDdE ZdFdG ZdHdI ZdJdK ZdLdM ZdNdO ZdPdQ ZdRdS ZdTdU ZdVdW ZdXdY ZdZd[ Zd\d] Zd^d_ Zd`da Zdbdc Zddde Zdfdg Zdhdi Zdjdk Zdldm Zdndo Zdpdq Zdrds Zdtdu Zdvdw Zdxdy Zdzd{ Zd|d} Zd~d Zdd Zdd Zdd Zdd Zdd Zdd Zdd Zdd Zdd Zdd Zdd Zdd ZddddZdd Zdd Zdd Zdd Zdd Zdd Zdd Zdd Zdd Zdd Zdd Zdd Zdd Zdd Zdd Zdd Zdd Zdd Zdd Z
dddÄZ
dddńZddǄ Z
dddɄZdd˄ Z dd̈́ Zddτ Zddф Zddӄ ZddՄ Zddׄ Zddل Zddۄ Zdd݄ Z	dd߄ Z
dd Zdd Zdd Zdd Zdd Z
dddZdd Zdd Zdd Zdd Zdd Zdd Zdd Zdd Zdd Zdd Zd d Zdd Zdd Zdd Zdd	 Zd
d Z dd Z!dd Z"dd Z#dd Z$dd Z%dd Z&dd Z'dd Z(dd Z)dd Z*d d! Z+d"d# Z,d$d% Z-d&d' Z.d(d) Z/d*d+ Z0d,d- Z1d.d/ Z2d0d1 Z3d2d3 Z4d4d5 Z5d6d7 Z6d8d9 Z7d:d; Z8d<d= Z9d>d? Z:d@dA Z;dBdC Z<dDdE Z=dFdG Z>G dHdI dIe?Z@G dJdK dKe@ZAG dLdM dMe@ZBG dNdO dOe@ZCdPdQ ZDdRdS ZEdTdU ZFdVdW ZGdXdY ZHdZd[ ZI
d	d]d^ZJd_d` ZKdadb ZLdcdd ZMdedf ZNdgdh ZOdidj ZP
d
dkdlZQdmdn ZRdodp ZSdqdr ZTdsdt ZUdudv ZVdwdx ZWdydz ZXd{d| ZYd}d~ ZZdd Z[dd Z\dd Z]dd Z^dd Z_dd Z`dd Zadd Zbdd Zcdd Zddd Zedd Zfdd Zgdd Zhdd Zidd Zjdd Zkdd Zldd Zmdd Zndd Zodd Zpdd Zqdd Zrdd Zsdd Ztdd Zudd Zvdd Zwdd Zxdd Zydd Zzdd Z{dd Z|dÐdĄ Z}dŐdƄ Z~dǐdȄ Zdɐdʄ Zdːd̄ Zd͐d΄ ZdϐdЄ Zdѐd҄ ZdӐdԄ ZdՐdք Zdאd؄ Zdِdڄ Z
ddېd܄Z
ddݐdބZ
ddߐdZ
dddZ
dddZdd Z
dddZdd Zdd Zdd Zdd Zdd Zdd Zdd Zdd Zdd Z
dddZ
dddZ
ddd Z
dddZdd Zdd Zdd Zd	d
 Zdd ZddddZ
dddZ
dddZ
dddZdd Zdd Zdd Zdd Zdd Zd d! Zd"d# Zd$d% Zd&d' Zd(d) Zd*d+ Zd,d- Zd.d/ Zd0d1 Zd2d3 Zd4d5 Zd6d7 Zd8d9 Zd:d; Z
dd<d=Zeaejejeeee] d>d?d@ZdAdB Z
ddCdDZdEdF Z
ddHdIZdJdK ZddLdMdNZĐdOdP ZŐdQdR ZƐdSdT ZǐdUdV ZȐdWdX ZɐdYdZ Zʐd[d\ Zːd]d^ Z̐d_d` Z͐dadbdcddZΐdedf Zϐdgdh ZАdidj Zѐdkdl ZҐdmdn ZӐdodp ZԐdqdr ZՐdsdt Z֐dudv Zאdwdx Zؐdydz Zِd{d| Zڐd}d~ Zېdd Zܐdd Zݐdd Zސdd Zߐdd Zdd Zdd Zdd Zdd Zdd Zdd Zdd Zdd Zdd Zdd Zdd Zdd ZdddddZdd Zdd Zdd Zdd Zdd Zdd Zdd Zdd Zdd Zdd Zdd Zdd Zdd Zdd Zdd ZddÄ ZdĐdń ZdƐdǄ ZdȐdɄ Z dʐd˄ Zd̐d̈́ Z
ddΐdτZdАdф ZdҐdӄ ZdԐdՄ Zd֐dׄ Z
ddؐdلZdڐdۄ Z	dܐd݄ Z
dސd߄ Zdd Zdd Zdd Z
dddZdd Zdd Zdd Zedededededededededededededede# e# e~dede eje ejded e"eje"ejejdedeejeejejdedeejeejejdedeejeejejdede"eje"ejejdedeejeejdede"eje"ejejdedeejeejejdedeejeejded	eejeejded
e"eje"ejejdede!ejeje!ejejejdGdGdgZeea ed< ede!ejejeje!ejejejdGdede!ejejeje!ejejejdGdede!ejejeje!ejejeje\e
ddddejfdfdede!ejejeje!ejejeje\e
ddddejfdfdgZeea ed< ede# e!ejejdede# e!ejejdgZee ed< ede"ejejeje"ejejdede"ejejeje"ejejdgZee ed< ed e ejeje ejejdgZee ed!< d"d# Zd$d% Zd&d' Zd(d) Z d*d+ Z!d,d- Z"d.d/ Z#
dd1d2Z$d3d4d5d6Z%
dej&e'ej&d8d9d:Z(
d d<d=Z)d>d? Z*
d!ej&ee' dAdBdCZ+ej&ee' dAdDdEZ,
d"ej&e'dFdGdHZ-
d#dJdKZ.dLdM Z/e/
d$dOdPZ0dQdR Z1ej2dSdTdUZ3dVdW Z4
d%dXdYZ5eyddZej6e!ejejej7e!ejejejej7e\e
d[d\d]ej8fd^e\e
d[d\d_ej8fd^e\e
d[d\d`ej8fd^e\e
dadbdcddej9ej8gde\e
dadbdeddej9gde\e
dadbdfej:geEdge\e
dadbdhej9ej8gd^fdGdGdGdGdGdGdGdieyddjej;dke!ejeje!ej7ejejejdGdGdGe3ejdlejdej<dlife\e
dadbdmdej8geAdne\e
dadbdcdej8geAdne\e
dadbdfdej8geAdne\e
dadbdedej8geAdne\e
dadbdeddej9ej8gde\e
dadbdcddej9ej8gde\e
dad\doej8geAdge\e
dad\dpej8geAdge\e
dad\d]ej8geAdge\e
dad\dqej8geAdge\e
dad\d`ej8geAdgfdreydsdtej=due!ejeje!ej7ejejeje3ejdvifddGdGe\e
dadbdmdej8geAdne\e
dadbdcdej8geAdne\e
dadbdcddej9ej8gde\e
dadbdeddej9ej8gde\e
dadbdcdej8geAdne\e
dadbdedej8geAdne\e
dadbdfdej8geAdnfe`dwdx ddydzerdd\d{d|dxe!ejejejej7dGeÐdGdGdGe\e5ej7e6dld d}id~dfe\e
j>ddejfd^e\e
j>ddejfd^e\e
daddej?fd^e\e
dad~dej<ej?fd^fd
eade"ejejdGddGeee\e
j>dde\e
j>dde\e
j>dde\e
j>dde\e
j>dde\e
j>dde\e
j>dde\e
dadde\e
dadde\e
j>dde\e
j>dde\e
j>dde\e
j>ddej@fd^e\e
j>ddfdeadddx dej2jAe ejejdddeee\e
j>dde\e
j>dde\e
j>dde\e
j>dde\e
j>dde\e
j>dde\e
j>dde\e
j>ddfderdee"ejejejdGddGeBdde\e
j>d~ddde\e
j>dde\e
j>ddfderdee"ejejejdGddGeBdde\e
j>d~ddde\e
j>dde\e
j>ddfderdde!ej7ejejejdGdGdGdGderdd\d{ddxde!ejejej7dGdGdGeÐdGe\e5eje6dld d}id~de\e5ej7e6dld d}iddddde\e5ej7e6dd d}iddddde\e5ej7e6dd d}idddddfe\e
dad~dejCfd^e\e
dad~dejCfd^fdeade!eje ejeje ejfe8&rejgng  dGdGdGeFee\e
daddej<ej?fd^fd
eadde!eje ejfe8'sbe@'rlejgng  dGdGdGeFddgeeѐd\d\de\e
daddej<ej?fd^e\e
daddddejfde\e
daddejfd^fdeade!ejeejej<ej?fe8(sLe@(rVejgng  dGdGe֐dead
d&ddxe!eje ejfe9(re8(se@(rejgng  dGdGdGe\e5ej@e6ddd}ej<e6d@dd}iddge\e
daddde9 de\e
j>dde\e
daddfeאd
eade!ejeejej<ej?fe8)se@)rejgng  eejfe9)se@)rejgng ej<ej?f dGdGdGe\e5ej<e6d@dd}idddde\e5ej<e6d@dd}iddddgee\e
daddej<ej?fd^fdč
eade!eje ejfe8*se@*rejgng  dGeՐdGdGe\e
daddej<ej?fd^fdƍeade!eje ejfe8+se@+rejgng  eՐdGdGe\e
daddej<ej?fd^fdȍeade!eje ejfe9+re8+se@+rejgng  dGdGdGdGe\e
daddde9 dfeԐdʍ	eade!eje ejfe8+se@,rejgng  dGdGdGeӐd̍eade!ejejeje!ejeje!ejejfe8,sfe@,rpejgng  dGdGe\e
dadde!ejejejd^feeFd΍	eade!eje!ejejdGdGdGe\e
j>dde\e
j>ddej:ejDejEejFfd^feeeeِdύdЍ	eade eje ejejdGdGe\e
j>ddfeeeeِdύdэeyddejGdkdGdGdGdGdGdGdGe!ejeje!ej7ejejejdGe\e5eje6d@dӐd}idbdde3ejdlige\e
dadbdcddej9ej8gde\e
dadbdeddej9ej8gde\e
dadbdcdej8geAdne\e
dadbdedej8geAdne\e
dԡdՐdփfd׍eydؐdejHe!ejeje!ej7ejejeje3ejdvifddGdGdGdGdGdGdGe\e
dadbdcddej9ej8gde\e
dadbdeddej9ej8gde\e
dadbdfddej9ej8gde\e
dadbdmddej9ej8gde\e
dadbdcdej8geAdne\e
dadbdedej8geAdne\e
dԡdՐdփfdڍeyddejIe!ejeje!ej7ejejejdGdGdGdGdGdGdGdGe3ejdlife\e
dadbdfe@dd܍e\e
dadbdce@dej?gdݍe\e
dadbdcddej9ej8gde\e
dadbdeddej9ej8gde\e
dadbdfddej9ej8gde\e
dadbdcdej9ej8geAdne\e
dadbdedej9ej8geAdne\e
dԡdՐdփfdލerdߐde"ejeje"ejejejdGdGdGde\e
j>ddfd	eyddejJdke!ejeje!ej7ejejeje3ejdlifddGdGdGdGdGdGdGe\e
dadbdfddej9ej8gde\e
dadbdcddej9ej8gde\e
dadbdeddej9ej8gde\e
dadbdcdej9ej8geAdne\e
dadbdedej9geAdne\e
dԡdՐdփe\e
dadbdce@dej?gdݍfdeade ejejejKdde	e\e
dadde\e
dadde\e
dadfddeadejLe!ejejejddGdGdedeadejMejNOejPdk5r.ejMndeej@fdddddee\e
j>dde\e
dadde\e
dadde\e
dadde\e
daddfdeadejQe!ejejejeeddGdGde\e
j>dde\e
j>ddej@gd^fd
eade!ejejejej7ddGdGde\e
j>dde\e
j>ddej@gd^fedeydejRe$ejejSdderdejTe( e( ejUejVddGeBd de\e
dad~dfd
erdejWe( e( ejXejYddGeBd de\e
dad~dfd
eadejZe!ejejejdGdGddedeadej[e!ejejejddGdGdee\e
j>dde\e
j>dde\e
j>dde\e
j>ddej@fd^fd	eade dddedeyd ej\e"eje"ejejdGdGe\e
j>dde]dd e( D d^e\e
j>ddejEejFfe@ dgfdGdGdGdGdGdGdead e eee-e0gdeade e dGdGdGdGeee-e0ge\e
j>ddfdeadej^e eddGdGddx e-e0gd	eade!ejejejej7eedGdGdd	ead
eje!ejejejej7eҐeӐdGdGde\e
j>ddfd	eadddx e!ejejejej7eҐeӐdGdGdgdGde\e
j>ddfdeadddx e!ejejejeԐeՐdGdGde\e
j>dde\e
j>ddej_fd^e\e
j>dde\e
j>ddfd	eade ddeee\e
dadddej@gde\e
dadddej@gde\e
dadddej@gdfe-e0e;gdeaddee"eje"ejejeeeedύdGdGdGe\e
j>ddejfd^e\e
j>ddejfd^fdeydej`e!ejejej7ddGdGdeydejae!ejejejej7dGdGdGdddeyddejae!ejejejej7dGdGdGdGdGdGdGe\e
daddej@fd^e\e
d dՐd!fd"ead#e!ejejejedGdGdd$ead%e!ejejejej7edGdGdd$ead&e dGddGedd'ead(eejddGdGdee\e
j>dde\e
daddejfd^e\e
daddejfd^fd)erd*eejdGdGde\e
j>d~de\e
daddddfd+erd,e"ejejejdGdGdGdGd-ead.e!eje!ejfe8>se@>rejgng  edGdGde\e
daddej<ej?fd^fdd/	eydejbe!ejeje!ej7ejejejdGddGdGe3ejdlife\e
dadbdeej9ej8fddeAd0e\e
dadbdeej8fdd1e\e
dadbdcej9ej8geAdge\e
dadbdcddej9ej8geBdne\e
j>dbdedej7feAdnfd2
eydeejce!ejeje!ej7ejejejdGdGdGe\e
dadbdeddej:gde\e
dadbdeej8gd^e\e
dadbdcej9ej8geAdge\e
dadbdeej9ej8geAdge\e
dadbdcddej9ej8geBdne\e
dadbdeddej9ej8geBdne\e
j>dbdedej7feAdnfd3ead4e!eje!ejfe8Ase@Arejgng  e!ejfe8Bse@Br$ejgng  eeddGdGe\e
daddej<ej?fd^e\e
j>d\doe\e
j>d\d5e\e
j>d\dqe\e
d6d\d7e\e
j>dde\e
daddfd8
ead9e!eje!ejedGdGdGd:ead;e!eje!ejejdGdGe\e
j>ddfed<ead=e!eje!ejejdGdGe\e
j>dde\e
j>ddejfddd1fedd>ead?e"ejeje"ejejejeedd@dGdGdAeFdBeadCe"ejeje"ejejejeedd@dGdGdAeFdBeydDejde3ejdEejdEife"ejejejdGdGe\e
dadbdeejgd^fdFeadGejed\d7ejfejffdHdxe!ejejejdGdGdGe*ddAdI
erddJdKe!ejejeje!ejejejej7dGdGdGdGdGdGeBdGddLerddJdMe"ejejeeqeBd
dNdOdGdGdGdGdGdGeBdGde\e
j>ddPfdQerddJdRe"ejejeeqeBddNdOdGdGdGdGdGdGeBdGde\e
j>ddPfdQerdSe!ejejeje!ejejejej7dGdGdGdGeBdGddTeadUe!ejejejdVdx edddAdWeydeejge!ejeje!ejejejej7e\e
dadbdcejgd^e\e
dadbdeejej8gd^e\e
dadbdfejgd^e\e
dadbdcddej9ej8gde\e
dadbdeddej9ej8gdfdGdGdGdXeadYdZdx e!ejejejedGdGdGde\e
j>ddfd[	ead\d]dx e!ejejejdGdGede\e
j>ddfd^ead_e!ejeje!ej7ejejejdGdGeed`eadae!ejejejej7ddGdGdGeeedb	eadcdddee!ejejejej7ddGdGeeedf
eadge"ejejejddGdGedherdiejhe!ejejejej7dGde
dAdjerdkejie"ejejejdGdGde\e
dad~dfdlerdmejje"ejejejdGdGde\e
dad~dfdlerdnejke"ejeje"ejejdGdGdGddodGie\e
dad~dpejfd^e\e
dad~dqejfd^e\e
dad~dejfd^e\e
dad~dejCfd^fdr
erdsejle"ejeje"ejejdGdGdGdejmejndGdodGie\e
dad~dpejfd^e\e
dad~dqejfd^e\e
dad~dejfd^e\e
dad~dejCfd^e\e
daddejfd^e\e
dadtduejofdfdveyddwdx eejejeejejdGdGdGe\e
dadbdcejejej@ejpfd^e\e
j>ddejej@ejpfd^fd3eadxe1e\e
dyddge edGdGdGddddeFdzead{e edGdGdGdddde\e
d|ddfe1e\e
j>d\doe\e
j>d}d~fdeydejqe"eje"ejejdGdGe\e
j>dde]dd e( D d^e\e
j>ddejEejFfe@ dgfdGdGdGdGdGdGdeadejre!ejejejedGdGddeadejse!ejejejeedGdGddeadejte!ejejejeedGdGddeade dGee2e= dk de4ge\e
dadde\e
dadde\e
dadde\e
dadde\e
dadde\e
dad}de\e
dad}d~e\e
dadde\e
dadde\e
dadde\e
dadde\e
dadde\e
dad\d7e\e
dad\doe\e
dad\d5e\e
dad\dqfdeydeCQr(eejujvndde3ejdejdife"ejeje"ejejeje dGdGee\e
dadbdeej:fd^fderdee"ejejdeBdGddGe\e
dadde\e
dad~ejfd^e\e
dad~dej:fd^e\e
dad~dejfd^fdeydejwejweejejeejg dGdGe\e
dadbde\e
dadbdpe\e
dadbde\e
dadbde\e
dadbde\e
dadbdhe\e
dadbdfeAde\e
dadbdeeAde\e
dadbdceAdf	d	eydejxdde"ejeje"ejejeje3ejdife\e
dԡdՐdփfdGdGdGdGdGdGdGdGderdejyde"ejejejdGddAdeade ee.e0gde\e
j>dde\e
j>ddfderdejzde"ejejejdGddAdeydej{e'ej7ddGdGde\e
j>dbdhfdeade ej:ejDejEejFejejddGdGde\e
j>dde\e
daddej@ej<fd^e\e
dadde\e
dadfde1e"d
eade% e"ejdedeade"eje"ejdGdGeed`erdej|de"ejejejdGddAdeade!ejejdGdGdeee\e
j>dde\e
j>dde\e
j>dde\e
j>dde\e
j>dde\e
j>ddej@fd^e\e
j>dde\e
j>ddejDejEejFfddd1e\e
j>ddejDejEejFfddd1e\e
j>ddejCej:ejDejEejFfdd1e\e
j>ddejCej:ejDejEejFfdd1e\e
daddej9fdd1fdeade!eje!ejejdGdGdeee\e
j>dde\e
j>dde\e
j>dde\e
j>dde\e
j>dde\e
j>ddej@fd^e\e
j>dde\e
j>ddejDejEejFfdd1e\e
j>ddejDejEejFfdd1e\e
daddej9fdd1f
d	eydej}de!ejeje!ejejejej7e ejejej7dGdGdGe3ejdvife\e
dadbdcddej9ej8geAdnfe`ddx d\dydeydej~de3ejdvife!ejejdGe!ejejejdGdGe\e
dadbdcddej9ej8geAdnfe`ddx d\dydeydejde!ejeje!ejejejdGdGdGe3ejdife\e
dadbdcej9ej8gd^fe`ddx d\dyderde!ejejejdGdGdGddGdGde\e
j>dde\e
j>dde\e
j>dde\e
j>ddfe\e5ej<e6d@d@d}iddddgdeadeejeejeejdGdG
d'ddxdeadeejeejeejdGdG
d(ddxdeydeje3ejdEejdife!ejejejde\e
dadbde!ejejd^e\e
dadde!ejejd^fderdejde"ejejejdGddAdeadeje dGdGdGe0fedōeadeje dGdGdGdee.e0ge\e
j>dde\e
j>dde\e
j>ddfdǍ
eadeje dGddGee\e
dadddej@gde\e
dadddej@gde\e
dadddej@gde\e
dɡddʃfe0e.gdˍ	eade!ejejejej7eedGdGddd͍eade!ejejejedGdGdddAdύeade!ejejejdGdGee$dэeade eje ejfe8_s<e@_rFejgng  dӐedddGdGde\e
daddfddԍeadՐde!eje ejfe9_re8_se@_rejgng  dGdGdGdGdGdeedd׍e\e
daddde9 de\e5ej@e6dd d}iddde@de\e5ej@e6dd d}iddde@de\e5ej@e6d d@d}idddddge\e
j>dde\e
d١ddddejofde\e
dadtduejofde\e
daddddejofdfdڍeadېde"ejejeje`dGdAdGdݍeadېde"ejejejddGdGeadAdߍeade"eje"ejddGdGeeddddeade"eje"ejddGdGeeddddeade ejejeddGddGdeade ejejeddGddGdeaddeje!ejejejeedde\e
dadde\e
dadde\e
daddgddGdGdd
eadde!ejejejeedde\e
j>ddgdGdg dGdGddeadde"ejejeje`dGdGdAdeadde"ejejejddGdGeadAdߍeade eddGdGe\e
daddfddeade eddGdGe\e
daddfdderdېdde"ejejejdGdGdGejde\e
j>dde\e
j>d~dddfd
erde"ejejejdGdGejde\e
j>d~dddfderddde"ejejejdGdGdGejde\e
j>dde\e
j>d~dddfd
erde"ejejejdGdGejde\e
j>d~dddfderdeje!ejejejddGdderdeje!ejejejddGdderdeje!ejejejddGddAderd eje$ejejejddGe\e
j>d~dddfderdeje$ejejejddGe\e
j>d~dddfderdeje$ejejejddGe\e
j>d~dddfderdddx e"ejejejdde\e
j>d~de\e
dad~dfderdeje$ ddderd	eje$ dde\e
j>d~dej:fd^fderd
eje!ejejejeeddde\e
j>ddej?fd^e\e
j>d~de\e
dad~dfd	eaddddeejeejejedGdGdGdGdGdeadddde!ejejejeedGddGdGdGdGd
eaddeejeejejedddGdGdd
eaddde!ejejeedGdddGdGdd	eadeejeejejeddGdGe\e5ej@e6d@dӐd}idddddfe\e
j>ddddfd	eade eje ejejeHdGdGdead
d)ddxe"eje"ejejeje+fde)e(e\e
j>dddddfd	ead
d*ddxe!ejejejej7ddGdGdee\e
j>dde\e
d dde\e
d dde\e
d dde\e
d dde\e
d!d\fd"	ead#
d+d$dxe!ejejejej7ddGdGdee\e
d%dde\e
d&dde\e
d'dde\e
d(dde\e
d)d}d~e\e
d*dde\e
d+dde\e
j>d\doe\e
j>d\d5e\e
d,d\d7e\e
d-ddfd"	ead.d.e,eejeejejddGdGeUeVe\e
dad\dqe\e
j>d\d5e\e
j>dde\e
daddfd/ead0d0eejeejejdGdGdGee\e
j>ddddde\e
j>ddddde\e
j>dddde\e
j>d\dqe\e
j>dde\e
dad1d2e\e
dad1d3fd4	ead5d6eejeejejddGdGed7ead8eejeejejddGdGeFe9d9ead:eejeejeje\e
j>ddfddGdGeFe:d;	ead<eejeejeje\e
j>ddfdGddGdGeFe;d=
ead>eejeejejddGdGdeFe<d?	ead@eejeejeje\e
j>ddfddGdGdeFe=dA
eadBe eejeje\e
j>ddfddGdGdeFe>dA
eadCdDdGddGdGeejFejeejejeFelejdEeadFdGdGdGdGeejFeejejeFeneke\e
j>dddddfdHeadIdJdGdGdGdeejeejejeFee\e
daddej@fd^fdKeydLdMdNdx dGe"eje"ejejeddGdGdO
eadPeeJejjjdQdRdSe ejFe ejej7fe8qsFe@qrPejgng  eKdGdGdGeFe\e5ej@e6dؐdTd}idddde\e5ej7e6dvdvd}iddfe\e
daddej<fd^e\e
j>ddej<ej?fd^e\e
j>ddej_fd^e\e
j>ddejFfd^fddUeadVdWdXeejFeejfe8rs~e@rrejgng  eLdGdGdGeFe\e5ej@e6dؐdTd}iddddge\e
daddfddYeadZd[d\eejFeejfe8ss"e@sr,ejgng  eMdGdGdGdGeFe\e5ej@e6dؐdTd}idddde\e5ej@e6d]d]d}id}ddde\e5ej@e6d^dTd}idddde\e5ej@e6dؐd_d}id}d`de<dge\e
dadde\e
dadde\e
dbddfddceadddedfe ejFeje ejej7fe8tse@trejgng  eNeOdGdGdGeFe\e5ej7e6dldld}idde\e5ej7e6dӐdӐd}iddfe\e
dadde\e
j>dgdhej<ej?fd^e\e
j>ddej<ej?fd^fdGddieadjdkdle ejFeje ejej7fe8use@urejgng  eeQePeFdGdGdGdGe\e5ej7e6dmdvd}idde\e5ej7e6dldld}iddfe\e
dndde\e
j>dgdhej<ej?fd^e\e
j>ddej<ej?fd^fdGddoeadpdqdre-eejeejejddGdGe\e
j>ddej@fd^geRdGdseadteejeejejddGdGe\e
j>ddej@fd^e\e
j>d}d`e@dgeSdGdu	eadvdwdxdye+eejeejejddGdGdGe\e5ej@e6d@dӐd}iddgeTdGdzead{eejFejeejejddGdGe\e
j>ddej@fd^e\e5eje6dldld}iddgeWd|ead}dGdGe!ejejejede\e
j>ddejfd^e\e
j>ddejfd^fd~eaddd}dGdGdGe!ejejejeeddbdd	eadddGdGe e ejejeeddbe\e
daddej@fd^feFdd
eadddGdGe e ejeeddbe\e
daddej@fd^feFdd
eadde!ejejejeeddbdGdGdde\e
daddej@fd^e\e
d-ddfdd
eaddddGdGeXeejeejejdGdGdGddgdeadde ejeje ejejedGdGdGde\e
dddfd
eaddddGdGdGeejCejeejejCee\de\e
j>ddfddeaddddGdGdGeejeejee\de\e
j>ddfddeaddddGdGdGeejeejeFee\de\e
j>ddfddeaddddGdGdGeejeejee\deFe\e
j>ddfddeaddddGdGdGeejeejeFee\de\e
j>ddfddeaddddGdGdGe eejejee\deFe\e
j>ddfddeaddGdGdGeejeejeFee]de\e
j>ddfdd
eadeejeejejddGeeddedeaddGdGdGeejCejeejejCeFee]de\e
j>ddfdd
eade"eje"ejejdeeedGdGd	eade eejejddeސdeade eejejddedeaddddefeejeejej
d,ddxdGdGdGddGdGdgdeaddeejeejejeېdGe\e5ej@e6dؐdؐd}idde\e5eje6dldld}iddfe\e
daddddfdeadddGdGdGeejFejeejejemeie\e
j>ddddfd
eaddGddGdGddx de eejdege\e
j>dde\e
j>ddfdeaddGddGdGddx de eejdehe\e
j>dde\e
j>ddfdeadddGddGdGddeejeejeje\e
dddejfd^e\e
daddfeEeDdeadddGdddGdGddGeejeejejeFeDdeadddGddGdGdde eejejeFeGeDdeadddGdGdGdde eejee\e
dad\doe\e
dad\d5e\e
dad\dqe\e
j>d}d`dddfdÍeaddĐddGdGdGdde eejedōeadƐdǐdGdGdGdde eejee\e
j>d\dqe\e
dad\d5e\e
dad\doe\e
dad}d`fdÍeadƐdĐdǐdGdGdGddde eejedȍeadɐdʐdGdGdGdde eejee\e
j>d\dqe\e
dad\d5e\e
dad\doe\e
j>d}d`fdˍeadɐdĐdʐdGdGdGdde eejedōead̐ddGeYe!eje ejeje ejfe8sZe@rdejgng  e ejfe8se@rejgng  eFdGdGddGe\e
j>dde\e5eje6dldld}iddfd͍eadΐddGeZe"ejeejfe9re8se@r$ejgng  e\e
daddde9 de\e
daddejfd^fdGdGdGddύeadАdѐdGe[eejeejejeejejeejejdGdGddҍeydӐdԐ
d-dՐdxeejeejejdGdGdGddGdd֐dx 
d.dאdxe\e5eje6dӐdd}eje6dӐdd}idbddgd؍eydِdڐdېdx eejeejdGdGdGddGdeeeee\e
j>d\d5e\e
j>ddgd܍eydݐ
d/dސdxeejeejejdGdGdGddGddߐdx 
d0ddxe\e5eje6dӐdd}eje6dӐdd}idbddgdeyddddx ddx eejeejeje*dGdGdddx eeseBddNdGdde#e\e5eje6dӐdd}eje6dӐdd}idbddfe\e
j>dde\e
j>dde\e
j>d\d`e\e
ddbde\e
ddbdpe\e
ddbde\e
ddbdfdeyd
d1ddxeejeejejdGdGdGddGdddx e\e5eje6dldd}eje6dldd}idbddgdeadddx eeejeejejdddGde\e5ej@e6ddd}idddge\e
dadddde\e
dadde\e
dadddejfde\e
ddddejfde\e
dadddejfde\e
dadd2ddde\e
dad1d2ddde\e
dadde\e
dadde\e
dddf
deydd
d2ddxeejeejejdGdGdGdGdddx e\e5eje6dӐdӐd}eje6dؐdؐd}idbddge\e
dadbdmej9fddd1fd gdeydd*
d3ddxe e& ddddddx e\e5eje6dӐdӐd}eje6dؐdؐd}idbddge\e
dadbdmej9fddd1e\e
j>dde\e
dadbdeej<ej8fd^e\e
dadbdfej<fd^e\e
dadbdcej<fd^fdeydde!eejeejejdGdddGdeejjjdGde\e5eje6dؐdӐd}idbddge\e
j>d\d_e\e
j>dbdcde@dgdeyd	d
de eejeejejdGddGdGe\e3ejdlejdidbdfe\e3ejdlejdidbdee\e3ejdlejdidbdcge\e
j>dddddfdeyddddx e eejejdGdGdGddGdeejjjdGde\e5eje6dldӐd}idbddgdeydddx e!ejeje!ejejejdGdGdGddGde\e5eje6dӐd^d}idbge\e
dadbdfej'ej:fd^e\e
j>dbdeej<fd^fdeydddx e!eje!ejejdGdGdGddGde\e
dadbdmddej9ej8gde\e5eje6dldd}idbe\e5eje6dldld}iddge\e
j>dbdfej<ej?feBdge\e
ddbdeej<ej?feBdge\e
ddbdcej<ej?fddeBp.eAd0fdeydddx e"eje"ejejddx dGdGddGdddx e5deadee!eje!ejejddGdGdeadeedGd e!eje!ejejddGdGe\e
j>dde\e
j>ddfd!erd"eejddd#ead$d%dx e!ejejejdGdGdeoe\e
daddddde\e
dadde\e
dadde\e
daddfd&ead'e"eje"ejejdGdGdGepd(ead)d*eejeejejddGdGdGee\e
j>dde\e
daddddejfde\e
j>d}d`de@de\e5eje6dldld}iddfd+
ead)d,d*e& eejejddGdGe*e,ge\e5eje6dldld}iddfed-ead.d/ee eejejdddGdGdGe\e
dade\e
dadde\e5ej@e6dӐdӐd}iddfe\e
j>ddfd0erd1eejejd2e dde\e
j>ddfd3erd4eejejd5e dde\e
j>ddfd6eyd7d8d9eejeejejdGdGdeed:
eyd;d<d=eejeejejdGedGdGd>gd?
eyd@dAdBeej:ejDejEejFeje% eej:ejDejEejFejejeejdGeddGdGdCgdDeadEdFdGeCr|e%nde_dGdGe^eejeejejdGdGdGdHge\e
daddfdIeydJdKe"eje e"ejejeejdGddGdGdLgdMeadNe!eje ejfe8sLe@rVejgng  dGdGdGee\e
daddej<ej?fd^fdOeadPeje"ejejejdGdGe\e
j>ddfeudQedRdue e\e
j>dbdce\e
dadbdeejej:fd^e\e
dadbdfej:fd^f dSdx dTedUdVe e\e
j>dbdce\e
dadbdeejej:fd^e\e
dadbdfej:fd^f dWdx dTedXdYe e\e
j>dbdce\e
dadbdeejej:fd^e\e
dadbdfej:fd^f dZdx dTerd[ejd\e!ejejejdGddAdead]e!ejejejej7ddGdGe}e\e
j>d}de\e
j>d}d~e\e
j>d}d`e\e
j>dde\e
j>ddfd^ead_e!ejejejej7dGddde|e\e
j>dde\e
j>dde\e
j>dde\e
ddddde\e
dddddfd`eyddaeje!ejejej7edGdGdGdGdGdGdGdGdbeadceje ejejdGddGddGerdd	eadeejdfe!ejejejdGdGdeqdgeadheje deee/e0ge\e
j>dde\e
j>ddfdieadjeje!ejejejej7ddGg g dGdGdGdGeedkerdle!ejeje!ejejej7eje eje ejejej7dGddGdGdGdGeBd deBd de\e5ej<e6dؐdd}id~de\e5ej<e6dؐdd}ej?e6dؐdd}id~dmfe\e
j>d~dej:ejDejEejFgd^e\e
j>d~dnejDejEejFgd^e\e
dad~dejfd^e\e
dad~dqejfd^e\e
dad~dejfd^e\e
dad~dejej<ej?fd^e\e
dad~dnejej<ej?fd^e\e
dad~dejej<ej?fd^fdoerdpeje!ejejejdGdGdGdGdGeBd deBd de\e5ej<e6dؐdd}ej?e6dؐdd}id~dmfe\e
dad~de\e
dadde\e
dad~dej<ej?gd^e\e
dad~dnej<ej?gd^e\e
dad~dej<ej?gd^fdqeadreje edGdGde/e0gdseydteje3ejdEejdEife"ejejeje\e
dadbdfejgd^e\e
dadbdeejgd^e\e
dadbdcejgd^fdGdGdueydveje!ejejejej7ddGdGde\e
j>dbdhfdeadweje!ejejejej7eddGdGee+fdx	eadye!ejejejedGddGdGedzeydejd{e"eje"ejejdGdGe\e
j>dde]d|d e( D d^e\e
j>ddejEejFfe@ dge\e
daddejfd^fdGdGdGdGdGdGd}eydejd~d{eejeejejddx eesdd iddGdGdddeydejdd{eejeejejddx eesddide\e
dade\e
dad\e\e
dade\e
dadfdGdGdddeydejdd{eejeejejddx eesddide\e
dade\e
dad\e\e
dade\e
dadfdGdGdddeydeje!ejeje!ej7ejejejdGddGdGdGdGdGdGdGe\e
dadbdeej8fdd1e\e
dadbdcej9ej8fddeAd0e\e
dadbdeej9ej8fddeAd0e\e
dԡdՐdփfe3ejdlifdeyde de!ejeje!ejejejddGdGe3ejdlejdlife\e
dadbdfej9gd^fd
eydeeje!ejeje!ej7ejejejdGdGdGdGdGdGdGdGe3ejdlife\e
dadbdcddej9ej8geBp>eAdne\e
dadbdeddej9ej8geBpteAdne\e
dadbdeej8fd^e\e
dadbdeddej:gde\e
dԡdՐdփfdeydee"ejejeje"ejejejdGdGdGdGdGdGdGe\e
dadbdcejejej@ejpgd^fdeydee!ejejejej7e ejeje ejejej7dGdGdGdGdGdGdGe\e
dadbdcejejej@ejpgd^e\e
dadbdcddej<ej?gde\e
dadbdeddej<gde\e
dԡdՐdփfdeade!ejejejej7eeddLdGdGdg g dGd	eaddde!ejejejeeĐdGdLdGdGddeade!ejejejej7eg g ddGdGdGd	erdej2je!ejejejde\e
j>dde\e
j>ddfdGdGdGdgd	erdej2je!ejejejdGdodGidGde\e
j>d~de\e
j>dde\e
j>ddfdGdGdGddgderdej2je!ejejejde\e
j>dde\e
j>ddfdGdGdGdgd	erdej2je$ejdddGe\e
j>ddfderdej2je$ejdddGe\e
j>ddfderdej2je$ejdddGe\e
j>ddfdeadej2je!eje ejfe9re8se@rejgng  dGeedGd׍dGddGdGde\e
daddde9 de\e5ej<e6d@dd}idde\e5ej@e6d@dd}iddfe\e
j>dde\e
j>dde\e
d١ddddejofde\e
dadtduejofde\e
daddddejofdfderdej2jeejeje"ejejdGddGdGdGe\e
j>dde\e
j>ddfdGdgderdej2je!ejeje!eje!ejejddGdGe\e
j>dde\e
j>dde\e
dad\fdGdgderdej2je!ejejdGdGddGe\e
j>dde\e
j>ddfdGdgd
erde!ejejdGdGdddeÐdeadde!ejejejej7eߐdGdGdGddeade"ejejejedGdGdd$eadejjjj2e!ejejejej7edGdGdGdddd
eade"ejejejedGdGdGddeydeje"ejejejdGdGdGdGdGdd	eydeje!ejeje!ej7ejejejdGdGdGdGdGdGdGdGe\e
dadbdcddejgde\e
dadbdeddejgde\e
dadbdfddejgde\e
dadbdcddej9ej8geBpeAdne\e
dadbdeddej9ej8geBpeAdne\e
dadbdedejpge@dne\e
dԡdՐdփfe`ddx ejdydeydejdde3ejdlife!ejeje!ej7ejejejdGdGdGdGdGdGdGdGdGe\e
dadbdcddej9ej8geBpeAdne\e
dadbdeddej9ej8geBp eAdne\e
j>dde\e
dԡdՐdփfe`ddx d dydeadeje!ejejeje!ejejejddGdGe\e
j>d}de\e
j>d}d~e\e
j>d}d`fed	eade!ejejejejddGdGdeedÍeade!ejejejejddGdGdeedÍeade!ejejejejddGdGdeedÍeadeje eddGdGdǐdx e-e0ge\e
j>dde\e
j>d\d7e d^e\e
dadddej@gde\e
dadddej@gde\e
dadddej@gdfdȍ
eyd
deje"eje"ejejdGdGdGe\e
j>dde]dʐd e( D d^e\e
j>ddejEejFfe@ dgfdGdGdGdGdGdˍeyd̐deeje"ejejeje"ejejejdGdGd΍eyddeeje"ejeje"ejejejdGdGdGdGdGdGdGdGe\e
dadbdcddejgde\e
dadbdeddejgde\e
dadbdfddejgde\e
dԡdՐdփfdЍeydeje"ejejeje"ejejejdGdGdGe\e
dԡdՐdփfdҐdx dӍ	eydeejăe!ejejejdGdGdGe\e
dadbdcej9ej8gd^e\e
dadbdcejgd^e\e
dadbdeejgd^e\e
dadbdfejgd^fdԍeydՐd֐dx de!ejeje!ej7ejejeje3ejdvifdGdGdGe\e
dadbdcej9ej8fd^e\e
j>dbdeej7fd^fd׍
eydejŐdGde!ejeje!ej7ejejejdGdGdGdGdGdGdGe3ejdie\e5ej7e6dld d}idbdefe\e
dadbdeddej9ej8feBdne\e
dadbdeejfd^e\e
dԡdՐdփfdٍeydeje!ejejeje3ej<dejdifdGdGe\e
dadbdeej9ej8gd^e\e
dadbdcdej9ej8gde\e
dadbdeejgd^fd܍eade eje ejeje ejejeǐdGdGdGdލeydeje!ejejeje!ej7eje3ejdlejdlife ejeje ej7dGdGdGdGdGdGdGe\e
j>dbdfejejej@ejpfd^fdeydeje!ejejejej7dddeydeje!ejejejej7ddGdGdGdGdGdd
eydeje"ejejejdGdGdGdGdGdd	eydeje"ejejejdGdGdGdGdGdd	eydeje!ejejejej7dddeydeje!ejejejddGdGdGdGdGdd
eadddx e!eje ejfe8se@rejgng  e ejfe:re8se@rejgng  ddGdGdee\e
j>dde\e
daddfdeadeje edGdGdGddde.e0e;ge\e
daddej<ej?fd^e\e
dadddej@gde\e
dadddej@gde\e
dadddej@gdfdeadddx e dGdddddGdGee/e0e;e\e5ej@e6dӐdӐd}iddddge\e
j>dde\e
j>dde\e
j>ddfdeadddx e dGdddddGdGee/e0e;e\e5ej@e6dӐdӐd}iddddge\e
j>dde\e
j>dde\e
j>ddfderde dGeBd dde\e
dad~de\e
j>d\d7fdeydddx deCrende"ejeje"ejejdGdGee\e
j>ddfddx deydddx deCrende"ejeje"ejejdGdGee\e
dad\e\e
dade\e
dade\e
dade\e
dadbdce\e
dadbdefddx e`ddx d\dydeydd dx deCrende"ejeje"ejejdGdGee\e
dad\e\e
dade\e
dade\e
dade\e
dadbdce\e
dadbdee@de\e
dadbdfe@dfddx e`ddx d\dydeydddx deCr"ende"ejeje"ejejdGdGee\e
dad\e\e
dade\e
dade\e
dade\e
dadbdcfddx e`ddx d\dydeydddx d	eCrende3ejd
ej@d
ife"ejeje"ejejdGdGee\e
dad\e\e
dade\e
dade\e
dade\e
dadbdce\e
dadbdee@de\e
dadbdfe@dfddx e`ddx d\dydeadeje!ejejejej7ddGdGdeϐdeade!ejejejej7eאeؐeddGdGdeadddx e!ejejejej7eeאdGdeeؐdGdeeِdGdddGdGe\e
j>ddfd
eadddx e!ejejejejddGdGdGeאeؐee\e
j>ddfdeadddx e!ejejejejddGdGeeאdGdeeؐdGdeeِdGde\e
j>ddfd
eade!ejejejejdGddGdGdee\e
j>dde\e
j>ddej@gd^fd	eade!ejejejejdGddGdGde\e
j>dde\e
j>ddej@gd^feڐd	eade!ejejejejdGddGdGde\e
j>dde\e
j>ddej@gd^feڐd	ead e!ejejejej7e5ddGdGdeܐeݐd!	ead"eje!ejejejej7ddGdGeސd#ead$e!ejejejej7dGdGde\e
j>ddfeېd%ead&eje dddGdGeFdee.e0ge\e
dadddej@gde\e
dadddej@gdfd'ead(e!ejejeje!ejejejeeFdGdGed)ead*e!ejejejddGdGdesd+ead,e!ejejejdGdGdGddAeseFd-	ead.e!ejejejej7e ejejej7ese%dGdGdGeFd/	ead0e!ejejejej7dGdGdGdese\e
j>ddejfd^e\e
j>ddejfd^feFd1	ead2e"ejejdGe\e
j>d}d~fetd3ead4e!ejejejej7dGddGdGddej2je\e
j>dde\e
daddddfe2d5ead6e!ejejejej7ddGdGdGdde3e\e
j>ddfd7
ead8e"ejejeje"ejeje4dGdGdAdȍead9e"ejeje"ejeje7dde\e
j>dde\e
j>dde\e
j>ddejej@ejpfe@ dgfd:ead;e"ejeje"ejeje8dde\e
j>dde\e
j>dde\e
j>ddejej@ejpfe@ dgfd:ead<e!ejejejddGdGddevd=ead>e!ejejejddGdGewed?ead@e!ejejejdGdGeːedэeydAdBdx e!ejejejej7dee\e
j>d\e\e
j>dde\e
j>dde\e
dadde\e
daddfdCeydDdEdx e!ejejejej7dede\e
j>dde\e
j>ddfdFeydGdHdx e!ejejejdede\e
j>dde\e
j>ddfdFeydIdJdx e!ejejejej7dede\e
j>dde\e
j>ddfdFeydKdLdx e!ejejejej7dedGdGe\e
j>dde\e
j>ddfdMeydNdOdx e!ejejejej7dee\e
j>d\e\e
j>dde\e
j>ddfdCeydPdQdx e!ejejejdedGe\e
j>d\e\e
j>dde\e
j>ddfdFeydRdSdx e!ejejejdede\e
j>dde\e
j>ddfdFeydTdUdx e!ejejejej7dede\e
j>dde\e
j>ddfdFeydVdWdx e!ejejejdede\e
j>dde\e
j>ddfdFeydXdYdx e!ejejejej7dee\e
j>d\e\e
j>dde\e
j>ddddde\e
j>dde\e
j>ddddde\e
j>ddddde\e
j>ddfdCeadZe!ejejejej7deede\e
dadde\e
dadde\e
dadde\e
dadde\e
dadde\e
dadde\e
dadde\e
dade\e
dadde\e
dadd[e\e
d\d}dfd]ead^e!ejejejej7deddAd_ead`e!ejejejej7deddAd_eadae ejejejdbdx dGede\e
dcdde\e
dcdddee\e
dcdddfe\e
j>dde\e
j>ddddde\e
j>dde\e
j>dde\e
j>dde\e
j>dde\e
j>dde\e
j>dde\e
j>dde\e
j>ddfdgeadhe ejejejdidx deddGe\e
j>dde\e
j>dde\e
djddfdkeadleejejejej<ej?dmdx dede\e
j>dde\e
j>dde\e
djddfdgeadne"ejejdodx dede\e
j>dde\e
j>ddfdgeadpe!ejejejdeddAd_eadqdrdx e!ejejejej7dee\e
j>ddfddseadtdudx e!ejejejej7dee\e
j>ddfddseadvejddGdGe!ejejejej7dGee\e
j>dde\e
j>dde\e
j>dde\e
j>dde\e
j>dde\e
dadde\e
j>ddfdw	eadxejddGe!ejejejej7dGee\e
j>dde\e
j>dde\e
j>dde\e
j>dde\e
j>dde\e
dadde\e
j>ddfdyeadzd{dx e!ejejejej7dee\e
j>dde\e
dadde\e
dadde\e
dadde\e
dadde\e
dadde\e
dadde\e
dadde\e
dade\e
dadd[e\e
d|d}de\e
d|ddfddsead}d~dx e!ejejejej7deedGdde\e
j>dde\e
dadde\e
dadde\e
d-dde\e
d-dde\e
d-dde\e
d-dde\e
d-dde\e
d-dd[e\e
d-dde\e
d-d}de\e
d-dde\e
d-dde\e
d-dde\e
d-dde\e
d-dde\e
d-dde\e
d-dde\e
d-dde\e
d-ddfdFeade!ejejejej7ede\e
j>dde\e
dadde\e
dadde\e
dadde\e
dadde\e
dadde\e
dadde\e
dadde\e
dade\e
dadd[e\e
dd}de\e
j>dde\e
ddde\e
ddde\e
dde\e
dddfdeade!ejeje!ejejejeedGde\e
j>dde\e
j>dde\e
j>dde\e
dadde\e
dadde\e
dadde\e
dadde\e
dadde\e
j>ddf	deadddx e!ejejejej7dee\e
j>ddfddseadddx ddx eejeejdGee!e\e
j>dde\e
dadde\e
j>dde\e
j>ddfdd
eadddx deejejeejejdGee\e
j>dde\e
j>dde\e
j>dde\e
j>dde\e
dd\fdeaddddx deejejeejejdGee\e
j>dde\e
j>dde\e
j>d\d7e\e
dd\fd	eadddx dddx eejeejejdGdGdGeee\e
j>d\dqe\e
j>dde\e
j>dde\e
j>dde\e
j>dde\e
daddfdeade!ejejeje̐edGdGdeade!ejejejejedGdGdGe\e
j>dde\e
j>ddfdeade!ejejejejeedGdGderdeejeejejdGdGddeade e e+de\e
j>dde\e
dadtdudfdeade e e,de\e
j>dde\e
j>ddfdeadeejeej:ejDejEejFe-dGde\e
j>dddde\e
daddfd:eade$ e.dde\e
daddfdeade"ejeje"eje/de\e
dddfdeade"ejeje"eje0de.e\e
dddfdeadede!ejejejejeeedGdGdGdGe\e
j>dde\e
j>ddfdeade!ejejejejeeedGdGdGdd	eadde!ejejejejeedGdGe\e
j>ddfdeade!ejejejejeedGdGddeadddx e!ejejejej7e ejejdGddGdGdde\e
j>dde\e
j>ddfeÐdeade"ejejeje"ejejddGdGeƐdAdeadde!ejejejej7ddGdGdexeyezd
eade ejejeee\e
dddddejfdfde}dddx eje!ejejejdGddGdGe{e\e
j>ddfd
eade!ejejejej7ddGg g dGdGdGddedeydeedej2j֐e	eesdÐdGiddGdGde!ejejejejde\e
j>dde\e
dġde\e
dġdfdōeadƐdǐdx dej2jde!ejejejdde\e
j>dde\e
j>dde\e
dȡd}dfe֐dɍ
eadʐdːdx dej2je!ejejejdde\e
j>dde\e
d̡d}dfe֐d͍	eade!ejejeje!ejejejddGdGde'eFdύ	e}deje!ejejejdGddGdGe{dэeade!ejejddGdGde~d+eade!ejejddGdGde~d+eade!eje!ejejdGdGddedՍeade!ejejejej7ddGdGdddGdGg g ed׍erdؐde"ejejejdGdGdGdGeBdlddڍeadېdܐdx dej2je!ejejejdGddGdGdGe\e
j>ddfeݐdݍeadސde"ejeje"ejejejdGdGdGdeߐd	eade# e!ej7ejejeje ejejedddGdGed
eadeddGe!ejejejej7ddGdGded
eadddx e!ejejejej7ddGdGe\e
j>dde\e
j>ddfedeadddx e!ejejejej7ddGdGde\e
j>dde\e
j>ddfed	eadddx e!ejejejej7dGddGdGe\e
j>dde\e
j>ddfed	eadddx de!ejejejej7dGddGdGde\e
j>dde\e
j>ddfedeade!ejejeje!ej7ejejdGdGeАdeade!ejejeje!ej7ejejdGdGeАdeadeejEejFfed ejoddfddxdde\e
dadde\e
dadde\e
dadde\e
daddfdeadeejEejFfed ejoddfddxdde\e
dadde\e
dadde\e
dadde\e
daddfdeade!ejejeje!ejejejdGddGdGeɐdeade!eje ejfe8se@rejgng  e ejejdGdGdeʐdeade!eje ejfe8sXe@rbejgng  e ejejdGdGdee\e
daddfd	ead ddx ee!ejejeje eejejddGdGdde\e
j>d\dej8fd^e\e
ddde\e
dadde\e
j>dde\e
dȡd}de\e
dȡd}d~e\e
dȡdde\e
dddfdeadeejeejejeejeeje\e
j>ddddfee&d	eyd	d
deCr0ende3ejdlej<dejdlife\e
dadbdcej<ej8gd^e\e
dadbdeej7ej<ej8gd^e\e
j>ddfe!ejeje!ejejejejdGdGdGe`ddx d dydeydeCr.ejujndde3ejdife"ejeje"ejejdGdGdeydeCrejujndde3ejdlejdlife\e
dԡdՐdփfe"ejeje"ejejejdGdGdGdGdGdGdGdGdGdeydeCr0ejujndde3ejdlejdlife"ejeje"ejejejdGdGdGd	eydeCrejujndde3ejdlejdlej@dife"ejeje"ejejdGdGdGdGdGdGdke\e
dadbdceCo6eTejPdk de\e
dadbdeeCoheTejPdk de\e
dadbdfeCoeTejPdk dfdeade0eeejejeejeejeejddGdGe\e
j>ddfdeade/ddx e
ee ejejddGdGe\e
j>ddej@fd^fd	eydeCrxe"ndde3ejdEife"ejeje"ejejdGdGe\e
dadbdcejgd^e\e
dadbdeddejgde\e
dadbdfddejgde\e
dadbdcej@ejpgeAdge\e
dadbdeej@ejpgeAdgfe`d dx d\dyd!
ead"e ddGdGee-e0gd#ead$d%dGd&eejeejejedGdGdGd'
ead$d(d%dGe!ejejejej7eedGddGdGdGd)	eyd*d+eCrnejujndd,d-dGdGe3ejdejdife"ejeje"ejejejed.ead/d0dx d1dx eeeddGdGe\e*ddfe\e
j>dde\e
daddfe!ejejejej7d2ead3e!ejejejej7ede\e
j>dde\e
j>dde\e
j>dde\e
j>dde\e
j>ddfdeyd4ejߐjd5d6dx e!ejejejdde*e\e5eje6dldld}idbdce\e5eje6dldld}idbd7e\e5eje6dldld}idbdme\e5eje6dldld}idbdfge\e
j>dde\e
j>dde\e
j>dde\e
d8d}de\e
dadbdcejgd^e\e
dadbd7ejgd^e\e
dadbdmejgd^e\e
dadbdeej<ge@dge\e
j>dde\e
dadf
d9erd:ejߐjjd;d\d{d\d{d<dxe!ejejejeedd=d>ddde*ge\e
j>dde\e
j>dde\e
j>dde\e
d8d}de\e
j>dde\e
dadfd?
ead@ejߐjjdAd\d\dd\d\ddBdxe!ejejejeedCdDdEdFdde*ge\e
j>dde\e
j>dde\e
j>dde\e
d8d}de\e
j>dde\e
dadfdG	erdHejߐjjdId\dJdKdx e!ejejejeeddLd>ddde*ge\e
j>dde\e
j>dde\e
j>dde\e
d8d}de\e
j>dde\e
dadfd?
eadMejߐjjdNddJd\d{dOdxe!ejejejeeddPdde*ge\e
j>dde\e
j>dde\e
j>dde\e
d8d}de\e
j>dde\e
dadfdG	ead ee ejejdGdGdGe\e
j>dddQdfdRead dSdTee.e0gdddGdGe e e\e
j>dde\e
j>ddej<ej@fd^fdUead dVdWee eje ejejdGddGe\e
daddej<ej?fd^e\e
j>dde\e
j>ddej<ej@fd^fdX
ead dYee ejejdGdGde\e
j>dddQdfdZead[eddGdGddg g e!ejejejdGe d\ead]d^dx eejeejeje\e
j>dde\e
j>dde\e
daddddfdGdGdded_dx d`eadadbdx eejeejeje\e
j>dde\e
j>ddfdGdGddeedcdddedx dfeadgdhdx eejeejeje\e
j>dde\e
j>ddfdGdGddeedidddjdx dfeadkdldx dmeejeejeje\e
j>dde\e
j>dde\e
j>d\dqe\e
j>d\d`fdGdGdGdeedGdiddndx doeadkdpdx dqe!ejejeje\e
j>dde\e
j>ddfe*dGdGdeeddrdsdx dteadue(deejFfedveadwdxdydx eejejeedGdGe\e
j>dde\e
j>dde\e
dadddde\e
d̡d}dfdGddzead{d|dx eejeejejeejee\e
j>dde\e
j>dde\e
d̡d}dfeFddd}
eyd~de$ddx eesdddddGdGeejeejeje\e5eje6dldld}eje6dldld}idbfd
eadde/ddx eddGdGeeje eejejeejeje\e
j>ddej@fd^fdeade eejdedddeadeje!ejejejddedeeddGddeje!ejejejeeje\e
j>dde\e
j>dde\e
j>dde\e
j>ddejCgd^fdeeddddeje!ejejejeeje\e
j>dde\e
j>dde\e
j>dde\e
j>ddejCgd^fdeedddGddGe"ejejejeeje\e
j>dde\e
j>ddfe(d	eedddGddGe"ejejejeeje\e
j>dde\e
j>ddfe(d	eeddddGejFe"ejejeejdde\e
dadde\e
daddfdeedddejFe"ejejeejdde\e
dadde\e
daddfdeedd ddejFe!ejejejeeeeje\e
dadde\e
dadde\e
dadde\e
dadde\e
dadde\e
dadde\e
dadde\e
daddfd	eed;ddGdGddGdGdGe ejejeeje4e\e
dadde\e
dadde\e
dadde\e
daddejgd^e\e
dadddej<gdfdeedddGdGdGddGeejejecdGdeeje\e
dadde\e
dadde\e
dadde\e
daddejgd^e\e
dadddejgde\e
dadddej<gdfdeeddddGdGdGdGdGde ejeje ejejee1eje3e\e
dadde\e
dadde\e
dadde\e
dadde\e
dadde\e
daddfdeeddddGdGdGdGdGde ejeje ejejee1eje3e\e
dadde\e
dadde\e
dadde\e
dadde\e
dadde\e
daddfdeedd\dddGddGdGdGeFe!eje!ejejejej7eeeje\e
dadde\e
dadde\e
dadde\e
dadde\e
dadde\e
daddejej<gd^e\e
daddejCejej<gd^fdeedd dddGdGdGe!ejejeje!ejejejej7eeje\e
dadde\e
dadde\e
dadde\e
daddejgd^e\e
daddejgd^fdeedd ddGdGdGddGe"ejejejecdGdeeje\e
dadde\e
j>dde\e
j>dde\e
daddejgd^fdeade dee\e
j>d\doejpfd^e\e
j>d\d5ejpfd^e\e
daddej@fd^e\e
dddeEdfdeade"ejeje"ejejejddGdGedeadeejeejejdedGdGdGe\e
daddej@fd^fd	eadeejeejejdGddGdGee\e
j>d}d~e\e
j>d}d`e\e
j>d}de\e
daddej@fd^fe\e5eje6dldld}eje6dldld}iddfd
eadeejeejejddGdGeeed	eaddeejejddGeee\e
daddej@fd^fdčeadŐeee dddƍeade"eje"ejejddGdGe edȍeade"ejejeje"ejeje6dde\e
daddej@fd^fd:eade!ejejejej7e ejejej7eddGdGde\e
daddej@ej<fd^fdˍ	ead̐
d4dϐdxee!ejejddGdGe\e
daddej@ej<fd^fdЍeadѐee!ejejejddGdGe\e
j>dddde\e
daddej@ej<fd^fdҍeadӐee!ejejejddGdGe\e
j>dddde\e
daddej@ej<fd^fdҍeadԐeeejeejejddGdGdeadՐ
d5d֐dxee!ejeje!ejejejddGdGdd׍	eadؐde"ejejejdGdGe͐dٍeadؐde"ejejeje"ejejee\e
j>d}d~e\e
j>d\dqe\e
j>d\d`e\e
j>d\d7fdڍeadؐd;e"ejeje"ejejdGdGe͐dۍeadؐde"ejejeje"ejejdGddGe͐d܍eadؐde"ejejeje"ejejdGddGe͐d܍eadݐdaeejejddee\e
daddddfdލeadݐdeejejddeeΐdߐdbe\e
daddddfdލgZeea ed< eejj7 Zedde\e
j>ddej7fddeBpeA d0e\e
j>ddej7fddeBpeA d0fdedddeddsddedddeddddeddve\e
j>dde\e
j>dde\e
j>ddfddeddxe\e
j>dde\e
j>dde\e
j>ddfddedde\e
j>dde\e
j>dde\e
j>dde\e
j>ddejFfd^fddedde\e
j>dde\e
j>dde\e
j>dde\e
j>ddejDejEejFfddd1e\e
j>ddejDejEejFfddd1e\e
j>ddejCej:ejDejEejFfdd1e\e
j>ddejCej:ejDejEejFfdd1e\e
j>ddejCej:ejDejEejFfdd1fdddedde\e
j>dde\e
j>dde\e
j>dde\e
j>ddejDejEejFfdd1e\e
j>ddejDejEejFfdd1e\e
j>ddejDejEejFfdd1fdddedddddedd$ddeddddeddddedddde\e
dadde\e
dadde\e
dadde\e
daddfdedddde\e
dadde\e
dadde\e
dadde\e
daddfdedddddedddddedddeddde	d dde	dd dde	dddde	ddde	ddde	dddde	ddde	dddde	ddde	d	dde	d
dde	dddde	dddGd	de	dddde	dddde	dddde	dddGd	de	dddGd	de	dddGd	de	dddGd	de	dddG	de	dddGd	de	dddde	ddde	d	ddRdde	d	ddUdde	d	ddXdde	ddde	ddde	ddde	ddde	d ddde	d!d$de	d"ddde	d#dde	d$ddde	d%dvdde	d&dde	d'ddde	d(dՐde	d)d	dd	d*e	d+dde	d,ddd	d*e	d-ddde	d.dde	d/dde	d0dde	d1dde	d2dde	d3de\e
daddej<fd^fde	d4dde	d5dde	d6d
dde	d7d*dde	d8dݐde	d9ddde	d:d]e\e
	d;dde\e
	d;dde\e
	d;dde\e
	d;dde\e
	d;dde\e
	d;dde\e
	d;dde\e
j>ddf	d<e	d=dӐde	d>d@dde	d?dEde	d@dve\e
daddej@fddd1fde	dAdddG	dBe	dCd̐dG	de	dDdŐdGde\e
j>ddf	dEe	dFdde	dGdǐde	dHdِde	dIdLdde	dJdJde	dKdde	dLdde	dMd~de	dNddde	dOddde	dPddde	dQddde	dRddG	de	dSdde	dTd;dde	dUd7dde	dVdddG	dWe	dXdߐde	dYd de	dZddde	d[dde	d\dde	d]d,de\e
dad~df	d^e	d_ddKddGde\e
daddejej<ej?fd^e\e
j>ddejfdd1e\e
j>ddejfdd1f	d`e	d_ddMddGd	dae	d_ddRddGd	dae	dbdide	dcdpde\e
j>d~df	d^e	dddeBdGdddGde\e
daddejfd^e\e
daddejfd^f	dee	dfdkdd	dge	dhdmdd	dge	didndodGidGe\e
daddejfddd1e\e
daddejfddd1f	dje	dkd	dde	dldde	dmdde	dnddd	dge	doddd	dge	dpd1dde	dqd4dde	drd
de\e
j>d~df	d^e	dsddde	dtdde	dudde	dvdde	dwdde	dxdde	dydde	dzdde\e
j>d	d{f	d^e	d|dde\e
j>d	d{f	d^e	d}dddGe\e
j>ddejfd^e\e
j>ddejfdd1e\e
j>ddejfdd1f	d~e	dd[de	dd"dde	ddlde\e
j>ddejfd^e\e
j>ddejfdd1e\e
j>ddejfdd1f	d^e	ddse\e
daddejfddd1e\e
daddejfddd1fde	dde\e
j>ddej7fddd1e\e
j>ddej7fddd1fde	ddddGe\e
j>ddej7fddd1e\e
j>ddej7fddd1f	d~e	ddSddGe\e
j>ddejfd^e\e
j>ddejfdd1e\e
j>ddejfdd1f	d~e	ddde	ddde\e
j>d	d{f	d^e	ddde\e
j>d	d{f	d^e	dddde	dd
dde	dddd	de	dddd	de	dddd	de	dde!ejejejde\e
d dde\e
d dde\e
d dde\e
d ddf	de	dddde	ddde	ddde	ddde\e
j>d	d{f	d^e	dddde	dd$dde	dddde	dd}dde	dddde	dddde	ddcdde	ddadde	dddde	ddYdde	dd\dde	dd dde	dddde	dddde	dddde	ddde\e
j>d	d{f	d^e	dd]de\e
j>dde\e
j>ddf	d^e	dd.de	ddjde	dddde	dddd	de	dddde	dddde	ddwdd	de	ddydd	de	dddd	de	ddde	dde\e
j>dde\e
j>ddfdde	dddde	dddde	ddde	dd[de	dddde	dd֐de	dddde	dddde	ddde\e
j>d	d{f	d^e	dd"dde	dddde	ddde	ddde	ddde	ddde	dd;dG	de	dddG	de	dÐdde	dĐddG	de	dŐd;dGd	de	dƐdd	dǍe	dȐddGd	de	dɐddG	de	dʐdd	dǍe	dːddeejeje\e
j>ddf	d̍e	d͐d0e de\e
j>dde\e
j>dddddf	d΍e	dϐdde\e
j>ddf	dЍe	dѐde\e
j>dde\e
	dҡdde\e
	dӡddf	d<e	dԐd dGdd	dՍe	d֐de\e
ddde\e
ddde\e
ddde\e
ddde\e
ddde\e
ddde\e
ddde\e
	dסddfde	dؐdZde\e
ddde\e
ddde\e
ddde\e
ddde\e
ddde\e
ddde\e
ddde\e
	d١ddf	d^e	dڐda	dېdx de\e
	dܡdde\e
dcdde\e
dcdde\e
dcdde\e
dcddf	dݍe	dސdde\e
dadde\e
dadde\e
daddf	d^e	dߐdzde\e
ddde\e
ddde\e
ddde\e
ddde\e
ddde\e
ddde\e
ddde\e
	dddf	d^e	dd}e\e
	ddde\e
	ddde\e
	ddde\e
	ddde\e
	ddde\e
	dddfde	dddde	ddtdde	ddqdde	dddde	dd/	ddx d	de	dd.de\e
j>dde\e
j>d	d{f	d^e	dd,de\e
j>ddf	d^e	dd0de\e
j>ddf	d^e	dd*de\e
j>ddf	d^e	ddddgZeejj7 Zee Z	d	d eD Z	d	d eD Ze]	dd eD Z	d	d eD Z	d	d eD Z	d	d eD Z	d	d eD Z	d	d eD Z	d	d eD Z	d	d eD Z	d	d eD Z 	d	d eD Zeddf	d	dZdeddf	d	dZ
d 
d Z
d
d ZdS (6
      )wrapspartial)productchainisliceN)infnan)AnyDictListTupleUnionmake_tensor)_dispatch_dtypesfloating_typesfloating_types_andcomplex_typesfloating_and_complex_typesfloating_and_complex_types_andall_types_and_complex_andall_types_andall_types_and_complexintegral_types_and	all_typesempty_typescomplex_types_andintegral_types)onlyCUDAonlyNativeDeviceTypesdisablecuDNNskipCUDAIfNoMagmaskipCUDAIfNoMagmaAndNoCusolverskipCUDAIfNoCusolverskipCPUIfNoLapackskipCPUIfNoFFT
skipCUDAIfprecisionOverrideskipCPUIfNoMklSparsetoleranceOverridetol)CUDA11OrLaterSM53OrLaterSM60OrLaterwith_tf32_off
TEST_CUDNN_get_torch_cuda_version)	4make_fullrank_matrices_with_distinct_singular_valuesTEST_WITH_ROCM
IS_WINDOWSIS_MACOS
TEST_SCIPYtorch_to_numpy_dtype_dictTEST_WITH_ASANGRADCHECK_NONDET_TOLfreeze_rng_state)tree_flatten)LooseVersion)0LMSXS_NOTHING_getattr_qualDecorateInfoSampleInput
ErrorInput	AliasInfoNumericsFilterOpInfo_generate_reduction_inputs_generate_reduction_kwargssample_inputs_reductionReductionOpInfo#reference_inputs_elementwise_binary$make_error_inputs_elementwise_binary#generate_elementwise_binary_tensors7generate_elementwise_binary_arbitrarily_strided_tensors/generate_elementwise_binary_small_value_tensors/generate_elementwise_binary_large_value_tensors2generate_elementwise_binary_extremal_value_tensors0generate_elementwise_binary_broadcasting_tensors/generate_elementwise_binary_with_scalar_samplesBgenerate_elementwise_binary_with_scalar_and_type_promotion_samples1generate_elementwise_binary_noncontiguous_tensors sample_inputs_elementwise_binaryBinaryUfuncInfosample_inputs_elementwise_unary"generate_elementwise_unary_tensors.generate_elementwise_unary_small_value_tensors.generate_elementwise_unary_large_value_tensors1generate_elementwise_unary_extremal_value_tensors"reference_inputs_elementwise_unaryUnaryUfuncInfosample_inputs_spectral_opsSpectralFuncTypeSpectralFuncInfoShapeFuncInfosample_inputs_foreachForeachFuncInfo!gradcheck_wrapper_hermitian_input"gradcheck_wrapper_triangular_input9gradcheck_wrapper_triangular_input_real_positive_diagonal"gradcheck_wrapper_masked_operation,gradcheck_wrapper_masked_pointwise_operationclone_sample)_find_referenced_opinfo_inherit_constructor_argsPythonRefInfoReductionPythonRefInfoElementwiseUnaryPythonRefInfoElementwiseBinaryPythonRefInfo)(np_unary_ufunc_integer_promotion_wrapperreference_reduction_numpy)opinfo)
sample_inputs_linalg_cholesky%sample_inputs_linalg_cholesky_inversesample_inputs_crosssample_inputs_linalg_qr_geqrfsample_inputs_linalg_invertiblesample_inputs_lu_solvesample_inputs_legacy_solvesample_inputs_svd'sample_inputs_linalg_det_logdet_slogdetsample_inputs_linalg_lu)sample_inputs_i0_i1sample_inputs_polygammareference_polygamma)sample_inputs_softmax_variant)stats皙?c              	   C   sJ   |   r&tttt| }ntt| }||k |d| kB S N   )
is_complextorchabsview_as_complexfracview_as_real)xepsy r   V/tmp/pip-unpacked-wheel-gikjz4vx/torch/testing/_internal/common_methods_invocations.pyclose_to_int   s    r   c                 k   sz   t t||d d |d}t|ddV  t|ddddddd	V  t|dddddddd
V  t|dddddddd
V  d S )Ndevicedtypelowhighrequires_grad   r         (   r   )dimstartend)r   r   r   step   r   r   rC   op_infor   r   r   kwargs
make_inputr   r   r   sample_inputs_slice   s      r   c                 k   s   t t||d d |d}tdddgftdftdddgdftddddddgd d d dfdd	d
dddf
}|D ]}t|tttf|dV  qvd S )Nr   r   r   r            )r   r   )r   r   )r   r   r   r   r   r   args)r   r   r   tensorrC   r>   )r   r   r   r   r   r   Z
args_casesr   r   r   r   sample_inputs_tensor_split   s$      
"r   c              
   K   sF   t td||d d |dddt ttttf||d d |ddddgfdfS )Nr   r   r   r   r   r   r   r   r   r   r   rC   r   r>   r   r   r   r   r   r   r   r   sample_inputs_hsplit   s    
  
r   c              
   K   sJ   t tdtf||d d |dddt ttttf||d d |ddddgfdfS )Nr   r   r   r   r   r   r   r   r   r   r   r   sample_inputs_vsplit   s      
r   c              
   K   sL   t ttttf||d d |ddddgfdt tttdf||d d |dddfS )Nr   r   r   r   r   r   r   r   r   r   r   r   sample_inputs_dsplit   s     
 r   c           	      k   s   d}t tdtj|ddd}dt d}t ttttftj|ddd}d}t ttttftj|dd	d}t||d
V  t||d
V  t|t|dV  d S )Nz]torch.hsplit requires a tensor with at least 1 dimension, but got a tensor with 0 dimensions!r   r   r   r   r   zQtorch.hsplit attempted to split along dimension 1, but the size of the dimension & is not divisible by the split_size 0!-received an invalid combination of arguments.abcerror_regex
error_typer   )rC   r   r   float32r>   rD   	TypeError	r   r   r   err_msg1si1err_msg2si2err_msg3Zsi3r   r   r   error_inputs_hsplit   s0    r   c           	      k   s   d}t ttftj|ddd}dt d}t ttttftj|ddd}d}t ttttftj|ddd}t||d	V  t||d	V  t|t|d
V  d S )Nz]torch.vsplit requires a tensor with at least 2 dimension, but got a tensor with 1 dimensions!r   r   r   zQtorch.vsplit attempted to split along dimension 0, but the size of the dimension r   r   r   r   r   )rC   r   r>   r   r   rD   r   r   r   r   r   error_inputs_vsplit   s0    r   c                 K   s`   d}t ttftj|ddd}dt d}t ttttftj|ddd}t||dt||dfS )Nz]torch.dsplit requires a tensor with at least 3 dimension, but got a tensor with 1 dimensions!r   r   r   zQtorch.dsplit attempted to split along dimension 2, but the size of the dimension r   r   rC   r   r>   r   r   rD   )r   r   r   r   r   r   r   r   r   r   error_inputs_dsplit  s"    

r   c                 k   sP   t t|||d}d}|D ]2\}}}	}
||}t|
d}t|||	f|dV  qd S )Nr   r   r   )r   r   r   r   r   r   r   r   r   r   r   r   r   r   r      r   r   r   r   r   r   r   r   r   r   )r   r   r   r   )r      r   r   r   storage_offsetr   r   r   r   dictrC   )r   r   r   r   r   make_arg
test_casesinput_shapeoutput_shapestrider   input_tr   r   r   sample_inputs_as_strided  s    
r   c                 K   sl   t t|||d}dddddg}g }|D ]@\}}	}
}||}||	}t|d}|t|||	|
f|d q&|S )	Nr   r   r   r   r   r   r   r   )r   r   r   appendrC   )r   r   r   r   r   r   r   samplesr   r   r   r   r   Z	input_srcr   r   r    sample_inputs_as_strided_scatter/  s    
r   c                 K   sj   d}dddg}t ||ddg}g }|D ]:\}	}
}tj|	|||d}t|
|d}|t||d	 q&t|S )
N)r   r   r   r   r   r   r   r   r   r   FTr   )rwith_replacementr   )r   r   r   r   r   rC   tuple)r   r   r   r   r   inputsZrvalsproductsr   Z
input_datar   r   r   r   r   r   sample_inputs_combinationsE  s    
r   c           
      K   sn   t tj|||d}|d}|d}|d}g }	|	t| |	t||fd |	t|||fd t|	S )Nr   r   r   r   r   )r   r   r   r   rC   r   )
r   r   r   r   r   r   abcr   r   r   r   sample_inputs_cartesian_prodZ  s"    r   c                 k   s   t t|||d}ttfddiftdfddiftfdddfd	ddiftttfddifttfi ff}|D ]"\}}t||||f|d
V  qft|d|dfddid
V  t|d|dfddid
V  t|d|dfddid
V  d S )Nr   r   r   r   r   r         ?)r   r   r   r   r   r   r   )r   r   r   r   r   r   r   r   r>   r=   rC   )r   r   r   r   r   r   casesr   r   r   r   sample_inputs_cosine_similarityw  s    

	r  c                 k   s  t t|||d}t t||dd}tttfddddfdddd	fd
ddd	fdddifdddifdddddfdddddfdi ff}|D ]|\}}t|dkr|d nd}	|	dkr||	nd }
|	dkr||	nd }||	dd}||	dd}t|||||
|f|dV  q|	d d g}d |	d g}dddg}t|||D ]4\}
}}t||||||	||	fd|idV  q2t|ddddidV  d S )Nr   FTr   333333?)trainingmomentumr   r   r   r   333333)r  r  r           r   r  r   r   r   r         r   r   r   r   r   r   r   )NNNN)r   r   r>   lenrC   zip)r   r   r   r   r   r   make_arg_without_requires_gradr  r   channelsweightbiasrunning_meanrunning_varweightsbiasesZis_trainingr  r   r   r   sample_inputs_batch_norm  sP    





r  c              
   k   s   t | |||f|}|D ]r}|j dkr*q|j}|jdd}|jdd}	|jdd}
t|j|d |d	 |d |d
 ||	|
fdV  qd S )Nr   r  Tr  r   r   h㈵>r   r   r   r   )r  inputnumelr   r   getrC   )r   r   r   r   r   r   sampler   r  r  r   r   r   r   sample_inputs_native_batch_norm  s    r  c                 k   sD   t t|||d}dtfttftttff}|D ]}t||V  q,d S Nr   r   r  r   r   r   r   r   r   r  shaper   r   r    sample_inputs_nn_activation_relu  s    r#  c                 k   s  |  ||d d }t| ||||dE d H  tt|||d}dtfttftttff}|D ]b}dD ]*}	tj|	|||d}
t|||
fdV  q^t	|dkrV|d }t||||ffdV  qVtjd	|||d}
t|ttft
|
d
dV  t|ttft
|tfd
dV  d S )Nr   	op_kwargsr   r   )r  r
  皙?      ?r   r   r   r'  r  r   )sample_kwargsrY   r   r   r>   r=   r   r   rC   r  r   )r   r   r   r   r   r%  r   r  r"  r  weight_tensorZchannel_sizer   r   r   sample_inputs_prelu  s(    
r+  c                 k   s4   t | |||f|E d H  t| |||f|E d H  d S N)r+  r^   )opr   r   r   r   r   r   r   reference_inputs_prelu  s    r.  c                 C   sN   t jt | |d}|t jkr.|jt jdd}n| }| }d|id|ifS )Nr   r   cpur   r  )r   randr   bfloat16tor   r0  numpy)r   r   r  r  Z
weight_cpuZ	np_weightr   r   r   !sample_kwargs_prelu_scalar_weight  s    
r5  c                 c   s   t t |tjd}t d|tjd}tt|d|idddV  t d|tjd}t d|tjd}tt|d|idd	dV  t d|tjd}t d
|tjd}tt|d|idddV  d S )Nr/  r   r  r   z Not allow zero-dim input tensor.r   )r      r   )	   z5Mismatch of parameter numbers and input channel size.r   zFprelu: Expected `weight` to be a scalar or 1D tensor, but got ndim = 2)r   r   r   r   rD   rC   )r-  r   inpr  r   r   r   error_inputs_prelu  s    r9  c                 k   s  t t|||d}ttfddfttfddfttfddfttfdd	fttfd
dfttfddfttfddfttfddfttfddfg	}tttfddftttfddftttfddftttfddftttfddff}ttfddfttfd d!fttfd"d#fttfd$d%fttfd&d'fttfd(d)ftttfd&d'ftttfd(d)ftttfd*d+ftttfd,d-fd.d/d0d1f}d2d3 |D }	t|||	D ] \}
}}t||
||d4V  qr|D ]$\}
}}t||
d5d6||d4V  qd S )7Nr   r   2r   0)r   Z0_5r   1r   3r   Zneg_1r   Zneg_2)      Zneg_0_5)g      Zneg_1_5)      ?Z1_5_default)rA  r   Z1_5_dim)rA  r   Z1_5_neg_dim)rA  r   TZkeepdim_1_5_dim)rA  r   TZkeepdim_1_5_neg_dim)r   r   Z	neg_2_dimr   r   Z	neg_1_dimr   Z0_dimr   r   Z1_dimr  Z2_dimr   Z3_dimr   r   TZkeepdim_2_dimr   r   TZkeepdim_3_dim)r   r   r   Z2_dim_scalar)r   r   r   Z3_dim_scalar)r   r   r   TZkeepdim_2_dim_scalar)r   )r   r   TZkeepdim_3_dim_scalarc                 s   sF   | ]>\}}}||d d |d  f |dd   | ddfV  qd S )Nr   r   Z_dimZ_neg_dim)replace).0r"  r   namer   r   r   	<genexpr>E  s   z%sample_inputs_norm.<locals>.<genexpr>r   rK  Texclude_zero)r   r   r>   	itertoolsr   rC   )r   r   r   r   r   r   r  Zcases_nonzero_inputZcases_posdimZcases_negdimr"  r   rK  r   r   r   sample_inputs_norm  sN    	rQ  c           
      k   sh   t t|||d}ttfddfttfddfttfdddgfdff}|D ]\}}}	t||||	d	V  qDd S )
Nr   r   default)froZfro_defaultrS  r   r   rM  r   r   r>   rC   
r   r   r   r   r   r   r  r"  r   rK  r   r   r   sample_inputs_norm_froO  s    rV  c           
      k   s^   t t|||d}ttfddftttfdddgfdff}|D ]\}}}	t||||	dV  q:d S )Nr   )nucrW  r   r   Znuc_batchedrM  rT  rU  r   r   r   sample_inputs_norm_nuc\  s    rX  c           
      k   sz   t t|||d}ttft fdfttftfdfttftdfdfttftdfdff}|D ]\}}}	t||||	dV  qVd S )	Nr   -infr   r   Z	inf_2_dimr   Zinf_2_neg_dimrM  )r   r   r>   r   rC   rU  r   r   r   sample_inputs_norm_infh  s    rZ  c                 k   s   t t|||d}dtfdfdtfftdftffttfdfttfttfff}|D ]Z\}}||}	||}
|t||k}t|	|
f|dV  ||krNt|	|	  fdV  qNd S )Nr   r   r   r   r   r   broadcasts_inputr   )	r   r   r>   r=   r   broadcast_shapesrC   clonedetach_)r-  r   r   r   r   r   shapes	shape_lhs	shape_rhslhsrhsr]  r   r   r   sample_inputs_equalv  s(       
	rf  c                 k   s   t t|||d}dtfdftdftffttfdftttfttfftttftttfftdtfttfftdtfdttffdf	}|d}|di }|D ]Z\}	}
||	}g }t|d D ]}|||
 q|	t|	|
k}t	|t
|||dV  qd S )	Nr   r[  r   r   )r   r   r   )r   
   r   
num_inputsr)  r   r   r]  )r   r   r>   r=   r  ranger   r   r^  rC   r   )r-  r   r   r   r   r   ra  ri  r)  rb  rc  rd  r   ir]  r   r   r   sample_inputs_jiterator  s(    

rm  c           	      k   s   dt fdft dft fft dft ftt fdft tt ftt fft tt ft tt fftdt ftt fftdt fdtt ffdf
}|D ]}|^}}t|t|dV  qxd S )Nr[  r   r   rg  r   )r>   r=   rC   r   )	r-  r   r   r   r   ra  r"  r8  Zarg0r   r   r   sample_inputs_broadcast_shapes  s    

rn  c           	      k   s   t | |||f|E d H  tt|||d}|ttff| j}|ttff| j}|tjk	rnt||fddidV  nt||fddidV  |j	s|j
rdnd}|ttff| j}|ttff| j}|tjk	rt||fd|idV  nt||fddidV  d S )	Nr   alphar   r   TQ	F)rW   r   r   r>   lhs_make_tensor_kwargsrhs_make_tensor_kwargsr   boolrC   is_floating_pointr   )	r-  r   r   r   r   r   rd  re  Z	neg_alphar   r   r   sample_inputs_add_sub  s    

rv  c                 k   s   t tdddtddV  t tdddtddV  t tdddtddV  t tdtd	d
fdtddV  t ttdddtddV  d S )Nr   rG  r   zstep must be nonzerr   )rq  r   z!bound inconsistent with step signr   r   r   r   zunsupported rangerY  r   )rD   rC   RuntimeErrorfloatr-  r   r   r   r   r   error_inputs_arange  s
     r{  c                 +   s   d}dd  d fdd	|D }d
}|| }|t jt jfkrF||7 }|D ]\}	}
}|	d kr|d kshtt|
||ddV  td|
||ddV  qJ|d krt|	|
f||ddV  qJt|	|
|f||ddV  qJtdV  tdddV  d S )N)	r   r   r   )r   rq  r   r   r   r   )r   r   r   )r   i)r   r   r   )FTT)r   r   N)Nr   Nc                 S   s:   | d k	r| d nd } |d }|d k	r,t |nd }| ||fS Nr   ry  )r   r   r   r   r   r   to_float  s    z&sample_inputs_arange.<locals>.to_floatr
  gA!         r'  gC  @       @r
  g       r  r'        @r  c                 3   s    | ]\}}} |||V  qd S r,  r   )rJ  r   r   r   r  r   r   rL    s     z'sample_inputs_arange.<locals>.<genexpr>))r   '  Nr   r   r   )r   r   r   r   r   r   r   r   )r  r  r  r  )r   int8uint8AssertionErrorrC   )r-  r   r   r   r   Zint_samplesZfloat_samplesZlarge_samplesr   r   r   r   r   r  r   sample_inputs_arange  s.        	
r  c                 k   sD   t t||dd}tfttff}|D ]}t|t|||ddV  q"d S )NFr   r   r   r  r   )r   r   r=   r>   rC   r   )r-  r   r   r   r   r   ra  r"  r   r   r   sample_inputs_randn  s    r  c           
      k   sb   t t||dd}tfddfttfddftttfddff}|D ] \}}}	t||||	fdV  q<d S )	NFr  id   r   r   r   r   r   r   r=   r>   rC   )
r-  r   r   r   r   r   r   r"  hilor   r   r   sample_inputs_uniform  s    
r  c                 k   s0   t fttff}|D ]}t|||ddV  qd S )Nr   r   )r=   r>   rC   )r-  r   r   r   r   sizessizer   r   r   sample_inputs_ones_zeros'  s
    r  c                 k   s,   t jdg|d}tt|ddtddV  d S )Nrh  r   r   r   zIuniform_ expects to return a \[from, to\) range, but found from=3 > to=-1r   )r   zerosrD   rC   rx  )r-  r   r   tr   r   r   error_inputs_uniform1  s    
r  c                 k   s4   t tdddtddV  t tdddtddV  d S )Nr   r   r   z$number of steps must be non-negativer   )r   r'  zmust be int, not float)rD   rC   rx  r   rz  r   r   r   error_inputs_linspace:  s    r  c                 k   sz   d}d}d}t t|||dg }|D ]@\}	}
}|tjkrB|
dk s&|	dk rLq&t|	|
|f||ddV  q&tdd	d
V  d S )N)rq  r   r   r   2   )       r   333333@r  )r   r   r  )r   r   r  r   r   r   r   r   r   )listr   r   r  rC   )r-  r   r   r   r   endsstartsnstepsr  r   r   nstepr   r   r   sample_inputs_linspace?  s    r  c                 k   s   d}d}d}|t jt jfkr dnd}t||||D ]\}	}
}}|t jkrP|
dk s2|	dk rZq2|dkrzt|	trz|jsz|jszq2|d krt|	|
|f||dd	V  q2t|	|
||f||dd	V  q2tdd
dV  d S )N)rq  r   333333?r   r   )r  r   r   r   r  )r   r   r   r   )r  皙?)Nr        @r  r  r   r   r   r   )r   r   r  r   )	r   r  r  r   
isinstancery  r   ru  rC   )r-  r   r   r   r   r  r  r  basesr   r   r  baser   r   r   sample_inputs_logpaceM  s    r  c              	   k   s   t | |||f|E d H  ddg}ddg}ddg}t|||}tt|||d}	|D ]J\}
}}|	ttff| j}|	ttff| j}t||ft|
||ddV  qPd S )Nr
  gHz>FTr   )rtolatol	equal_nanr   )	rW   r   r   r   r>   rr  rs  rC   r   )r-  r   r   r   r   rtolsatolsZ
equal_nansr   r   r  r  r  rd  re  r   r   r   sample_inputs_isclose`  s    r  c                 k   sf   t t|tjdd}tt|d|dfddidtddV  tt|d|dfd	didtd
dV  d S )NFr   r   r  gٿr   z*rtol must be greater than or equal to zeror   r  z*atol must be greater than or equal to zero)r   r   r   ry  rD   rC   rx  )r-  r   r   Zmake_float_argr   r   r   error_inputs_iscloses  s    r  c                 K   s2   t t|||d}t|dt|dt|dfS )Nr   r   r   r   r   r   r   r   r   r   r   r   r   r   sample_inputs_t  s
    


r  c                 +   sj   t t||d  fdd}ttfttf }}t | |fdV  |jrft |||fdV  d S )Nr   c                    s    |   S r,  conjrequires_grad_r  r   r   r   r   make_arg_conj  s    z'sample_inputs_mm.<locals>.make_arg_conjr   )r   r   r>   r=   rC   r   )r   r   r   r   r   r  first_shapesecond_shaper   r  r   sample_inputs_mm  s    r  c                 K   s<  | d|jrdnd}| d|jr&dnd}dg}dd	g}|| }	g }
|	D ]P\}}}}|
tt||||d
t||||d
t||||d
f||d|d qJ|jr8d}|
tt||||d
t|||dj|t||||d
f||dd |
tt||||d
t||||d
t|||dj|f||dd |
S )Nro         @      @r  beta      ?       @皙?)r  r   r  F)r   r   r  T)r   r   r  Tr  ro  r  rj  r   r   r   )r  r   r   rC   r   mHr  )r   r   r   r   r   Z	alpha_valZbeta_valZ
tests_listZtests_with_lhs_broadcastingr   sample_inputsZshape_aZshape_bZshape_cr]  r"  r   r   r   sample_inputs_addmm  s^    r  c                    s:   j r
dnd j rdnd fdd}t| S )Nr  r  r  r  c               
   3   st   t jddgddD ]\\} }}ttj| |d t| |fdt||fdf ddV  qd S )	Nr   r   r   repeatr/  r   r  r   )rP  r   rC   r   eyeZto_sparse_csrr  r   )mnkro  r  r   r   r   r   r   	generator  s(    z5sample_inputs_sparse_sampled_addmm.<locals>.generator)r   r  )r   r   r   r   r   r  r   r  r   "sample_inputs_sparse_sampled_addmm  s    r  c              
   K   s6   t tttf||d d |dttf||d d |dfdfS Nr   r   rC   r   r>   r=   selfr   r   r   r   r   r   r   sample_inputs_mv  s    r  c              
   K   s<   t ttttf||d d |dttttf||d d |dfdfS r  )rC   r   r=   r>   r  r   r   r   sample_inputs_bmm  s    r  c                    sl   t t||d  fdd}g }|t tf tffd |jrh|t tf|tffd |S )Nr   c                    s    |   S r,  r  r  r  r   r   r    s    z-sample_inputs_dot_vdot.<locals>.make_arg_conjr   )r   r   r   rC   r>   r   )r  r   r   r   r   r  r  r   r  r   sample_inputs_dot_vdot  s      r  c              	   k   s   t t|||d}tfttftfdddftfttftfdddff}dttftfdddfdttftfdddfdttftfdddfdttftfdddff}|| }|D ]:\}	}
}}}}t||	||
||ft||d	|d
V  qd S )Nr  r   Fr  r  r   Tr   r  ro  rj  )r   r   r>   r=   rC   r   )r   r   r   r   r   r   r   Ztest_cases_with_broadcastr  r  matZvecr  ro  r]  r   r   r   sample_inputs_addmv  s    
 r  c                 k   s@  t t|||d}ttftttftttfdddfdtttftttfdddfttftttftttfdddfdtttftttfdddfdtttftttfdddfdtttftttfdddfg}|D ]~\}}}	}
}}|jr|
d	 |d
  }}t||||||	ft||d|dV  t||||||	ft|
|d|dV  qd S )Nr   r   Fr   Tr  r  r   r  r  r  rj  )r   r   r>   r=   r   rC   r   )r   r   r   r   r   r   r   r   batch1_shapebatch2_shaper  ro  Zis_broadcastingZbeta_complexZalpha_complexr   r   r   sample_inputs_addbmm  s&    
 
 r  c           
   	      s  t t ft t ft t ffdft t ft dfdt ffdfdt t dfdt ffdfdt t fddfdfdt t dfdt ffdfg}g }|D ]\}}t fdd|D }	|t|	d	 |	dd  |d
 t fdd|D }	|t|	d	 |	dd  tdd|d qzt|S )NFr   r   T)r   r   r   Fr   c                 3   s.   | ]&}t |tr"t| d dn|V  qdS T)r   r   r   rO  Nr  r   r   rJ  argr   r   r   rL  7  s   z0sample_inputs_addcmul_addcdiv.<locals>.<genexpr>r   r\  c                 3   s.   | ]&}t |tr"t| d dn|V  qdS r  r  r  r   r   r   rL  B  s   Q	@valuerj  )r>   r   r   rC   r   )
r   r   r   r   r   r   r  Z
input_argsr]  r   r   r   r   sample_inputs_addcmul_addcdiv)  s6    

 
r  c                 k   s   t | |||f|E d H  | |}tt||d}tjtjftjtjff}d}t	||D ]\\}	}
}|	|ksV|
|krtqVt
|tkr|	tjk	rqV|ddg|d}|ddg|	d}|ddg|
d}|d k	rt|||ft|ddV  qVt|||fdV  qVd S )	Nr   r   )NTFr  r   r'  r   r
  r   rp  rq  yQ	@Gz@r   r   r   r  r   r   )r  supported_dtypesr   r   r   float64
complex128r2  r   r   typecomplexrC   r   )r   r   r   r   r   r  r   typesvaluesZtype2Ztype3r  Zarg1Zarg2Zarg3r   r   r    reference_inputs_addcmul_addcdivL  s:       




r  c                 K   sZ  t t tft t t ft t tfdddfdt t t ft t tfdddft t tft t t ft t tfdddfdt t t ft t tfdddfdt t t ft t tfdddfdt t t ft t tfdddfg}g }|D ]\}}}	}
}}t|||d d |dt|||d d |dt|	||d d |df}|t|d	 |d |d
 ft||
d|d |jr|t|d	  ||d  ||d
  |ft|d |
d d|d q|jrRt t t ft tt ft t tfg}t|d	 ||d d |dt|d ||d d |dt|d
 ||d d |df}|t|d	 	dd|d 
dd ||d
 
dd |ft|d |
d dd t|S )Nr   Fr   Tr  r  r   r   r   r   r  rj  r  r  r   r   )r>   r=   r   r   rC   r   r   r_  r  Z
transpose_	transposer  r   )r   r   r   r   r   r   r  r   r  r  ro  r  r]  r   ra  r   r   r   sample_inputs_baddbmmw  s         

 
   	r  c              	   k   st   t t|||d}tfttff}|D ]L}t||||ddfi dV  t||||ddfd||ddidV  q"d S )Nr   Fr   r   r  rT  )r   r   r   r   r   _make_tensorra  r"  r   r   r   )sample_inputs_multilabel_soft_margin_loss  s    r  c                 k   s  t tttf||d d |dttf||d d |dttf||d d |dfdV  t td||d d |dttf||d d |dttf||d d |dfddV  |jrd\}}n|jrd\}}nd\}}t tttf||d d |dttf||d d |dttf||d d |dft||d	d
V  t td||d d |dttf||d d |dttf||d d |dft||d	ddV  |jr|st tjt	j
gg||dtjdg||dtjdg||dftddd	ddV  t tjdgg||dtjt	j
g||dtjt	j
g||dftddd	ddV  d S )Nr   r   r   Tr\  )y?333333?y?333333?)r  r  r  r  r   rj  r  r
  )rC   r   r>   r=   r   ru  r   r   r   mathr   )r   r   r   r   r   ro  r  r   r   r   sample_inputs_addr  sd    



	
	
r  c                 k   s>   t t|||d}dtttftff}|D ]}t||V  q&d S r   rT  r!  r   r   r   sample_inputs_zero_  s    r  c           
   
   k   s   t t|||d}t |tjdd}d|g dddi ftf|g dtdddiftf|dgdtddd	ifttf|tgdtdd
difttf|tgdtddd iff}|D ] \}}	}t|||	f|dV  qd S )Nr   Fr   r   r   r   r   r   r   pr   marginr'  r  r   r   r   r   longr>   r=   rC   )
r   r   r   r   r   r  make_targetr   r   targetr   r   r   sample_inputs_multi_margin_loss  s    r  c              
   K   s   dt t fddft t fddft t fddft t fddff}g }|tjtjfkrNdnd}|D ]R}|d k	rj|d	 nd }	|D ]4\}
}}t|
||||	|d
}|t|||fd qrqVt|S )N)r   r   Tr   TFr?  r   )Ng     @@g    .Ar,  r   r   r   )r>   r   r   r  r   r   rC   r   )r  r   r   r   r   r   r   Zlowsr   r   r"  r   keepdimr  r   r   r   sample_inputs_logsumexp  s$     r  c           	   
   K   s   di ft t fi fdt dfi ft f||dft fdtjift fddift ftjddfg}tj rv|t fddif g }|D ].\}}t|||d d |d}|t||d	 q~t|S )
Nr   r   r   r   r   r0  cudar   r   	r>   r   doubler  is_availabler   r   rC   r   )	r  r   r   r   r   r   r   r"  r  r   r   r   sample_inputs_like_fns  s&    

 r	  c                 k   s   t | |||f|E d H  d}tt|||d}|D ]T}t||V  t||ddV  t||ddV  t||ddddV  q0d S )N)r   r   r   r   r   r   r   r   )r   r   r   r   )r   r   r   r   r   r  r   r   Tnoncontiguous)r	  r   r   rC   r  )r-  r   r   r   r   r  r   r"  r   r   r   reference_inputs_like_fns5  s    r  c           
      k   s   t t|||d}t |tjdd}g |g dddftg|tgdtdfttg|ttgdtdff}|D ]\}}	t|||	fdV  qdd S )Nr   Fr  r   r   r  r   r  )
r   r   r   r   r   r  r   r   r"  r  r   r   r   $sample_inputs_multilabel_margin_lossE  s    r  c                 C   s   |   | jS r,  )r_  r  r   )r   r   r   r   get_independent_tensorR  s    r  c           	      K   sr   g }d}d}t | |||f|D ]J}|t|j|f|j |jd |tt|j||f|j |jd qt|S )Nr   rh  r   )r	  r   rC   r  r   r   r  r   )	r  r   r   r   r   r   r   r   r  r   r   r   sample_inputs_randint_likeU  s    

r  c              	   k   s   t t|||d}dtfttftttff}d}d}|D ]J}	t||D ]:\}
}|
|d}t||	||	dd||	ddf|dV  qBq4d S )	Nr   r   )r
  r'  summeannone)r  	reductionFr  r   r   r   r>   r   rC   )r   r   r   r   r   r  ra  Zmargins
reductionsr"  r  r  r   r   r   !sample_inputs_margin_ranking_lossg  s"    


r  c           
      k   s  t | |||f|E d H  tt|||d}dD ]}|jr|d}td|d< |d}td|d< |d}	td|d< t|||	fd|id	V  |d}td
|d< |d}td
|d< |d}	td
|d< t|||	fd|id	V  |d}|d}|d}	t|||	fd|id	V  q,d S )Nr   r  rh  r   r   r   r7  r  r   r   r   r   )r   r   )r   r   r   )r  r   r   ru  ry  rC   )
r-  r   r   r   r   r   r  Zinp1Zinp2r  r   r   r   $reference_inputs_margin_ranking_loss|  s,    r  c                 k   sr   t t|tjd}tt|dd|dd|ddfddidtddV  tt|dd|dd|dfd	d
dV  d S )Nr/  r   r   r  r   r   is not a valid valuer   r   z.margin_ranking_loss : All input tensors shouldr   r   r   r   r   rD   rC   
ValueErrorr-  r   r   r   r   r   r    error_inputs_margin_ranking_loss  s    (  r   F)
is_stridedc                K   s
  dddi ft t fddi fdt dfddi ft fdd||d	ft fd
t fdtjift fdt ttfddift fdttt ftjdd	fg}tj r|t fddddif g }|D ]T\}}	}
}t|||d d |d}|r|t	||	|
f|d q|t	||	f|d qt
|S )Nr   rF  r   r   r   r   r   r   r   r  )r   r6  r   r  r   )r   r      r   r0  r   r   r   )r   r   r  r   r   )r>   r   r  r<   r=   r  r  r   r   rC   r   )r  r   r   r   r!  r   r   r   r   r   stridesr  r   r   r   sample_inputs_new_fns  s*    

 r'  c                 k   s.   d}|D ] }|||d}t |d|dV  qd S )N)r   r   r   r   r   r   )r   r   r   )r   r   r   r   r   r   r   rC   )r-  r   r   r   r   r  case_kwargsr   r   r   sample_inputs_empty  s    r,  c           	   
   k   sr   d ddddddt ttf
}t||D ]J\}}|d kr4q"|||d}|d krZt|d|d	V  q"t||f|d	V  q"d S )
Nr   r   r   r   r   r   r   r   r   )r<   r=   r>   r   rC   )	r-  r   r   r   r   r  r  r  r+  r   r   r   sample_inputs_eye  s    r-  c                 k   sX   |t jd}ttdd|dddV  ttdd|dd	dV  ttd
d|dddV  d S )Nr/  r   r   r   z'n must be greater or equal to 0, got -1r   )*   z'n must be greater or equal to 0, got -7r   )rq  z'm must be greater or equal to 0, got -3)r   r   rD   rC   )r   r   r   r+  r   r   r   error_inputs_eye  s    r0  c           	      K   sh   dd }g }t | |||f|D ]@}d|jkr6|jd n|}|t|j|j||f |jd qt|S )Nc                 S   s   t g | dd S Nr0  r   r   itemr  r   r   r   get_val  s    z'sample_inputs_new_full.<locals>.get_valr   r   )r'  r   r   rC   r  r   r   )	r  r   r   r   r   r4  r   r  Z	use_dtyper   r   r   sample_inputs_new_full  s      
r5  c                 K   s   dd }d||i ft t f||i fdt df||i ft f||||dft f|tjdtjift f||ddift f|tjtjddfg}tj r|t f||dd	if g }|D ]4\}}	}t|||d d |d
}
|t|
|	f|d qt|S )Nc                 S   s   t g | dd S r1  r2  r  r   r   r   r4    s    z(sample_inputs_full_like.<locals>.get_valr   r   r   r   r   r0  r  r   r   r  )r  r   r   r   r   r4  r   r   r"  Z
fill_valuer  r   r   r   sample_inputs_full_like  s(    
 r6  c           
      K   s   dgdi fdgdi fddgdi fdgdt ddfdgdt ddfddgdt ddfddgdt ddfg}g }|D ]4\}}}t|||dd |d}	|t|	|f|d	 qpt|S )
Nr   rh  F)replacementTr   r   r   r   )r   r   r   rC   r   )
r  r   r   r   r   r  r   r"  num_samplesr  r   r   r   sample_inputs_multinomial  s"    


 r9  c                    sR    fdd}g }|D ]0\}}	}||}
||	}| t|
|f|d qt|S )Nc                    s"   t | trt|  dd dS | S )Nr   r   )r  r  r   )Zvalue_or_shaper   r   r   get_value_or_make_tensor)  s    
 z=sample_inputs_normal_common.<locals>.get_value_or_make_tensorr   )r   rC   r   )r  r   r   r   r  r   r:  r   Zvalue_or_mean_shapeZvalue_or_std_shaper  stdr   r   r   sample_inputs_normal_common(  s    r<  c                 K   s`   g g i fdgdgi fdddgdddgi fddgdi fdddgdddgi fg}t | ||||f|S )Nr   r   r   r  r   r   r<  r  r   r   r   r   r  r   r   r   !sample_inputs_normal_tensor_first7  s    r?  c                 K   s$   ddgdi fg}t | ||||f|S )Nr   r   333333?r=  r>  r   r   r   "sample_inputs_normal_tensor_secondC  s    rA  c           	   	   K   sP   dgg ddgdddgg}g }|D ]&}t |||dd|d}|t| q t|S )Nr   r   r   r   r   r   )r   r   rC   r   )	r  r   r   r   r   ra  r   r"  r  r   r   r   sample_inputs_bernoulliI  s     rB  c                 k   s<   t jd|dd}d}ttt |d|id|dV  d S )Nr   r  r   unsupported operationoutr   r   )r   r1  expandrD   rC   	rand_like)r   r   r   r   err_msgr   r   r   error_inputs_bernoulliY  s
    rH  c              
   K   s   t t t fdft t t fdfdf}g }dD ]R}|D ]H\}}	t|||d d |d}
|rb|
 dkrbd|
d< |t|
|	fd q.q&t|S )Nr   r   r   r   TFr   r  r   )r>   r   r   r   rC   r   )r  r   r   r   r   r   r   Zlarge_numberr"  r   r  r   r   r   sample_inputs_logcumsumexp`  s      rK  c              	   K   s   t tttf||d d |dfS Nr   r   r  r   r   r   sample_inputs_tracet  s
     rM  c                 c   s"   t ttdtj|dddV  d S )Nr   r   r   r   zexpected a matrixr   )rD   rC   r   r   r   )r-  r   r   r   r   error_inputs_tracez  s    rO  c           	      k   sr   t t|||d}tttfdftttfdftttfdftttftdddfff}|D ]\}}t|||dV  qRd S )	Nr  )r   r   r   )r   r   r   r   r   r   r   r   )r   r   r>   ry  rC   	r  r   r   r   r   r   r  r"  r   r   r   r   sample_inputs_renorm~  s    rQ  c           	   
   k   sZ   t t|||d}ddddddttfdftttfd	ff}|D ]\}}t|||d
V  q:d S )Nr  )r   )r   r   )r   r   r   )r   )r   r   )r   r   )r   r   r   )r   rS  r   rF  r   r  rP  r   r   r    sample_inputs_transpose_swapdims  s    
	rT  c                 C   s   | j dkr| S t| ||S r   )ndimnpswapaxes)r   Zdim0dim1r   r   r   _numpy_ref_transpose  s    
rY  c              	      sJ   t t|||d ddttftttftttfttttff} fdd|D S )Nr  r   r   c                 3   s   | ]}t  |V  qd S r,  r)  rJ  r"  r   r   r   rL    s     z(sample_inputs_adjoint.<locals>.<genexpr>)r   r   r=   r>   r  r   r   r   r   ra  r   r[  r   sample_inputs_adjoint  s    (r]  c                    s.   t t|||d dttff} fdd|D S )Nr  r   c                 3   s   | ]}t  |V  qd S r,  r)  rZ  r[  r   r   rL    s     z"sample_inputs_T.<locals>.<genexpr>)r   r   r=   r\  r   r[  r   sample_inputs_T  s    r^  c                 k   s   ddddg}dddg}t |||D ]f\}}}	ttdt||	D ]F}
t|||
f|||d	}t||	|
f|||d	}t||f|d
V  q@q"dS )z
    This function produces two tensors of shape (*, m, k) and (*, n, k) with k <= min(m, n).
    Their matrix product could be used to generate tensor of shape (*, m, n) of rank k.
    r   r   r   rC  r   r   rh  r   r  r   N)r   rk  minr   rC   )r   r   r   r   r   batchesr  batchr  r  r  r   r   r   r   r   %sample_inputs_singular_matrix_factors  s    
rb  c                 k   s   t | |||f|D ]j}|jj^ }}}|jd j^ }	}
}	|d d}t|f|V  t|||
f|||d|d< t|f|V  qd S )Nr   )qr=   r  r=   )rb  r  r"  r   rk   r   )r   r   r   r   r   r  ra  r  r  _r  r%  r   r   r   sample_inputs_svd_lowrank  s    
re  c                 c   s(   t | }tt||}|sq$|V  qd S r,  )iterr   r   )iterabler  itchunkr   r   r   
chunk_iter  s
    rj  c                 k   sZ   t | |||f|}t|dD ]8\}}|jd= |jd= d|jd< d|jd< |V  |V  qd S )Nr   r=   FcenterT)re  rj  r   )r   r   r   r   r   r   s1s2r   r   r   sample_inputs_pca_lowrank  s    

rn  c                 C   s,   | j tjkrt| tjS t| S d S r,  )r   rV  float16sincastyper   r   r   r   r   np_sinc_with_fp16_as_fp32  s    rs  c                    sr   t ddft t t fft dt ft t t fft dft t t ffdt t t ffdt fddt ffddf}t fdd|D S )Nr   r   r[  r   r   r   r   c              
   3   s0   | ](\}}t t| d d d|fdV  qd S r  rC   r   )rJ  r  r"  r   r   r   rL    s
   z-sample_inputs_broadcast_to.<locals>.<genexpr>)r>   r   )r   r   r   r   r   r   r   r   r   sample_inputs_broadcast_to  s    
rw  c           	   	      sR   t t|||d d}g }|D ]0^}}|t |t fdd|D d q|S )Nr  ))r   r   r   r   rC  )r   r   r   c                 3   s   | ]} |V  qd S r,  r   rJ  sr[  r   r   rL  
  s     z2sample_inputs_broadcast_tensors.<locals>.<genexpr>r   )r   r   r   rC   r   )	r   r   r   r   r   r   r   r"  other_shapesr   r[  r   sample_inputs_broadcast_tensors  s    *r|  c                 k   s   t | |||f|E d H  tt|||d}tt|||dd}d}|D ]T\}}	}
}t||||	||
||fdV  t||||	||
||fdV  qBd S )Nr  Tr   r   r   r  ))r   rC  )r   r   r   r   r   r   r   )r   r   r   )r   r   r   r   )r   r   r   r   r   )r6  r   r   r   r   )r|  r   r   rC   )r-  r   r   r   r   r  r  r  r   r   r   dr   r   r   "reference_inputs_broadcast_tensors  s    $r  c              	      s   t t|||d dtfdtfdtfftdftdftdffddtftfff}g }|D ]^}}|t |t fdd|D d |tjks|tjkrR|tjkrtj	ntj
}	t t|	||d}
|t|
|t fd	d|D d qR|S )
Nr  r   r   r   )r   r   r   c                 3   s   | ]} |V  qd S r,  r   ry  r[  r   r   rL  (  s     z+sample_inputs_block_diag.<locals>.<genexpr>r   c                 3   s   | ]} |V  qd S r,  r   ry  r[  r   r   rL  -  s     )r   r   r>   r   rC   r   r   	complex32	complex64r   r  )r   r   r   r   r   r   r   r"  r{  Znon_complex_dtypeZmake_arg_non_complexr   r[  r   sample_inputs_block_diag  s    (*r  c                 K   s  d}t t dft t d dfft t ft t fft t t ft t t ffddddt dffddd	d
dd|||d df|||d dff|dd|fd||ffdd|f|d||fff}g }dD ]`}dddddddtdfD ]B}	|D ]8\}
}|tt|
|||dt||||d|	|fd qqq|S )Nr   r   )r   r   r  )r   r   r   r  )r   r   rC  )r   r   r   r   )r  r  )r   r   r   r  )r  r   r   r   )r  r(  )r   r   r   r  )Zuse_mm_for_euclid_distZdonot_use_mm_for_euclid_distr
  r'  r  r  r   rA        @r   r  r   )r>   ry  r   rC   r   )r   r   r   r   r   Zsmall_Sr   r   cmr  Zt1_sizeZt2_sizer   r   r   sample_inputs_cdist1  s6    
r  c           	      k   s\   t t||d d |d}tttfdfdtttf|dfff}|D ]\}}t|||dV  q<d S )Nr   r   )r   r   r   r   rT  	r   r   r   r   r   r   r  r"  r   r   r   r   sample_inputs_fill_U  s      r  c                 C   s   |   } | | | S r,  )copyfill)r   r  r   r   r   _fill_np`  s    
r  c              	   C   s*   | d }t   || W 5 Q R X |S )NF)r   Zno_gradfill_)r   r  r  r   r   r   
_fill_atene  s    
r  c                 C   s$   |t jkrd}nd}d|id|ifS )NTr   r  )r   rt  )r   r   r  r  r   r   r   _fill_sample_kwargsk  s    
r  c                 k   sL   t | |||f|E d H  tt|||d}|ttf}t|| fdV  d S Nr   r   )rW   r   r   r>   rC   r_  )r-  r   r   r   r   r   rd  r   r   r   sample_inputs_comparison_opss  s    r  c                 k   sn   t t|||d}d}|D ]P\}}g }	t|D ]}
|	|| q,tdt|d D ]}t|	|fdV  qRqd S )Nr   ))r"  r   ))r   r   r   r   r   ))r   r   r   r   r   r   r   )r   r   rk  r   r  rC   )r   r   r   r   r   r   r  r"  Znum_tensorstensorsrd  r   r   r   r   sample_inputs_stack|  s    r  c           	   	   k   s   t t|||d}ttfttfddifttfttfddifttfttfddifddddifddddifdtfttfddifd	d	i ff}|D ]$\}}}t||||g|d
V  qd S )Nr   r   r   r   r   r   r   r   r   r   r  )	r   r   r   r   r   r   r  Zinput_shape1Zinput_shape2r   r   r   sample_inputs_cat_concat  s    
r  c                 k   s,  t t|tjd}tt|ttf|ttfgd|dtfdt tfidddV  ttg ddidd	dV  tt|ttttf|td
td tfgddidddV  tt|td
td tf|ttttfgddidddV  tt|td d
f|td
td tfgddidddV  tt|td
td tf|td d
fgddidddV  tj	d
|d}tj
d|d}d}tt||fd
|dd|dV  tt||fd
|dd|dV  tj	d|d}tt||fd|d dd d f id|dV  t|jdkr:td|tjd}tddtjd}	tt||	fddV  tt|tdf|tddf|tddfgddV  tt|tdtf|tddf|ttdfgddidddV  tt|tddfd ftddV  tt|d|dgddV  td|tjd}
td|tjd}tt|d|
idtddV  d S )Nr/  rD  r   r   r   rC  r   r   znon-empty list of Tensorsr   z/Sizes of tensors must match except in dimension+Tensors must have same number of dimensionsr  )r   r   z7the written-to tensor refer to a single memory locationr   rD  r  r   r0  -Expected all tensors to be on the same devicezSizes of tensors must matchzgot Noner   r   z(zero-dimensional.*cannot be concatenatedr  z invalid combination of arguments)r   r   r   r   rD   rC   r>   rE  r<   r  randnr   r  r=   r   r  )r   r   r   r   r   r   rG  zZx_cudaZy_cpur  r   r   r   error_inputs_cat  sv    0000$**r  c           	      k   s   t | |||f|E d H  tt|||d}|d}|ddtjd}|dtjddd	d
}t|||fddidV  |d}|d}t|||fV  t|||fV  d S )Nr   r   r   r   r#  T)r  r   r   r   r   r  r   r   r   r   r   r   )r  r   r   r   r  ro  permuterC   )	r-  r   r   r   r   r   r   r   r   r   r   r   reference_inputs_cat  s    r  c                    sH   dd  t |d }t fdd|D }tjj|d| i\}}t| S )Nc                 S   s   t | tjrt| S | S r,  )r  rV  ndarrayr   
from_numpyrr  r   r   r   _maybe_torch  s    
z0_elementwise_type_promo_np.<locals>._maybe_torchr   c                 3   s   | ]} |V  qd S r,  r   rJ  r   r  r   r   rL    s     z-_elementwise_type_promo_np.<locals>.<genexpr>type_promotion_kind)r:   r   primsutilsZelementwise_dtypesr6   )r  r   Z	flattenedZtransformedresult_dtyperd  r   r  r   _elementwise_type_promo_np  s    
r  c                 C   sL   t dd | D }t|dkr>t| tjjjd}tjd|dS tj	||dS )Nc                 s   s&   | ]}|j d kr|jdks|V  qdS )r   r   N)rU  r  r  r   r   r   rL    s     
 
 z_cat_np.<locals>.<genexpr>r   r  r  axis)
r   r  r  r  r  ELEMENTWISE_TYPE_PROMOTION_KINDZ	NO_OPMATHrV  emptyconcatenate)Z	input_seqr   r   Znp_dtyper   r   r   _cat_np  s    r  c                 C   sL   t | |tjjjd}t| tjr*| |} t|tjr@||}t	| |S )Nr  )
r  r  r  r  DEFAULTr  rV  r  rq  floor_divide)r   r   r   r   r   r   _floor_divide_np  s    

r  c                 k   sj   t t|||d}tftftffttfttfttfff}|D ]*\}}}	||||||	f}
t|
V  q:d S Nr  rT  )r   r   r   r   r   r   tensor_shapesrl  rm  s3r  r   r   r   "sample_inputs_hstack_dstack_vstack  s    r  c                 c   sx   t ttj|dd}tfttttftfff}|D ]2\}}}||||||f}tt|ddV  q.ttdddV  d S )NFr  r  r   r   zexpects a non-empty TensorList)r   r   r   int32r>   rD   rC   )r-  r   r   r  rl  rm  r  r  r   r   r   !error_inputs_hstack_dstack_vstack#  s    r  c                 k   sp   t fdft t fdft t fdft t fdft dt fdft t t fdff}|D ]$\}}tt||||d|fdV  qFd S )Nr   r   r   r  r   )r>   rC   r   )r   r   r   r   r   Z
shape_dimsr"  r   r   r   r   sample_inputs_unbind0  s    



r  c                 c   sN   t ttj|dd}tt|dddtddV  tt|dddtd	dV  d S )
NFr  r   r   r   z5Dimension specified as 0 but tensor has no dimensionsr   r   Dimension out of range)r   r   r   r  rD   rC   
IndexError)r   r   r   r   r   r   error_inputs_unbind@  s    r  c                    s&   t  fddt| | j   D S )z&A numpy implementation of torch.unbindc                 3   s   | ]}|  V  qd S r,  )squeezery  r   r   r   rL  I  s     z#reference_unbind.<locals>.<genexpr>)r   rV  splitr"  )r  r   r   r  r   reference_unbindG  s    r  c                 K   s   t tttf||d d |ddtttfdtd|dfdt tttf||d d |ddtttd fdtd|dfdt td||d d |ddtjdgtj|d	fdt ttf||d d |ddtjg tj|d	fdt td||d d |ddtjdtj|d	fdfS )
Nr   r   r   Tr  r   r   r   r   )	rC   r   r=   r>   gather_variabler   r   int64r  r   r   r   r   sample_inputs_gatherK  s*    r  c                 C   s   t |dkrdn|D ]t}t |dkr&dn|D ]Z}t |dkr>dn|D ]@}	|||	g}
td| |d |
|< t|d| | t|
< qDq,qd S )Nr   r   r   )rk  slicer  r   randpermr   )idxr   dim_sizeZelems_per_rowr  r  orl  jr  iir   r   r   _fill_indices_  s    
r  c           
      k   sT  t jd|t jd}t jd|t jd}td|t jd}tt|d|fdddV  |t j}tt|d|fdd	dV  t jd|t jd}t jd|t jd}t j	d
|t j
d}tt|d|fd|idddV  t jd|t jd}t jd|t jd}tt|d|fdddV  t jd|t jd}t jd|t jd}tt|d|fdddV  t |jdkrt jd|t jd}t jd|t jd}tt|d|fdddV  t jd|dd}t jd|d}t jdddg|t jd}	tt|d|	ft|ddtddV  tt|d|	ft|ddtddV  tt|	 d|	dd  ft|	d d ddtddV  d S )N)r   r"  r/  )rS  r
  rC  r   r   z"Size does not match at dimension 0r   Expected dtype int64 for indexr   rD  r   z!Expected out tensor to have dtyperS  z4Index tensor must have the same number of dimensionsr   r   r0  ))r      r
  z'index 23 is out of bounds for dimensionr   r  r   r   r   rD  rC  r   )r   r   r   r  r   rD   rC   r3  r  r  r  r   r  r1  rE  r  r   rx  r_  )
r   r   r   srcr  Zbad_srcZbad_idxrD  r   indr   r   r   error_inputs_gatherg  s^    ,r  c                 k   s   t jd|dd}t jd|d}t jdddg|t jd}tt||ft|d	d
tddV  tt||ft|d	d
tddV  tt|	 |dd  ft|d d d	d
tddV  d S )Nr   r  r   r   r   r   r   r/  r  r   rC  r   r   )
r   r1  rE  r   r  rD   rC   r   rx  r_  )r   r   r   r   r  r  r   r   r   error_inputs_take  s    *r  c                 k   s  t d|tjd}tjd|tjd}tjd|tjd}tt|d||fdddV  t d|tjd}tjd|tj	d}tjd|tjd}tt|d||fdd	dV  t d|tjd}tjd|tjd}tjd
|tjd}tt|d||fdddV  t d|tjd}tjd|tjd}tjd|tjd}tt|d||fdddV  t
|jdkrt d|tjd}tjd|tjd}tjd|tjd}tt|d||fdddV  d S )N)r   r   r/  )r   r   r  r   r   z,Expected self.dtype to be equal to src.dtyper   r  )r   r   r   zCIndex tensor must have the same number of dimensions as self tensor)r   r   r   ))"   r   r   zBIndex tensor must have the same number of dimensions as src tensorr0  z5index 34 is out of bounds for dimension 0 with size 3)r   r   r   r   r  r  r  rD   rC   r  r   r  )r   r   r   r  r  dstr   r   r   $error_inputs_scatter_and_scatter_add  s>    r  c                 k   s*   t jd|d}tt|ddtddV  d S )Nr   r  )r   r   r'  r   z-needs at least 2 dimensions, got 0 dimensionsr   r   r  rD   rC   rx  r   r   r   zero_dr   r   r   error_inputs_renorm  s    r  c           	      k   s   t jd|d}tt|||fdtddV  t jdd|d}t jdd|d}t jd	d|d}d
}d
}tt|||||fdtddV  d S )Nr   r  r   z%input must have at least 2 dimensionsr   r   r   r   r   r   r   Tz?tau.shape\[-1\] must be less than or equal to input.shape\[-1\])r   r  rD   rC   rx  full)	r   r   r   r  Ztensor_0Ztensor_1Ztensor_2Zbool_3Zbool_4r   r   r   error_inputs_ormqr  s    r  c                 k   sT   t jd|d}tt|ddtddV  t jddd|d}tt|ddtddV  d S )Nr   r  r   r   zmatrix or a vector expectedr   r   r  r  r   r   r   error_inputs_diag  s    r  c                 k   sb   t jdd|d }t jd|dt jd|ddddg}|D ]}tt||fdtddV  q>d S )Nr   r  r'  r   r   z'weight' must be 2-Dr   )r   r1  r  r   reshaperD   rC   rx  )r   r   r   indicesr  r  r   r   r   error_inputs_embedding  s    r  c              	   k   s&   t ttjdddd|dddV  d S )Nr   r   r   r   r  zexpects a tensor with <= 2r   )rD   rC   r   r  )r   r   r   r   r   r   error_inputs_t		  s    r  c                 k   s>  t jdddt j|d}tt|ddddV  t jddt j|d}tt|ddd	dV  t jddt j|d}t jddt j|d}tt|dt|d
dddV  t jdt j|d}tt|ddddV  t jdt j|d}tt|ddddV  t jdt j|d}tt|ddddV  t jdt j|d}tt|ddddV  ddtdfdt dfddtff}d}d}t 	|j
dkrzdnd}|D ]}	d|	d}|D ]0}
ttt |
|d|	dkr|n|dV  qt jd|d}tt||d|dV  t jdd|d}tt||d|dV  d|dd d f< tt||d|dV  qd S ) Nr   r   r   r   r   r   zprob_dist must be 1 or 2 dimr   z9multinomial only supports floating-point dtypes for inputr  r   z#multinomial expects Long tensor outr   z#cannot sample n_sample <= 0 samplesr>  )r   Fz"cannot sample n_sample > prob_disti  r   z"number of categories cannot exceed)r'  r  r'  r'  z>probability tensor contains either `inf`, `nan` or element < 0z invalid multinomial distributionr0  FTF)r8  r7  r   Fr  )r   r  r  rD   rC   r  r   r   r   r   r  r   r  )r   r   r   r   r   r   r   r   Zrep_argrepr"  r   r   r   error_inputs_multinomial	  sf     
r  c              	   k   s  t jt jt jfD ]t}t jdddgdddgddd	gg||d
}d}dg}tt|t||dddtddV  tt|tdddtddV  d}d}tt|t||dddtddV  d}t jdddgddt jdddgddg}tt|t||dddtddV  tt|tdddt	ddV  t dgdgdgg}tt|tdddtddV  t ddgddgg}tt|tdddtddV  qd S )Nr   r   r   r   r   r   r   r6  r7  r/  r
  r   )spacingr   
edge_orderr   z<torch.gradient expected spacing to be unspecified, a scalar r   )r  z;torch.gradient only supports edge_order=1 and edge_order=2.rC  z0dim 1 appears multiple times in the list of dimsr   r0  r  metaz=torch.gradient expected each tensor to be on the same device,r   z:torch.gradient expected each dimension size to be at least)
r   r  r   r  r   rD   rC   r   rx  r  )r   r   r   r   r  r   r  coordinatesr   r   r   error_inputs_gradientL	  sL    (( r  c                 k   s4   t ttf|tjd}tt|ddddddV  d S )Nr/  r@  r   )lowerupperr   z;Lower bound should be less than or equal to the upper boundr   )r   r>   r   r   rD   rC   )r   r   r   r  r   r   r   error_inputs_rrelus	  s    r  c                 k   s   t jd|dd}t jd|d}t jddddddg|d}tt||ft|ddtd	d
V  tt||ft|ddtd	d
V  tt| |ft|ddtd	d
V  d S )Nr   r  r   r   TFr  r   rC  r   )	r   r1  rE  r   rD   rC   r   rx  r_  )r   r   r   r   r   maskr   r   r   error_inputs_masked_selectx	  s    r  c                 k   s`   t jd|dd}t jd|d}t jddgt j|d}tt|d|ft|dd	td
dV  d S )N)r   r   r  )r   r   )r   r   r   r   r   r  r   rC  r   )	r   r1  rE  r   r  rD   rC   r   rx  )r   r   r   r   r   r  r   r   r   error_inputs_index_select	  s    r  c                 k   sL   d}t jdd|dt jdd|dg}|D ]}tt||fdtddV  q(d S )	Nr   r   r   r  r   r   r  r   )r   r  rD   rC   r  )r   r   r   r   Zsrcsr  r   r   r   error_inputs_logcumsumexp	  s     r  c                 K   s  t tttf||d d |dtttfdtd|ddfdt tttf||d d |dtdtd fdtd|ddfdt tdtf||d d |dtttd fdtd|ddfdt tttf||d d |dtttd fdtd|dfdt tttf||d d |dtttd fdtd|dfdfS )Nr   r   Tr  r   r   r   )rC   r   r>   r  r   r   r   r   sample_inputs_take_along_dim	  sH         r  c                 k   s  t dt f}d}d}| jdkr:tttj||d|dV  n&| jdkr`tttj||d|dV  dgd	 }d
}tttj||dddid|dV  tttj||dddid|dV  | jdkrddg}d}	tjt t t t |d}
|D ]}tt|
d|id|	dV  qtjtttj|d}tj	ttj|d}tj	ttj
|d}tj	ttj|d}d}d}| jdkrtt|d|dd|dV  n,| jdkrtt|d||fdd|dV  d}d| jkrtnt}tttj||dddid||dV  d S )Nr   r  zOcannot compute aminmax over an empty dimension as the operation has no identity)amaxamin
_refs.amax
_refs.aminr  r   )aminmaxr   A   z-only tensors with up to 64 dims are supportedr   r   r   @   rS  )r   r~  zin the list of dimsr   z-Expected the dtype for input and out to matchz?Expected out tensor to have dtype float, but got double insteadr  refsr   )r>   rK  rD   rC   r   r1  r  r<   r   r  r  intr  rx  )r   r   r   r"  Zerr_msg_amax_aminZerr_msg_aminmaxr  r   dimsr   r   r   Zinput5Z
max_valuesZ
min_valuesZillegal_valuesZerr_msg_amax_amin2Zerr_msg_aminmax2r   r   r   r   r   error_inputs_aminmax_amax_amin	  sR    




 r  c              
   K   s   t t t fi ft t t fddift t t fdddfdddifdi fddddff}g }|D ]&\}}|tt||||d|d qV|S )	Nr   r   T)r   r  r   r   r  r   )r>   r   rC   r   )r   r   r   r   r   r   r   r"  r   r   r   sample_inputs_aminmax	  s    
	
r  c                 K   s  t t|||d}dtfdd d ftdfdd d ftdfdd d fttfdd d fttfdd d fttfddtfdtffttfdd dtfftttfdd d ftttfdd d ftttfdtdtftdtfftttfdttdfttdfftttfdtttftttfff}g }|D ]\}}	}
}|
d krdn|
|	 }|d kr.dn||	 }||	 | | }t|D ]L}||}|
rh||
nd }|rz||nd }|t|||	||fd qNq|t|tttftd dfd |t|tttftd d d|tttf|tttffd |S )Nr  )r   r   NNr   r   r   r   r   )r   r   r>   r?   rk  r   rC   )r   r   r   r   r   r   r   r  r  r   Zsize_prependZsize_appendZprepend_sizeZappend_sizer  r  input_tensorprependr   r   r   r   sample_inputs_diff	  s8     $@r  c              
   K   s   t t|||d}dtfttftttftdtftdtff}g }t|tddddgddgD ]n\}}	}
}||}|
rx||nd }|t||	ft||dd	 ||	d f}|t||ft||dd	 qX|S )
Nr  r   r   r   r   FTr  densityr   )r   r   r>   r   rk  r   rC   r   )r   r   r   r   r   r   r  r  r  bin_ctweightedr  r	  r*  bins_tensorr   r   r   sample_inputs_histogram
  s    ((


r  c              
      s   t t|||d ttftttftdtftdtff}d}g }t||ddgddgD ]\}}	}
} |}|	d |d  }|
r |d d nd }|t||ft||dd	  fd
d|D }|t||ft||dd	 qP|S )Nr  r   r   ))r   r   r   r   r   )r   r   r   r   r   )r   r   r   r   r   FTr   r  r   c                    s   g | ]} |d  qS r   r   )rJ  ctr[  r   r   
<listcomp>A
  s     z-sample_inputs_histogramdd.<locals>.<listcomp>r   r   r>   r   r   rC   r   )r   r   r   r   r   r  Zbin_ct_patternsr  r  Zbin_ct_patternr  r  r	  r  r*  r  r   r[  r   sample_inputs_histogramdd2
  s     ""


r  c                 K   s   t t|||d}dtfttftttftdtftdtff}g }t|ddgddgD ]R\}}	}
|t||t|	|
dd d	D ]$}|t||t||	|
d
d q|qP|S )Nr  r   r   r   r   rh  )r_  maxr   )r   r   rh  )binsr_  r  r  )r   r   r   r   r   r   r  r  r  r_  r  r  r   r   r   sample_inputs_histcG
  s    (
r  c              
   K   s   t t|||d}g }tttfddgD ]t\}}tjd||f||d}	|rR||fnd }
t|	 	 }d|d |d| fD ]}|
t|	t|
|dd qzq&|S )	Nr  FTr   r   r   )r  	minlengthr   )r   r   r   r>   r=   r   randintr  r  r3  r   rC   r   )r   r   r   r   r   r   r  r  r  r	  r*  max_valr  r   r   r   sample_inputs_bincountY
  s    
r  c              
   K   s   t t|||d}dtfttftttftdtftdtff}g }t|ddgddgD ]>\}}	}
||}|tf }|t||ft|	|
dd qP|S )	Nr  r   r   r   FT	out_int32rightr   )r   r   r>   r   msortr   rC   r   )r   r   r   r   r   r   r  r  r  r  r  r	  Z
boundariesr   r   r   sample_inputs_bucketizej
  s    (

r!  c                 K   s0  t t|||d}dtfdttfdtttff}g }t|ddgddgddgD ]\}}	}
}|||	d}|||	d}t|dkr|}t|tj||	d	}nt|\}}|rd
nd}|t	||ft
|
|dd |t	||ft
|
|dd |t	||ft
|
||dd |t	||ft
|
||dd qJ|S )Nr  r   rS  r   r   r   FTr  r   )r   r   r  r  leftr  r   )r  side)r  r  sorter)r  r$  r%  )r   r   r=   r   rV  r   r  sortr   rC   r   )r   r   r   r   r   r   r  r   r  r  r  r  Zunsorted_tensorr	  Zboundary_tensorr%  r$  r   r   r   sample_inputs_searchsortedz
  s(    &r'  c              
   K   s  g }t fd d dft fdd dft t fd d dft t fddgd dft t fddgddfdddgddff}|D ]<\}}}	}
t|||d d |d}|t|t|	||
d	d
 qdd}|D ]h\}}}	}
t|||d d |d}g }|D ]"}tj||d}||| q|t|t|	||
d	d
 qt|S )Nr   r  r   g @r   r   r   r   r'  r   )r   r  r  r   ))r   r   r   ))r  r  g      @)g      @r         @r   r   r   )r)  ))r'  r  r  )g       @r*  r'  r   r   r  )	r>   r   r   rC   r   r   r   r3  r   )r   r   r   r   r   r  Ztest_cases_floatr  r  r   r  r  Ztest_cases_tensorr  Zcoordinates_tensor_listZcoordsr   r   r   r   sample_inputs_gradient
  s(    r,  c                 k   s  t t|||d}ddgftddftdddgfdddgdddgdddggfdddgdddgdddggftd td ddggftd ddgtd gfddgtd td gfddgddgtd gfddggfddgtd gfddgtgfdddgdddgtdddggftdt|dfttffg}|D ]}t	|tttf|dV  q(t	|ttttftd ddgtd ddggfdV  d S )Nr  r   r   r   r   r  r   )
r   r   r  Ellipsisr   Z
LongTensorindex_variabler>   mask_not_all_zerosrC   )r   r   r   r   r   r   Z	test_argsr   r   r   r   sample_inputs_getitem
  s(    

"
r0  c           	   
   K   s   t t|||d}g }dD ]}|t|ttftdt|df|dtfft|dd |rjtjttj	dnt
tf}|t|ttf|f|tfft|dd q|S )Nr  r  r   r  )
accumulater   r  )r   r   r   rC   r>   r.  r   r   r  rt  r/  )	r   r   r   r   r   r   r   r1  r  r   r   r   sample_inputs_index_put
  s    


r2  c              
      sX   fdd} fdd}g }| t|  tdd}ddg}	t||	|	D ]P\}
}}| t| |
|fd	 t jd
krR| t| t|
||dd qR| ttjd d | ttjd ddd	 | ttjd ddd	 | t| tddd | t| tdddd | t| tddddd |S )Nc                     s8   t jtt t t j dttt} | } | S Nr   )r   r  r>   r  viewr3  r  resr   r   r   small_3d_unique
  s    $z+sample_inputs_sort.<locals>.small_3d_uniquec                     s.   t jtt t t j d} | } | S r3  )r   r  r<   r  r3  r  r5  r   r   r   large_1d_unique
  s    z+sample_inputs_sort.<locals>.large_1d_uniquerq  r   TFr   r0  )r   
descendingstabler   r   r  r   r   Tr:  r   )r   r:  )	r   rC   rk  r   r   r   r  r   r   )r   r   r   r   r   r7  r8  r   r  flagr   r9  r:  r   r   r   sample_inputs_sort
  sB    





r>  c           	      K   sd   t t|||d}dtfttftttff}g }|D ].}|t|||d |d fd q0|S )Nr  r   r   )r   r   r>   r   rC   r3  )	r   r   r   r   r   r   r  r   Zx_sizer   r   r   sample_inputs_threshold  s    ,r?  c                  O   s   dd t | |D S )Nc                 S   s   g | ]}d |j kr|qS r<  r   )rJ  sample_inputr   r   r   r    s     
 z)sample_inputs_argsort.<locals>.<listcomp>)r>  r   r   r   r   sample_inputs_argsort  s    rA  c                 K   s6  dt ft t ft t t ft dt ft dt ff}g }t|ddgddgddgd dddddgD ]\}}}	}
}d|krz|d|k	rzqT|d k	r|t| k sT|t|krqTt||	|
|d	}tj||||d
}|t||	 d t
|tj|dd
||}|t||	 d t
||||d
}|t||	 d qT|S )Nr   r   r   FTr   r   r   )sortedreturn_inversereturn_countsr   r  r   )r>   r   indexr  r   r   r  r   rC   r  r   rt  r3  r  )r   r   r   r   r   r  r  r"  rB  rC  rD  r   r   r   r   r   sample_inputs_unique  s(    (&"rF  c                  o   s0   t | |D ] }|jd s
|jd |V  q
d S )NrB  )rF  r   pop)r   r   r@  r   r   r    sample_inputs_unique_consecutive7  s    
rH  c           	      k   sV   t t|||d}d}|D ]8\}}t|||fdV  t||dd  |fdV  qd S )Nr   )))r   r6  r6  r  )r   r6  r6  r   )rI  r   r   r   r   	r   r   r   r   r   r   r  r   output_sizer   r   r   !sample_inputs_adaptive_avg_pool1d=  s
    rL  c           	      k   sV   t t|||d}d}|D ]8\}}t|||fdV  t||dd  |fdV  qd S )Nr   )))r   r6  r6  r6  )r   r   ))r   r6  r6  r6  )Nr   )r   r6  r   r   )r   N)rM  NN)rM  r   r   r   r   rJ  r   r   r   !sample_inputs_adaptive_avg_pool2dM  s
    rO  c           	      k   sV   t t|||d}d}|D ]8\}}t|||fdV  t||dd  |fdV  qd S )Nr   )))r   r6  r6  r6  r6  )r   r   r   )r   r6  r   r   r   NNN)rP  r}  )r   r   r6  r6  r   )r   r   N))r   r   r6  r6  r   )r   Nr   )rR  Nr   r   r   r   r   rJ  r   r   r   !sample_inputs_adaptive_avg_pool3d`  s
    	rT  c           	      k   sp   t t|||d}d}t|dD ]L\}}t||d |d |fdV  t||d dd  |d |fdV  qd S )Nr   ))r   r   r   r   )rU  r   rJ  r   r   r   r   r   r   rC   	r   r   r   r   r   r   r  ra  Z
return_idxr   r   r   !sample_inputs_adaptive_max_pool1ds  s
    rX  c           	      k   sp   t t|||d}d}t|dD ]L\}}t||d |d |fdV  t||d dd  |d |fdV  qd S )Nr   )))r   r   r   r   r  )r   r   r   r   )Nr   )rY  rC  )r   r   r   r   r   N)rZ  rN  )rZ  r   rJ  r   r   r   rV  rW  r   r   r   !sample_inputs_adaptive_max_pool2d  s
    r\  c           	      k   sp   t t|||d}d}t|dD ]L\}}t||d |d |fdV  t||d dd  |d |fdV  qd S )Nr   ))r   r   r   r   r   rQ  )r]  r}  )r   r   r   r   r   )r   r   N))r   r   r   r   r   )r   Nr   )r^  rS  rJ  r   r   r   rV  rW  r   r   r   !sample_inputs_adaptive_max_pool3d  s
    
r_  c                   @   s,   e Zd Zdd Zdd Zdd Zdd Zd	S )
_TestParamsMaxPoolBasec                 C   sD   dgdd gddgddgdgddgd| _ ddd gdgddgg| _d S )	Nr   r   TFr   r   )kernel_sizer   	ceil_modepaddingdilationreturn_indicesr   )r   ra  r  r   r   r   __init__  s    
z_TestParamsMaxPoolBase.__init__c                 c   s^   t | j D ]N}|d d kr&|dd  }|tjfV  t| jdkr
t|dkr
|tjfV  q
d S )Nr   r   r   )r   ra  r   contiguous_formatr  channels_lastr  r"  r   r   r   
_gen_shape  s    z!_TestParamsMaxPoolBase._gen_shapec                 c   s2   | j  }t| j   D ]}tt||V  qd S r,  )r   keysr   r  r   r  )r  rl  r  r   r   r   _gen_kwargs  s    
z"_TestParamsMaxPoolBase._gen_kwargsc                 c   s   t |  |  E d H  d S r,  )r   rk  rm  rf  r   r   r   gen_input_params  s    z'_TestParamsMaxPoolBase.gen_input_paramsN)__name__
__module____qualname__rg  rk  rm  rn  r   r   r   r   r`    s   r`  c                       s   e Zd Z fddZ  ZS )_TestParamsMaxPool1dc                    s^   t    | jd  dg7  < | jd  dg7  < | jd  dg7  < | jd  dg7  < d S )Nra  r   r   r   rc  r   rd  )superrg  r   rf  	__class__r   r   rg    s
    
z_TestParamsMaxPool1d.__init__ro  rp  rq  rg  __classcell__r   r   rt  r   rr    s   rr  c                       s   e Zd Z fddZ  ZS )_TestParamsMaxPool2dc                    sl   t    | jd  dg7  < | jd  dg7  < | jd  dg7  < | jd  dg7  < | jd	g d S )
Nra  r   r   r   r  rc  rC  rd  r   r   rs  rg  r   ra  r   rf  rt  r   r   rg    s    
z_TestParamsMaxPool2d.__init__rv  r   r   rt  r   rx    s   rx  c                       s   e Zd Z fddZ  ZS )_TestParamsMaxPool3dc                    sf   t    | jd  dg7  < | jd  dg7  < | jd  dg7  < | jdg | jdg d S )	Nra  )r   r   r   r   r   r   r   rd  rx  r   r   rz  rf  rt  r   r   rg    s    
z_TestParamsMaxPool3d.__init__rv  r   r   rt  r   r{    s   r{  c                 k   sf   t t||dd}tttd}|| j  }| D ]0\\}}	}||j|	d|}
t	|
|dV  q0d S )NFr   )nn.functional.max_pool1dnn.functional.max_pool2dnn.functional.max_pool3d)memory_formatr   )
r   r   rr  rx  r{  rK  rn  r3  r  rC   )r   r   r   r   r   r   Zparams_generator_type_dictZparams_generatorr"  r  r  r   r   r   sample_inputs_max_pool  s    r  c              	   k   s8  dD ],}t t|tj|d}|d}tt|dddddd	d
dV  tt|dddddd	ddV  d}tt|d|dddid	|dV  tttjg ||dddid	|dV  tt|d|dddid	|dV  tt|d|dddid	|dV  t|jdkr|sdnd}tt|ddddd	|dV  t|jdkrP|sPdnd}tt|ddddddd	|dV  t|jdkr|sdnd }tt|d!d"ddddd	|dV  t|jdkr|sd#nd}tt|ddid	|dV  t|jdkr|sd$nd}tt|dddd	|dV  qd S )%NrJ  r   r   r   1   r   r  r   Tra  r   rc  re  r   pad must be non-negativer   r   )pad should be at most half of kernel sizezPExpected 2D or 3D \(batch mode\) tensor with optional 0 dim batch size for inputr   r  ra  r   r  )r   rh  )r   rh  r   r0  z+stride must be greater than zero, but got 0zstride should not be zeror)  r   )ra  r   z-dilation must be greater than zero, but got 0z6dilation should be greater than zero, but got dilation)ra  r   rc  rd  z Invalid computed output size: -2zYGiven input size: \(2x1x2\). Calculated output size: \(2x1x-2\). Output size is too smallr%  r   z%kernel_size must be greater than zeroz stride must be greater than zero)	r   r   r   ry  rD   rC   r   r   r  )r   r   r   r   r   r   	error_msgr   r   r   error_inputs_max_pool1d  s    


r  c                 k   s   t t|tjdd}|d}tt|dddddd	d
dV  tt|dddddd	d
dV  tt|dddddd	ddV  tt|dddddd	ddV  d}tt|dddid	|dV  tt|dddid	|dV  d S )NFr   r  r   r  r   Tr  r   r  r   ry  r   r  zPExpected 3D or 4D \(batch mode\) tensor with optional 0 dim batch size for input)r   r   rh  ra  r   )r   r   rh  r   r   r   r   ry  rD   rC   r   r   r   r   r   rG  r   r   r   error_inputs_max_pool2dJ  s2    

r  c                 k   s   t t|tjdd}|d}tt|dddddd	d
dV  tt|dddddd	d
dV  tt|dddddd	ddV  tt|dddddd	ddV  d}tt|dddid	|dV  tt|dddid	|dV  d S )NFr   )r   r   r  r  r   r  r   Tr  r   r  r   r#  r   r  z>Expected input\'s non-batch dimensions to have positive length)r   r   r   rh  ra  r   )r   r   r   r   r   r  r  r   r   r   error_inputs_max_pool3dh  s>    
 
 

r  c              
   k   s   t tdd|||d}ddddfdd	ddfd
dddfddddfddddfddddfdi fdddiff}|D ]\}}t|||dV  qtd S )Nr   r   r   r   r   r   r   )r   r   r   r   r'  r   )r  r   )r   r   r   r   r  )r   r   r   r   r   r   )r   r   r   r   r  r
  r   r  r   -C6?r   r   )r  r   r   r   r   r   r  r   r   r   r   sample_inputs_normalize  s    

r  c                 C   s   t |}|d }	|d }
t |}|d }|d }| |||	||||}| |||
||||}| ||| |	|
 ||||}|| d|| |   S )N).r   ).r                 ?)r   r   )fn
input_sizer  grad_outputr   rc  rd  groupsZgrad_output_Zgrad_output_rZgrad_output_iZweight_Zweight_rZweight_ir   r   r   r   r   r   complex_conv  s    

r  r   c	              
   C   s
  |d k	st tjjjtjjji}	tjjjdi}
t| t| } }t| j	|
| k}|sd| 
d} |d k	r|t|
d}| }||d|dd |||||d}|j	}|	| }|jjrt||||||||}n||||||||}|d k	r|| }|s|dS |S )Nr   r   r   r  r   rc  output_paddingr  rd  )r  r   nn
functionalconv_transpose1dgradZconv1d_inputr  r  r"  	unsqueezer3  r   r   r  r  )r  r  r  r   rc  r  rd  r  r  Zgrad_fn_mapZbatched_dim_mapZ
is_batchedr  Zconv_transpose_outputr  Zgrad_fnrD  r   r   r   conv_transpose_ref  s2    
   r  c           
      k   s   t t|||d}dddddddd	fd
d
dddddddfdddddddddfddd ddddd	fddd i ff}|D ]l\}}}	}t|||||	d k	r||	n|	f|dV  t||dd  |||	d k	r||	n|	f|dV  qvd S )Nr   r   r   r   r)  r   r   r   r   r   r   rc  r  r  r   r   r   r   r  )r   r   r   r   r  )r   r6  r   r   r   
r   r   r   r   r   r   r  r   r  r  r   r   r   sample_inputs_conv_transpose1d  s<    r  c           
      k   s   t t|||d}dddddddd	fd
ddddddddfdddddddddfddd ddddd	fddd ddifddd i ff}|D ]l\}}}	}t|||||	d k	r||	n|	f|dV  t||dd  |||	d k	r||	n|	f|dV  qd S )Nr   r   r   r   r   r   r   r   r   r   r   r   rC  r   r  )r   r   r   r   )r   r   r   r   r  ry  r   r  r   r   r  r  )r   r   r   r   r   r   r   r   r   )r   r6  r   r   r6  r   r   r   r  r   r   r   r   r   )r   r6  r   r   r   r   r  r   r   r   sample_inputs_conv_transpose2d  s>    r  c           
      k   s   t t|||d}dddddddd	fd
ddddddddfdddddddddfddd ddddd	fddd i ff}|D ]l\}}}	}t|||||	d k	r||	n|	f|dV  t||dd  |||	d k	r||	n|	f|dV  qvd S )Nr   )r   r   r   r   r   )r   r   r   r   r   r   r%  r   r}  r   r  )r   r   r   r   r   )r   r   r   r   r   r  )r   r   r   r   r   r   r   r(  r  )r   r   r   r   r   )r   r   r   r   r   r   r   r   r   )r   r   r   r   r   r   r   r   r   r   )r   r   r   r   r   )r   r6  r   r   r   r   r   r  r   r   r   sample_inputs_conv_transpose3d  s<    r  c           
      k   s   t t|||d}dddddddfd	d
ddddddfddd dddfddddddddfddd i ff}|D ]l\}}}	}t|||||	d k	r||	n|	f|dV  t||dd  |||	d k	r||	n|	f|dV  qld S )Nr   r  r)  r   r   r   r   r   rc  r  )r   r   r6  r   r   r   r   r   rc  r  rd  r  )r   r   r   validr   rc  r  )r   r   r   r   same)r   r   r   r   r   r  r   r   r   sample_inputs_conv1d6  s(    
r  c                 k   sH   t jd|t jd}t jd|t jd}d}tt|||ddddV  d S )	N)!   r   r   r  r   r   )r   r   r   r   r  r  r   $non-positive groups is not supportedr   )r   r  r  rD   rC   )rt   r   r   r  r  r  r   r   r   error_inputs_conv1dU  s    r  c                 k   s   t jdd|d}t jdd|d}t jdt j|d}tt|||fddd	V  t jd|t jd
}t jd|t jd
}t jdt j|d}tt|||fddd	V  t jd|t jd
}t jd|t jd
}d}tt|||dddd	V  d S )Nrh  )r   r   r   r   )r   r  r   )r   r   r   r   r   r   zshould be the samer   r  r  )r6  r   r   r   r   r  r   r  )	r   r  r1  r   rD   rC   r  r  r  )rt   r   r   r  r  r  r  r   r   r   error_inputs_conv2d_  s    r  c                 k   s  t t|||d}dddddddfd	d
ddddddfddddddddfddddddddfddd ddddfddddddfdddddddfdddddifdd d!ddifdd d ddifdddddd"fddddd#d$fd%d&dddd'fd(d)d*ddifdd+d i ff}|D ]r\}}	}
}t||||	|
d k	r8||
n|
f|d,V  t||dd  ||	|
d k	rn||
n|
f|d,V  qd S )-Nr   r  r  r   r   r   r   r  )r   r   r6  r6  )r   r   r   r   r   ry  r  r  r  r  )r   r   r   r   r   r  )r   r   r   r   )r   r   r   r   r  r  r  r   )r   rc  rd  )r   r   r   r   )r   r   r   r   r  r  r   r  r6  )r  r   rC  )r  rc  )r   r   r   r   )r   r   r   r   )r  rd  )r   r   r   r   )r   r   r   r   r   )r   r   r   r   r   r   )r   r   r   r   Zjit_fail_sampler   r   r  r   r  r  r   r   r   sample_inputs_conv2ds  sX    



r  c                 k   s   t t|||d}d}|D ]V\}}}	||d }
||d }|	d krL|
|dn
|
||	d}t|||f|dV  qt|ddd	V  d S )
Nr   ))r   r   r   r   r   )r   r   r   r   r@  )r   r   N)r   r   r   Nr   )r  r  )r  r  r   r   r   r   r   r   )rt   r   r   r   r   r   r  r   
num_groupsr   r  r  r   r   r   sample_inputs_group_norm  s    
r  c              	   k   sn  t t|||d}t t||dd}tttfdddftttfddddfdd	d
ifdd	difddddfddddff}|D ]^\}}|d }	||	}
||	}||	dd}||	dd}|||
|d|}t||d|dV  qz|	d g}d d g}t||D ]b\}}||	dd}||	dd}t||d|||d k	r4||nd |d k	rH||nd ddV  qt|di dV  d S )Nr   Fr   r  )r  r   T)r  r   Zuse_input_statsr  r  r	  r
  r  r  r   r   r  )r  r  r  r  r   r   r   r   )r   r   r>   rC   r  )rt   r   r   r   r   r   r  r  r   r  r  r  r  r  Z
new_kwargsr  r  Zweight_channelsZbias_channelsr   r   r   sample_inputs_instance_norm  sT    

	

r  c                 k   s   t t|||d}ddddifddddifddi fd	d
i fddi ff}|D ]4\}}}||}	||}
t||||	|
f|dV  qHt|d	ddV  d S )Nr   r   r   r   r  r  r@  r   r   r   r   r   )r   r   r   )rt   r   r   r   r   r   r  r   normalized_shaper  r  r   r   r   sample_inputs_layer_norm  s     
r  c                 k   s   t t|||d}d}|D ]\}}}	||}
||}t||||
||	fdV  t|||d ||	fdV  t||||
d |	fdV  t|||d d |	fdV  qd S )Nr   ))r   r   r   )r  r  r@  )r   r   r  )r   r   r  )r   r   r  r   r   )rt   r   r   r   r   r   r  r   r  r   r  r  r   r   r   sample_inputs_native_layer_norm  s*    



r  c                 k   s   t t|tjdd}d}d}t||t d d dfd}t||dV  d}|d}d	}	t||||d dfd}
t|
|	dV  |d}d
}t|||d |dfd}t||dV  d}t|ddd}t||dV  d S )NFr   r   z6Expected normalized_shape to be at least 1-dimensionalr  r   r   r   z7Expected weight to be of same shape as normalized_shapez5Expected bias to be of same shape as normalized_shapezGiven normalized_shape=r  )r   NNr  )r   r   r   r   rC   r   rD   )rt   r   r   r   r   r   rl  r  r  r   rm  r  r   r  Zerr_msg4Zs4r   r   r   error_inputs_native_layer_norm7  s:      
 
 r  c           	      k   s   t t|||d}ddddddfdddddfddddd	fddddd
fddddifddddifddddifddi fddddddfddddddfddddddff}|D ] \}}}t|||f|dV  qd S )Nr   r  r   giUMu>r   g      ?)ro  r  r  )r  r  )ro  r  r  ro  r  r  r  r   r   r   r   r   r   r   r   r   )	rt   r   r   r   r   r   r  r   r  r   r   r   !sample_inputs_local_response_normW  s    r  c                    s&   d  fddt d D }|S )Nr   c                    s0   g | ](}t t d   d  fdddqS )r   r   r   r   r   r   r   rv  rJ  rd  Nr   r   r   r   r   r  o  s     z+sample_inputs_hardswish.<locals>.<listcomp>r   rk  )r  r   r   r   r   r  r   r  r   sample_inputs_hardswishl  s
    r  c                 K   s   ddgddgg}g dgdgddgg}t t|||ddd}g }tdd	g||D ]b\}	\}
}}|||
g }|||
g}|	s|t||fd
 qN||g}|t|||fd
 qN|S )Nr   r   r6  r   r   r   r  TFr   r   r   rP  r   r   rC   )r  r   r   r   r   features_optionsbatch_optionscreate_tensorr  has_biasZin_featout_featbatch_shaper	  r  r  r   r   r   sample_inputs_linears  s,      
r  c                 K   s   dddgdddgg}g dgdgddgg}t t|||ddd}g }td	d
g||D ]x\}	\}
}}}|||
g }|||g }|||
|g}|	s|t|||fd qR||g}|t||||fd qR|S )Nr   r   r   r6  r   r   r   r  TFr   r  )r  r   r   r   r   r  r  r  r  r  Zin_feat1Zin_feat2r  r  Zinput_tensor1Zinput_tensor2r  r  r   r   r   sample_inputs_bilinear  s.      
r  c                 K   s   dgddgddgdddgddddgg}g dgdgddgg}t t|||d	dd
}g }t||D ]d\}	}
t|	t|
 }t|D ]B}||
|	 }||}|dkr~|d dkr~|t||fd q~q^|S )Nr   r   r6  r   r   r   r   r   r   r  r   )	r   r   rP  r   r  rk  r  r   rC   )r  r   r   r   r   r  r  r  r  featuresr  rU  r   r	  r  r   r   r   sample_inputs_glu  s(    &  
r  c                    s  d\ d}d}d}d}	| dkr$d}	dd	dgdgd	gd	gdgdd	dgd
}
d fdd	}t t|||ddd}g }|	D ]}|
|  D ]}|t|||||||dd | |fdt|||||||dd | |fdt||||d d| |fdt||||d d| |fdg qqv|S )Nr  r   r   r   r,  )linearbilinearbicubic	trilinear)TFNr   r   )nearestr  r  r  r  areaTc                    s(   |rt  g| g|  S t | g| S r,  r   r  rankZwith_batch_channelCr  r   r   r"    s    z(sample_inputs_interpolate.<locals>.shaper   r  Fr   333333?r  )T)r   r   extendrC   )moder  r   r   r   r   Dr>   r<   Zalign_corners_optionsranks_for_moder"  r   r  align_cornersr  r   r  r   sample_inputs_interpolate  sL    	  


r  c                    s   d\ d}d}d}dddgdgd}	d fd	d
	}
t t|||ddd}g }|	|  D ]}|t||
||t|
||dddt||
||t|
||dddt||
||tdddt||
||tdddg qV|S )Nr  r   r   r   r   r   )r  r  Tc                    s(   |rt  g| g|  S t | g| S r,  r  r  r  r   r   r"    s    z%sample_inputs_upsample.<locals>.shaper   r  Fr  r   r  )Zscale_factorr  )T)r   r   r  rC   r   )r  r  r   r   r   r   r  r>   r<   r  r"  r   r  r  r   r  r   sample_inputs_upsample  s<      r  c           	      K   sZ   d}g }t d|D ]B}dD ]8}|tt|d |d f|||dddt|dd	 qq|S )
Nr   r   )r  tanhr   rq  r   r  approximater   )rk  r   rC   r   r   )	r  r   r   r   r   r  r  rd  r  r   r   r   sample_inputs_gelu  s      r  c                 k   s*   t ttdtj|dddidddV  d S )Nr   r   r  Zasdfr   z#approximate argument must be eitherr   rD   rC   r   r   ry  rz  r   r   r   error_inputs_gelu  s    r  c                    sB   g }t t t fdft t t fdfddf}t fdd|D }|S )Nr   r   Tr   r   r   r;  c              
   3   s.   | ]&\}}t t| d d d|dV  qd S r  rv  rJ  r	  r   r   r   r   rL  !  s   
 z;sample_inputs_max_min_reduction_with_dim.<locals>.<genexpr>r>   r  )r   r   r   r   r   r   Zargs_for_reduction_with_dimr   r   r   (sample_inputs_max_min_reduction_with_dim  s    r  c                 K   sJ   g }| tttttf||d d |d | ttd||d d |d |S )Nr   r   )r   rC   r   r>   )r   r   r   r   r   r   r   r   r   &sample_inputs_max_min_reduction_no_dim(  s     
 
r  c                 k   s`   t | ||E d H  |js|jr\tjdtjdg| ||dV  tjtjdgddgg| ||dV  d S )Nr   r   r   r   r   )rH   r   ru  r   r   r   )r   r   r   r   r   r   r   _generate_nan_reduction_inputs2  s    r  c                    s    fdd}|S )Nc                    s`   g }t |||D ]J}|t| | t|j D ] }|t| ||d q8q|S )Nr   )r  r   rC   r_  r  rI   rU  )r   r   r   r   r   r   r  supports_multiple_dimsr   r   r  =  s    z'sample_inputs_nan_reduction.<locals>.fnr   )r  r  r   r  r   sample_inputs_nan_reduction9  s    r   c                 K   s   dt d||dd|df}ddg}g }|D ]}t|||D ]}	|t|	 ||fd t|	jd	d
D ]N}|dd |dd	 |D ],}
|
|d< |t|	 ||f|d qqhq8q(|S )Nr   r   r   r   r   r  Zmidpointr   Fr  r   r  interpolationr   )	r   rH   r   rC   r_  r  rI   rU  
setdefault)r   r   r   r   r   Ztest_quantilesZtest_interpolationsr   Z	quantilesr  r  r   r   r    sample_inputs_reduction_quantileK  s$     r  c                  o   s(   t | |D ]}|jdd |V  q
dS )zSample inputs for count_nonzeror  N)rJ   r   rG  )r   r   r  r   r   r   %sample_inputs_reduction_count_nonzero`  s    r  c                    s&   d  fddt d D }|S )Nrh  c              	      s$   g | ]}t t  fd qS )r   rv  r  r  r   r   r  i  s   z,sample_inputs_leaky_relu.<locals>.<listcomp>r   r  r   r   r   r   r   r  r   r  r   sample_inputs_leaky_relug  s
    r  c                 K   s   t t|||d}d}g }|D ]x\}}	dD ]j}
|t|||	ftd|
dd |t|||	ftd|
dd |t|||	ftd|
d	d q(q|S )
Nr   ))r   r   r7  r7  r   )r  r  )r  r   r   )r   r   r7  r7  r   )r   r   r   r   r   )r   r   r   r   r  r  r   rK  re  r   r  )r   r   Zoutput_ratiore  r   r   r   rC   r   r   r   r   r   r   r   r  r   r   ra  re  r   r   r   #sample_inputs_fractional_max_pool2dm  s*    


r  c                 K   s   t t|||d}d}g }|D ]x\}}	dD ]j}
|t|||	ftd|
dd |t|||	ftd|
dd |t|||	ftd|
d	d q(q|S )
Nr   )))r   r   r   r   r   r%  ))r   r   r   r   r   r   ))r   r   r   r   r   r  ))r   r   r   r   r   r  ))r   r   r   r   r   r   r   r   )r   r   r   r   r   r   r   r   ))r   r   r6  r   r   )r   r   r   )r   r   r   r   r   r  r  r   r  r   r  )r   r   r   r  r  r  r   r   r   #sample_inputs_fractional_max_pool3d  s*    	


r  c              	   k   s`   t t|||d}d}|D ]0\}}}	}
}}}t||||	|
|||fdV  qt|dddV  d S )Nr   ))r  r   r   r   TFr   )r  r  r  r   TFr   )r  r  r   r  TTr   )r	  r   rC  r   TFr   )r
  r   r   r   FTr   )r  r  r   r   TTNr   r  r   r   )r   r   r   r   r   r   r  r   ra  r   rc  rb  count_include_paddivisor_overrider   r   r   sample_inputs_avgpool2d  s    
r  c           	      k   s   t t|||d}ddi fddtddddd	fdd
tddddd	fddtddddd	fdd
tddddd	fddtddddfddtddddfddtdddfddtdddfg	}|D ] \}}}t|||f|dV  qd S )Nr   )r   r   r7  r   )r   r   r7  r   r   TF)r   rc  rb  r  r   r   r   )r   r   r7  )r   r   r7  )r   r   rc  rb  )r   rb  r   r   	r   r   r   r   r   r   r  r   ra  r   r   r   sample_inputs_avgpool1d  s    r  c           	      k   s   t t|||d}ddi fddtdddddd	fd
dtdddddd	fd
dtddddfddtdddddd	fddtdddddd	fddtddddd d	fddtddddd d	fg}|D ] \}}}t|||f|dV  qd S )Nr   )r   r   r   r   r   r%  )r   r   r   r   r   r   r   TF)r   rc  rb  r  r  )r   r   r   r   r   r  r   r   r   r  r  )r   r   r   r   r   )r   r   r   r  )r   r   r   r  r  r  r   r   )r   r   r   r   r   r   r   r   r  r  r|  r   r   r  r   r   r   sample_inputs_avgpool3d  s<          r  c                 k   sV   t jdddgt jd}tt|ddddd	d
dV  tt|ddddd	ddV  d S )Nr   r   r  r  r   r  r   ra  r   rc  r   r  r   r   r  )r   r1  r   rD   rC   r   r   r   r   r   r   r   error_inputs_avg_pool1d  s    r!  c                 k   s   t jdddgt jd}tt|ddddd	d
dV  tt|ddddd	d
dV  tt|ddddd	ddV  tt|ddddd	ddV  t ddd}tt|dddd	ddV  d S )Nr   r   r  r  r   r  r   r  r   r  r   ry  r   r  r   r   ra  r  divisor must be not zeror   r1  r   rD   rC   r  r   r   r   r   error_inputs_avg_pool2d  s"    r%  c                 k   s   t jddddgt jd}tt|ddddd	d
dV  tt|ddddd	d
dV  tt|ddddd	ddV  tt|ddddd	ddV  t dddd}tt|dddd	ddV  t jdddgt jd}tt|ddddd	ddV  d S )Nr   r   r  r  r  r   r   r  r   r  r   r#  r   r  r   r%  r"  r#  znon-empty 4D or 5Dr$  r   r   r   r   error_inputs_avg_pool3d  s*    r&  c                 k   s^  t t|||d}|g}t|jdkrHtj rDtdtdgn|}tjtjg}t	|ddgddg|D ]:\}}}	}
d|
i}t
|ttttf|tj||	f|dV  qjt	ddgddg|D ]6\}}	}
d|
i}t
|ttttftj||	f|dV  qt	|ddgddg|D ]P\}}}	}
d|
i}|ttttftj|d}t
|ttttf|||	f|dV  qd S )	Nr   r0  zcuda:0TFr  r   r   )r   r   r   r   r  r  r  Zpreserve_formatri  r   rC   r>   r  )r   r   r   r   r   r   devicesZmemory_formatsnbcpZmem_fotherr   r   r   sample_inputs_to1  s*    "" ( &" r+  c                    sv   fdd}g }| t|tttfdd | t|tttfdd | t|tttfdd | t|tttfdd | t|tttfdd | t|tttfd	d | t|tttfd
d | t|ddd | t|ddd | t|ddd | t|ddd | t|ddd | t|ddd | t|ddd |S )Nc                    s   t |  dS r  r   r  r   r   r   get_tensor_inputS  s    z,sample_inputs_topk.<locals>.get_tensor_inputr   r   r   rw  rE  )r   r   T)r   r   TT)r   r   TTr   r   r
  r   r   r   r   T)r   r   T)r   r   TT)r   r   TT)r   rC   r>   r=   )r   r   r   r   r   r,  r   r   r   r   sample_inputs_topkR  s"    r/  c                 K   s@   g }t tf|||d}t tf|||d}|t||fd |S Nr  r   )r   r>   r=   r   rC   )r   r   r   r   r   r   Zarg_aZarg_br   r   r   sample_inputs_outeri  s
    r1  c                 k   sj   t t|||d}tttftftdtfdttff}d}t|||D ]$\}}	}
t||||	|
fdV  q@d S )Nr   r   r   r   r   r  )r   r   r   r   r   r   r  ZpsZsize_xZsize_yr  r   r   r   sample_inputs_distp  s
     r2  c                 +   sX  d| j k}d| j k}d| j k}d| j k}tt ||d}	ttj tjd}
 fdd}d	d
ttfg}|r~|tjkrxd}qd}nd}t||D ]\}}|	|}g }|j	dkrdnd}|
| |s|r|
n|}||j	dkr|j| nd}|
| |s|r|
|	| n|r$|
|	d
  t|}|d kr:i nd|i}t|||dV  qd S )Nindex_select	index_add
index_copy
index_fillr   r/  c                    s   t | f tjd| dS Nr   r   r   r   r   r   r   r  )r  r  r   r   make_idx  s    z%sample_inputs_index.<locals>.make_idxr   r   rJ  )r   r   r   r,  r   r   r   ro  r   )rK  r   r   r   r  r  r>   rt  r   rU  r   r"  r3  r   rC   )r   r   r   r   r   selectaddr  r  r   Zmake_permutationr:  ra  alphasr"  ro  r  r   r   Zmake_idx_fnr  r   r  r   sample_inputs_indexz  s8    







r>  c                 +   sh  t t ||d} fdd}ddttfttfftttftttffg}d}d}	t|||	D ]\}
}}|
\}}t|dkrzd	nd
}|t|d
kr|| nd	t|d
kr|| nd	}|||||f}t|||d|idV  qX|rdtjd
dgd
d
gddgg| |d}tjdd
gd
d
gddgddgg| |d}tjd
d	dd
gtj	 d}t|d
||dfddidV  d S )Nr   c                    s   t | f tjd|dS r7  r9  )r  r  r  r   r   r:    s    z,sample_inputs_index_reduce.<locals>.make_idxr[  )r   r   rJ  )prodr  r  r  r   r   r   include_selfr            r  r   r   r?  T)
r   r   r>   r=   r   r  rC   r   r   r  )r   r   r   r   r   r   r:  ra  Zinclude_selfsZreducesr"  r@  reduceZ
self_shape	src_shaper   r  r   r  r  r   r  r   sample_inputs_index_reduce  s0    (
$*
rF  c                    sR   g }t t t fdft t t fdft t t fdfddddf}t fdd	|D }|S )
Nr   r   r  r[  r  r  ))i  r   c              
   3   s.   | ]&\}}t t| d d d|dV  qd S r  rv  r  r   r   r   rL    s   
 z%sample_inputs_mode.<locals>.<genexpr>r  )r   r   r   r   r   r   r   r   r   r   sample_inputs_mode  s    
rG  c                 +   s  t t|||d t tdtj|ddd}tj|| |tjdd | }|| d g}t|dD ].\}}t ||f|  |f|fd	V  q^d
dg}	 fdd|	D }
fdd|	D } fdd|	D }t|
||dD ]8\}}}}t| || | ||fd	V  qdd
ddg} fdd|D }
ddd} d}t|dD ]6\}}t| || | ||fd	V  qPd S )Nr  r   Fr   r   r   r   r   r/  r   rJ  r  r   r   r   c                 3   s   | ]} |V  qd S r,  r   rJ  r  r[  r   r   rL    s     z$sample_inputs_put.<locals>.<genexpr>c                 3   s   | ]} |d dV  qdS r   r   Nr   rJ  r:  r   r   rL    s     c                 3   s   | ]} |V  qd S r,  r   rJ  r[  r   r   rL    s     r   ry  c                 3   s   | ]} |V  qd S r,  r   rJ  r[  r   r   rL    s     rL  )	r   r   r   r  r  r   rC   r_  r  )r   r   r   r   r   r>   r  Zidx_listaccscalar_sizesZtgt_genidx_gensrc_genZtgtr  Z	tgt_sizesr   r   r:  r   sample_inputs_put  sD    

rS  c                 +   s  t t|||d t tdtj|ddd}|f|| d}|| d fD ]}t ||f|fdV  qHd	d
g} fdd|D }	fdd|D }
t|	|
D ]&\}}t| || fdV  qdd	d
dg} fdd|D }	ddd}|	D ]"}t| || fdV  qd S )Nr  r   FrH  r   rL  r   rI  r   r   c                 3   s   | ]} |V  qd S r,  r   rJ  r[  r   r   rL    s     z%sample_inputs_take.<locals>.<genexpr>c                 3   s   | ]} |d dV  qdS rK  r   rJ  rM  r   r   rL    s     r   ry  c                 3   s   | ]} |V  qd S r,  r   rJ  r[  r   r   rL  #  s     )r   r   r   r  rC   r   r_  r  )r   r   r   r   r   r>   rE  r  rO  rQ  rP  r  Z	src_sizesr   rR  r   sample_inputs_take  s(    
rT  c              
   K   s`   t td||d d |dddddgddddgfdt td||d d |dddd	d
gd
d	ddgfdfS )N)r   r   r   r   r   r   r   r   r   r   r   r   rq  rv  r   r   r   r   sample_movedim_moveaxis*  s    rU  c           
      k   sV   t | |||f|E d H  tt|||d}d}|D ] \}}}	t||||	fdV  q0d S )Nr   )r  )r   r   r   r   r   r   )rV  r   r   r+  )r   r   r   r   r   r   rq  r   r   r   r   )rX  rq  r   r   r   r[  )r   r   r   r   r   )r   r   r   r   r   )r   r   r   r   r   )r\  )rq  r   r~  r  r   )r   r   r   r   r   )r\  )r   r   r   r~  r  )r  r   r   r   r   r   )rU  r   r   rC   )
r   r   r   r   r   r   r   r"  sourceZdestinationr   r   r   reference_movedim_moveaxis4  s
    r^  c                 k   sN  t t|tjd}tt|dddddddd	d
V  tt|ddddddddd
V  tt|ddddddddd
V  tt|ddddddddd
V  tt|ddddddddd
V  tt|ddddddddtdV  tt|ddddddddtdV  tt|ddddddddtdV  tt|ddddddddtdV  d S )Nr/  r   r   r   r   r   ))r   rq  rZ  r   zmovedim: Invalid source or destination dims: source \(\[3, -3\] dims\) should contain the same number of dims as destination \(\[1, 0, -1\] dims\)r   )rY  r
  zmovedim: Invalid source or destination dims: source \(\[3, -3, 4\] dims\) should contain the same number of dims as destination \(\[1, 0\] dims\))r   r   r  r   r   r   z2movedim: repeated dim in `source` \(\[0, 4, -5\]\))r`  r_  z7movedim: repeated dim in `destination` \(\[0, 4, -5\]\)))r   r   r~  r_  z2movedim: repeated dim in `source` \(\[1, 0, -4\]\))r   r   r   r   r   zKDimension out of range \(expected to be in range of \[-5, 4\], but got -6\)r   r   )rc  ra  )rb  r   )r   rb  )r   r   r   r   rD   rC   r  r   r   r   r   r   r   r   error_movedim_moveaxisP  sR    rf  c                 K   sx   t t|||d}d}d}|r$d}d}| jdk}g }	t||D ]6\}
}|rZt|
t|k rZq<|	t|||
fd q<|	S )Nr  )	r   r   r   r  rC  r  r  )r   r   r   )r   r   r   r   )r   r   r   rG  ry  )r   r   r   )r   r   r  rC  r  ru  r~  )r   r   r   ry  )r  _refs.repeatr   )r   r   rK  r   r  r   rC   )r   r   r   r   r   r   Zrep_dimsra  Zis_repeat_opr   Zrep_dimr"  r   r   r   sample_repeat_tile  s    
rh  c           	   	   k   st   t t t fdft t t fdft t t fdft t t fdft t t fdff}|D ]*\}}t|||d d |d}t||dV  qDd S )Nr  r|  )r   r   r   )r   r   r   r|  r   r   r>   r   rC   	r   r   r   r   r   Zshapes_and_argsr"  r   r   r   r   r   sample_inputs_narrow_copy  s    rk  c                 k   sP   t | |||f|D ]8}|V  t|j|jd t|jd |jd fdV  qdS )z
    sample_inputs_narrow accepts the same inputs as narrow_copy, in addition
    narrow also accepts `start` argument to be a Tensor.
    r   r   r   r   N)rk  rC   r  r   r   r   )r   r   r   r   r   r  r   r   r   sample_inputs_narrow  s    rl  c                 K   s   ddi fddddifddi fdd i fddi fddi fddddifdd d	d
ifdd d	difg	}g }|D ]d\}}}	t |||d d |d}
|d k	rt |||d d |d}|t|
|f|	d qd|t|
|	d qd|S Nr  r   r   r   r   r   r   r   r  Zdxr  r   r  r   r   r   r   r   rC   r   r   r   r   r   Zy_shape_x_shape_and_kwargsr   Zy_shapeZx_shapekwargZy_tensorZx_tensorr   r   r   sample_trapezoid  s,    rr  c                 K   s   ddi fddddifddi fdd i fddi fddi fddddifdd d	d
ifdd d	difg	}g }|D ]d\}}}	t |||d d |d}
|d k	rt |||d d |d}|t|
|f|	d qd|t|
|	d qd|S rm  ro  rp  r   r   r   sample_cumulative_trapezoid  s,    rs  c           
   	   K   sT   ddddddddd	g	}g }|D ]0\}}t |||d d |d
}	|t|	|fd q|S )N)rN  r   )rN  r   )rN  r   )rN  r   )rN  rq  rI  )r   r   )r   r   )r   r   r   r   ro  )
r   r   r   r   r   Zshapes_and_axesr   r"  r  r   r   r   r   sample_unsqueeze  s"    rt  c                 k   s|   d}d}d}d}d}	t |||||	}
|
D ]4\}}}}}t||||d}t|||||fdV  q(ttd|||dddV  d S )	N))r   r   r   r   r   r   r   r   )r   r   r   r   )r   r   r   )r   r   r   )r   r   rC  r  r   ru  )r   )r   r   rC   )r   r   r   r   r   ra  Zkernel_sizesZ	dilationsZpaddingsr&  r  r"  ra  rd  rc  r   r   r   r   r   sample_inputs_nn_unfold  s    rv  c           	   	   k   s   t dt dfdfdt dt dfdft dt dfdft dt dfdft dt dfdfdf}|D ]*\}}t|||d d |d	}t||d
V  qRd S )Nr   r   )r   r   r   r>  r   r?  r  r   r   ri  rj  r   r   r   sample_inputs_squeeze   s    
rw  c                 k   s   |dkst |dkrd}n"|dkr(d}n|tjkr8d}nd}tt|||d}|dkrft|d	d
dV  |dkr|D ]\}}	t|||	|fdV  qrn0dD ]*}
|D ] \}}	t|||	||
fdV  qqd S )N)constantreflect	replicatecircular)ry  rz  )rn  r   rn  r   r   r   r   r   r  r   r   r   r   r   r  r   r  r   r   r   r   r   r   r   r   r  r   r   r   r   r  r  r   r   r   r   r   r   r   r   r   r   r   r  r  )r   r   r   r   rx  )r|  r}  )rn  r  r~  r  )r  r  )r  r  r  r  r  )r  r  )r  r   )r  r   r  )r  r  )r  r   )r  r   r  r  )r  r   )r  r   )r  r  r  r  )))r   r   r   r   r  )r~  r  r  r  r  r  r  r  r   r  )r   r   )ry  rz  r{  )r'  r  )r  r   rt  r   r   rC   )r   r   r   r   r  r   r  Zmake_inpr"  padZ	pad_valuer   r   r   sample_inputs_nn_pad2  s"    
r  c           	      /   sd   t | ||f|ddi|}ddlm} || d fdd	}|D ]}||jf|j|jV  qBd S )Nr  rx  r   )dtype_to_typec                    s.   |d krt | |fdS t | | |fdS d S )Nr   r)  )r  r  r  r  Zscalar_typer   r   drop_mode_argument  s    z9sample_inputs_constant_pad_nd.<locals>.drop_mode_argument)NN)r  Ztorch._prims_commonr  r  r   r   )	r   r   r   r   r   Z
nn_samplesr  r  r  r   r  r   sample_inputs_constant_pad_nd  s    r  c              
   K   sr   t t|||d}t|dtdddt|dtdddt|dtddddt|dttjd	|d
dddgS )Nr   r   r   )repeatsr   r  r   )r  r   r   r  )r   r   rC   r   r   aranger   r   r   r   sample_inputs_repeat_interleave  s     r  c                 +   s    fdd}t |dtdddV  dD ]:}t |dtd|d	dV  t |d
tdd|ddV  q,tddd d}t |dtd|d|ddV  t |dtd|d|ddV  jst |d
td|dddV  d S )Nc                    s   t | f d|S Nr   r   )r"  r   r   r   r   mt  s
    
zsample_inputs_stft.<locals>.mtr  rh  n_fftr   r  r   r  rk  )rh  r  r   r   r  Z
hop_lengthrk  r   r  r   r   r   r   r   )r   r  T)r  windowreturn_complexrk  )r   r  F)r  r  onesided)rC   r   r   r   )r   r   r   r   r   r  rk  r  r   r   r   sample_inputs_stft  s&       r  c           	   	   +   s2   fdd}t |dtdddV  t |dtdd	d
dV  t |dtddd
dV  dD ]:}t |dtd|ddV  t |dtdd|ddV  q`tddd d}t |dtd||jddV  t |dtd|d d d|dddV  js|n|j}t |dtd|d d |ddV  d S )Nc                    s*   j r
| n| d }t|f d|S )Nr   r   )r   r   )r"  r   Z
real_shaper   r   r   r    s    
zsample_inputs_istft.<locals>.mt)rh  r   rh  r  r   )r   r   r   F)r  r  )r   r   Tr  )rh  rh  r   r  )r   r7  rh  r   r   r  r   r  r  )r  r  rk  r  )rh  rh  rh  r6  )r  r  Z
win_lengthrk  r  )rh  r   r   )r  r  rk  )rC   r   r   r   real)	r   r   r   r   r   r  rk  r  Zreal_windowr   r   r   sample_inputs_istft  s.    
   
 
   r  c                    s&   t t|||d  fdd}t| S )Nr  c                  3   s   ddddg} dddg}dd	g}t | t ||||D ]r\}\}}}} |||f} |t||f}	|rr||fn||f}
 ||
}||d
}t||	|f|dV  q2d S )Nr   r   r   r  r   r   r   TF)r#  r  r   )r   r_  rC   )r`  nstfra  r  r  r#  r  Z
reflectorstauZother_matrix_shaper*  r   r   r   r   
gen_inputs  s    
$
z'sample_inputs_ormqr.<locals>.gen_inputs)r   r   r   )r   r   r   r   r   r  r   r  r   sample_inputs_ormqr  s    r  c                 k   sH   t | |||}|D ]0}ttjddgdd|_dd |_|V  qd S )NTF)r  Zeigenvectorsc                 S   s   | d t | d fS Nr   r   )r   outputr   r   r   <lambda>      z&sample_inputs_symeig.<locals>.<lambda>)ry   rt  rV  randomchoicer   output_process_fn_grad)r   r   r   r   r   rD  r  r   r   r   sample_inputs_symeig  s    
r  c              	   k   sP   t | ||dd}|D ]6}|j}t|j|||d d d|_||f|_|V  qd S )NFr  )r   r   r   r   r   )rv   r  r   r"  r  r   )r   r   r   r   r   Zcholesky_inverse_samplesr  Z
psd_matrixr   r   r   sample_inputs_cholesky_solve  s       r  c                 k   sZ   t t|||d}d}t|ddD ]4\}}}	|t|	 tf }
||
 }t|d|fdV  q d S )Nr  )r   r   r   rJ  )r   r   r   r   r   Tr   )r   r1   r   r>   rC   )r   r   r   r   r   r   Zbatch_shapesr  Z	get_infosZ
size_deltar"  r  r   r   r   sample_inputs_lu  s      r  c           	      k   sT   dd }t | |||f|D ]4}tj|j\}}|| t||j|dV  qd S )Nc                 S   s   | d | d fS )Nr   r   r   r  r   r   r   out_fn  s    z'sample_inputs_lu_unpack.<locals>.out_fnr  )r~   r   ZlinalgZ	lu_factorr  r  rC   with_metadata)	r   r   r   r   r   r  Z	lu_sampleZlu_dataZpivotsr   r   r   sample_inputs_lu_unpack  s
    
r  c                 k   sL   t t|||d}d}|D ].}t|d|dV  t|tttf|dV  qd S )Nr   )rS  r   r  rF  rW  )r  r   r   ))r   r   r   r  r"  r   )r   r   rC   r>   r   r   r   r   r   r   r   r  r   r   r   sample_inputs_roll  s
    r  c           	      k   s   d}t ttftj|dt fd}t||dV  d}t tttftj|ddd}t||dV  d}t ttftj|ddd}t||td	V  d S )
Nz`shifts` requiredr   r   r   z shifts and dimensions must align)r  r   zout of ranger  rd  )rC   r   r>   r   r   r   rD   r  	r   r   r   r   rl  r   rm  r   r  r   r   r   error_inputs_roll  s$       r  c                 k   sb   t t|||d}ttdddddg}t|tttfV  |D ]}t|tttf|dV  q@d S )Nr   r  r   r   r   r-  r   )r   r   rP  r   rk  rC   r>   r  r   r   r   sample_inputs_rot90)  s
    r  c           	      k   s   d}t tttftj|dddid}t||dV  d}t ttftj|d}t||dV  d}t tttftj|ddd	id}t||dV  d S )
Nzexpected total rotation dimsr   r  r   r   r   zexpected total dims >= 2z&expected rotation dims to be differentrC  r   r  r   r   r   error_inputs_rot903  s"      r  c                 K   s   t ttttf|||d}t ttf|||d}t| t| tdddt| tdddddt| tdddddt| tdddddt| td	td
 ddt| td ddddt| ddt| ddt| d d dg
S )Nr   r   r  r   T)r   unbiasedr  r   Fr   r   )r   
correction)r   r  r  )Tr   r  )r   r   r>   rC   r   )r   r   r   r   r   Z	tensor_ndZ	tensor_1dr   r   r   sample_inputs_std_varG  s"    r  c                 k   s,   ddddg}|D ]}t ||| |dV  qd S )Nr   r   ry  r  r  r   )r   r   r   r   ra  r"  r   r   r   _generate_correlation_inputs^  s    r  c                 K   s   dd t |||D S )Nc                 S   s   g | ]}t |qS r   r)  rJ  r  r   r   r   r  e  s     z*sample_inputs_corrcoef.<locals>.<listcomp>)r  r   r   r   r   sample_inputs_corrcoefd  s    r  c              
   K   s   g }t |||D ]}|t| | dk r6| n|d}t|ftj|ddd}t|ftj	|dd|d}	t
t|d |gd |	gD ].\}
}}|t| ||
||dd qq|S )	Nr   r   rh  )r   r   r   r   r   r   )r  fweightsaweightsr   )r  r   rC   Z
ndimensionr  r  r   r   r  ry  r   rk  r_  r  )r   r   r   r   r   r   r  Znum_observationsr  r  r  fwZawr   r   r   sample_inputs_covh  s    "
r  c                 K   s  t jt|d}g }|ttt jttt|ddd |tt|dt jtt|diddd |tt|dt jtt|diddd |tt|dt jt|didd	d |tt|dt jd
d
g|diddd |tt|dt jd
g|diddd |tt|dt jd
|diddd |tt|dt jdddddg|diddd |tt|dt jdddddg|diddd |S )Nr  z.expected input to have two or fewer dimensionsr   r  r   z1expected fweights to have one or fewer dimensionsr  z1expected aweights to have one or fewer dimensionsz(expected fweights to have integral dtyper   z.expected aweights to have floating point dtypez(expected fweights to have the same numelz(expected aweights to have the same numelr   r   rq  r~  r  zfweights cannot be negativer  r  g      r  g      zaweights cannot be negative)r   r1  r>   r   rD   rC   r   )r   r   r   r   Zerror_inputsr   r   r   error_inputs_covu  sN    ""r  c           	      k   sB   t t|||d}ddddg}|D ]\}}t|||fdV  q d S )Nr   )r  )r   r   r   r   )r  )r   r   r   r   r[  )r  )r   r   r   r   r   r   r  r   r   r   sample_inputs_permute  s    r  c                 k   s   t | |||f|E d H  tt|||d}d}|D ]X\}}t|D ]D}	|||	}
t|
|fdV  ||dd|	}
t|
|fdV  qBq0d S )Nr   )r[  )r   r   )r   r
  )r   r   )r   r   r   )r   r   r   )r  )r   r   r   )r  r`  )r  r  r   Tr  )r  r   r   rP  permutationsr  rC   )r-  r   r   r   r   r   r  r"  Zpermutationr  r   r   r   r   reference_inputs_permute  s    r  c                 k   s*   t ttdtj|dddidddV  d S )Nr   r   lambdr@  r   z:lambda must be greater or equal to 0, but found to be -0.5r   r  rz  r   r   r   error_inputs_softshrink  s    r  c                 k   sJ   t t|||d}dD ]}t|ttd|idV  qt| |||E d H  d S )Nr   )r
  r   r  r   r   r   rC   r>   rY   r   r   r   r   r   r   Zlbdar   r   r   sample_inputs_softshrink  s    r  c                 k   sJ   t t|||d}dD ]}t|ttd|idV  qt| |||E d H  d S )Nr   )r@  r
  r   r  r   r  r  r   r   r   sample_inputs_hardshrink  s    r  c                 k   sP   t t|||d}dD ]"\}}t|tt||ddV  qt| |||E d H  d S )Nr   ))r@  r   )r   r@  )r
  r
  )min_valr  r   r  )r   r   r   r   r   r   r  r  r   r   r   sample_inputs_hardtanh  s    r  c                    s   fdd}t d|| d}t d|| d}t d|| d}t d|| d}	t d|| d}
t d	|| d}t d
|| d}t d|| d}t d|| d}g }|t||gdd |t||||gdd |t||gdd |t||||	gdd |t||||gdd |t||
||gdd |t||||gdd |t||
||	gdd |t||gdd |t||gdd |t||
||gdd |S )Nc                    s   |    S r,  )r_  r  r  r  r   r   r     s    zsample_inputs_einsum.<locals>.cr   r  r  r  rn  r   r  r  r   r   r   r   )zi->r   )zi,j->ij)zij->i)z	ij,kj->ik)zij,Ab->ijAb)zaij,ajk->aik)zaij,jk->aik)z	ijk,ik->j)ziji->j)z	i...->...)z...ik, ...j -> ijro  )r   r   r   r   r   r   r   r   ABr  r  EHIr   r   r  r   sample_inputs_einsum  s.    r  c           
      k   sV   t t|||d}tttftdtff}d}t||D ]\}}	t||d|	idV  q2d S )Nr  r   )r  r   r  r>  r   r  r   )r   r   r>   r=   r   rC   )
r   r   r   r   r   r   r  Zall_dimsr  r  r   r   r   sample_inputs_flip  s
    r  c              	   K   sB   t tttf||d d |dt tdtf||d d |df}dd |D S )Nr   r   c                 S   s   g | ]}t |qS r   r)  rJ  r   r   r   r   r    s     z/sample_inputs_fliplr_flipud.<locals>.<listcomp>)r   r>   r=   r  r   r   r   sample_inputs_fliplr_flipud  s    r  c                 k   s"   t ttdtj|dddV  d S )Nr   r   zInput must be >= 2-d.r   r  rz  r   r   r   error_inputs_fliplr  s    r  c                 k   s"   t ttdtj|dddV  d S )Nr   r   zInput must be >= 1-d.r   r  rz  r   r   r   error_inputs_flipud  s    r  c                 k   s   t t||d d |d}tttf}t||||||fdV  t||||dd  ||dd  fdV  t|||tdtffdV  t||d ||fdV  t||||d fdV  d S )Nr   r   r   r  )r   r   r   r   r   r   r"  r   r   r   sample_inputs_clamp  s    
.r  )supports_scalarsc                k   s  || |||f|E d H  t t|||d}t tdd||d}| |}	d}
|
D ]^\}}}t||||||fdV  t||dd||dd	||dddd	fdV  qL|rd
ddd| | fg}
tj|	kr|
dtdddfg |
D ] \}}}t||||fdV  qtj	|	krtj
|	kr|dtj
d}|dtj	d}|d}|||f|||ff}
|
D ]\}}}t|||fdV  qd|js|jr|jrt	dntt	dt	d}|d}||d< ||d< |d}||d< ||d< |d}||d< t|||fdV  d S )Nr   r   r0  ))r  r  r  )r  r   r   r   r  )r  r  )r   r   r   ))r   r   r   r  r  ))r   r   r  r   r   )r  r   r  )r  r   r   )r   r  r  r   Tr  r   r   )r   r   r   )r   r'  r   )r  r'  r   r"  )r   r   r   r   r   r  r  r  r   )r$  r   r   r7  )r   r   r  rC   r  r   r  r  r  ry  r  ru  r   )r-  r   r   r   sample_inputs_funcr  r   r   Zmake_scalar_tensorr  r  r   r   r   r   r   r   r   $reference_inputs_elementwise_ternary(  sT    
"

"r  c                 C   s   t | |S r,  )rV  maximum)r   r_  r   r   r   _clamp_min_numpyp  s    r  c                 C   s   t | |S r,  )rV  minimum)r   r  r   r   r   _clamp_max_numpyt  s    r  c                 C   s<   |d krt | |S |d kr(t | |S t |t | |S r,  )rV  r  r  )r   r_  r  r   r   r   _clamp_numpyx  s
    r  c                 +   s    fddfdd}t dD ]}ttttf|fdV  q$dD ]}t|ddV  qHt|d	d
gddV  t|d	dgddV  t|d
dgddV  t|d
dgddidV  d S )Nc                    s   t |  dddS Nr   r   r   r   r"  r   r   r   r     s    z'sample_inputs_cumprod.<locals>.make_argc                    s   t | dkst dtf }|| d dd| d dd  || d dd| d dd  || d dd| d dd  |S )Nr   r   r   r   r   )r  r  r>   narrowzero_)Z
dim_selectresultr[  r   r   
prod_zeros  s    $$$z)sample_inputs_cumprod.<locals>.prod_zerosr   r   )r   r   r   r   r   r   r   r   r   r   )rk  rC   r>   )r   r   r   r   r   r  r   r  r   r   r   r   r   r   sample_inputs_cumprod  s    r  c                 K   s   t ttdf|||dgS )Nr   r  r   r   r   r   r   sample_inputs_view_as_complex  s    r  c                 K   s2   t ttf|||dt d|||df}dd |D S )Nr  r   c                 S   s   g | ]}t |qS r   r)  r  r   r   r   r    s     z.sample_inputs_view_as_real.<locals>.<listcomp>)r   r>   r  r   r   r   sample_inputs_view_as_real  s    r  c                 +   s.   fddfdd}t |  D ] }t|j V  |V  q*t |  D ]}d|jd< |V  qZt| V  tddd	V  tddddid
V  tddd	V  tddddid
V  d}|  t| V  t| dd	V  t| dddid
V  d S )Nc                    s   t |  dddS r  r   r  r   r   r   r     s    z$sample_inputs_prod.<locals>.make_argc                     s    dt f } d| d< | S )Nr   r   r   r>   )r  r[  r   r   prod_single_zero  s    z,sample_inputs_prod.<locals>.prod_single_zeroTr  r)  r   r   r   rG  r   r   )r  rC   r  r_  r  r   r  )r   r   r   r   r   r  r  zeror   r  r   sample_inputs_prod  s*    
r  c                 K   s$   t tjd|d}d}t||dfS )Nr  r  zNegation, the `\-` operator, on a bool tensor is not supported. If you are trying to invert a mask, use the `\~` or `logical_not\(\)` operator instead.r   )rC   r   r   rD   )r   r   r   simsgr   r   r   error_inputs_neg  s    r  c              
   K   s   t ttf||d d |d}tttf||d d |dtd||d d |dtd||d d |df}d}g }t||D ]$\}	}
|t |	 ||
d qj||g S )Nr   r  r   r   )r   r   r?  r   r   r   )rC   r   r=   r   r   r_  r  )r   r   r   r   r   Z
vec_sampler  r   r   r   r  r   r   r   sample_inputs_diag  s    r  c                 k   s   t t|||d}ttfddf}tttff}t tddtddtddf}tddddtddddtd	dddf}	tt||t||	D ]\}
}t||
|d
V  qd S )Nr  r  r   r   offsetr   r  rX  dim2r   r   r   )r   r   r>   r   r   r   rC   )r   r   r   r   r   r   	shapes_2d	shapes_3dZ	kwargs_2dZ	kwargs_3dr"  rq  r   r   r   !sample_inputs_diagonal_diag_embed  s     r  c                 k   s   t | |||f|E d H  tt|||d}d}ttff}tttff}i }	tdddtdddtdd	f}
|
tddd
df }t||	}t||
}t||}t|||D ].\}}| j	dkr|dkrqt
|||dV  qd S )Nr   r   r   r   r   rX  r  r   r   r  r  r   r  diagonal_refs.diagonalr  )r  r   r   r<   r=   r>   r   r   r   rK  rC   )r   r   r   r   r   r   shapes1dshapes2dshapes3dkwargs1dkwargs2dkwargs3d	samples1d	samples2d	samples3dr"  r   r   r   $reference_inputs_diagonal_diag_embed  sB       
   







r  c                 k   s  t t|tjd}d}ttff}tttff}i }tdddtddtddf}|}	t||}
t||}t||	}t	|
||D ]\}}||}t
||d}|d	}|d
}| jdkr| }n*| jdkr|dkrqz| d }ntd| }|d }t||d }|o||k}|o ||k}||krNd| d| }t||tdV  qz|sZ|r|rd|n|}d| d| d| d}t||tdV  qztdqzd S )Nr/  )r   r   r   r   r   r
  r  )rX  )r  r  rX  r  r  )
diag_embed_refs.diag_embedr	  zshould be unreachablez(diagonal dimensions cannot be identical , rd  z6Dimension out of range \(expected to be in range of \[z\], but got z\))r   r   r   r   r=   r<   r>   r   r   r   rC   r  rK  r   rx  rk  rD   r  )r   r   r   r   r  r  r  r  r  r  r  r  r  r"  r  r  rX  r  Znum_dimZbound1Zbound2Z	dim_rangeZ	dim1_condZ	dim2_conderrZerr_dimr   r   r    error_inputs_diagonal_diag_embed  sL    










r  c                 k   s   t t|||d}ttfddf}tttff}d}d}	tt||t||	D ]P\}
}||
}t|tsj|f}n|}|j|  }||}t	||f|dV  qHd S )Nr  r  r   )r   r   r?  r   )r  r  )r   r   r   r   )
r   r   r=   r   r   r  r   r  r  rC   )r   r   r   r   r   r   r  r  Zargs_2dZargs_3dr   r  input_Z	arg_tuplerE  r  r   r   r   sample_inputs_diagonal_scatterR  s    
r  c                 K   sJ   t t|||d}t|ttfjdd dt|ttfdjdd dfS )Nr   c                 S   s   |   S r,  Zto_denserr  r   r   r   r  n  r  z)sample_inputs_to_sparse.<locals>.<lambda>r  r   c                 S   s   |   S r,  r  rr  r   r   r   r  o  r  )r   r   rC   r>   r  r  r   r   r   sample_inputs_to_sparsek  s    r   c              	      s@  d \}d}i fdi fdi fdi fffdd|D  fdd|D t dd	ff}g }t|d
D ]\\}	}}
t|	 |d}|
rd|krq~t|	dd |d}nft|f|	dd  d tjd}d|kr$t||d kr$tt	t
|d h dd |d< |t||f|d q~|S )Nr  r  r  r  r   r   r   c                    s   g | ]} t |d fqS r  r   rJ  r  r  r   r   r  z  s     z/sample_inputs_cross_entropy.<locals>.<listcomp>c              	      s(   g | ] }t tf d |dfqS )r/  r  r  )r   r   r%  r   r   num_classesr"  r   r   r  {  s   )ignore_indexr  r   r)  r   r  r   r   r   r   r   )r   )r   r   )r   r   r   )r   rP  r   r   r   r  allr  r  setrk  r   rC   )r   r   r   r   r   
batch_sizer  Zinput_shape_and_kwargsr  r   Zprobabilities_targetr  r  r   r'  r   sample_inputs_cross_entropyq  sL    



	&r.  c           	      K   s   | j \}}|tjkr| jnd}|| }|| }tttttf|||||dtttttf|||||dddttd|||||dttd|||||dddf}|S )NgQ?r   )r  r   r   )domainr   ro  Z_domain_epsrC   r   r>   )	r   r   r   r   r   r   r   Z
domain_epsr   r   r   r   sample_inputs_logit  s(    
  	r0  c                 k   sL   t t|||d}t|tf|tffdV  t|tf|tffdV  d S r  )r   r   rC   r<   r>   r  r   r   r   sample_inputs_isin  s    r1  c                 k   s   t t|||d}t|ttftjtt|ddk|ttffdV  t|ttftjtf|ddk|ttffdV  t|ttft ||ttffdV  t|tftjtt|ddk|ttffddV  d S )Nr   r  r   r   Tr\  )r   r   rC   r>   r   r  bernoulli_scalarr3  r  r   r   r   sample_inputs_masked_scatter  s    22*
r3  c                 k   s  t t|||d}t|ttftjtt|ddkdfdV  t|ttftjtt|ddk|dfdV  t|ttftjt|ddkdfdV  t|dtjd|ddkdfdV  t|dtjd|ddk|dfdV  t|ttftjd|ddkdfdV  t|tftjtt|ddk|dfddV  t|tftjtt|ddkdfddV  t|jd	krt|ttftjtt|ddktdfdV  d S )
Nr   r  r   rh  r   r   Tr\  r  )r   r   rC   r>   r   r  r   r  r  r   r   r   sample_inputs_masked_fill  s"    *.($((

r4  c                 k   s   t t|tjdd}tt|d|ddk|dfddd	V  tt|d|ddkd
fddd	V  tttjdtj|d|ddktjd
|dfddd	V  t	|j
dkrtttjttfddtjttdddktjdddfddd	V  d S )NFr   r   r   r   r   r   zKonly supports a 0-dimensional value tensor, but got tensor with 1 dimensionr   r  z5value cannot be converted to type .* without overflowr   r   r  r  r0  zto be on same device)r   r   r   ry  rD   rC   onesr  r   r   r  r  r>   re  r   r   r   error_inputs_masked_fill  s(     r6  c                 K   sR  t tttf||d d |dtjtt|ddkfdt tttf||d d |dtjtf|ddkfdt ttf||d d |dtjttf|ddkfdt ttdtf||d d |dtjttf|ddkfdt td||d d |dtjd|tjdfdt tttf||d d |dtjd|tjdfdt td||d d |dtjttf|ddkfdf}|S )Nr   r  r   r   r   r   r/  )rC   r   r=   r   r  r   rt  r   r   r   r   r   r   r   r   r   sample_inputs_masked_select  s.    r8  c                 K   s6   t tttf|||dt ttttf|||df}|S r  r   r7  r   r   r   sample_inputs_matrix_exp  s    r9  c                 K   sB  t ft ffttftfftfttffttfttfftdfdtfftttftfftttfttffttdfdtfftftttffttftttffdtddffttttfttttffttttftfftfttttfff}g }|D ]`\}}	t|||d d |d}
t|	||d d |d}|s$|t|
|fd q|t||
fd qt|S )Nr   rS  r   r   )r<   r>   r=   r   r   rC   r   )r   r   r   r   
is_rmatmulr   r   r  Z	lhs_shapeZ	rhs_shaperd  re  r   r   r   sample_inputs_matmul   s.    
r;  )r   r   r   r   variantreturnc             	      s(  |dkrBt tj tttjt tj f ttjdf f ddd}nR|dkrt tj tttjt tj f ttjdf f ddd}ntd| d	tg }td
g}|g|g||g|||g||||gg}	g }
t|	ddhD ]@\}}| fdd|D \}}|
	t
||t|dd q|
S )Nvariadic.)r  r=  c                 S   s   | d t | dd  fS r  r  r  r   r   r   make_inputs>  s    z+sample_inputs_meshgrid.<locals>.make_inputsr  c                 S   s   | dfS )Nr   r   r?  r   r   r   r@  D  s    z?Unsupported variant, must be one of {"variadic", "list"}. Got "z".r   ZxyZijc                    s   g | ]}t | d qS )r  r   rZ  r   r   r   r  [  s   z*sample_inputs_meshgrid.<locals>.<listcomp>)indexingr  r   r   )r   r   Tensorr   r   r  SizerP  r   r   rC   r   )r   r   r   r   r<  r   r@  ZSCALARZVECTORr   r  ra  rA  r  r   r   r   r   sample_inputs_meshgrid:  sL      




rE  c                 k   s   t t|||d}ttfdf}d}dd }t||D ]L\}	}
||
}|jsR|d7 }n|dt|j 7 }t||	|d|
fd	V  q2d S )
Nr   r   r  c                 S   s   | d d S )Nr'  r   r   r  r   r   r   compute_min_valk  s    z/sample_inputs_mvlgamma.<locals>.compute_min_valr   r   r  r   )	r   r   r>   r   ru  r   finfor   rC   )r   r   r   r   r   r   r  r  rG  r"  r  r  r   r   r   sample_inputs_mvlgammab  s    
rI  c                 C   sN   t tdddf}| rJ|t tddt tddt tddf }|S )NSkipped!TestUnaryUfuncsZtest_float_domainsTestGradientsTestJit
TestCommon)rB   unittestskip)Zskip_redundantskipsr   r   r   skips_mvlgamma{  s    rR  c                 C   sB   t dtrtnd d| |ttjdifttjttjtdd||dS )Nmvlgamma)zspecial.multigammaln皙?T)refaliasesvariant_test_namer/  
decoratorsdtypesdtypesIfCUDAr  supports_forward_adsupports_fwgrad_bwgradrQ  r)  )	r_   r5   reference_mvlgammar'   r   ro  r   r2  rI  rW  r/  rQ  r)  r   r   r   make_mvlgamma_opinfo  s    
r_  Tc                    sv   d	 fdd	}t |tttfddt |tttfddt |dddg}|rr|t |tttfddid |S )
Nc                    s   t |  ||dS rL  r   r"  r   r   r   r   r   _make_tensor_helper  s    z9sample_inputs_cumulative_ops.<locals>._make_tensor_helperr   r   r   r   r   r   )NN)rC   r>   r   )r   r   r   r   supports_dtype_kwargsr   ra  r   r   r   r   sample_inputs_cumulative_ops  s    "rc  c           	      K   s  dt t t t fdft t t t fdft t t t fdft t t t fdft t t t fdft t t t fdft t t t fdft t t t fd	ft t t t fd
ft t t t fdft t t t fdft t t t fdftfdftfdftfdfdddddt t t fdff}g }|D ]*\}}|tt|||d d |d|dg7 }q|S )N)r   )r   r   r   )r   r   r   r  r  )r   r   r   )r   r   r   ru  r  r  )r   r   r   )r   r   r   )r   r   r   )r   r   r   r  )i  )r   r      )rd  )r   r      )rh  rh  r  )rg  r   )rg  r  r   r   )r>   r=   rC   r   )	r   r   r   r   r   r   r  r"  	argumentsr   r   r   sample_inputs_unfold  sB     ri  )	list_argsc          
      k   s   t t|||d}|rtttfttd tttd d  ttd gfftttfttd tttd d  ttd gdfftttfttd tttd d  ttd gdfff}n tttfdftttftdfff}|D ]\}}	t|||	dV  qd S )Nr   r   r   r   r   r   r   r   r   r>   r  rC   )
r   r   r   r   rj  r   r   r  r"  r   r   r   r   sample_inputs_split  s    466rl  c           	   	   k   s   t t|||d}tttfttd tttd d  ttd gfftttfttd tttd  dgfftttfttd tttd d  ttd gdfftttfttd tttd d  ttd gdfff}|D ]\}}t|||dV  qd S )Nr   r   r   r   r   r   rk  r  r   r   r   sample_inputs_split_with_sizes  s    4(66rm  c           	   	      sR   fdd  fdd}g }t ||}t ttttf|d d d}||gS )Nc                    s     t tjtjkr|  d S r,  )r   r   ro  r2  r  r  r  r   r   
apply_grad  s    z'sample_inputs_msort.<locals>.apply_gradc                    s0   t jtt t t j|d}|| } | |S r3  )r   r  r<   r  r3  )r   r   r6  )rn  r   r   r8    s    
z,sample_inputs_msort.<locals>.large_1d_uniquer   r  )	r   r   r   r   r   r8  r   Zlargesampler  r   )rn  r   r   r   sample_inputs_msort  s     ro  c                 K   s  t t|||d}t|ttf|ttfdfdt|ttf|tfdfdt|d|ddfdt|ttf|ddfdt|ttf|tf|ttffdt|ttf|tdf|tffdt|tf|ttfdfddt|d|ttfdfddt|tdf|ttfdfddt|tdf|ttf|tdffddt|ttf|ttf|ttffdt|tf|ttf|ttffddt|tf|tttf|ttffddt|ttf|tttf|tffddf}|jr|t|ttf|ttfdfdt|ttf|ttfd	fdt|ttf|tfdfdt|ttf|ttfd
fdt|d|ddfdt|d|ddfdt|ttf|ddfdt|ttf|ddfdf }|S )Nr  g?r   r   r   Tr\  y        ?y333333??y@      "@yffffff@Mbp?r  )r   r   rC   r>   r   )r   r   r   r   r   r   r   r   r   r   sample_inputs_lerp  s<    $$ "&&(( rp  c           
      K   sj   dddddgddgfff}g }|D ]>\}}}	| tt||||dt||||dft|	dd	 q"t|S )
N)r%  r%  r   r  r|  r   r   r   r  )r  r   )r   rC   r   r   r   )
r  r   r   r   r   r  r   r  r  r  r   r   r   sample_inputs_tensordot;  s    
rq  c              	   K   sl   t t fttfff}g }|D ]H\}}t|||d d |d}	t|||d d |d}
t|	|
fd}|| qt|S r  )r>   r=   r<   r   rC   r   r   )r   r   r   r   r   r   r  r   other_shaper  r*  r  r   r   r   sample_inputs_kronI  s    rs  c              	   K   sT   t ttf|||dttf|||dfdt td|||dtttf|||dfdfS )Nr  r   r   r   r  r   r   r   sample_inputs_innerV  s    rt  c                    s  |d d f fdd	} fdd}t jdt j d}|ttfd|ttfdt|ttfff|ttfd|ttfdt|ttfff|ttfd|ttfdt|ttfff|ttfd|ttd	 fdt|ttd	 fff|ttfd|ttd	 fdt|ttd	 fff|ttfd|ttd	 fdt|ttd	 fff|d
d|  |d
ff|d
d|  dfff}g }	|D ]j\}
}|	t|
|d s||	t|
  |ddid |j	r||	t|
  |ddid q||	S )Nc                    s   t | | ||dS rL  r   r"  r   r   r   r  r   r   _tensorg  s    z&sample_inputs_scatter.<locals>._tensorc                    s   t | || dS Nr  r  r"  	index_dimmax_indicesr  r   r   _gatherj  s    z&sample_inputs_scatter.<locals>._gatherr   r   r   r   r   r   r  r   rD  r<  r   multiply)
r   r   r  r=   r>   r_  detachr   rC   ru  )r   r   r   r   r   rv  r|  r  r   r   r   r   r   r  r   sample_inputs_scatterf  s8    (((000
 
 r  c           	         sj  |d d f fdd	} fdd}t jdt j d}|ttfd|ttfdt|ttfff|ttfd|ttfdt|ttfff|ttfd|ttfdt|ttfff|ttfd|ttd	 fdt|ttd	 fff|ttfd|ttd	 fdt|ttd	 fff|ttfd|ttd	 fdt|ttd	 fff|d
d|  |d
fff}dd |D S )Nc                    s   t | | ||dS rL  r   ru  r  r   r   rv    s    z*sample_inputs_scatter_add.<locals>._tensorc                    s   t | || dS rw  rx  ry  r  r   r   r|    s    z*sample_inputs_scatter_add.<locals>._gatherr   r   r   r   r   r   c                 S   s   g | ]\}}t ||d qS r   r)  rJ  r   r   r   r   r   r    s     z-sample_inputs_scatter_add.<locals>.<listcomp>)r   r   r  r=   r>   r_  r~  )	r   r   r   r   r   rv  r|  r  r   r   r  r   sample_inputs_scatter_add  s    (((000
r  c                 k   s  t t|||d}t t|d}tjdtj|d}ttfd|ttfdtttffttfd|ttfdtttffttfd|ttfdtttffttfd|ttd fdtttd ffttfd|ttd fdtttd ffttfd|ttd fdtttd ffdd| 	 dff}| j
}	t|d	d
d	gD ]6\\}
}}}}t||
|||||	fd|idV  q&|r|	dkrtjddgddgddgg|||d}tjddddgddddgddddgg|||d}tjddddgddddgddddggtj|d}t|d|||	fdd
idV  d S )Nr  r  r   r   r   r   r   r   FTr@  r   r?  rA     rC  r   r   r   r   )r   r   r  r   r   r  r=   r>   r_  r~  rW  r   rC   )r   r   r   r   r   r   gatherr  r   rD  	inp_shaper   rE  rE  r@  r  r  r  r   r   r   sample_inputs_scatter_reduce  s2    &&&
 $00
r  lengths)r  c                +   s*  |d d f fdd	}t jdt j d}tfdddddgdftfdddddgdftfdddd	dgdfttfdddddgdftttfddddd
dgdfttfddd ttD dfttfdddd	dgddddgd	dddgddddgddddggdftttfddd ttD dftttfdddd	dgddddgd	dddgddddgddddggdff	}dddddg}	t||	ddgD ]\}
}}|
\}}}}t j|t j d}|||d}|dkr||d< nR|dkrt|j}d||< t 	|
||f||}||d< ntd| dt|||f|dV  qrd S )Nc                    s   t | | ||dS rL  r   ru  r  r   r   rv    s    z-sample_inputs_segment_reduce.<locals>._tensorr   r   r   r   FTr   r   c                 S   s   g | ]}d dddgqS r  r   r  r   r   r   r    s     z0sample_inputs_segment_reduce.<locals>.<listcomp>c                 S   s   g | ]}d dddgqS r  r   r  r   r   r   r    s     r  r  r_  r  r?  )r  unsafeinitialr  offsetsz0mode most be one of 'offsets' or 'lengths' got 'z'.r   )r   r   r  r>   r=   rk  r   r  r"  cat	new_zerosZcumsum_rx  rC   )r   r   r   r   r  r   rv  r  r   r  r   rD  r  r  r   r  r  Z	lengths_tZsample_input_kwargsZzeros_shapeZ	offsets_tr   r  r   sample_inputs_segment_reduce  s:    @B




r  c                 K   sX   t ttttf||d d |dt td||d d |dt ttttf||d d |ddf}|S )Nr   r   T)r   r   r   r   r   r  r   r7  r   r   r   sample_inputs_ravel  s$     
   
r  c           	      k   s   t t|||d}ttfdfttfdfttfdfttfdfttfdftttfdftttfdfddttfdff}|D ]\}}t|||dV  qpd S )Nr  r   r   r>  r   r   r  r  r   r   r   sample_inputs_tril_triu  s    




	r  c                 k   s4   d}|D ]&}t |d |dd  ||ddV  qd S )N)rS  )r   r   )r   r   )r      r   )r   r  r   )r   r  r.  r   r   r   r   r)  )r   r   r   r   r   Z	args_listr   r   r   r   sample_inputs_trilu_indices	  s    r  c                 k   s6   t t|||d}t|tttfV  t|dV  d S )Nr  r   )r   r   rC   r>   r=   r  r   r   r   sample_inputs_clone_contiguous  s    r  c                 k   s  t | |||f|E d H  d}tt|||d}|D ]}t||V  t||ddV  t||ddV  t||ddddV  t||dtjidV  t||dddtjidV  t||dddtjidV  t||dddddtjidV  q0d	}|D ]F\}}	}
t|d
||	|
V  t|d
||	|
dtjidV  qt|ddtjidV  |d	dddd}t|dtjidV  t|ddtj
idV  |d	ddddd}t|dtj
idV  d S )N)r  )r   r   r   r   r   )r   r   r   r   r   r   r   )r   r   r   r   r   r   )	r   r   r   r   r   r   r   r   r   r   r  r   r   Tr  r  r   )))r   r   r   r   r   r   r   ))r   r   r   r  r   )r   r   r   )r   r   r   r   )r  )r   r   r   r   )r  )r   r   r   r   ))r7  r   r   )r   r   r   r   i  r   r   r   r   )r   r   r   r   r   r   )r  r   r   rC   r  r   rh  
as_stridedri  r  Zchannels_last_3d)r-  r   r   r   r   ra  r   r"  Zstrided_casesr&  r  r   r   r   r   !reference_inputs_clone_contiguous#  s,    	 &	&r  c           
   	   k   s   t t|||d}dtfdfttfdfttfdtffttfttfftttftdtffg}|D ]N\}}||}	t|	|fdV  |dkrqZt|	t|fdV  t|	|dV  qZd S )Nr  r[  r   rC  r   r   r   )r   r   r>   rC   r  )
r   r   r   r   r   r   sample_shapesr   r   r   r   r   r   sample_inputs_sum_to_sizeV  s    
	r  c                 k   s~   t tt f}d}tt||tjdt t fd}t||dV  t d ttt f}d}tt||tjdt d dfd}t||dV  d S )Nzis not expandable to sizer/  r   r   r   )r=   r>   rC   r   r   r   rD   )r   r   r   r"  rG  r  r   r   r   error_inputs_sum_to_sizel  s    
 r  c           
      k   s   t t||d}tttftt tffddf}|D ]R\}}| jdkrH|f}	n"| jdkrb||ddf}	ntdt|||d|	d	V  q.d S )
Nr   r[  )r   r}  resize_
resize_as_Fr  z>sample_inputs_resize_ops is being used with incorrect operatorr   )r   r   r>   rK  r  rC   )
r   r   r   r   r   r   r  r"  Zargs_or_shaper   r   r   r   sample_inputs_resize_opsx  s    

r  c           
      k   s   t t|||d}tttftt tfdftt tftttfdftt tftdtfdftt d tftdfdftftfdfddf}|D ]D\}}}	|dr|	sq|dr||dd	}t|||fd
V  qd S )Nr  Tr   Fr   )r   r   F)r   r   T
tensor_argr  r   )r   r   r>   r  rC   )
r   r   r   r   r   r   r  r   r   is_tensor_supportedr   r   r   sample_inputs_view_reshape  s    
r  c                 k   s
  t | |||f|E d H  d}d}tt|||d}|D ]\}}	}
|drN|
sNq4|drt||||	ddfdV  t||	||ddfdV  q4t|||	fdV  t||	|fdV  q4|D ]D\}}	}
|dr|
sq|dr||	dd}	t|||	fdV  qd S )N)))}   )   r   T))r  r  r   r   r   r   r   r   r   r   T))r       )r   r   r   r   r   r   r   T))r   r$  r$  r   T))r   r   r$  r  T))r   r   r   r   )r  r   T)r   r   r   r  T)r  )r   r   r   r   r   T))r   r   r   )r   r   r   Tr   r   F)r   r   r   r   r  T))r   r   r   r   r   r  Tr  )r  )r   r   r   r   r   r   T)r   r   F))r   r>  F))r   r   r7  r   r   )r   r   r   r   r   Fr  r  Fr  r   )r  r   r   r  rC   )r-  r   r   r   r   r  Zirreversible_casesr   r   r   r  r   r   r   reference_inputs_view_reshape  s$    

r  c                 k   s   d}t ttj|dd}|D ]\}}}|dr4|s4q|dkrBd}nN|dkrPd}n@d	tt|}	t|t	krp|nt
tj|d
}
d|	 d|
 }|dr||dd}tt|||fdt|dV  qd S )N))r   r   F))r   r   r   r   F))r   r   r   r   T)r(  )r   r   r   T)r(  )r   r   r   F)r(  r   r   r   F)r   r+  F)r  r+  FFr  r  r  z"only one dimension can be inferredr  zcannot reshape tensor of 0 elements into shape \[0, -1\] because the unspecified dimension size -1 can be any value and is ambiguousr  r   z	shape '\[z!\]' is invalid for input of size r  r   r   )r   r   r   r   r  joinmapstrr  r  	functoolsrD  operatormulrD   rC   	Exception)r-  r   r   r  r   r   r   r  r   r"  r  r   r   r   error_inputs_view_reshape  s"     
r  c           
      K   sv   g }t t t t ft t t ft t ft fdf}tt|||d}g }|D ]$}	|||	 |t||	 q>|t| |S )Nr   r  r>   r   r   r   rC   )
r   r   r   r   r   
input_listra  make_tensor_partialr   r"  r   r   r   sample_inputs_atleast1d2d3d  s    "r  c           
      K   sj   g }t ddft ddfft t dffddt fff}tt|||d}|D ]"\}}	|t||||	g qB|S )Nr   r   r   r   r   r  r  )
r   r   r   r   r   r  r  r  Zshape1Zshape2r   r   r   sample_inputs_column_stack  s    
 
r  c           	   	   K   sv   g }t t t ft t ft fdf}tt|||d}|D ]@}|t|| t|dkr0|t||tdddd q0|S )Nr   r  r   r   )	start_dimend_dimr   )r>   r   r   r   rC   r  r   )	r   r   r   r   r   r   ra  r  r"  r   r   r   sample_inputs_flatten  s     r  c           
      k   s   t | |||f|E d H  d}tt|||d}|D ]`\}}}	t||||	fdV  t||dddd||	fdV  t||dd||	fdV  q0d S )N))r   r   r   r   r   r   r   r   )r  r   r   ))r   r   r   r   r   r   r   r   )r   r   r   )r   r   r   ))r   r   r   r   r   )r  r   r   )r  r   r   )r  r   r   ))r   r   r   r   r   r   r   r   r   r   )r  r   r   ))r   r   r   r   r   ))r   r   r   r   r   r   r  r   Tr  r   r   )r  r   r   rC   r  )
r-  r   r   r   r   r  r   r"  r   r   r   r   r   reference_inputs_flatten%  s    "r  c           
      k   s>   d}t t|||d}|D ] \}}}	t||||	fdV  qd S )N)
)r  r   r  )r  r   r  )r  r   r%  )r  r   rR  )r   r   r   r   r  )r  r   r  )r  r   )r   r   ))r   r   r$  r   r#  )r   r   r   r   )r  r   )r   r   r   r   r  r   r   )
r   r   r   r   r   r   r  in_shaper   r  r   r   r   sample_inputs_unflatten?  s    r  c           	      k   sp   t t|||d}tttfdftttfdftttfdftttfdftfdff}|D ]\}}t|||dV  qPd S )Nr  r   rR  r   r   r-  r  r   rT  r  r   r   r   sample_inputs_selectQ  s    r  c                 k   s   t t|||d}tttfttfdftttfttfdftttfttfdftttfttfdftfddff}|D ].\}}}	||}
||}t|
|f|	dV  qjd S )	Nr  r   rR  r  r-  r   r  r   rT  r   r   r   r   r   r   r  r   rE  r   r  r  r   r   r   sample_inputs_select_scatter_  s    
r  c                 k   sz  t t|||d}tttftttfddtdfftttftd ttfdtd tdfftttftd ttfdtd tdfftttftttfddtdfftttfttd tfdtd tdfftttfttd tfdtd tdfftttftttfddtdfftttftttd fdtd tdfftttftttd fdtd tdfff	}|D ]0\}}}	||}
||}t|
|f|	dV  qDd S )Nr  r   r   r   r   r   )r   r   r<   rC   r  r   r   r   sample_inputs_slice_scattero  s    $$$$$$r  c           
   
   k   s   t t|||d}tddftttfftdtftttfftdtfdtdfftdtfdttfftdftttffdtttffdtfddtffddf	}|D ] }|\}}	t|||	fdV  qd S )Nr  r   r   r   r[  rt  r   rT  
r   r   r   r   r   r   r  r*  r"  r   r   r   r   sample_inputs_expand  s    r  c           
      k   sn   t t|||d}d}d tjg}t||D ]&\}}	t|||	rFd|	ini dV  q*t|ddtjidV  d S )Nr  )r   r  r  r   )r   r   r   r   )r   r   r   rh  rP  r   rC   ri  )
r   r   r   r   r   r   ra  Zmemory_format_optionsr"  r  r   r   r   sample_inputs_conversion  s    

r  c           	      k   sZ   t t||d}tddftttffddf}|D ](\}}t|||d||ddfdV  q,d S )Nr   r   r[  )r   rC  r  Fr   rT  )	r   r   r   r   r   r   r  r"  Zshape_otherr   r   r   sample_inputs_expand_as  s    r  c                 +   s   t t| |d} fdd}ttfttfttfdftdtfttfttdfdfdtdtfdttdfdfdttfddff}|D ],\}}	}
}t||||	||
f|d	V  qzd S )
Nr  c                    sf   t | tj dd}| dkr"|S | dkr<|d |S | dkrbdd }d|||j< |S |S )NFr  r   r   Tc                 S   s   t tdd | S )Nc                 S   s   t d| S Nr   )r  r  )Zmax_idxr   r   r   r    r  zSsample_inputs_where.<locals>.make_bool_mask.<locals>.random_index.<locals>.<lambda>)r   r  r  r   r   r   random_index  s    zAsample_inputs_where.<locals>.make_bool_mask.<locals>.random_index)r   r   rt  r  r  r  r"  )r"  mask_tr  r  r   r   make_bool_mask  s    
z+sample_inputs_where.<locals>.make_bool_maskFr   T)r   r   r   Fr   r\  )r   r   r=   rC   )r   r   r   r   r   r   r  r  r"  Z
mask_shaperr  r]  r   r  r   sample_inputs_where  s    r  c                 k   s  t | |||f|E d H  tttj||d}tt|||d}|ddd}|ddd}|ddd}	t|||	fd	V  |tjk	rtjntj}
|ddd}|dtjd
}|d}	t|||	fd	V  |ddd}|d	 }|d	 }	t|||	fd	V  |j
s|jrf|j
rtd}nttdtd}|d}|ddd}||d< |d}	||	d< t|||	fd	V  dD ]*}t|||	fd	V  t|||fd	V  qjd S )Nr  )rh  r   Tr  )rh  r   )r   rh  r   r   r   r   r  r   r   )r   rh  r   r  rn  r  )r   r
  y               @F)r  r   r   r   rt  r  rC   r  r  r3  ru  r   ry  r  )r-  r   r   r   r   Z	make_condr   r   r   r   Zother_dtyper   Zscalarr   r   r   reference_inputs_where  s:    
r  c              	   k   s   t f}d}td|fddD ]b}tt|dkrtt||d tjdt|tj|d d	t||d tjdfd
}t	||dV  qd S )Nr  r0  r   r  r   r   r/  r   r   r   r   )
r>   r   r  r,  rC   r   r   r   rt  rD   )r   r   r   r"  rG  r'  r  r   r   r   error_inputs_where  s    r  c                 k   s   t t|||d}dtfttftttftdtftdtff}g }|D ]R}tj||||d}	||	 ||d}
t|tj|dd}d|
|< ||
 q@t|ddgD ]&\}}t	|
 |t|ddV  qd S )	Nr  r   r   r   FT)as_tupler   )r   r   r>   r   r  r   r  rt  r   rC   r_  r   )r   r   r   r   r   r   r  r   r"  r  mixedr  r   r  r   r   r   sample_inputs_nonzero  s    (
r  c           
      k   sh   t t|||d}tttfdftttftdfftttftdfff}|D ]}|\}}	t|||	dV  qDd S )Nr  r   r   r   r   rT  r  r   r   r   sample_inputs_chunk!  s    r  c           
      k   sV   t | |||f|E d H  tt|||d}d}|D ] \}}}	t||||	fdV  q0d S )Nr  ))rA  r7  re  r  r   )r  re  r   ))rA  r$  r   )rB  r$  r   )r  r   r   )r  r7  r   )r   r   r7  r   )r  r7  r   )r  r   r   )r  r   r   )r  r   r   )r  r   r   )r  r   r   r   )r  r   r   rC   )
r-  r   r   r   r   r   r  r"  chunksr   r   r   r   reference_inputs_chunk,  s
    r  c                    s   |d d f fdd	}|t t t fdf|t t t fdf|t t t fdf|t t t fdf|t t t fdf|t fdf|t fd	f|d
df|d
df|d
dfg
}dd |D S )Nc                    s   t | | ||dS rL  r   ru  r  r   r   rv  F  s    z'sample_inputs_kthvalue.<locals>._tensorr   r  )r   r   rD  )r   r   TrF  rH  r   r   r
  r.  c                 S   s   g | ]\}}t ||d qS r  r)  r  r   r   r   r  V  s     z*sample_inputs_kthvalue.<locals>.<listcomp>r  )r   r   r   r   r   rv  r   r   r  r   sample_inputs_kthvalueE  s    


r  c              	   K   s   t dtj|d}tjd|tjd}t|dd||fid}d}t|d	d
tttjdd|ddd|d
tttjdd|ddd|d
tttjd|ddd|d
fS )Nrh  r   r   r/  r  rD  r   z,selected number k out of range for dimensionrC  r   r   r  rG  r   r   )	r   r   r   r  r  rC   rD   r  r   )r   r   r   r  r  r  Zk_out_of_range_errr   r   r   error_inputs_kthvalueX  s    
r  )trainvalid_input_dimc                k   s   t t|||d}|r$dd |D }nttftfdf}dddg}	|d k	rL|gndd	g}
t||	|
D ]$\}}}t||t||d
dV  q`t||t dV  d S )Nr   c                 s   s   | ]}t f| V  qd S r,  r  rJ  rl  r   r   r   rL  l  s     z(sample_inputs_dropout.<locals>.<genexpr>r   r
  r   r'  TF)r  r  r   )r   r   r>   r   rC   r   )r   r   r   r   r  r  r   r   r  Zp_valsZtraining_valsr*  r  r  r   r   r   sample_inputs_dropoutg  s    
r  c                 +   s$   fdddd fdd
}fdd}t jd	d
g t jd}dD ]}dD ]}	|rf|	dkrfqR|tfd	td}
|||
}tttf|
f||	|ddV  |tfd	tdd}
|||
}tttf|
f||	|ddV  |tfd	tdd}
|||
}tttf|
ft jd	d	d
g t jd|	|ddV  |ttfd	td}
|||
}tttf|
f|	|ddV  |ttfd	tdd}
|||
}tttf|
f|	|ddV  |dd	td}
d|
d	< d|
d< |||
}tttf|
fd||	|ddV  |dd	td}
d|
d< d|
d< |||
}tttf|
fd|	|ddV  |dd	td}
ttf}t jd	d
dg t jd}|||
}t||
f|	|dddV  sR|d d	td}
ttfd }|||
}t||
fd!|	|d"dV  |dd	td}
ttfd }|||
}t||
fd!d!|	||d#dV  |	d$krR|d d	td}
d%|
d< d%|
d&< ttf}|||
}t||
fd|	|d'dV  |dd	td}
ttf}|||
}t||
fd||	|d(dV  |dd	td}
d%|
d	< d%|
d%< d	|
d
< ttfd }|||
}t||
fddd	d!||	|d)dV  qRqHd S )*Nc                    s   t |  dS r  r   r  r   r   r   r   z  s    z/sample_inputs_embedding_bag.<locals>.make_inputFr  c                   s   t |  tj|||dS )N)r   r   r   r   r  r   r   r  )r"  r   r   r  r  r   r   make_long_input}  s    z4sample_inputs_embedding_bag.<locals>.make_long_inputc                    s   | r |j S d S r,  r  )r=  r  r  r   r   make_per_sample_weight  s    
z;sample_inputs_embedding_bag.<locals>.make_per_sample_weightr   r   r/  rJ  )r  r  r  )r  r  r  )r  r  per_sample_weightsr   T)r   r   r  )r  r  r   r   r   )padding_idxr  r  r  r   r   rS  rC  )r  r  r  r   )r  r  Zinclude_last_offsetr   r'  )max_normr  r  )r  	norm_typer  r  r  r  r   r   )scale_grad_by_freqr  r  )sparser  r  r  )r  r  r  r  r  r  r  )r   r   r  r>   r=   rC   )r   r   r   r   r   r  r  r  Zgenerate_per_sample_weightr  r  r  r  Zoffsets_r   r   r   r   r   r   sample_inputs_embedding_bagy  s    







 




 

 
  r  c           	      +   sB   fdd} fdd}|ddt d}t|t tf|fdV  |tfdt d}t|t tf|fdV  |ttfdt d}t|t tf|fdV  s>|d	dtd}d
|d< d
|d< t|ttf|fdd
idV  |d	dtd}d|d< d|d< t|ttf|fddidV  |d	dtd}|ttfd
 }t||fddidV  |d	dtd}|ttfd
 }t||fddddV  |d	dtd}d|d< d|d< |ttf}t||fddidV  |d	dtd}|ttf}t||fddidV  |ddtd}d|d< d|d< d|d< |ttfd
 }t||fddddddV  d S )Nc                    s   t |  dS r  r   r  r   r   r   r      s    z+sample_inputs_embedding.<locals>.make_inputc                   s   t |  tj||dS )Nr8  r  r`  r  r   r   r    s    z0sample_inputs_embedding.<locals>.make_long_inputr   r   r  r   r   r   rS  rC  r  r   r   r   r  r'  )r  r  r   r   r  Tr  r   r
  )r  r  r  r  )r=   rC   r>   )	r   r   r   r   r   r   r  r  r  r   r   r   sample_inputs_embedding  sT     r  c                    s@    fdddt fttt ff}d}fddt||D S )Nc                   s   t |  ||dS )Nr   r   r`  r   r   r   r   B  s    z)sample_inputs_one_hot.<locals>.make_inputr   )r   rh  c                    s<   g | ]4\}}t  |d |dkr dn|d dt|ddqS )r   r   rh  r   r  )r(  r   )rC   r   )rJ  r"  r(  r  r   r   r  H  s   	z)sample_inputs_one_hot.<locals>.<listcomp>)r>   r<   r=   rP  r   )r   r   r   r   r   ra  Znum_classessr   r  r   sample_inputs_one_hotA  s    
	
r  c           	      k   s   | d|}tt|||d}dtftddftftddftftddfttfd ftttfd ff}|D ]&\}}t|||||df|d	V  qfd S )
Nrhs_requires_gradr   )r   Nr  r#  r  r  r  r   )r  r   r   r>   r   rC   )	r   r   r   r   r   r  r  shapes_and_kwargsr"  r   r   r   sample_inputs_lossU  s    
	r  c                 K   s   t t|||ddd}d}d}d}d}	d}
g }dD ]x}|dkrD|dn|}t||
|	D ]P\}}}|t|||ftg| ||ftg| |fft|||d
d qVq0|S )Nr   r   r  r   )r  r  r  )r  ZborderZ
reflectionr  r  )r  padding_moder  r   )r  )r   r   rP  r   r   rC   r>   r   )r   r   r   r   r   r  r-  Znum_channelsmodesZalign_cornerssZpadding_modesr  r   Zmodes_r  r  r  r   r   r   sample_inputs_grid_samplei  s2    
 r  c              
   +   sz   t t d} fdd}ttftff}d}t||D ]8\}	}
t||	||	||	ft|
tddddV  q<d S )	Nr   c                    sV   t | dkrdn| d f} tjdd|  tjd}|d d }|jd }|S )Nr   r   r   r   r/  r  )r  r   r  r  r3  r`  r  )r"  r  r  r   r   r   r     s
    z8sample_inputs_cosine_embedding_loss.<locals>.make_targetr  r  r  r   r   )r  r  r   )r   r   r>   r   rC   r   r  uniform)r   r   r   r   r   r   r   ra  r  rz  r   r   r   r   #sample_inputs_cosine_embedding_loss  s    r  c                 +   s   d}d}d}d} fdd}	d}
d}t |
|D ]|\}}|	|||f}tjd	|||ftj d
}tj|f|tj d
}tjd||ftj d
}t||||ft||ddV  q2d S )Nr  r   r   r   c                    s2   t |  d}|dj d jd}|S )Nr/  r   r  )r   log_softmaxr3  r~  r  )rz  r  	log_probsr   r   r   make_log_probs  s     z.sample_inputs_ctc_loss.<locals>.make_log_probsr  rJ  r   r   rh  )r  Zzero_infinityr   )r   r   r  r  r  rC   r   )r   r   r   r   r   Zinput_lengthra  Znum_charZtarget_lengthr  r  Zzero_infr   r  r  targetsZinput_lengthsZtarget_lengthsr   r   r   sample_inputs_ctc_loss  s    r  c                 +   sx   dd t t ||dt t |ddd
 fdd	fdd}| D ]\}}}t||f|d	V  qVd S )Nr  r   r   Fc                    sl   t | dkr"| d f| dd  nd}|r<tj| tjdS t|dt | dkrV| d n| d  tjdS d S )Nr   r   r   r   r/  r*  )r  r   r  r  r   )r"  r  rz  r  r   r   r     s    &z+sample_inputs_nll_loss.<locals>.make_targetc                  3   s>  fd f} d}t || D ]\}} ||t|dfV   ||t |dfV   ||tdd|dfV   ||tdd|dfV  |}d }|| r|d	kr|d  ||td |d
fV   ||td | dfV  |d	kr ||ddtd|d
fV  qd S )Nr   r  r#  r&  r   r  rL  r   r  )r)  r  )r)  r  r  T)r  )r   r   eqr+  r  )ra  r  r  rz  r  ignore)r   r   make_weightr(  r"  r   r   gen_shape_kwargs  s    ""
 z0sample_inputs_nll_loss.<locals>.gen_shape_kwargsr   )Fr   )r   r   r   r   r   r  r  r  r   )r   r   r   r  r(  r"  r   sample_inputs_nll_loss  s    r  c           	      +   s   t t||d t  ddd}d fdd}dd	 d
dtfttftttffD dd	 D |  fdd	D  fdd	D }|D ]*\}}t ||d|||df|dV  qd S )Nr/  r   r   r  r!  c                     s<   g } ddt ft t t ffD ] |  fddD  q| S )Nr   r   c                    s$   g | ]}t t ft| d fqS )r  r  r>   r   r%  )maker"  r   r   r    s     zdsample_inputs_binary_cross_entropy_with_logits.<locals>.make_weight_shape_kwargs.<locals>.<listcomp>)r>   r  r   r  r  r  r   make_weight_shape_kwargs  s    zPsample_inputs_binary_cross_entropy_with_logits.<locals>.make_weight_shape_kwargsc                 S   s   g | ]}|d fqS r,  r   rZ  r   r   r   r    s     zBsample_inputs_binary_cross_entropy_with_logits.<locals>.<listcomp>r   r   c                 S   s   g | ]}t t ft|d fqS r"  r  r%  r   r   r   r    s     c              	      s*   g | ]"}t t ft| t fd ddfqS r   r  )r  
pos_weightr  r%  r  r   r   r    s     c              
      s4   g | ],}t t ft| t t f t fd ddfqS )r   r  )r  r  r  r  r%  r  r   r   r    s     r  r   rT  )	r   r   r   r   r   	make_probr  r  r"  r   r  r   .sample_inputs_binary_cross_entropy_with_logits  s     "
r	  c              
   k   s  t tjddddg|||dV  tjdddddgdddddgdddddgdddddgdddddggtj|d}tttf|||d}d||< t |V  tttf|||dd}d||< t |V  ttdf|||d}t |V  t tjtf|||dV  t td|||dV  d S )	Nr   r   r   r  r   Tr}  r   )rC   r   r   rt  r   r>   r  )r   r   r   r   r   r  r  r   r   r   sample_inputs_argwhere  s(      


r
  c                  c   s<   t ft t ft t t ff} d}t| |D ]\}}||fV  q$d S )Nr  )r>   r   )ra  r  rz  r   r   r   r    _generate_sample_shape_reduction  s    r  c           	      +   sf   t t|||d t td|||ddd  fdd}| D ] \}}}}t|||f|dV  q@d S )	Nr   r   r   r   r   r   c                 s   s*   | V  | d d dV  | d d V  d S )Nr   r   )r   r   r  r   r   r   	gen_shape  s    z2sample_inputs_gaussian_nll_loss.<locals>.gen_shapec                  3   s   t  D ]\} }t| | D ]\}} |  ||t|dfV   |  ||td|dfV   |  ||ttdd|dfV   |  ||tdtdd|dfV  q qd S )Nr#  T)r  r  ư>MbP?)r   r  )r  r   r  )r  r   r   r  r  )rz  r   Zt_sZv_sr  r  Zmake_varr   r   r     s$       
    z9sample_inputs_gaussian_nll_loss.<locals>.gen_shape_kwargsr   r   )	r   r   r   r   r   r  r  r  varr   r  r   sample_inputs_gaussian_nll_loss  s    r  c                 k   s>   t t|||d}t D ]"\}}||||t|dfV  qd S )Nr   r#  )r   r   r  r   )r   r   r   r   r   r  rz  r   r   r   r   _generate_sample_inputs_nn_loss4  s    r  c           
      k   s   t | |||f|D ]L\}}}t|dk}d||< d|| < tdd|d< t||f|dV  qtt|||d}	t|	d	|	d	fd
V  d S )Nr   r   r   r7  r  r   r   r   r   )r  r   rF  r  r  rC   r   r   )
r   r   r   r   r   r  r  r  r  r  r   r   r   "sample_inputs_hinge_embedding_loss:  s    
r  c                 k   s@   t t|tjd}tt|dd|ddfddidtddV  d S )	Nr/  r   r   r  r   r   r  r   r  r  r   r   r   !error_inputs_hinge_embedding_lossG  s
      r  c           
      k   s&  t | |||f|E d H  tt|||d}dD ]}|jr|d}td|d< |d}t|dk}	d||	< d||	 < t||fd	|id
V  |d}td|d< |d}t|dk}	d||	< d||	 < t||fd	|id
V  |d}|d}t|dk}	d||	< d||	 < t||fd	|id
V  q,d S )Nr   r  r  r   r   r   r   r   r  r   r   r   r  )r   r   )r  r   r   ru  ry  r   rF  rC   )
r-  r   r   r   r   r   r  r8  r  r  r   r   r   %reference_inputs_hinge_embedding_lossM  s0    


r  c                 k   sD   t | |||f|D ],\}}}tdd|d< t||f|dV  qd S )Nr  r7  deltar   )r  r  r  rC   )r   r   r   r   r   r  r  r  r   r   r   sample_inputs_huber_lossn  s    r  c                 k   s~   t t|tjd}d}tt|dd|ddfddidt|dV  d	D ]4}d
}tt|dd|ddfd|idt|dV  qDd S )Nr/  z"is not a valid value for reductionr   r   r  r   r   r   r+  z:huber_loss does not support non-positive values for delta.r  )r   r   r   r   rD   rC   r  rx  )r-  r   r   r   r  r  r   r   r   error_inputs_huber_losss  s        r  c           	      +   s   t t|||d  fdd}| D ]\}}}t||f|dV  q"|jrtjtjfD ]<}t |d |dfdV  t |d |dfdV  qRd S )Nr   c                  3   s   t  D ]\} }dD ]}dD ]} | } | } | dd} | dd}|sZ|  |  |  |  ||t|||dfV  ||t||tdd|dfV  qqqd S )NrJ  r   r  )	log_inputr  r  :0yE>r  )r  r  r   r  )r  Zabs_r   r  r  )rz  r   lifi1i2t1t2r  r   r   r    s.      
z8sample_inputs_poisson_nll_loss.<locals>.gen_shape_kwargsr   r  r   )r   r   rC   r   r   rt  r  )	r   r   r   r   r   r  r  r  r  r   r#  r   sample_inputs_poisson_nll_loss  s    r$  c                 k   sb   t t|tjd}tt|dd|ddfddidtddV  tt|dd|dfd	d
dV  d S )Nr/  r   r   r  r   r   zabc is not validr   r   z]The size of tensor a \(5\) must match the size of tensor b \(4\) at non-singleton dimension 1r   r  r   r   r   r  r   r   r   error_inputs_poisson_nll_loss  s    r&  c                 k   sb   t t|tjd}tt|dd|ddfddidtddV  tt|dd|dfd	d
dV  d S Nr/  r   r   r  r   r   z&abc is not a valid value for reductionr   r   z]The size of tensor a \(4\) must match the size of tensor b \(5\) at non-singleton dimension 1r   r  r%  r   r   r   error_inputs_soft_margin_loss  s    r(  c           
      k   s~   t tttf|||d}dd dD tddfdd dD }|D ]8}| }| | f}	|rhtj |d	< t||	|d
V  q@d S )Nr   c                 S   s   g | ]}t |d qS ))r  r$  )rJ  r  r   r   r   r    s     z5sample_inputs_triplet_margin_loss.<locals>.<listcomp>)r  r'        $@T)Zswapc                 S   s   g | ]}t |d qS r"  r$  r%  r   r   r   r    s     r!  Zdistance_functionr   )	r   r   r>   r=   r   r   r  ZPairwiseDistancerC   )
r   r   r   r   with_distancer   r  Zkwargssr  r   r   r   r   !sample_inputs_triplet_margin_loss  s    r+  c              
      s   t t|||d d\}}}}}	|||	f}
|||	f}||||	f}||||	f}|
|f||fg}g }t|ddgddgddgD ].\}}}}||d |d t|||d	f qx fd
d|D S )Nr   )r   r   r   r   r   TFr
  r   r   r   )	is_causalneed_attn_weights	dropout_pc                    s0   g | ](\}}}t  | | |f|d qS r   r)  )rJ  Zshape_qZshape_kvr   r  r   r   r    s   z>sample_inputs_scaled_dot_product_attention.<locals>.<listcomp>)r   r   r   r   r   )r   r   r   r   r   r  ZN_primer<   r>   r  Zdim_3_q_shapeZdim_3_kv_shapeZdim_4_q_shapeZdim_4_kv_shapeZ
qkv_shapesr  r,  r-  r.  r   r  r   *sample_inputs_scaled_dot_product_attention  s.    

   
r0  c              
      sz   t t|||d d}d|}|d f|d f|tddf|tddf|tddf|tddf|td	d
fg} fdd|D S )Nr   r   r   T)r  r  rF  r  r'  )r   c                    s(   g | ] \}}t  | |f|d qS r/  r)  )rJ  r"  r   r  r   r   r     s    z3sample_inputs_pairwise_distance.<locals>.<listcomp>)r   )r   r   r   )r   r   r   r   r   r"  Zbatched_shaper  r   r  r   sample_inputs_pairwise_distance  s    

r1  c                    s,    fdddD  fdddD  S )Nc              	      s*   g | ]"}t td  dt|ddqS ))r   r7  r   r   r   upscale_factorr   rC   r   r   )rJ  r3  r   r   r   r    s
   z/sample_inputs_pixel_shuffle.<locals>.<listcomp>rn  c              	      s*   g | ]"}t t| d tdddqS )r   r   r2  r   r4  rZ  r   r   r   r    s
   )r   r   r   r   )r   r   r   r   )r   r   r   r   r   r   r   r   r   sample_inputs_pixel_shuffle  s    r6  c                    s,    fdddD  fdddD  S )Nc              	      s*   g | ]"}t td  dt|ddqS ))r   r   r   r   r   downscale_factorr   r4  )rJ  r8  r   r   r   r    s
   z1sample_inputs_pixel_unshuffle.<locals>.<listcomp>rn  c              	      s*   g | ]"}t t| d tdddqS )r   r   r7  r   r4  rZ  r   r   r   r    s
   r5  r   r   r   r   r   sample_inputs_pixel_unshuffle  s    r9  c           
      +   s   t t||d t  ddd}d}dd dd	tfttftttffD d
d |D  fdd|D }|r~| fdd|D  |D ]2\}	}t|r n||	|d||	|df|dV  qd S )Nr/  r   r   r  r!  c                 S   s   g | ]}|d fqS r,  r   rZ  r   r   r   r  1  s     z6sample_inputs_binary_cross_entropy.<locals>.<listcomp>r   r   c                 S   s   g | ]}t t ft|d fqS r"  r  r%  r   r   r   r  2  s     c                    s(   g | ] }t t ft| t t fd fqS r   r  r%  r  r   r   r  3  s     c              	      s*   g | ]"}t t ft| t fd ddfqS r  r  r%  r  r   r   r  8  s     r  r   )r   r   r>   r  rC   )
r   r   r   r   Zlogitsr   r  r  r  r"  r   r  r   "sample_inputs_binary_cross_entropy*  s"    "r:  c                 K   s   g }dt t t t fg}ddg}ddg}d}	t|||D ]\}
}}t|
|||d}||  |}t||ft||dd	}|| t|
|||d}t|
|||d}t||ft||dd	}|| q4|S )
Nr   {Gz?gؗҜ<r   r   r  r   )r  r  r   )r>   r   r   r~  r  rC   r   r   )r   r   r   r   r   r   r  r  r  r   rz  r  r  r  closeZclose_sampler   r   Zr_sampler   r   r   sample_inputs_allcloseB  s    
r=  c                 k   sn   t | |||f|E d H  |jrjttd||d}t||d|tjdfdV  t|tjd||dfdV  d S )Nr   r  r  r   )r  r   r   r   rC   r   r  r   r   r   r   r   r  r   r   r   sample_inputs_l1_lossW  s
    r?  c                 k   sb   t t|tjd}tt|dd|ddfddidtddV  tt|dd|dfd	d
dV  d S r'  r  r%  r   r   r   error_inputs_l1_loss`  s    r@  c                 k   sv   t | |||f|E d H  ttttf|||d}t|ddd|dddftdddV  t| | ftdddV  d S )	Nr   r   r   r  r   r   )r  r   )r  r   r   r>   rC   r   r>  r   r   r   sample_inputs_smooth_l1_lossn  s    (rA  c                 +   s   t td||d  fdd} fdd}d}d}t||d	D ]@\}	}
}||	}|r`||	n||	}t||ft|
|d
dV  qBd S )Nr
  r  c                    s"   t jj | d}| |S Nr   )r   r  r  r  r  r"  rD  r  r   r   make_log}  s    
z&sample_inputs_kl_div.<locals>.make_logc                    s"   t jj | d}| |S rB  )r   r  r  softmaxr  rC  r  r   r   r    s    
z'sample_inputs_kl_div.<locals>.make_prob)r   r  )r  r  Z	batchmeanr  rJ  )r  
log_targetr   )r   r   r   rC   r   )r   r   r   r   r   rD  r  ra  r  r"  r  rF  r  r  r   r  r   sample_inputs_kl_divx  s    rG  c                 +   s`   t t|||d  fddtjdtfddD E d H   fdddd	d
dtdfD E d H  d S )Nr   c                 3   s"   | ]\}}t  ||fV  qd S r,  r)  )rJ  r  r  r  r   r   rL    s     z&sample_inputs_pdist.<locals>.<genexpr>r   r   r  c                 3   s(   | ] }t  ttft|d dV  qdS )rF  r   N)rC   r>   r   )rJ  r  r  r   r   rL    s     r
  r'  r  r)  r   )r   r   rP  r   r>   ry  r   r   r  r   sample_inputs_pdist  s    &rH  r   c                 C   s^   t jjj}|dkr(|| d| jd  }n*|tdkrD|| dd }n|| d|d}|| jS )	Nr   Zhammingr   r   c                 S   s   t | |  S r,  )rV  r   r  )r   r   r   r   r   r    r  z!reference_pdist.<locals>.<lambda>Z	minkowskirF  )scipyZspatialZdistancepdistr"  ry  rq  r   )r  r  rJ  r  r   r   r   reference_pdist  s    
rK  c              	   K   sZ   t t|||d}t|dt|dt|dt|dtdddt|dtdddgS )	Nr   r   r   r   r   r  r   r   )r   r   rC   r   r   r   r   r   sample_inputs_diagflat  s    


rL  c                 k   s  t jjjt jjjt jjjd}dddd}tdd | D }|| j }|| j }	t		| }
|| j |
_t
|
|||f|D ]}|j |d krq||jd dkrq||jd r||	|jf|j\}}| |}|jd	 |jd
 |jd |j d}t||f|dV  q|d S )N)nn.functional.max_unpool1dnn.functional.max_unpool2dnn.functional.max_unpool3dr   r   r   c                 s   s"   | ]\}}|d |j  fV  qdS )znn.functional.N)ro  )rJ  r  vr   r   r   rL    s    z+sample_inputs_max_unpool.<locals>.<genexpr>rd  re  ra  r   rc  )ra  r   rc  rK  r   )r   r  r  
max_pool1d
max_pool2d
max_pool3dr   itemsrK  r  r  r  r   r   r~  r  r  rC   )r   r   r   r   r   Zunpool_name_to_pool_method_dictZunpool_name_to_dimZunpool_to_pool_name_dictZpool_dimZpool_methodZpool_op_infor  poolr  r  r)  r   r   r   sample_inputs_max_unpool  s:    




rV  c                 k   s@   t | |||f|D ](}|jd }|  | kr|V  qd S r  )rV  r   uniquer  )r   r   r   r   r   r  r  r   r   r   sample_inputs_max_unpool_grad  s    
rX  expacosasinatancoscoshloglog10log2tanr  sinsinhneg)rY  rZ  r  sqrt)rY  rZ  ceilerferfcexpm1floorlog1proundr   
reciprocalZsigmoidtruncr   )rY  rZ  r[  r\  foreach_unary_op_dbr<  )rY  rZ  Zsupports_alpha_paramsubr  z#Unable to reproduce failure locallyZTestForeachZ"test_binary_op_scalarlist_fastpathr  )device_typerY  )rY  rZ  rQ  divforeach_binary_op_dbZaddcmulZaddcdivforeach_pointwise_op_dbr  r  foreach_minmax_op_dbnormforeach_reduce_op_dbc                 C   s.   | j tjkr$tj| tjdtjS t| S Nr  )r   rV  Zbool_signr  rq  rr  r   r   r   reference_sign  s    r{  c                 C   sn   | j tjtjfkrt| S | t|  }|jdkrT| dkrPtjtdd| j dS |S | dk}tdd||< |S Nr   r  )	r   rV  r  r  r{  r   rU  arrayr  )r   rD  r  r   r   r   reference_sgn  s    
r~  c                 C   s2   | j tjtjfkr&ddt|    S tj| S r   )r   rV  r  r  rY  rI  specialZexpitrr  r   r   r   reference_sigmoid  s    r  c              	   C   s2   t | dk | t t |  t t |   S r  )rV  whererl  rY  rr  r   r   r   reference_logsigmoid  s
    r  c                 C   s4   | d d }t |dd }t |dkd|| jS )Nr   r   r   r   )rV  clipr  rq  r   )r   Zintermediater   r   r   r   reference_hardsigmoid  s    r  c                 C   sZ   | j jdkr2t| tdktjtd| j d| } tj| }| j tj	krV|
tj	}|S )Nr  rY  r   r  )r   kindrV  r  ry  r}  rI  r  Zgammalnro  rq  )r   rD  r   r   r   reference_lgamma  s    
&r  c                 C   s0   | j tjkr"tj| |tjS tj| |S r,  )r   rV  ro  rI  r  Zmultigammalnrq  )r   r  r   r   r   r]    s    r]  r   c                 C   s<   | | |k}|   }tdt|| |   | ||< |S r   )r  rV  r_  rY  )r  r  	thresholdZ
non_linearr  r   r   r   reference_softplus  s    $r  r  r  c                C   s,   dd }dd }|dkr || S || S d S )Nc                 S   s   | t j|  S r,  )r   rw  Zcdf)Xr   r   r   	_gelu_ref  s    z!reference_gelu.<locals>._gelu_refc                 S   s>   t dt j }|| dt| d   }d|  dt|  S )Nr   gHm?r  r   r'  )r  rf  pirV  powerr  )r  ZM_SQRT_2_PIZr   r   r   _tanh_gelu_ref  s    z&reference_gelu.<locals>._tanh_gelu_refr  r   )r  r  r  r  r   r   r   reference_gelu  s
    r  r   )r   r(  r=  c                 C   sp   |dkrt t| d }| dtjd| jtjd|  }tj| j|f| jd}t	||d |j| j
d S )Nr   r   r   r  )r   )r  rV  r  r  r  r  r  r  r   putr"  )r   r(  ZidcsZone_hotr   r   r   reference_one_hot  s    "r  r  c                 C   s8   | | d }|dkrt |S |dkr0t |S |S d S )Nr   r  r  )rV  r  r  )r  r  r  ser   r   r   reference_mse_loss  s    

r  c              
   O   s2   t  " td | ||W  5 Q R  S Q R X dS )zWrapper to set seed manually for some functions like dropout
    See: https://github.com/pytorch/pytorch/pull/62315#issuecomment-896143189 for more details.
    r/  N)r9   r   Zmanual_seed)r-  r   r   r   r   r   wrapper_set_seed  s    
r  r  )r8  r  c                 C   s   t | ||||d S r  )reference_native_layer_norm)r8  r  r  r  r   r   r   r   reference_layer_norm%  s    r  c                 C   s  t |}| d|}|jddd}|jdddd}|| t ||  }	|d krj|d k	rj|	|d }	nH|d k	r|d kr|	|d }	n(|d k	r|d k	r|	|d |d }	| jt| }
| jd |
 dt|  }|	j| j ||dt ||  |fS )Nr   Tr  keepdimsr   r  ddofr  r   r'  )	rV  r?  r  r  r  rf  rU  r  r"  )r8  r  r  r  r   Zfeature_sizeinp_viewr  r  Yr  Z
stat_shaper   r   r   r  )  s    
r  )r8  r  c           	      C   s   | }t | jdkr*| | jd |df}|jddd}|jdddd}|| t ||  }|| j}|d k	rt|jdkrt t 	|ddgt
| jdd   }|| }|d k	rt|jdkrt t 	|ddgt
| jdd   }|| }|S )Nr   r   Tr  r  r   r   )rV  r?  r"  r  r  r  rf  r  tileZexpand_dimsr  )	r8  r  r  r  r   r  r  r  r  r   r   r   reference_group_norm:  s     ((r  r#  c                    sn  |sdkrdndt jdkrHtj d}|rD|tjS |S jd dkrd k	rf tj   d}|r|tjn|}| jS  j}tjd d }t	d|}	|d |d  d k	r|dfdd|	D }
 fd	d|	D }fd
d|	D }fddt
|
||D }|rVdd |D n|}t||S d S )Nr  r#  r   r$  r%  r   r   c                    s   g | ]} | qS r   r   r  )sorted_sequencer   r   r  f  s     z*reference_searchsorted.<locals>.<listcomp>c                    s   g | ]} | qS r   r   r  )boundaryr   r   r  g  s     c                    s    g | ]} d k	r | nd qS r,  r   r  )r%  r   r   r  h  s     c                    s$   g | ]\}}}t j|| |d qS )r  )rV  searchsorted)rJ  Zs_seqr   Zs_sort)r$  r   r   r  j  s   c                 S   s   g | ]}| tjqS r   )rq  rV  r  r  r   r   r   r  l  s     )r  r"  rV  r  rq  r  flattenr  r?  rk  r  stack)r  r  r  r  r$  r%  retZ
orig_shapeZ
num_splitssplitsZsplit_sequenceZsplit_boundaryZsplit_sorterZ	split_retr   )r  r$  r  r%  r   reference_searchsortedR  s0    


r  c                    s   d d dd fdd
}|S )Nr  )size_averagerD  r  c                   sR   |d k	s|d k	rt d | |f|}|dkr8t|S |dkrJt|S |S d S )NzbThe keyword arguments 'size_average' and 'reduce' are deprecated and not supported by this wrapperr  r  )rx  rV  r  r  )r  r  r  rD  r  Zother_kwargsr  r  r   r   wrapperp  s    

z1loss_reference_reduction_wrapper.<locals>.wrapperr   )r  r  r   r  r    loss_reference_reduction_wrappero  s    r  r'  c                 C   sX   | | }t |}||k}t | }|| d|  ||< ||  d d|  || < |S )Nr   r   )rV  r   
empty_like)r  r  r  diffZabs_diffZabove_thresholdZlossr   r   r   reference_smooth_l1_loss  s    

r  c                    s(   t |  t tjd fdd}|S )z>Forwards unbiased/correction kwargs as NumPy's equivalent ddofrr  c                    sV   d|krd|krt d|kr0t|d|d< nd|krF|d|d<  | f||S )Nr  r  r  )r  r  rG  r   r   r   gr   r   r    s    z"reference_std_var.<locals>.wrapper)rs   r   rV  r  )r  r  r   r  r   reference_std_var  s    
r  r  c                 k   sx   dddifV  dddifV  d|krtd|krtdddifV  ddd	ifV  t | j|d  }dd|d
 ifV  dS )z:Generates unbiased/correction kwargs for std/var operatorsr   r  TFr   r  r  r   r   r   N)r   r   r"  r  r?  )r  r   r  r   r   r   generate_std_var_kwargs  s    r  c           	   	   K   s   d}t tdtj|dg fd}d}t tdtj|dg fdtjid}d}t tdtj|dg ftjtg tj|dd	d}t||d
t||d
t||d
fS )Nzomean\(\): could not infer output dtype. Input dtype must be either a floating point or complex dtype. Got: LongrN  r   r   zrmean\(\): could not infer output dtype. Optional dtype must be either a floating point or complex dtype. Got: Longr   r   z?Expected out tensor to have dtype double, but got float instead)r   rD  r   )rC   r   r   r  r   r  rD   r   r   r   r   error_inputs_mean  s.    


r  c                 C   s   | j }t|}||fD ]L}|dkr*|dks| |  kr@|k sn td|  d|d  d| q|dkrp|n|| }|dkr|n|| }|dkr|}||k rtdttj|||d  d}|d | |f ||d d   }t	| |S )Nr   rW  z4Dimension out of range (expected to be in range of [r  r   z], but got z?flatten() has invalid args: start_dim cannot come after end_dim)
r"  r  r  rx  r  rD  r  r  rV  r  )r  r  r  r  Zin_rankr  Zflatten_bit_dimZ	out_shaper   r   r   reference_flatten  s    (""r  )absolutez.In-place abs not supported for complex tensorsrL  Ztest_inplace_grad)rY  Ztest_inplace_gradgradZtest_inplace_forward_mode_ADrJ  rK  Z test_reference_numerics_extremalr0  Ztest_reference_numerics_largeZtest_reference_numerics_small)rY  	active_ifZtest_out_arg_all_dtypes)rV  rU  rY  rZ  rQ  r\  assert_autodiffedsupports_sparse_csrsupports_sparse_cscsupports_sparse_bsrsupports_sparse_bscr[  )arccosrB  r;  Ztest_reference_numerics_normal)rr  rY  r  Ztest_fn_gradZtest_method_gradZtest_forward_mode_AD)
rV  rU  r/  rY  rZ  r  r[  r\  rX  rQ  acosh)arccosh)r   NrT  c                 C   s    |   s| dk S tj| tjdS )Nr   r  )r   r   
zeros_likert  rr  r   r   r   r  D   r  r  )	conditionZsafe_val)rV  rU  r/  rY  rZ  rX  supports_inplace_autogradr[  r\  rQ  reference_numerics_filter)ro  c                C   s(   |dkrt | |S t | t ||S r   rV  r<  r}  r  r*  ro  r   r   r   r  H   s   )r  r  ZTestBinaryUfuncsZtest_reference_numericsZTestCudaFuserOpInfoZtest_nvfuser_correctnessZTestNNCOpInfoZtest_nnc_correctnessrN  Ztest_numpy_refsZ'test_reference_numerics_extremal_values)	rU  rY  r  r  r\  r[  supports_two_python_scalarsrX  rQ  r  ZTestNormalizeOperatorsZ"test_normalize_operator_exhaustiveZtest_noncontiguous_samplesZtest_variant_consistency_eagerZTestMathBitstest_neg_viewZtest_conj_viewZtest_neg_conj_viewZTestLazyOpInfoZtest_dispatched_to_lazyZtest_correctnessZ test_correctness_with_reusing_irZtest_nvfuser_extremal_valuesrM  Ztest_variant_consistency_jitZtest_out_warning)rY  supports_outsupports_autogradis_factory_functionerror_inputs_funcr  rQ  r  c                 O   s   t tjj| f||S r,  )r  r   rC  uniform_r8  r   r   r   r   r   r     r  ZTestProxyTensorOpInfoZ test_make_fx_symbolic_exhaustiveZ
TestDecompZ
test_quick)
r-  method_variantinplace_variantrY  r  r  r  r  r  rQ  Z	clamp_maxrN  Ztest_type_promotion)rr  Ztest_errors)rU  rY  r[  supports_rhs_python_scalarr\  rs  rQ  Z	clamp_min)r}  )rV  rY  r  r[  r\  r  c                C   s   t | t ||S r,  )rV  subtractr}  r  r   r   r   r     r  )r  Z#test_complex_half_reference_testingg{Gzt?Ztest_comprehensiveZ$test_reference_numerics_small_values)
rU  rV  rY  r  r[  r\  r  r  rX  rQ  ZaddmmZTestSchemaCheckModeOpInfoZtest_schema_correctness)	rY  dtypesIfROCMrZ  r  r[  r\  gradcheck_nondet_tolr  rQ  Z
decomposedz	aten::addzaten::mmr  )
rW  rY  rZ  r  r[  r\  r  autodiff_nonfusible_nodesr  rQ  Zaddmv)rY  rZ  r[  r\  r  Zaddbmmc                 C   sF   t t t j|| jd| t t j||jdt jt ||ddS )Nr  r   r  )rV  r<  r}  Zasarrayr   r  matmul)r=   Zbatch1Zbatch2r  ro  r   r   r   r  +!  s   g'eRC>ga2U0*S?Ztest_dtypes)rr  r  )	rU  rY  rZ  gradcheck_fast_moder[  r\  rX  rQ  r  Zbaddbmm)	rY  rZ  backward_dtypesIfCUDAr  r[  r\  rX  r  rQ  dot)rY  rZ  r  r  r[  r\  rQ  Zvdot)rY  rZ  r  r[  r\  rQ  Zbmm)rY  rZ  r  assert_jit_shape_analysisr[  r\  rQ  r  mv)rY  rZ  r  r[  r\  r  addr)rY  backward_dtypesr  r[  r\  rQ  r  r  )r  )rY  rZ  r  r[  r\  rQ  r  reference_inputs_func)rY  rZ  r[  r\  rQ  r  r  )arcsinr  z&Skipped! sparse backward not supportedZTestSparseUnaryUfuncsZtest_sparse_fn_grad)rV  rU  r/  supports_sparser  r  r  r  r[  r\  rY  rZ  r  rX  rQ  asinh)arcsinh)rV  rU  rY  rZ  rX  r  r[  r\  r  r  r  r  r  rQ  )arctan)r  rr  )r  rr  rY  )rV  rU  rY  rZ  r  r[  r\  r  r  r  r  r  rX  rQ  atan2)Zarctan2Ztest_jit_alias_remapping)rV  rY  rZ  r[  r\  promotes_int_to_floatr  rQ  atanh)arctanh)rV  rU  r/  rY  rZ  rX  r  r[  r\  r  r  r  r  r  rQ  allclose)rY  rU  r  r[  r  rQ  r  broadcast_to)rU  rY  r  r[  r\  check_batched_forward_gradr  r^  z1.20.0)
r-  rU  rY  r  supports_gradgradr  r  supports_scriptingr  rQ  Zbroadcast_tensors)	rU  rY  r  r  r  r[  r\  r  rQ  Z
block_diag)rY  r  r[  r\  r  rQ  r  bitwise_not)rU  rY  operator_variantr  bitwise_left_shiftr  )	r-  rY  rZ  r  inplace_operator_variantr  supports_one_python_scalarrs  rQ  bitwise_right_shiftcombinations)r-  rY  r[  r\  r  r  r  cartesian_prod)r-  rY  r  r[  r\  r  r  rQ  Zcdist)rY  r  r  r  r  c                 c   s   | ]}|t jkr|V  qd S r,  r   r  r  r   r   r   rL  "  s     
 rL  )rU  rY  rZ  r[  r\  rQ  r  r  r  r  r  r  Zcholesky)rY  r  gradcheck_wrapperrX  Zcholesky_inverseZtest_out)
rY  r  r  r\  r[  check_batched_gradgradr  r  rX  rQ  cholesky_solvec                  O   s   t | ddi|S Nr  r   rg   r   r   r   r   r  #  r  )r-  rY  r  r  r[  r\  r  rX  ri  )rY  r  r  r[  r\  r  r_  Ztest_numpy_ref)rU  rY  r  r  r[  r\  r  rQ  
contiguousc                 O   s   | j ||S r,  )r  r  r   r   r   r  '#  r  zaten::contiguous)
r-  rY  r  r  r[  r\  autodiff_fusible_nodesr  r  rQ  sum_to_sizec                 O   s   | j ||S r,  )r  r  r   r   r   r  4#  r  )r-  rY  r  r  r[  r\  r  rQ  ZsymeigZmps)rY  check_batched_gradr  r  r  rQ  rX  clamp)r  )
rV  rU  rY  rZ  r  r  r  r[  r\  rQ  positive)rU  rY  r  r[  r\  r  )rU  rY  r  r[  r\  r  r  Zconj_physicalZ_conj_physicalz2Skipped! conj_physical_ not implemented for sparseZtest_inplace)decomp_aten_namerU  rY  r[  r\  r  r  r  r  r  rQ  Zresolve_conj)rY  r  r[  r\  r  Zresolve_negr   )rY  r[  r  r\  r  Ztest_conjugated_samplesr   )rY  r  r[  r\  r  r  rQ  r  )rY  r[  r\  r  rQ  copysign)rY  r  r  r[  r\  Zcorrcoef)rY  rZ  r  r[  r\  r  rQ  r  )rY  rr  r  )rY  rr  )	rU  rY  rZ  r  handles_large_floatsr[  r\  rX  rQ  )rU  rY  rZ  r  r[  r\  rQ  ZcovZtest_fn_gradgradzBarely failsZtest_fn_fwgrad_bwgrad)	rY  rZ  r  r  r  r  r[  r\  rQ  Zcross)rY  rZ  r  r\  r  r[  Zcumsum)rY  rZ  r[  r\  rQ  r  Zcumprod)rY  rZ  r[  r\  rQ  r  r  Zcummax)rb  r   )rY  rZ  r  r[  r\  rQ  r  ZcumminZdeg2radgffffff?)rU  rX  rY  r[  r\  rQ  r  c                 C   s.   t | |||d krt jn||d kr(t jn|S r,  )rV  r  _NoValue)r  r  r   r
  r   r   r   r   r  s$  s    )	r-  rU  rY  r  r[  r\  r  r  rQ  )divideZno_rounding_mode)rV  rW  rY  rZ  r  r[  r  r\  r  r  rs  Ztrunc_rounding)Zrounding_mode)r)  Ztest_working)rV  rW  rY  r  r  r[  r  r\  r  r  rs  rQ  Zfloor_roundingZtrue_divide)rY  rZ  r[  r  r\  r  rs  equalc                 C   s   | |k  S r,  )r+  )r  r*  r   r   r   r  $  r  )rY  rU  r  r  Zsupports_tracingrQ  )rU  rY  rZ  rQ  r  r[  r\  rE  c                 C   s
   |  |S r,  )rE  rj  r   r   r   r  $  r  )r-  rY  r  r[  r\  r  r  rQ  	expand_asc                 C   s
   |  |S r,  )r  )r  r*  r   r   r   r  $  r  )r-  rY  r[  r\  r  r  rQ  Zdiag)rY  rZ  r[  r\  r  r  r  )rY  r  r  r[  r\  r  r  r  r  )zlinalg.diagonalZdiagonal_backward)	rV  aten_backward_namerY  r  r[  r\  r  r  r  Zdiagonal_scatter)rY  r  r[  r\  r  r  )rU  rY  always_returns_boolr  r  rQ  fmax)r-  rY  r[  r\  r  rQ  fminfmodrO  Ztest_contig_vs_every_otherZtest_non_contig)	rU  rY  rZ  r  r[  r\  r  rs  rX  	remainderZ
TestOpInfoZxla)rU  rY  rZ  r  r[  r\  r  r  r  r  rs  rX  c                 C   s   t | d S r  )rV  modfrr  r   r   r   r  c%  r  Zstftz0Skipped! stft does not match the native function)rX  rY  r  r  r[  r\  r  r  r  r  r  Zistftz1Skipped! istft does not match the native functionZTestCompositeComplianceZtest_backward)rY  r  r  r[  r\  r  r  r  r  rX  rQ  c                 c   s   | ]}|t jkr|V  qd S r,  r  r  r   r   r   rL  %  s     
 flip)r-  rY  r  r[  r\  r  fliplr)r-  rY  r  r  r[  r\  r  flipudzsparse.sampled_addmm)re  r   z!cusparseSDDMM was added in 11.2.1ZTestTagsZ	test_tagsZtest_operator)rY  r  r  rX  rQ  i0)z
special.i0r@  r   )
rU  rV  rX  rY  rZ  r  r[  r\  r  rQ  r  )rU  rY  r  rs  r  rQ  frexpZtest_batch_vs_slicingZtest_contig_vs_transposedZtest_non_contig_expandZtest_variant_consistency)r  )r-  rU  rY  rZ  rX  r[  r\  rQ  )zspecial.log1p)r   N)rU  rV  r/  rY  rZ  rX  rQ  r[  r\  r  r  r  r  r  r  ge)greater_equal)rU  rV  rY  r  r  rQ  Zgeqrf)rY  r  rX  r  rQ  gt)greaterimag)rU  rY  r  r[  r\  r  rQ  Zgradient)	rY  r  r[  r\  r  rQ  r  r  r  isin)rY  rZ  r  r  Zkthvaluele)
less_equalZlinspace)rY  r  r  r  r  r  rQ  Zlogspace)rY  rZ  r  r  r  r  r  rQ  )r   Nc                 C   s   t | dk S r  r   r   rr  r   r   r   r  &  r  )rU  r/  rY  rZ  r  r  r[  r\  rX  rQ  r  c                 C   s   t | dk S r  r  rr  r   r   r   r  &  r  )
rU  r/  rX  rY  r  rZ  r[  r\  rQ  r  c                 C   s   t | dk S r  r  rr  r   r   r   r  '  r  )
rU  r/  rY  rZ  r  r[  r\  rX  rQ  r  ldexp)
rY  r  r[  r\  r  r  r  r  rQ  rX  Z	logaddexpc                 K   s0   t tttf|||dtttf|||dfdfS r0  r   r   r   r   r   r  0'  s    )rY  rZ  r  r[  r\  r  Z
logaddexp2c                 K   s0   t tttf|||dtttf|||dfdfS r0  r   r   r   r   r   r  9'  s    logical_not)rU  rX  rY  r  rQ  lt)less	lu_unpack)r-  rY  r  r[  r\  rQ  r  lu)	r-  rY  r  r[  r\  r  r  rX  rQ  lu_solvezTests different backward pathsZ'test_floating_inputs_are_differentiable)r-  rY  r[  r  r\  r  rQ  rX  Zmasked_fill)rY  r  r  r[  r\  r  r  Zmasked_scatter)rY  r  r[  r\  r  r  rQ  Zmasked_select)rY  r[  r\  r  r  Z
matrix_exp)zlinalg.matrix_exp)rY  rZ  rV  r  r  r  r[  r\  r  rQ  r  r  )zlinalg.matmul)r:  r  z67470!)rV  rY  rZ  r  r  r  r[  r\  r  r  rX  rQ  r  Zreduction_with_dim)rW  rY  r  r\  rQ  r[  Zreduction_no_dim)rW  rY  r  r[  r\  r  rQ  Zmedianr  )rY  rZ  r  r[  r\  r  Z	nanmedianZvar_mean)rY  r  r  r[  r  r\  Zstd_meanmeshgridZvariadic_tensorsr>  )r<  ZTestOperatorSignaturesZ(test_get_torch_func_signature_exhaustive)	rW  rU  rY  r  rQ  r  r\  r[  r  Zlist_of_tensorsr  )
rW  rY  r  rQ  r  r  r  r\  r[  r  r_  )rW  rY  r  r\  r[  rQ  Zquantile)rY  r  r[  r\  rQ  r  Znanquantile)r  binary)	rV  rW  rY  r[  r\  r  rU  r  rQ  )rY  r[  r\  rU  r  rQ  )r  logical_and)rU  rY  r  r  r  
logical_orlogical_xor)rU  rY  r  r  r  rQ  bitwise_and)rU  rY  r  r  r  r  rQ  
bitwise_orbitwise_xor	heavisidec                 C   s6   | j tjkr*|j tjkr*tt| |S t| |S r,  )r   rV  r  r+  )r   r   r   r   r   r  (  s    )rU  rY  r  r  rQ  lcm)rU  rY  r  r  gcdisclose)rU  rY  r  r  r  r  r  rQ  rE  )zspecial.softmaxznn.functional.softmaxZ_softmax_backward_data)rV  	aten_namer  rY  rZ  r  r  r  r[  r\  r  
with_dtype)r0  )	rV  rW  r/  rY  r  r  r[  r\  r  znn.functional.softminZsoftmin)	r/  rY  rZ  r  r  r  r[  r\  r  )rW  r/  rY  r  r  r[  r\  r  znn.functional.cross_entropy)rY  rZ  r  r  r[  r\  rX  rQ  znn.functional.normalize)rY  rZ  r  r[  r\  r  c                 C   s    t j| ||dt j| ||dfS )Nr  )rV  r  r  )r   r   r  r   r   r   r  h)  r  )rU  rY  rZ  rX  r  r  r  rQ  r  c                 C   s   t j| |||dS Nr   )r   r  )r   r  r   r   r   r   r   r  t)  s    z&Errors when storage_offset is includedzNumerous errors)r-  rY  r  r[  r\  "check_inplace_batched_forward_gradr  rQ  as_strided_scatterc                 C   s   t j| ||||dS r1  )r   r3  )r   r  r  r   r   r   r   r   r  )  s    zWorks only for CPU complex64z,Works for float64, fails for everything elsez*Works for int64, fails for everything elsez3Fails in most cases, passes on LAZY for some reasonz.Only fails for LAZY, passes on everything elsez$Passes on complex64 and float32 onlyzFails on cuda + rocmz%Passes on complex128 and float64 onlyz-Expected: new_empty_strided is not comparableZnative_layer_norm)
r/  rU  rY  rZ  r  r  r\  r  r  rQ  Znative_batch_normZTestFakeTensorZtest_fake_autocastZ	test_fake)r/  rY  rZ  r[  r\  r  r  rQ  znn.functional.cosine_similarityZcosine_similarity)r/  rY  rZ  r  r[  r\  r  z!nn.functional.adaptive_avg_pool1d)rY  rZ  r  r[  r\  r  r  z!nn.functional.adaptive_avg_pool2d)rY  rZ  rX  r  r[  r\  r  r  z!nn.functional.adaptive_avg_pool3d)	rY  rZ  rX  r  r  r[  r\  r  r  z!nn.functional.adaptive_max_pool1d)rY  rZ  r  r[  r\  r  r  r  z!nn.functional.adaptive_max_pool2d)	rY  rZ  rX  r  r[  r\  r  r  r  z!nn.functional.adaptive_max_pool3dznn.functional.avg_pool1dZ
avg_pool1d)
r/  r  r  r[  r\  rY  rZ  r  r  r  znn.functional.avg_pool3dZ
avg_pool3d)
r/  r  r[  r\  rY  rZ  r  r  r  rQ  z.nn.functional.binary_cross_entropy_with_logitsZ binary_cross_entropy_with_logits)
r/  r  r[  r\  r  rY  rZ  r  r  rQ  znn.functional.reluZreluc                 C   s   t | dkd| S r  rV  r  )r   r   r   r   r  o*  r  )	r/  rU  r  rY  rZ  r  r  r\  r[  znn.functional.conv_transpose1dr  r  )r  gkNuϵ>)rU  r/  rV  rY  rZ  r  r[  r\  r  r  rX  rQ  r  znn.functional.conv_transpose2dconv_transpose2d)r5  )r/  rV  rY  rZ  r  r[  r\  r  r  rX  rQ  r  znn.functional.conv_transpose3dconv_transpose3d)r6  g-C6*?gC8
!?gh㈵>Ztest_forward_adzSkipped! 75029zSkipped! 75363)r/  rV  rY  rZ  r  r[  r\  r  r  r  rX  rQ  r  znn.functional.conv1d)conv1dr7  ZTestDtypeCustomRulesZtest_custom_rules)rV  r/  rY  rZ  r  r  r[  r\  r  r  rX  rQ  supports_expanded_weightr  znn.functional.conv2d)conv2dr9  gQ?zWorks on some configs!)rV  r/  rY  rZ  r  r  r  r  r[  r\  r  rX  rQ  r8  r  znn.functional.group_norm
group_norm)r:  )r/  rV  rU  rY  rZ  r  r[  r\  rX  r  r8  znn.functional.instance_norm)rY  rZ  r  r[  r\  rX  r  r8  znn.functional.layer_norm
layer_normZlayer_norm_backward)r;  )r/  r  rV  rU  rY  rZ  r  r[  r\  r  rX  r  r8  z!nn.functional.local_response_norm)rY  rZ  r  r[  r\  rX  r  Zconstant_pad_nd)r[  r\  rY  r  r  rQ  znn.functional.padrx  )rW  r/  r  r[  r\  rY  r  r  ry  )	rW  r[  r\  rY  rZ  r  rQ  r  r  rz  r{  )	rW  rY  r  r[  r\  r  r  rQ  r  znn.functional.hardswishZ	hardswishZhardswish_backwardzaten::hardswish)r/  r  r  r  r  rY  rZ  r  r[  r\  r  r  znn.functional.unfoldZim2colzInternal assert failed!)	r/  rY  rZ  r  r  r[  r\  r  rQ  znn.functional.interpolateZinterpolater  )
r/  rW  r  r\  r[  rY  rZ  r  rQ  r  r  r  )r/  rW  r\  r  r[  rY  rZ  r  r  rQ  r  r  )r/  rW  r  r[  r\  rY  rZ  r  r  rQ  r  r  )r/  rW  r  r[  r\  rY  rZ  r  r  rQ  r  r  znn.functional.upsample_bilinear)	r  r[  r\  rY  rZ  r  r  rQ  r  znn.functional.soft_margin_loss)r  )rY  rZ  r  r[  r  r  znn.functional.upsample_nearestz!nn.functional.margin_ranking_loss)rY  rZ  r  r  r  r  r[  r\  znn.functional.multi_margin_loss)rY  rZ  r  r  r  z$nn.functional.multilabel_margin_lossznn.functional.leaky_relu
leaky_reluZleaky_relu_backwardc                 C   s   t jjj| |ddS NTinplace)r   r  r  r<  )r   Znegative_sloper   r   r   r  s,  s    zaten::leaky_relu)rV  r/  r  r  rY  rZ  r  r  r  r  r  r[  r\  r  z)nn.functional.multilabel_soft_margin_loss)r  rY  rZ  r  r[  rX  rQ  znn.functional.avg_pool2dZ
avg_pool2d)	r/  r  r[  r\  rY  rZ  r  r  rQ  z#nn.functional.fractional_max_pool2dc                 O   s   t tjjj| f||S r,  )r  r   r  r  Zfractional_max_pool2drB  r   r   r   r  ,  s    )r  r  r[  r\  r-  r  rY  rZ  r  r  rX  z#nn.functional.fractional_max_pool3dc                 O   s   t tjjj| f||S r,  )r  r   r  r  Zfractional_max_pool3drB  r   r   r   r  ,  s    r}  rQ  zWorks on some configs)r/  r  r  r[  r\  r  r  rY  rZ  rQ  r  r  r~  rR  )r/  r  r  r  r[  r\  r  r  rY  rZ  r  r  r  rS  )r/  r  r  r[  r\  r  r  rY  rZ  r  r  r  rM  Zmax_unpool1d)
r/  r  r[  r\  r  r  rY  rZ  r  rQ  r  )
rW  r/  r  r[  r\  r  r  rY  rZ  r  rN  Zmax_unpool2d)rW  r/  r  r[  r\  r  r  r  rY  rZ  r  rO  Zmax_unpool3d)
r/  r  r[  r\  r  r  rY  rZ  r  rQ  znn.functional.linear)r/  r  r  rY  r  rZ  r  r  r[  r\  r  r8  rX  znn.functional.bilinear)
r/  r  r  rY  rZ  rQ  r  r[  r\  r  znn.functional.gluZglu)
r/  r  r  rY  r  rZ  r  r[  r\  r  znn.functional.eluZelu_backwardc                 C   s&   t d| t d|t | d   S Nr
  r   rV  r  r  rY  r   ro  r?  r   r   r   r  -  s    c                 C   s   ddiddifS Nro  r&  r   r   r   r  r   r   r   r  -  s    c                 C   s   t jjj| |ddS r=  )r   r  r  Zelur   ro  r   r   r   r  -  s    )r  rU  rY  rZ  r[  r\  r  r  r  r  r)  r  rX  znn.functional.preluZprelu_backwardc                    sF   t d| t d| | jdkr" n  fddtd| jD   S )Nr
  r   c                    s   g | ]}|d kr j nd qS r   r  r  r(  r   r   r  -  s     z<lambda>.<locals>.<listcomp>r   )rV  r  r  rU  r  rk  )r   r  r   r(  r   r  -  s    ,)r  rU  rY  rZ  r[  r\  r  r  r  r  r)  r  r  r  rX  znn.functional.celuc              	   C   s*   t d| t d|t | | d   S r@  rA  rB  r   r   r   r  -  s    c                 C   s   ddiddifS rC  r   rD  r   r   r   r  -  s    c                 C   s   t jjj| |ddS r=  )r   r  r  ZcelurE  r   r   r   r  -  s    )rU  rY  rZ  r[  r\  r  r  r  r  r)  r  rX  znn.functional.rreluZrrelu_with_noise_backwardc                 O   s   t tjjj| f||S r,  r  r   r  r  ZrrelurB  r   r   r   r  -  s    c                 O   s    t tjjj| f|ddi|S Nr?  TrF  rB  r   r   r   r  -  s    c                 C   s   t ddddt ddddfS )Nr
  r'  Tr  r  r  r$  rD  r   r   r   r  -  s    r
  rH  r$  zDifferent noise)r  r-  r  rY  rZ  r  r[  r\  r  r)  r  r  rX  rQ  znn.functional.seluc              	   C   s*   dt d| t ddt | d    S )Ng2֫?r
  g,x?r   rA  r   r?  r   r   r   r  .  s    $c                 C   s   t jjj| ddS r=  )r   r  r  Zselurr  r   r   r   r  '.  r  g;On?)rU  rY  rZ  r[  r\  r  r  r  r  r  rX  z+nn.functional._scaled_dot_product_attentionc                 O   s   t tjjj| f||S r,  )r  r   r  r  Z_scaled_dot_product_attentionr  r   r   r   r  3.  s    g-C6
?gh㈵>ZTestMetaZ	test_metazNot ImplementedZtest_dispatch_metaZTestFakeTensorNonErroringZSkipped)
r-  r  rY  rZ  r  r[  r\  r  rX  rQ  znn.functional.siluZsilu_backwardc                 C   s   | dt |    S r   rV  rY  rI  r   r   r   r  U.  r  c                 C   s   t jjj| ddS r=  r   r  r  Zsilurr  r   r   r   r  ].  r  z
aten::silu)r  rU  rY  rZ  r[  r  r\  r  r  r  rX  rQ  r  c                 C   s   | dt |    S r   rJ  rI  r   r   r   r  x.  s    c                 C   s   t jjj| ddS r=  rK  rr  r   r   r   r  .  r  )rW  rU  rY  rZ  r[  r  r  r  r  rX  rQ  znn.functional.hardsigmoidZhardsigmoid_backwardr>  )r  rU  rY  rZ  r  r  r  r[  r  r  rX  rQ  znn.functional.logsigmoidZlog_sigmoidZlog_sigmoid_backward)r/  r  rU  rY  rZ  r  r  r[  r  rX  rQ  znn.functional.mishZmish_backwardc                 C   s   | t t|  S r,  )rV  r  r  rr  r   r   r   r  .  r  )r  rU  rY  rZ  r[  r\  r  r  r  r  r  rX  znn.functional.softsignc                 C   s   | t | d  S r   rV  r   rr  r   r   r   r  .  r  )rU  rY  rZ  r[  r\  r  r  r  r  rX  rQ  znn.functional.tanhshrinkc                 C   s   | t |  S r,  )rV  r  rr  r   r   r   r  .  r  gMb?z#Fails on some jobs works on others!znn.functional.thresholdc                 C   s   t | |k|| | jS r,  )rV  r  rq  r   r   r  r  r   r   r   r  /  r  c                 C   s   t jjj| ||ddS r=  )r   r  r  r  rM  r   r   r   r  /  s    c                 C   s    t dddt dddfS )Nz	0x1.3ap-3r  )r  r  )ry  fromhexrD  r   r   r   r  /  s   )rU  rY  rZ  r  r[  r\  r  r  r  r)  r  z!nn.functional.triplet_margin_loss)r  rY  rZ  r  r[  r\  z/nn.functional.triplet_margin_with_distance_loss)r*  )r  rY  rZ  r  r[  r\  rQ  Z	nextafter)rY  r  r  r3  c                 O   s   | j ||S r,  )r3  r  r   r   r   r  M/  r  )r-  rY  r[  r\  r  r  rQ  Ztopk)rY  rZ  r[  r\  r  r  znn.functional.batch_normZ
batch_norm)	r/  rY  rZ  r  r[  r\  r  r  rQ  Zwithout_cudnn)
rW  r/  rY  rZ  r  r[  r\  rX  rQ  r  z"nn.functional.binary_cross_entropyZbinary_cross_entropy_backward)r  r  rY  rZ  r  r  r  r[  r\  rX  rQ  Zigamma)ztorch.special.gammainc)rY  rV  rZ  r  r  rQ  Zigammac)ztorch.special.gammaincc)rY  rV  rZ  r  r  rQ  znn.functional.softshrinkZ
softshrinkZsoftshrink_backward)	r/  r  rY  rZ  r[  r\  r  r  r  znn.functional.hardshrinkZ
hardshrinkZhardshrink_backwardzaten::hardshrink)	r/  r  rY  rZ  r  r  r[  r\  r  znn.functional.hardtanhZhardtanhZhardtanh_backwardzaten::hardtanh)r/  r  rY  r  rZ  r  r  r  r  r[  r\  r  znn.functional.geluZgeluZgelu_backwardz
aten::gelu)r/  r  rU  r  r  r  r  rY  rZ  r  r[  r\  r  rQ  znn.functional.relu6Zrelu6zaten::relu6)
r/  rY  r  rZ  r  r  r  r[  r\  r  mm)rY  rZ  r  r[  r\  r  rQ  r  )r-  rY  r[  r\  rQ  r  Zmvlgamma_p_1c                 C   s   ddiddifS )Nr  r   r  r   rD  r   r   r   r  x0  r  r^  Zmvlgamma_p_3)r   Nc                 C   s   ddiddifS )Nr  r   r  r   rD  r   r   r   r  0  r  Zmvlgamma_p_5r[  c                 C   s   ddiddifS )Nr  r   r  r   rD  r   r   r   r  0  r  ne)	not_equalr  )rY  r  r[  r\  r  rQ  Znarrow_copy)rY  r  r[  r\  r  r  rQ  )negative)rV  rU  rY  r  r[  r\  r  r  r  r  r  r  dist)r-  rY  r  r  r[  r  r\  r  outer)Zger)r-  rV  rY  r[  r\  r  r  ormqr)r-  rY  r  r  r  rX  rQ  r  )rU  rY  r  r  r  r  r  r[  r\  supports_varargsr  r  powZtest_scalar_supportZ$test_reference_numerics_large_values)rY  rZ  rU  r  r  r  r  r[  r\  r  r  rs  rr  rX  rQ  float_power)rU  rY  r  r  r[  r\  r  rs  rr  rX  rQ  qr)r-  rY  r  r[  r\  r  rX  Zrad2deg)rU  rX  rY  rQ  r[  r\  r  roll)rU  rY  r  r  r[  r\  r  rX  Zrot90)rY  r  r  r  r[  r\  r  )zspecial.roundc                 c   s   | ]}|t jkr|V  qd S r,  r  r  r   r   r   rL  1  s     
 )rU  rV  rY  rZ  r[  r\  rQ  r  r  r  r  r  r  Z
decimals_0c                 C   s   ddiddifS )Ndecimalsr   r   rD  r   r   r   r  1  r  r[  )rU  rW  rV  rY  rZ  r)  r  r[  r\  r  r  Z
decimals_3c                 C   s   ddiddifS )Nr[  r   r   rD  r   r   r   r  1  r  r   )rU  rW  rV  rY  rZ  r)  r  rQ  r[  r\  r  r  Zdecimals_neg_3c                 C   s   ddiddifS )Nr[  rq  r   rD  r   r   r   r  1  r  rq  )rU  rY  rZ  r  r  r  r  r  r  r  r[  r\  rQ  rX  rp  )zspecial.sinc)	rU  rV  rY  rZ  r  r[  r\  rX  rQ  )rU  rY  rZ  r  r[  r\  r  r  r  r  r  rX  rQ  rz  )rU  rY  rZ  r[  r\  r  r  r  r  r  rQ  Zsgn)rU  rY  r  r  r[  r\  r  r  r  r  r  rQ  r  )rY  r  r[  r\  r  r  r  r  Zsplit_with_sizesrj  )r   rW  rY  r  r[  r\  r  )rY  r  r  r  r  r[  r\  r  __radd__)r-  rY  r  rQ  r  r[  r\  r  __rdiv__z	aten::mulzaten::reciprocal)r-  rY  r  rr  r  r  rQ  r[  r\  r  r  __rmul____rand__)r-  rY  r  r  r[  rQ  __ror____rxor____rmatmul__)r-  rY  rZ  r  r  r  r  r[  r\  r  rX  rQ  __rmod__zaten::remainder)r-  rY  rZ  r  r  r[  r\  r  rQ  r  r  __rpow__z	aten::pow)
r-  rY  r  r  r  r[  r\  rQ  r  r  __rsub__z
aten::rsub)	r-  rY  r[  r\  r  r  rQ  r  r  Zrsub)rY  r[  r\  r  r  r  r  r;  Zselect_backward)r  rY  r  r  r[  r\  r  Zselect_scatterr  )	r-  rY  r  r  r[  r\  r  r  r  Zslice_scatter)rY  r  r  r[  r\  r  signbit)rU  rY  r  r  r  r  r  r  c                 C   s   t | tjd  S )Nr   )r   r  r  rr  r   r   r   r  H3  r  )rU  rY  rZ  r  r[  r\  r  r  r  r  r  rQ  r  Ztanh_backward)znn.functional.tanhc                 C   s*   |   rt| tjd  S | jdtjdS )Ny              ?Fr  r   r   r  r  Z
new_tensorr   rt  rr  r   r   r   r  h3  s    )rU  r  rV  rX  rY  rZ  r  r  r[  r\  r  r  r  r  r  rQ  r  Ztensor_split)rU  rY  rZ  r  r[  r\  rQ  r  Zhsplit)rY  r  r[  r\  r  r  r  ZvsplitZdsplittriangular_solvec                  O   s   t | ddi|S r  r  r   r   r   r   r  3  r  )	r-  rY  r  r  r[  r\  r  rX  rQ  )Zfixc                 c   s   | ]}|t jkr|V  qd S r,  r  r  r   r   r   rL  3  s     
 )rV  rU  rY  rZ  r[  r\  r  rQ  r  r  r  r  r  exp2)zspecial.exp2)rV  rU  rY  rZ  r[  r\  )zspecial.expm1)rV  rU  rY  rZ  r[  r\  r  r  r  r  r  r  rQ  
nan_to_numc                 C   s4   |t jkr,i t t jjt t jjdfS i i fS )N)ZposinfZneginf)r   r2  rH  r  r_  rD  r   r   r   r  3  s    )rU  rY  rZ  r[  r\  r  rQ  r)  )rU  rY  r  r[  r\  rQ  Zrsqrtc                 C   s   t t | S r,  )rV  rn  rf  rr  r   r   r   r  4  r  )	rU  r/  rY  rZ  rX  r  r[  r\  rQ  gQ?)rU  r  r/  rY  rZ  r  r[  r  r  r  r  r\  rX  rQ  squarega2U0*3?)rU  rY  rX  r[  r\  rQ  Zlerp)rY  rZ  r  r  r[  r\  r  angle)rU  rY  rZ  rX  r  r  r[  r\  r  r  r  r  Zsupports_complex_to_floatrQ  isfinite)rU  rY  r  r  isinf)	rU  rY  r  r  r  r  r  r  r  isposinfisneginfisrealisnaneinsumc                 C   s   t || S r,  )r   rs  )r  Zequationr   r   r   r  4  r  )
r-  rY  rZ  r  r  r[  r\  r  r  rQ  svd)r-  rY  r  r  r[  r\  r  r  r  rX  rQ  svd_lowrankc                  O   s   t dd f| |S )Nc                 [   s   t j| |j f|S r,  )r   ru  mTr   r   r   r   r   r   r  4  r  <lambda>.<locals>.<lambda>r  r   r   r   r   r  4  s   )r-  rY  r  r  r  r  r  r\  r[  r  rX  rQ  pca_lowrankc                  O   s   t dd f| |S )Nc                 [   s   t j| |j f|S r,  )r   rz  rv  rw  r   r   r   r  4  r  rx  ry  r   r   r   r   r  4  s   )r-  rY  r  r  r  r  r  r[  r\  r  rX  rQ  Zpolar)rY  r[  rr  r  rQ  	polygammac                 K   s   t j|| f|S r,  r   r{  r   r  r   r   r   r   r  5  r  Zpolygamma_n_0c                 C   s   ddiddifS )Nr  r   r   rD  r   r   r   r  5  r  )
r-  rW  rU  rY  rZ  r[  r\  r  rQ  r)  c                 K   s   t j|| f|S r,  r|  r}  r   r   r   r   5  r  Zpolygamma_n_1c                 C   s   ddiddifS )Nr  r   r   rD  r   r   r   r  25  r  c                 C   s   | dk S r  r   rr  r   r   r   r  45  r  )r-  rW  rU  rY  rZ  r[  r\  r  rQ  r)  r  c                 K   s   t j|| f|S r,  r|  r}  r   r   r   r  65  r  Zpolygamma_n_2c                 C   s   ddiddifS )Nr  r   r   rD  r   r   r   r  J5  r  c                 C   s   | dk S r  r   rr  r   r   r   r  L5  r  c                 K   s   t j|| f|S r,  r|  r}  r   r   r   r  N5  r  Zpolygamma_n_3c                 C   s   ddiddifS )Nr  r   r   rD  r   r   r   r  ^5  r  c                 C   s   | dk S r  r   rr  r   r   r   r  `5  r  c                 K   s   t j|| f|S r,  r|  r}  r   r   r   r  b5  r  Zpolygamma_n_4gMb@?c                 C   s   ddiddifS )Nr  r   r   rD  r   r   r   r  w5  r  c                 C   s   | dk S r  r   rr  r   r   r   r  y5  r  )r-  rW  rU  rX  rY  rZ  r[  r\  r  rQ  r)  r  ravelr  )rY  r  r  r  r  r[  r\  
reshape_asc                 C   s
   |  |S r,  )r  r   r*  r   r   r   r  5  r  )r  )	r-  rY  r  r  r  r  r[  r\  rQ  r4  c                 C   s
   |  |S r,  )r4  r   r"  r   r   r   r  5  r  )
r-  rY  r  r[  r\  r  r  r  r  rQ  view_asc                 C   s
   |  |S r,  )r  r  r   r   r   r  5  r  )	r-  rY  r  r[  r\  r  r  r  rQ  Z
atleast_1d)rY  r  r  r[  r\  r  r  rQ  Z
atleast_2d)rY  r  r  r[  r\  r  rQ  r  Z
atleast_3dr  )rY  rU  r  r[  r\  r  r  r  	unflatten)r-  rY  r  r[  r\  r  Zcolumn_stack)rY  r[  r\  r  rQ  r  pinverse)r-  rY  r  r  r[  r\  r  r  r  rX  rQ  r  )rY  rZ  r  r  r[  r\  r  r6  )rY  r  r[  r\  r  r  r5  )rY  r  r[  r\  r  rQ  r  r  r3  )rY  r  r  r  r[  r\  r  r  r4  )rY  r  r[  r\  r  r  rQ  r  Zindex_reduce)rY  r  rQ  r  __getitem__)
rY  r  r  r[  r\  r  r  r-  rQ  r  Z	index_put)	rY  r  r  r[  r\  r  r  r  rQ  r&  rW  )rY  rZ  r  r  r  rQ  Zunique_consecutiver  )rY  r  r[  r\  r  r  r  Ztake)rY  r  r[  r\  r  r  Zscatterr2  c                 O   s   | j ||S r,  )r2  r  r   r   r   r  6  r  )r-  rY  r  r  rQ  rt  c                 O   s   | j ||S r,  )rt  r  r   r   r   r  6  r  )r-  rY  r  r  r  rQ  bytec                 O   s   | j ||S r,  )r  r  r   r   r   r  6  r  charc                 O   s   | j ||S r,  )r  r  r   r   r   r  6  r  r  c                 O   s   | j ||S r,  )r  r  r   r   r   r  6  r  )r-  rY  r  r  r[  r\  rQ  ry  c                 O   s   | j ||S r,  r  r  r   r   r   r  6  r  halfc                 O   s   | j ||S r,  )r  r  r   r   r   r  6  r  r  c                 O   s   | j ||S r,  )r  r  r   r   r   r  7  r  r  c                 O   s   | j ||S r,  )r  r  r   r   r   r  7  r  shortc                 O   s   | j ||S r,  )r  r  r   r   r   r  7  r  chalfc                 O   s   | j ||S r,  )r  r  r   r   r   r  *7  r  r  Ztest_non_standard_bool_valuesz&Expected: empty_like is not comparable)rY  r  r  r  r  rQ  r  )rY  r  r  r  rQ  Z	ones_liker  c                  O   s   t tjf| |S r,  )r  r   r  r   r   r   r   r  r7  r  zTest expects tensor inputZTestVmapOperatorsOpInfoZtest_vmap_exhaustiveZtest_op_has_batch_rule)rY  r-  r  r  r  rQ  
randn_likec                 O   s   t tj| f||S r,  r  r   r  r  r   r   r   r  7  s    z5Expected: randn_like is not comparable between dtypes)rY  r-  r  r  r  r  rQ  rF  c                 O   s   t tj| f||S r,  r  r  r   r   r   r  7  s    randint_likec                 O   s   t tj| f||S r,  )r  r   r  r  r   r   r   r  7  s    Z	full_liker  c                 O   s   | j ||S r,  )r  r  r   r   r   r  7  r  )r-  rY  r  r  rQ  r  new_onesc                 O   s   | j ||S r,  )r  r  r   r   r   r  7  r  r5  )r-  r  rV  r  rY  r  r  rQ  r  )r-  r  r  rY  r  r  rQ  	new_emptyc                 O   s   | j ||S r,  )r  r  r   r   r   r  7  r  z%Expected: new_empty is not comparablenew_empty_stridedc                 O   s   | j ||S r,  )r  r  r   r   r   r  8  r  Ztest_make_fx_exhaustiveZtest_make_fx_fake_exhaustiver  z!Expected: empty is not comparable)rY  r  r  rQ  r  )rY  rZ  r  r  r  r  rQ  new_fullc                 O   s   | j ||S r,  )r  r  r   r   r   r  8  r  multinomialc                 O   s   t tj| f||S r,  )r  r   r  r  r   r   r   r  8  s    c                 O   s   t tjj| f||S r,  )r  r   rC  r  r  r   r   r   r  8  s    )	r-  r  rY  rZ  r  r  r  rQ  r  normalc                 O   s   t tj| f||S r,  r  r   r  r  r   r   r   r  8  s    zGradients are incorrect!)r-  r  rY  rZ  r  r  rQ  Znumber_meanc                 O   s   t tj|| f||S r,  r  )r;  r  r   r   r   r   r   r  8  s    )rW  r-  r  rY  rZ  r  r  rQ  	bernoullic                 O   s   t tj| f||S r,  )r  r   r  r  r   r   r   r  8  s    c                 O   s   t tjj| f||S r,  )r  r   rC  r  r  r   r   r   r  8  s    )r-  r  r  rY  rZ  r  r[  r\  r  r  rQ  Zscatter_add)rY  r  r  r[  r\  r  )rY  r  r  r[  r\  rQ  Zhstackhypot)rY  rZ  r[  r\  r  Z	histogram)rY  rZ  r  r  rQ  ZhistogramddZhistcZbincount)rY  r  r  r  rQ  Z	bucketizezExpected failure!r  )rY  rZ  r  r  rU  rQ  r  )concatr  )rU  rV  rY  r  r  r  r  r[  r\  r  rQ  Zunbind)rY  rU  r  r  r[  r\  r  r  Zvstack)Z	row_stack)rV  rY  r  r  r[  r\  rQ  Zdstack)rY  r  r  r[  r\  r  unfoldc                 G   s
   | j | S r,  )r  r   r   r   r   r   r  9  r  )r-  rY  r  r  r  r[  r\  r  r  rQ  r  r   )rY  rZ  r  r[  r\  r  rQ  Zmovedim)Zmoveaxis)	rV  rY  r  r[  r\  r  r  r  r  ZrenormzInconsistent accuracy)rY  r  r  rQ  r  c                 C   s
   |  |S r,  r  )r   r  r   r   r   r  9  r  )	r-  rU  rY  r  r  r[  r\  r  rQ  r  )rY  r  r  r  r  r  r[  r\  r2  r  r  r  r  zNo fill_ op)r-  rU  r  r  r)  r  r[  r\  r  rY  r  rQ  r  c                 C   s   |   |S r,  )r_  r  r  r   r   r   r  9  r  zAllowed exception)	r-  r  r  r  rY  r  r  rQ  r  r  c                 C   s   t |  |S r,  )r   r  r_  r  r   r   r   r  9  r  zAllowed exemption)r-  r  r  rY  r  r  rQ  r  Ztake_along_dim)rY  rZ  r  r[  r\  r  r  r  r  )rU  rY  r  r  r[  r\  r  ZtrapzZ	trapezoidZcumulative_trapezoid)rY  rZ  r[  r\  r  r  r  r  )rY  r  r[  r\  r  r2  r  r  r  r  r  Zxlogy)zspecial.xlogy)rV  rY  r  r[  r\  r  rs  r  c                 C   s   t |  S r,  )r   r  r_  rr  r   r   r   r  B:  r  )r-  r  r  rY  r  r  r[  r\  r  rQ  r  Z	logsumexp)zspecial.logsumexp)rV  rY  rZ  r  r[  r\  r  r  trace)	rY  rZ  r  r  r  r  r[  r\  r  r  )ZswapdimsrW  )	rU  rV  r  rY  r  r[  r\  r2  r  Tc                 C   s   | j S r,  )r  rr  r   r   r   r  o:  r  )r-  rY  r  r[  r\  rQ  r  r  c                 C   s   | j S r,  )r  rr  r   r   r   r  z:  r  )r-  rY  r  r[  r\  r  rQ  r  rv  c                 C   s   | j S r,  )rv  rr  r   r   r   r  :  r  )r-  rY  r  r  r[  r\  rQ  r  r  c                 C   s   | j S r,  )r  rr  r   r   r   r  :  r  )Zadjoint)
r-  rV  rY  r  r  r[  r\  r  rQ  r  ZtrilZtriutriu_indicesc                 C   s   t jt | |||dS ry  )rV  r}  r  hwZofsr   r   r   r   r   r  :  r  )rY  r  rU  r  r  rQ  tril_indicesc                 C   s   t jt | |||dS ry  )rV  r}  r  r  r   r   r   r  :  r  Zkron)rY  rZ  r  r  r[  r\  r  inner)rY  rZ  r  r[  r\  r  r  Z	tensordot)rY  rZ  r  r[  r\  r  r  rQ  	to_sparsec                 G   s
   | j | S r,  )r  r  r   r   r   r  :  r  Ztest_nondifferentiabler  z*csr.to_sparse(1) not implemented. Skipped!ZTestSparseCSRZtest_sparse_csr_consistency)r-  r  rY  r  r  r  r  r  r  r  rQ  Zlogcumsumexp)rY  rZ  r  r  rQ  r  r  )zspecial.expitznn.functional.sigmoidZsigmoid_backwardc                 C   s*   |   rt| tjd  S | jdtjdS )Nr  Fr  rg  rr  r   r   r   r  -;  s    )rV  r  rU  rX  rQ  rY  rZ  r[  r\  r  r  digamma)zspecial.psizspecial.digamma)rU  rV  rX  rY  rZ  r[  r\  )zspecial.erf)rU  rV  rX  rQ  rY  rZ  r  r  r  r  r  r  r  r[  r\  )zspecial.erfc)rU  rV  rX  rY  rZ  r  r[  r\  erfinv)zspecial.erfinvz1.4.0)rU  rV  rX  rY  rZ  r  r  r  r  r[  r\  r/  rQ  znn.functional.smooth_l1_loss)
rU  r  rY  r  rZ  r  r  r[  r\  rQ  znn.functional.l1_lossc                 C   s   t | | S r,  rL  r  r  r   r   r   r  ;  r  )rU  r  r  rY  r  r[  r\  rQ  lgamma)zspecial.gammalnc                 C   s   | dk S r  r   rr  r   r   r   r  ;  r  )	rU  rV  rX  rY  rZ  r[  r\  rQ  r  Zlogdet)rY  r  r[  r\  r  rX  r  )zspecial.log_softmaxznn.functional.log_softmaxZ_log_softmax_backward_data)	rV  r  r  rY  rZ  r  r[  r\  r  r   )rW  rV  r  rY  r  r[  r\  r  logitZlogit_backwardr   )zspecial.logit)
r  rU  r/  rV  r[  r\  rX  rY  rZ  r  r  c                 C   s   t || |S r,  )r   r  r  r  r*  r   r   r   r  ;  r  c                 C   s   t || |S r,  r4  r  r   r   r   r  ;  r  )r-  rU  r  r  r  r  r[  r\  rX  rQ  rY  ZnonzeroZjiterator_unaryz8template <typename T> T unary(T x) { return x * x + x; }c                 C   s   | |  |  S r,  r   rr  r   r   r   r  ;  r  Ztest_reference_numerics_hardrP  )r-  rU  rY  r  r  rX  rQ  Zjiterator_binaryzKtemplate <typename T> T binary(T x, T y, T alpha) { return x + alpha * y; }c                C   s(   |dkrt | |S t | t ||S r   r  r  r   r   r   r  )<  s   rp  )ri  ro  )	r-  rU  rY  r  r  r  r  rX  rQ  Z!jiterator_4inputs_with_extra_argszttemplate <typename T> T binary(T i0, T i1, T i2, T i3, T alpha, T beta) { return alpha * i0 + beta * i1 + i2 + i3; }c                C   s   ||  ||  | | S r,  r   )r  r  r   Zi3ro  r  r   r   r   r  D<  r  r   r  g)ri  ro  r  )r-  rU  rY  r  r  r  rX  rQ  Zjiterator_binary_return_by_refz
            template <typename T>
            void binary_return_by_ref(T i0, T i1, T& out0) {
                out0 = i0 + i1;
            }
            )Znum_outputsc                 C   s   | | S r,  r   )r  r  r   r   r   r  b<  r  gzGڿZjiterator_2inputs_2outputsz
            template <typename T>
            void binary_2outputs(T i0, T i1, T& out0, T& out1) {
                out0 = i0 + i1;
                out1 = i0 - i1;
            }
            c                C   s   | | | | fS r,  r   )r  r  ro  r   r   r   r  <  r  )ri  r  )r  rY  r  r[  r\  rQ  rW  Znuclear_norm)rW  r/  r  rX  r  r  r[  r\  rY  rZ  rQ  rS  Zfrobenius_norm)	rW  r/  r  rY  rZ  r[  r  r\  rQ  r   )rW  r  rY  r[  r\  r  rQ  r  )r  r  r[  r\  r  r2  r  r  rY  r  r  znn.functional.dropoutc                 O   s   t tjjj| f||S r,  r  r   r  r  ZdropoutrB  r   r   r   r  <  s    c                 O   s    t tjjj| f||ddiS rG  r  rB  r   r   r   r  =  s    )
r-  rY  rZ  rQ  r[  r\  r  r  r  r  znn.functional.dropout2dc                 O   s   t tjjj| f||S r,  r  r   r  r  Z	dropout2drB  r   r   r   r  =  s    r"  )r  c                 O   s    t tjjj| f||ddiS rG  r  rB  r   r   r   r  #=  s    )
r-  rY  rZ  rQ  r[  r\  r  r  r  r  znn.functional.dropout3dc                 O   s   t tjjj| f||S r,  r  r   r  r  Z	dropout3drB  r   r   r   r  '=  s    r  c                 O   s    t tjjj| f||ddiS rG  r  rB  r   r   r   r  5=  s    z#nn.functional.feature_alpha_dropoutc                 O   s   t tjjj| f||S r,  r  r   r  r  Zfeature_alpha_dropoutrB  r   r   r   r  ;=  s    Z
with_trainc                 O   s    t tjjj| f||ddiS rG  r  rB  r   r   r   r  P=  s    )r-  rW  rY  rZ  rQ  r  r[  r\  r  r  r  c                 O   s   t tjjj| f||S r,  r  rB  r   r   r   r  T=  s    Zwithout_train)r  c                 O   s    t tjjj| f||ddiS rG  r  rB  r   r   r   r  a=  s    )
r-  rW  rY  rQ  r  r[  r\  r  r  r  znn.functional.one_hot)rU  r  rY  r  znn.functional.embeddingZembedding_dense_backwardc                 K   s   t jjj|| f|S r,  )r   r  r  Z	embeddingr  r  r   r   r   r   r  p=  r  )
r  r-  rY  r  r  r[  r\  rQ  r8  r  znn.functional.embedding_bagc                 K   s   t jjj|| f|S r,  )r   r  r  Zembedding_bagr  r   r   r   r  =  r  )	r-  rY  rZ  r  r  rQ  r  r  r  znn.functional.softplusZsoftplus_backwardc                 C   s   ddddddfS )Nr   r  r  r  r   rD  r   r   r   r  =  r  r  r  )	r  rU  r)  r  r[  r\  rY  rZ  rX  znn.functional.mse_lossZmse_loss_backwardc                 C   s   | | d S )Nr   r   r  r   r   r   r  =  r  )r  rU  r  r  r[  r\  rY  r  rZ  r  rQ  znn.functional.grid_samplegV瞯<)rY  rZ  r  r  r  r  argwhere)rU  rY  r  r  r  r+  ZTestReductionsZtest_dim_default_keepdimZtest_dim_noneZtest_dim_none_keepdimZtest_result_dtype)identityr  r  r  rY  rU  rQ  anyr  	propagateZtest_dim_emptyZtest_dim_empty_keepdim)
nan_policyr[  r  r\  rY  rU  rQ  r  r  argmax)Zsupports_keepdims)r  r  r  r  rY  rU  rQ  argmin)r  r  r  rY  rU  rQ  count_nonzeroZtest_dim_single_keepdimZtest_dim_multi_keepdimZtest_dim_multi_unsorted_keepdimZtest_dim_offbounds_keepdim)r  r  r  r  rY  r  rU  rQ  Ztest_ref_small_inputZtest_ref_extremal_values)r  r[  r\  r  r  r  r  rY  rU  r  rQ  nanmeanZomitZtest_ref_duplicate_values)
r  r  r  r[  r  r\  rY  r  rU  rQ  r;  Ztest_ref_large_input)r  r  complex_to_realr[  r\  r  r  r  rY  rZ  r  rU  generate_args_kwargsrQ  r  )r  r  r  r  r  r[  r\  r  rY  rZ  r  rU  r  rQ  r?  )r  r  r  r  r  r[  r\  promotes_int_to_int64r  rY  rZ  r  rU  rQ  r  )
r  r  r  r[  r\  r  rY  rZ  rU  rQ  nansum)r  r  r  r  r[  r  r\  rY  r  rU  rQ  znn.functional.ctc_losszFails with ASAN)rY  r  r  rQ  z#nn.functional.cosine_embedding_lossznn.functional.nll_loss)rY  rZ  r  r  r[  r\  r  rQ  znn.functional.gaussian_nll_loss)	rY  rZ  r  r  r[  r\  r  rQ  rX  z"nn.functional.hinge_embedding_loss)rY  rZ  r  r[  r\  r  r  r  znn.functional.huber_lossZhuber_loss_backward)r  rY  r  r[  r  r  rQ  znn.functional.pdist)rU  r  rY  r  r  znn.functional.poisson_nll_loss)rY  rZ  r  r[  r\  r  r  ZargsortZrepeat_interleave)rY  r  r  r  r[  r\  r  rQ  znn.functional.pairwise_distancer  r  c                 C   s*   t jt | | | | d|dd|  S )Nr   r  r   )rV  r  r   )r   r   r  r   r  r   r   r   r  ?  s    )rU  r  rY  r  r[  r\  rQ  znn.functional.pixel_shuffle)r  rY  r  r[  r\  rQ  znn.functional.pixel_unshuffleznn.functional.kl_divdiagflatc                 C   s   t j| |dS )N)r  )rV  r  )r  r  r   r   r   r  ?  r  )rU  r  rY  rZ  r  r[  r\  r  Zscatter_reduce)rW  rY  r[  r\  r  )rW  rY  rZ  r  rQ  )rW  rY  rZ  r[  r\  r  )rW  rY  rZ  r[  r  r\  r  Zsegment_reduce)rW  rY  r  r  r  rQ  r  op_dbz	_refs.absZtest_python_refZtest_python_ref_torch_fallback)torch_opinfo_namerQ  z
_refs.acos)r  z_refs.acosh)r  supports_nvfuserz
_refs.asinz_refs.asinhz
_refs.ones)r  rQ  r  z_refs.zerosz_refs.arangeZtest_python_ref_metaz_refs.linspaceZtest_python_ref_executor)r  rQ  validate_view_consistencyr  z_refs.logspacez_refs.meshgrid)r  torch_opinfo_variant_namer  z_refs.toz
_refs.triuz
_refs.trilz_refs.triu_indices)r  r  r  rQ  z_refs.tril_indicesz_refs.movedim)rV  r  r  z
_refs.atanz_refs.atanhz_refs.bitwise_notz
_refs.ceilz_refs.conj_physicalz	_refs.cosz
_refs.coshz_refs.digammaz	_refs.erfz_refs.erfinvz
_refs.erfcz	_refs.expz_refs.expm1z
_refs.exp2z
_refs.fill)r  r  r  z_refs.floorz
_refs.fracz
_refs.imagz_refs.isfinitez_refs.isinfz_refs.isposinfz_refs.isneginfz_refs.isnan)r  r  z_refs.isrealz_refs.i0z_refs.lgammaz_refs.special.multigammalnrS  z	_refs.logz_refs.log1pz_refs.log10z
_refs.log2z_refs.logsumexpz_refs.log_softmaxz_refs.nan_to_numz	_refs.negz_refs.positivez
_refs.realz_refs.reciprocalz_refs.roundz_refs.rsqrtz_refs.sigmoid)r  Zhandles_complex_extremal_valuesr  z
_refs.signz	_refs.sgnz_refs.signbitz	_refs.sinz
_refs.sincz
_refs.sinhz_refs.softmaxz
_refs.sqrtz_refs.squarez	_refs.tanz
_refs.tanhz_refs.truncz_refs.special.logitz_refs.nn.functional.celuz_refs.nn.functional.thresholdz_refs.nn.functional.dropoutz#Expected: dropout is not comparable)r  rX  z_refs.nn.functional.eluz_refs.nn.functional.hardtanhz_refs.nn.functional.geluz_refs.nn.functional.layer_normz_refs.nn.functional.glu)r  r  r  z%_refs.nn.functional.pairwise_distancez_refs.nn.functional.pdist)r  r  r  rQ  z_refs.nn.functional.leaky_reluz$_refs.nn.functional.poisson_nll_lossz_refs.nn.functional.preluz_refs.nn.functional.reluz_refs.nn.functional.relu6z_refs.nn.functional.mishz_refs.nn.functional.seluz_refs.nn.functional.softplusz_refs.nn.functional.l1_lossz'_refs.nn.functional.margin_ranking_lossz_refs.nn.functional.mse_lossz(_refs.nn.functional.hinge_embedding_lossz_refs.nn.functional.huber_lossz_refs.nn.functional.tanhshrinkz_refs.nn.functional.hardshrinkz_refs.nn.functional.softshrinkz	_refs.add)r  r  r  z_refs.atan2z_refs.bitwise_andz_refs.bitwise_left_shiftz_refs.bitwise_orz_refs.bitwise_xorz_refs.copysign)r  r  rQ  z	_refs.div)r  r  r  r  r  rQ  )r  r  r  r  r  z_refs.eqz_refs.float_powerz_refs.floor_divide)r  rs  r  r  r  rQ  z
_refs.fmax)r  r  r  z
_refs.fminz
_refs.fmod)r  rs  r  rQ  z	_refs.gcdz_refs.gez_refs.gtz_refs.heavisidez_refs.hypotz_refs.igammaz_refs.igammacz_refs.isclosez	_refs.lcmz_refs.lez_refs.logical_andz_refs.logical_notz_refs.logical_orz_refs.logical_xorz_refs.ltz_refs.maximumZtest_python_ref_errorsz_refs.minimumz	_refs.mul)r  r  r  rQ  z_refs.nez_refs.nextafterz	_refs.powz_refs.remainderz
_refs.rsubz	_refs.subz_refs.true_dividez_refs.addcdivz_refs.clamp_minz_refs.clamp_maxz_refs.clampz_refs.clonez_refs.atleast_1d)r  r  r  z_refs.atleast_2dz_refs.atleast_3dz_refs.as_strided)r  rY  r  rQ  z_refs.broadcast_shapesz_refs.broadcast_tensorsz_refs.broadcast_toz	_refs.catz_refs.chunkz_refs.column_stackz
_refs.conjz_refs.constant_pad_ndz_refs.contiguousz_refs.dsplitr  r  z_refs.dstackz_refs.expandz_refs.expand_asz_refs.flattenz
_refs.flipz_refs.fliplrz_refs.flipudz_refs.hstackz_refs.narrowz_refs.native_layer_normz_refs.permutez_refs.ravelrg  )r  r  r  z_refs.reshapez_refs.reshape_asz
_refs.rollz_refs.rot90z_refs.stackz_refs.squeezez_refs.tensor_splitz_refs.hsplitz_refs.vsplitz_refs.transposez_refs.tz_refs.unfold_copyz_refs.unsqueezez
_refs.viewz_refs.view_asz_refs.vstackz_refs.unflattenz_refs.unbindz	_refs.allr  r   z	_refs.anyz
_refs.meanz	_refs.stdz_refs.std_meanz	_refs.sumz_refs.cumsumz_refs.sum_to_size)r  r  z
_refs.prodz	_refs.varz_refs.var_meanzops.nvprims.var_mean)r  r  rY  rX  zops.nvprims.native_batch_norm)r  rY  r  rX  z
_refs.addr)r  r  rX  z_refs.tracezdiag is not supported by metaz diag is not supported by nvfuserz
_refs.norm)r  r  r  r  z_refs.emptyzCan't check result for emptyz_refs.empty_likez!Can't check result for empty_likez_refs.randnc                  O   s   t tjf| |S r,  )r  r  r  r   r   r   r   r  1F  r  z(make_traced() doesn't set seed properly!)r  r-  r  rQ  z	_refs.eyez_refs.new_emptyz Can't check result for new_emptyz_refs.new_empty_stridedz)Expected: empty_strided is not comparablez_refs.new_fullz_refs.new_onesz_refs.new_zerosz_refs.masked_fillz_refs.wherec                 C   s   t || |S r,  )r  r  r  r   r   r   r  F  r  )r  r-  r  z_refs.index_selectz_refs.index_copyz_refs.index_addz_refs.index_fillz_refs.allclosec                 C   s   g | ]}t |tr|qS r   )r  r_   rJ  r-  r   r   r   r  F  s     
 r  c                 C   s   g | ]}t |tr|qS r   r  rX   r  r   r   r   r  F  s     
 c                 c   s   | ]}t |tr|V  qd S r,  r  r  r   r   r   rL  F  s     
 c                 C   s   g | ]}t |tr|qS r   )r  rb   r  r   r   r   r  F  s     
 c                 C   s    g | ]}t |tr|jr|qS r   )r  r_   r  r  r   r   r   r  F  s     
  c                 C   s    g | ]}t |tr|jr|qS r   )r  r_   r  r  r   r   r   r  F  s     
  c                 C   s    g | ]}t |tr|jr|qS r   )r  rK   r  r  r   r   r   r  F  s     
  c                 C   s   g | ]}t |tr|qS r   )r  rc   r  r   r   r   r  F  s     
 c                 C   s   g | ]}t |tr|qS r   )r  rK   r  r   r   r   r  F  s     
 c                 C   s   g | ]}|j d k	r|qS r,  )rU  r  r   r   r   r  F  s     
 c                 C   s   g | ]}|j d r|qS zmasked.rK  
startswithr  r   r   r   r  F  s      c                 C   s   g | ]}|j d r|qS r  r  r  r   r   r   r  F  s      c                 C   s6   t | ts| f} tj| tj|d|  }|S r3  )r  r   r   r1  r  Zmul_Zfloor_r  )r"  r{  r   rE  r   r   r   r.  F  s    
"r.  c                 C   s   t | dkst|dk std| }tj| tj|d}t| | D ],}|||tj||dd | |   qD|r||d||d |S )Nr   r   r   r  r   )	r  r  r   r  r  rk  r;  Zcopy_r  )r"  rz  r{  Z	duplicater   Z	batch_dimrE  rl  r   r   r   r  F  s    r  c                   C   s   t jdt jd S r|  )r   r   rt  Z
bernoulli_r   r   r   r   r2  F  s    r2  c                 C   s6   t | dkstt| d}| dkr|S qd S r  )r  r  r   r  r  r  )r"  r  r   r   r   r/  F  s    r/  )r   )F)F)F)r   )r   r   r   r   r   N)F)F)F)F)F)F)F)F)F)F)F)N)N)NN)F)F)T)F)F)r   )r   r   )r   )r  )NNr  )NNr  )FFr#  N)r'  )r   r   )r   r   )F)F)NF)r   )r   )r;  )r'  F)r'  )r'  F)r'  )F)F)F)r  r  F)r   (  r  r   r   rP  r   r   r   r  r  r  rO  r  r   r4  rV  Z
torch._sixr   r   typingr	   r
   r   r   r   Ztorch.testingr   Z$torch.testing._internal.common_dtyper   r   r   r   r   r   r   r   r   r   r   r   r   r   Z*torch.testing._internal.common_device_typer   r   r    r!   r"   r#   r$   r%   r&   r'   r(   r)   r*   Z#torch.testing._internal.common_cudar+   r,   r-   r.   r/   r0   Z$torch.testing._internal.common_utilsr1   r2   r3   r4   r5   r6   r7   r8   r9   Ztorch._refsZ_refsr  Ztorch._refs.nn.functionalZtorch._refs.specialZtorch._refs.linalgZtorch._primsZ_primsr  Ztorch.utils._pytreer:   Zdistutils.versionr;   Z#torch.testing._internal.opinfo.corer<   r=   r>   r?   r@   rA   rB   rC   rD   rE   rF   rG   rH   rI   rJ   rK   rL   rM   rN   rO   rP   rQ   rR   rS   rT   rU   rV   rW   rX   rY   rZ   r[   r\   r]   r^   r_   r`   ra   rb   rc   rd   re   rf   rg   rh   ri   rj   rk   Z#torch.testing._internal.opinfo.refsrl   rm   rn   ro   rp   rq   Z$torch.testing._internal.opinfo.utilsrr   rs   Ztorch.testing._internalrt   Z1torch.testing._internal.opinfo.definitions.linalgru   rv   rw   rx   ry   rz   r{   r|   r}   r~   Z2torch.testing._internal.opinfo.definitions.specialr   r   r   Z2torch.testing._internal.opinfo.definitions._maskedr   rI  r   Zscipy.spatialZscipy.specialr   r   r   r   r   r   r   r   r   r   r   r   r   r  r  r  r#  r+  r.  r5  r9  rQ  rV  rX  rZ  rf  rm  rn  rv  r{  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r	  r  r  r  r  r  r  r   r'  r,  r-  r0  r5  r6  r9  r<  r?  rA  rB  rH  rK  rM  rO  rQ  rT  rY  r]  r^  rb  re  rj  rn  rs  rw  r|  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r!  r'  r,  r0  r2  r>  r?  rA  rF  rH  rL  rO  rT  rX  r\  r_  objectr`  rr  rx  r{  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r   r  r  r  r  r  r  r  r  r!  r%  r&  r+  r/  r1  r2  r>  rF  rG  rS  rT  rU  r^  rf  rh  rk  rl  rr  rs  rt  rv  rw  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r   r.  r0  r1  r3  r4  r6  r8  r9  r;  r   r   rt  r  rE  rI  rR  r_  rc  ri  rl  rm  ro  rp  rq  rs  rt  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r	  r
  r  r  r  r  r  r  r  r  r$  r&  r(  r+  r0  r1  r6  r9  r:  r=  r?  r@  rA  rG  rH  rK  rL  rV  rX  r2  r  rp  __annotations__ro  rP  rt  ru  rv  rx  r{  r~  r  r  r  r  r]  r  r  r  r  r  r  r  r  r  r  r  r  r  r  rC  r  r  r  r   r  ZcdoubleZcfloatr  r  r  r  ZexpectedFailurer  r   r  r   r  Zint16r  r  r  r  r  r  r  r  r^  libZNumpyVersion__version__Zbroadcast_arraysr  invertr  lshiftilshiftr  rshiftirshiftr  r  rg  r   r  ry  r  r  r]  r^  radiansr  r  rY  r  r	  r
  r  r  modimodr  r  rk  r  r  r  r  r  r  rl  r  r  r  r  r_  r`  ra  r  r  r   r!  r"  r#  r  r  r%  r&  r'  r(  and_iandr)  or_iorr*  xorixorr,  r-  r.  r  r  r  ZhardsigmoidZmishr  rQ  rR  rS  rT  rU  r  r  r  rX  rY  degreesr  rZ  rm  rc  rd  r\  r]  r^  r_  r`  ra  rb  rc  rd  re  opsZatenr  rf  rb  r  r  Zarray_splitrh  ro  ri  rj  rj  rn  rf  rk  rl  rm  rn  ro  rp  rq  rr  rt  r~  r  r  r  r5  r  r  r  r  r  r  r  rh  ri  r  r  r  Z	jiteratorZ_create_jit_fnZ_create_multi_output_jit_fnr  r+  r  r  r  r  r  r  r  r  r;  r  r?  r  r  r  ZdefinitionsZpython_ref_dbZops_and_refsZunary_ufuncsZbinary_ufuncsZbinary_ufuncs_and_refsZspectral_funcsZsparse_unary_ufuncsZsparse_csr_unary_ufuncsZsparse_reduction_opsZshape_funcsZreduction_opsZreference_filtered_opsZreference_masked_opsZsparse_masked_reduction_opsr.  r  r2  r/  r   r   r   r   <module>   svP   @< ,2 0


9
3:
	,

#+38		

	





$




	


E










A
&<'	2#.	%	I       *
-:"" *#
&(
!
4&%
A
Q


!
(
H	$'9: ("5%''34+
#2
  B!+!*	

4















h  &
(

	&""      !               (         
"  $'

       "
 


 $


  $

     





$


 
       #                 "        !	&	
	  

	

   
 
 $ 
$$
 


      
      


"




 		  

  







$"
  
(
 
 
  *



     *
   !  
  


	


	 		    	




$         +	



	
 



 


	


  















   
&

  
&        "    %    &


      
$
$$
















 




 	









 

$$


   




   



    
'

   

        !

   	 #
   	    #
   
   
  
  

   
      !




	


#
	
    ()*



" 












  	
   	3   	 	






       
       	
	






	

	

	


$  	  $ $




	       
 "   
"			
   


     


   	 
 

		




   
 
 











	



  		
   










 

 "
 

	
	
 
                 0 '
	



	









	

	
	 






	
		

	




	




  


  	
   
  


    


 


     *  
	#$
$

 	













 	




  







 
  



 "	
$
$  
$


	


                                                                                                                                 G    
      $
 
		        			
  	                  
            		 				


		                        u