shevchenko 3.1.6 → 3.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (74) hide show
  1. package/dist/cjs/anthroponym-declension/anthroponym-inflector.js +2 -2
  2. package/dist/cjs/anthroponym-declension/bootstrap.js +2 -2
  3. package/dist/cjs/anthroponym-declension/family-name-classifier/artifacts/model.bundle.json.js +2 -2
  4. package/dist/cjs/anthroponym-declension/family-name-classifier/cache/incorrect-predictions.json.js +2 -2
  5. package/dist/cjs/anthroponym-declension/family-name-classifier/family-name-class-transformer.js +2 -2
  6. package/dist/cjs/anthroponym-declension/family-name-classifier/family-name-classifer.js +2 -2
  7. package/dist/cjs/anthroponym-declension/family-name-classifier/model-bundle-loader.js +2 -2
  8. package/dist/cjs/anthroponym-declension/family-name-classifier/model-config.js +2 -2
  9. package/dist/cjs/anthroponym-declension/family-name-classifier/word-transformer.js +2 -2
  10. package/dist/cjs/anthroponym-declension/family-name-inflector.js +2 -2
  11. package/dist/cjs/anthroponym-declension/given-name-inflector.js +2 -2
  12. package/dist/cjs/anthroponym-declension/name-inflector.js +2 -2
  13. package/dist/cjs/anthroponym-declension/patronymic-name-inflector.js +2 -2
  14. package/dist/cjs/extension.js +2 -2
  15. package/dist/cjs/gender-detection/artifacts/given-name-rules.json.js +2 -2
  16. package/dist/cjs/gender-detection/artifacts/patronymic-name-rules.json.js +2 -2
  17. package/dist/cjs/gender-detection/detect-gender.js +2 -2
  18. package/dist/cjs/gender-detection/grammatical-gender-detector.js +2 -2
  19. package/dist/cjs/index.js +2 -2
  20. package/dist/cjs/input-validation.js +2 -2
  21. package/dist/cjs/language/alphabet.js +2 -2
  22. package/dist/cjs/language/grammatical-case.js +2 -2
  23. package/dist/cjs/language/grammatical-gender.js +2 -2
  24. package/dist/cjs/language/letter-case.js +2 -2
  25. package/dist/cjs/language/linguistics.js +2 -2
  26. package/dist/cjs/language/word-class.js +2 -2
  27. package/dist/cjs/shevchenko.js +2 -2
  28. package/dist/cjs/word-declension/append-command-runner.js +2 -2
  29. package/dist/cjs/word-declension/bootstrap.js +2 -2
  30. package/dist/cjs/word-declension/command-runner-factory.js +2 -2
  31. package/dist/cjs/word-declension/declension-rule-inflector.js +2 -2
  32. package/dist/cjs/word-declension/declension-types.js +2 -2
  33. package/dist/cjs/word-declension/replace-command-runner.js +2 -2
  34. package/dist/cjs/word-declension/rules/artifacts/declension-rules.json.js +6 -108
  35. package/dist/cjs/word-declension/word-inflector.js +10 -5
  36. package/dist/es/anthroponym-declension/anthroponym-inflector.js +2 -2
  37. package/dist/es/anthroponym-declension/bootstrap.js +2 -2
  38. package/dist/es/anthroponym-declension/family-name-classifier/artifacts/model.bundle.json.js +2 -2
  39. package/dist/es/anthroponym-declension/family-name-classifier/cache/incorrect-predictions.json.js +2 -2
  40. package/dist/es/anthroponym-declension/family-name-classifier/family-name-class-transformer.js +2 -2
  41. package/dist/es/anthroponym-declension/family-name-classifier/family-name-classifer.js +2 -2
  42. package/dist/es/anthroponym-declension/family-name-classifier/model-bundle-loader.js +2 -2
  43. package/dist/es/anthroponym-declension/family-name-classifier/model-config.js +2 -2
  44. package/dist/es/anthroponym-declension/family-name-classifier/word-transformer.js +2 -2
  45. package/dist/es/anthroponym-declension/family-name-inflector.js +2 -2
  46. package/dist/es/anthroponym-declension/given-name-inflector.js +2 -2
  47. package/dist/es/anthroponym-declension/name-inflector.js +2 -2
  48. package/dist/es/anthroponym-declension/patronymic-name-inflector.js +2 -2
  49. package/dist/es/extension.js +2 -2
  50. package/dist/es/gender-detection/artifacts/given-name-rules.json.js +2 -2
  51. package/dist/es/gender-detection/artifacts/patronymic-name-rules.json.js +2 -2
  52. package/dist/es/gender-detection/detect-gender.js +2 -2
  53. package/dist/es/gender-detection/grammatical-gender-detector.js +2 -2
  54. package/dist/es/index.js +2 -2
  55. package/dist/es/input-validation.js +2 -2
  56. package/dist/es/language/alphabet.js +2 -2
  57. package/dist/es/language/grammatical-case.js +2 -2
  58. package/dist/es/language/grammatical-gender.js +2 -2
  59. package/dist/es/language/letter-case.js +2 -2
  60. package/dist/es/language/linguistics.js +2 -2
  61. package/dist/es/language/word-class.js +2 -2
  62. package/dist/es/shevchenko.js +2 -2
  63. package/dist/es/word-declension/append-command-runner.js +2 -2
  64. package/dist/es/word-declension/bootstrap.js +2 -2
  65. package/dist/es/word-declension/command-runner-factory.js +2 -2
  66. package/dist/es/word-declension/declension-rule-inflector.js +2 -2
  67. package/dist/es/word-declension/declension-types.js +2 -2
  68. package/dist/es/word-declension/replace-command-runner.js +2 -2
  69. package/dist/es/word-declension/rules/artifacts/declension-rules.json.js +6 -108
  70. package/dist/es/word-declension/word-inflector.js +10 -5
  71. package/dist/es/word-declension/word-inflector.test.d.ts +1 -0
  72. package/dist/umd/shevchenko.min.js +57 -57
  73. package/package.json +1 -1
  74. package/bibi.ts +0 -9
@@ -1,13 +1,13 @@
1
1
  /**
2
2
  * @file JavaScript library for declension of Ukrainian anthroponyms
3
3
  * @module shevchenko
4
- * @version 3.1.6
4
+ * @version 3.2.1
5
5
  * @author Oleksandr Tolochko <shevchenko-js@tooleks.com>
6
6
  * @license MIT
7
- * @copyright 2017-2025 Oleksandr Tolochko <shevchenko-js@tooleks.com>
7
+ * @copyright 2017-2026 Oleksandr Tolochko <shevchenko-js@tooleks.com>
8
8
  * @see {@link git+https://github.com/tooleks/shevchenko-js.git}
9
9
  */
10
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).shevchenko={})}(this,(function(e){"use strict";function t(e,t,n,a){return new(n||(n=Promise))((function(t,i){function s(e){try{o(a.next(e))}catch(e){i(e)}}function r(e){try{o(a.throw(e))}catch(e){i(e)}}function o(e){var a;e.done?t(e.value):(a=e.value,a instanceof n?a:new n((function(e){e(a)}))).then(s,r)}o((a=a.apply(e,[])).next())}))}var n,a;!function(e){e[e["а"]=1]="а",e[e["б"]=2]="б",e[e["в"]=3]="в",e[e["г"]=4]="г",e[e["ґ"]=5]="ґ",e[e["д"]=6]="д",e[e["е"]=7]="е",e[e["є"]=8]="є",e[e["ж"]=9]="ж",e[e["з"]=10]="з",e[e["и"]=11]="и",e[e["і"]=12]="і",e[e["ї"]=13]="ї",e[e["й"]=14]="й",e[e["к"]=15]="к",e[e["л"]=16]="л",e[e["м"]=17]="м",e[e["н"]=18]="н",e[e["о"]=19]="о",e[e["п"]=20]="п",e[e["р"]=21]="р",e[e["с"]=22]="с",e[e["т"]=23]="т",e[e["у"]=24]="у",e[e["ф"]=25]="ф",e[e["х"]=26]="х",e[e["ц"]=27]="ц",e[e["ч"]=28]="ч",e[e["ш"]=29]="ш",e[e["щ"]=30]="щ",e[e["ь"]=31]="ь",e[e["ю"]=32]="ю",e[e["я"]=33]="я"}(n||(n={})),Object.keys(n).length,e.WordClass=void 0,(a=e.WordClass||(e.WordClass={})).NOUN="noun",a.ADJECTIVE="adjective";const i=/[аоуеиіяюєї]/gi;function s(e){return 1===function(e){const t=e.match(i);return null==t?0:t.length}(e)}var r,o,l;function c(e,t=0){const n=e.charAt(t);return n===n.toUpperCase()}function u(e,t=0){const n=e.charAt(t);return n===n.toLowerCase()}e.GrammaticalCase=void 0,(r=e.GrammaticalCase||(e.GrammaticalCase={})).NOMINATIVE="nominative",r.GENITIVE="genitive",r.DATIVE="dative",r.ACCUSATIVE="accusative",r.ABLATIVE="ablative",r.LOCATIVE="locative",r.VOCATIVE="vocative",e.GrammaticalGender=void 0,(o=e.GrammaticalGender||(e.GrammaticalGender={})).MASCULINE="masculine",o.FEMININE="feminine";class h{constructor(e){this.command=e}exec(e){return e+this.command.value}}!function(e){e.REPLACE="replace",e.APPEND="append"}(l||(l={}));class p{constructor(e){this.command=e}exec(){return this.command.value}}class d{make(e){switch(e.action){case l.APPEND:return new h(e);case l.REPLACE:return new p(e);default:throw new TypeError(`Invalid command action: ${e.action}.`)}}}class f{constructor(e){this.rule=e,this.commandRunnerFactory=new d}inflect(e,t){const[n]=this.rule.grammaticalCases[t];if(n){const t=new RegExp(this.rule.pattern.modify,"gi"),a=e.replace(t,((e,...t)=>{let a="";const i=function(e){const t=new RegExp(`${e.toString()}|`).exec("");return null==t?0:t.length-1}(this.rule.pattern.modify);for(let e=0;e<i;e+=1){let i=t[e];const s=n[e];null!=s&&(i=this.commandRunnerFactory.make(s).exec(i)),a+=i}return a}));return function(e,t){let n="";for(let a=0;a<t.length;a+=1){const i=e[a]||e[e.length-1],s=t[a];u(i)?n+=s.toLowerCase():c(i)?n+=s.toUpperCase():n+=s}return n}(e,a)}return e}}class m{constructor(e){this.declensionRules=[...e].sort(((e,t)=>t.priority-e.priority))}inflect(e,n){return t(this,0,void 0,(function*(){const[t]=yield this.findMatchingRules(e,n);return null==t?e:new f(t).inflect(e,n.grammaticalCase)}))}findMatchingRules(e,n){return t(this,0,void 0,(function*(){const t=this.declensionRules.filter((e=>e.gender.includes(n.gender))).filter((e=>!n.applicationType||0===e.applicationType.length||e.applicationType.includes(n.applicationType))).filter((t=>new RegExp(t.pattern.find,"gi").test(e))).filter((e=>!n.wordClass||e.wordClass===n.wordClass)).filter(((e,t,a)=>!n.customRuleFilter||n.customRuleFilter(e,t,a)));return t}))}}const g=new m([{description:"жіноче ім'я любов",examples:["любов"],wordClass:"noun",gender:["feminine"],priority:6,applicationType:["givenName"],pattern:{find:"^любов$",modify:"(.{1})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"append",value:"і"}}],dative:[{0:{action:"append",value:"і"}}],accusative:[],ablative:[{0:{action:"append",value:"'ю"}}],locative:[{0:{action:"append",value:"і"}}],vocative:[{0:{action:"append",value:"е"}}]}},{description:"чоловічі імена федір, сидір",examples:["федір","сидір"],wordClass:"noun",gender:["masculine"],priority:6,applicationType:["givenName"],pattern:{find:"^(федір|сидір)$",modify:"(.{1})(.{1})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"replace",value:"о"},1:{action:"append",value:"а"}}],dative:[{0:{action:"replace",value:"о"},1:{action:"append",value:"у"}},{0:{action:"replace",value:"о"},1:{action:"append",value:"ові"}}],accusative:[{0:{action:"replace",value:"о"},1:{action:"append",value:"а"}}],ablative:[{0:{action:"replace",value:"о"},1:{action:"append",value:"ом"}}],locative:[{0:{action:"replace",value:"о"},1:{action:"append",value:"ові"}},{0:{action:"replace",value:"о"},1:{action:"append",value:"у"}}],vocative:[{0:{action:"replace",value:"о"},1:{action:"append",value:"е"}}]}},{description:"слово суддя",examples:["суддя"],wordClass:"noun",gender:["masculine","feminine"],priority:6,applicationType:["familyName"],pattern:{find:"^суддя$",modify:"(.{1})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"replace",value:"і"}}],dative:[{0:{action:"replace",value:"і"}}],accusative:[{0:{action:"replace",value:"ю"}}],ablative:[{0:{action:"replace",value:"ею"}}],locative:[{0:{action:"replace",value:"і"}}],vocative:[{0:{action:"replace",value:"е"}}]}},{description:"слово рілля",examples:["рілля"],wordClass:"noun",gender:["masculine","feminine"],priority:6,applicationType:["familyName"],pattern:{find:"^рілля$",modify:"(.{1})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"replace",value:"і"}}],dative:[{0:{action:"replace",value:"і"}}],accusative:[{0:{action:"replace",value:"ю"}}],ablative:[{0:{action:"replace",value:"ею"}}],locative:[{0:{action:"replace",value:"і"}}],vocative:[{0:{action:"replace",value:"е"}}]}},{description:"друга відміна / чоловічий рід / м'яка група / на -(голосний)вень",examples:["півень"],wordClass:"noun",gender:["masculine"],priority:6,applicationType:[],pattern:{find:"[аеєиіїоуюя]вень$",modify:"(.{1})(.{1})(.{1})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"replace",value:""},2:{action:"replace",value:"я"}}],dative:[{0:{action:"replace",value:""},2:{action:"replace",value:"ю"}},{0:{action:"replace",value:""},2:{action:"replace",value:"еві"}}],accusative:[{0:{action:"replace",value:""},2:{action:"replace",value:"я"}}],ablative:[{0:{action:"replace",value:""},2:{action:"replace",value:"ем"}}],locative:[{0:{action:"replace",value:""},2:{action:"replace",value:"еві"}},{0:{action:"replace",value:""},2:{action:"replace",value:"ю"}}],vocative:[{0:{action:"replace",value:""},2:{action:"replace",value:"ю"}}]}},{description:"друга відміна / чоловічий рід / м'яка група / на -(голосний)лець",examples:["стрілець","білець"],wordClass:"noun",gender:["masculine"],priority:6,applicationType:[],pattern:{find:"[аеєиіїоуюя]лець$",modify:"(.{1})(.{1})(.{1})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"replace",value:"ь"},2:{action:"replace",value:"я"}}],dative:[{0:{action:"replace",value:"ь"},2:{action:"replace",value:"ю"}},{0:{action:"replace",value:"ь"},2:{action:"replace",value:"еві"}}],accusative:[{0:{action:"replace",value:"ь"},2:{action:"replace",value:"я"}}],ablative:[{0:{action:"replace",value:"ь"},2:{action:"replace",value:"ем"}}],locative:[{0:{action:"replace",value:"ь"},2:{action:"replace",value:"ю"}},{0:{action:"replace",value:"ь"},2:{action:"replace",value:"еві"}}],vocative:[{0:{action:"replace",value:"ь"},2:{action:"replace",value:"ю"}}]}},{description:"друга відміна / чоловічий рід / тверда група / на -(к|п|кр|пл|др|жив)іт",examples:["кіт","кріт"],wordClass:"noun",gender:["masculine"],priority:6,applicationType:[],pattern:{find:"(к|п|кр|пл|др|жив)іт$",modify:"(.{1})(.{1})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"replace",value:"о"},1:{action:"append",value:"а"}}],dative:[{0:{action:"replace",value:"о"},1:{action:"append",value:"у"}},{0:{action:"replace",value:"о"},1:{action:"append",value:"ові"}}],accusative:[{0:{action:"replace",value:"о"},1:{action:"append",value:"а"}}],ablative:[{0:{action:"replace",value:"о"},1:{action:"append",value:"ом"}}],locative:[{0:{action:"replace",value:"о"},1:{action:"append",value:"ові"}},{0:{action:"replace",value:"о"},1:{action:"append",value:"і"}}],vocative:[{0:{action:"replace",value:"о"},1:{action:"append",value:"е"}}]}},{description:"друга відміна / чоловічий рід / тверда група / на -грім",examples:["грім"],wordClass:"noun",gender:["masculine"],priority:6,applicationType:[],pattern:{find:"грім$",modify:"(.{1})(.{1})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"replace",value:"о"},1:{action:"append",value:"а"}}],dative:[{0:{action:"replace",value:"о"},1:{action:"append",value:"у"}},{0:{action:"replace",value:"о"},1:{action:"append",value:"ові"}}],accusative:[{0:{action:"replace",value:"о"},1:{action:"append",value:"а"}}],ablative:[{0:{action:"replace",value:"о"},1:{action:"append",value:"ом"}}],locative:[{0:{action:"replace",value:"о"},1:{action:"append",value:"і"}},{0:{action:"replace",value:"о"},1:{action:"append",value:"ові"}}],vocative:[{0:{action:"replace",value:"о"},1:{action:"append",value:"е"}}]}},{description:"друга відміна / чоловічий рід / тверда група / на -(дзвін|хрін)",examples:["дзвін"],wordClass:"noun",gender:["masculine"],priority:6,applicationType:[],pattern:{find:"(дзвін|хрін)$",modify:"(.{1})(.{1})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"replace",value:"о"},1:{action:"append",value:"а"}}],dative:[{0:{action:"replace",value:"о"},1:{action:"append",value:"у"}},{0:{action:"replace",value:"о"},1:{action:"append",value:"ові"}}],accusative:[{0:{action:"replace",value:"о"},1:{action:"append",value:"а"}}],ablative:[{0:{action:"replace",value:"о"},1:{action:"append",value:"ом"}}],locative:[{0:{action:"replace",value:"о"},1:{action:"append",value:"ові"}},{0:{action:"replace",value:"о"},1:{action:"append",value:"і"}}],vocative:[{0:{action:"replace",value:"о"},1:{action:"append",value:"е"}}]}},{description:"друга відміна / чоловічий рід / тверда група / на -батіг",examples:["батіг"],wordClass:"noun",gender:["masculine"],priority:6,applicationType:[],pattern:{find:"батіг$",modify:"(.{1})(.{1})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"replace",value:"о"},1:{action:"append",value:"а"}}],dative:[{0:{action:"replace",value:"о"},1:{action:"append",value:"у"}},{0:{action:"replace",value:"о"},1:{action:"append",value:"ові"}}],accusative:[{0:{action:"replace",value:"о"},1:{action:"append",value:"а"}}],ablative:[{0:{action:"replace",value:"о"},1:{action:"append",value:"ом"}}],locative:[{0:{action:"replace",value:"о"},1:{action:"replace",value:"зі"}},{0:{action:"replace",value:"о"},1:{action:"append",value:"ові"}}],vocative:[{0:{action:"replace",value:"о"},1:{action:"replace",value:"гу"}}]}},{description:"друга відміна / чоловічий рід / тверда група / на -сокіл",examples:["сокіл"],wordClass:"noun",gender:["masculine"],priority:6,applicationType:[],pattern:{find:"сокіл$",modify:"(.{1})(.{1})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"replace",value:"о"},1:{action:"append",value:"а"}}],dative:[{0:{action:"replace",value:"о"},1:{action:"append",value:"у"}},{0:{action:"replace",value:"о"},1:{action:"append",value:"ові"}}],accusative:[{0:{action:"replace",value:"о"},1:{action:"append",value:"а"}}],ablative:[{0:{action:"replace",value:"о"},1:{action:"append",value:"ом"}}],locative:[{0:{action:"replace",value:"о"},1:{action:"append",value:"ові"}}],vocative:[{0:{action:"replace",value:"о"},1:{action:"append",value:"е"}}]}},{description:"друга відміна / чоловічий рід / м'яка група / на -кріль",examples:["кріль"],wordClass:"noun",gender:["masculine"],priority:6,applicationType:[],pattern:{find:"кріль$",modify:"(.{1})(.{1})(.{1})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"replace",value:"о"},2:{action:"replace",value:"я"}}],dative:[{0:{action:"replace",value:"о"},2:{action:"replace",value:"ю"}},{0:{action:"replace",value:"о"},2:{action:"replace",value:"еві"}}],accusative:[{0:{action:"replace",value:"о"},2:{action:"replace",value:"я"}}],ablative:[{0:{action:"replace",value:"о"},2:{action:"replace",value:"ем"}}],locative:[{0:{action:"replace",value:"о"},2:{action:"replace",value:"ю"}},{0:{action:"replace",value:"о"},2:{action:"replace",value:"еві"}}],vocative:[{0:{action:"replace",value:"о"},2:{action:"replace",value:"ю"}}]}},{description:"чоловічі імена ігор, лазар",examples:["ігор","лазар"],wordClass:"noun",gender:["masculine"],priority:5,applicationType:[],pattern:{find:"^(ігор|лазар)$",modify:"(.{1})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"append",value:"я"}}],dative:[{0:{action:"append",value:"ю"}},{0:{action:"append",value:"еві"}}],accusative:[{0:{action:"append",value:"я"}}],ablative:[{0:{action:"append",value:"ем"}}],locative:[{0:{action:"append",value:"ю"}},{0:{action:"append",value:"еві"}}],vocative:[{0:{action:"append",value:"ю"}}]}},{description:"слово сіль",examples:["сіль"],wordClass:"noun",gender:["masculine"],priority:5,applicationType:["familyName"],pattern:{find:"^сіль$",modify:"(.{1})(.{1})(.{1})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"replace",value:"о"},2:{action:"replace",value:"і"}}],dative:[{0:{action:"replace",value:"о"},2:{action:"replace",value:"і"}}],accusative:[],ablative:[{2:{action:"replace",value:"лю"}}],locative:[{0:{action:"replace",value:"о"},2:{action:"replace",value:"і"}}],vocative:[{0:{action:"replace",value:"о"},2:{action:"replace",value:"е"}}]}},{description:"друга відміна / чоловічий рід / м'яка група / на -(голосний)(твердий приголосний)е(ц|н)ь",examples:["половець"],wordClass:"noun",gender:["masculine"],priority:5,applicationType:[],pattern:{find:"[аеєиіїоуюя]([бвгґджзклмнпрстфхцчшщ]|дз|дж)е(ц|н)ь$",modify:"(.{1})(.{1})(.{1})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"replace",value:""},2:{action:"replace",value:"я"}}],dative:[{0:{action:"replace",value:""},2:{action:"replace",value:"ю"}},{0:{action:"replace",value:""},2:{action:"replace",value:"еві"}}],accusative:[{0:{action:"replace",value:""},2:{action:"replace",value:"я"}}],ablative:[{0:{action:"replace",value:""},2:{action:"replace",value:"ем"}}],locative:[{0:{action:"replace",value:""},2:{action:"replace",value:"ю"}},{0:{action:"replace",value:""},2:{action:"replace",value:"еві"}}],vocative:[{0:{action:"replace",value:""},2:{action:"replace",value:"ю"}}]}},{description:"друга відміна / чоловічий рід / м'яка група / на -(твердий приголосний)(твердий приголосний)е(ц|н)ь",examples:["жнець"],wordClass:"noun",gender:["masculine"],priority:5,applicationType:[],pattern:{find:"([бвгґджзклмнпрстфхцчшщ]|дз|дж)([бвгґджзклмнпрстфхцчшщ]|дз|дж)е(ц|н)ь$",modify:"(.{1})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"replace",value:"я"}}],dative:[{0:{action:"replace",value:"ю"}},{0:{action:"replace",value:"еві"}}],accusative:[{0:{action:"replace",value:"я"}}],ablative:[{0:{action:"replace",value:"ем"}}],locative:[{0:{action:"replace",value:"ю"}},{0:{action:"replace",value:"еві"}}],vocative:[{0:{action:"replace",value:"ю"}}]}},{description:"друга відміна / чоловічий рід / тверда група / на -(рід|плід)",examples:["рід","плід"],wordClass:"noun",gender:["masculine"],priority:5,applicationType:[],pattern:{find:"(рід|плід)$",modify:"(.{1})(.{1})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"replace",value:"о"},1:{action:"append",value:"а"}}],dative:[{0:{action:"replace",value:"о"},1:{action:"append",value:"у"}},{0:{action:"replace",value:"о"},1:{action:"append",value:"ові"}}],accusative:[{0:{action:"replace",value:"о"},1:{action:"append",value:"а"}}],ablative:[{0:{action:"replace",value:"о"},1:{action:"append",value:"ом"}}],locative:[{0:{action:"replace",value:"о"},1:{action:"append",value:"ові"}},{0:{action:"replace",value:"о"},1:{action:"append",value:"і"}}],vocative:[{0:{action:"replace",value:"о"},1:{action:"append",value:"е"}}]}},{description:"друга відміна / чоловічий рід / тверда група / чоловічі прізвища на -ніс, без чергування",examples:["іваніс","ханіс","деніс","маніс"],wordClass:"noun",gender:["masculine"],priority:5,applicationType:[],pattern:{find:"^([аеєиіїоуюя])?([бвгґджзйклмнпрстфхцчшщ]|дз|дж)[аеєиіїоуюя]ніс$",modify:"(.{1})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"append",value:"а"}}],dative:[{0:{action:"append",value:"у"}},{0:{action:"append",value:"ові"}}],accusative:[{0:{action:"append",value:"а"}}],ablative:[{0:{action:"append",value:"ом"}}],locative:[{0:{action:"append",value:"ові"}},{0:{action:"append",value:"і"}}],vocative:[{0:{action:"append",value:"е"}}]}},{description:"друга відміна / чоловічий рід / тверда група / на -(з|яв)ір",examples:["дивозір","явір"],wordClass:"noun",gender:["masculine"],priority:5,applicationType:[],pattern:{find:"(з|яв|г)ір$",modify:"(.{1})(.{1})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"replace",value:"о"},1:{action:"append",value:"а"}}],dative:[{0:{action:"replace",value:"о"},1:{action:"append",value:"у"}},{0:{action:"replace",value:"о"},1:{action:"append",value:"ові"}}],accusative:[{0:{action:"replace",value:"о"},1:{action:"append",value:"а"}}],ablative:[{0:{action:"replace",value:"о"},1:{action:"append",value:"ом"}}],locative:[{0:{action:"replace",value:"о"},1:{action:"append",value:"ові"}},{0:{action:"replace",value:"о"},1:{action:"append",value:"і"}}],vocative:[{0:{action:"replace",value:"о"},1:{action:"append",value:"е"}}]}},{description:"друга відміна / чоловічий рід / тверда група / на -орел",examples:["орел"],wordClass:"noun",gender:["masculine"],priority:5,applicationType:[],pattern:{find:"орел$",modify:"(.{1})(.{1})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"replace",value:"л"},1:{action:"replace",value:"а"}}],dative:[{0:{action:"replace",value:"л"},1:{action:"replace",value:"ові"}},{0:{action:"replace",value:"л"},1:{action:"replace",value:"у"}}],accusative:[{0:{action:"replace",value:"л"},1:{action:"replace",value:"а"}}],ablative:[{0:{action:"replace",value:"л"},1:{action:"replace",value:"ом"}}],locative:[{0:{action:"replace",value:"л"},1:{action:"replace",value:"ові"}}],vocative:[{0:{action:"replace",value:"л"},1:{action:"replace",value:"е"}}]}},{description:"друга відміна / чоловічий рід / тверда група / на -якір",examples:["якір"],wordClass:"noun",gender:["masculine"],priority:5,applicationType:[],pattern:{find:"якір$",modify:"(.{1})(.{1})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"replace",value:"о"},1:{action:"append",value:"я"}}],dative:[{0:{action:"replace",value:"о"},1:{action:"append",value:"ю"}},{0:{action:"replace",value:"о"},1:{action:"append",value:"еві"}}],accusative:[{0:{action:"replace",value:"о"},1:{action:"append",value:"я"}}],ablative:[{0:{action:"replace",value:"о"},1:{action:"append",value:"ем"}}],locative:[{0:{action:"replace",value:"о"},1:{action:"append",value:"еві"}},{0:{action:"replace",value:"о"},1:{action:"append",value:"і"}},{0:{action:"replace",value:"о"},1:{action:"append",value:"ю"}}],vocative:[{0:{action:"replace",value:"о"},1:{action:"append",value:"ю"}}]}},{description:"друга відміна / чоловічий рід / м'яка група / на -бідь",examples:["лебідь"],wordClass:"noun",gender:["masculine"],priority:5,applicationType:[],pattern:{find:".бідь$",modify:"(.{1})(.{1})(.{1})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"replace",value:"е"},2:{action:"replace",value:"я"}}],dative:[{0:{action:"replace",value:"е"},2:{action:"replace",value:"ю"}},{0:{action:"replace",value:"е"},2:{action:"replace",value:"еві"}}],accusative:[{0:{action:"replace",value:"е"},2:{action:"replace",value:"я"}}],ablative:[{0:{action:"replace",value:"е"},2:{action:"replace",value:"ем"}}],locative:[{0:{action:"replace",value:"е"},2:{action:"replace",value:"ю"}},{0:{action:"replace",value:"е"},2:{action:"replace",value:"еві"}}],vocative:[{0:{action:"replace",value:"е"},2:{action:"replace",value:"ю"}}]}},{description:"друга відміна / чоловічий рід / м'яка група / на -мінь",examples:["кремінь"],wordClass:"noun",gender:["masculine"],priority:5,applicationType:[],pattern:{find:".мінь$",modify:"(.{1})(.{1})(.{1})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"replace",value:"е"},2:{action:"replace",value:"я"}}],dative:[{0:{action:"replace",value:"е"},2:{action:"replace",value:"ю"}},{0:{action:"replace",value:"е"},2:{action:"replace",value:"еві"}}],accusative:[{0:{action:"replace",value:"е"},2:{action:"replace",value:"я"}}],ablative:[{0:{action:"replace",value:"е"},2:{action:"replace",value:"ем"}}],locative:[{0:{action:"replace",value:"е"},2:{action:"replace",value:"ю"}},{0:{action:"replace",value:"е"},2:{action:"replace",value:"еві"}}],vocative:[{0:{action:"replace",value:"е"},2:{action:"replace",value:"ю"}}]}},{description:"друга відміна / чоловічий рід / м'яка група / на -сіль",examples:["кисіль"],wordClass:"noun",gender:["masculine"],priority:5,applicationType:[],pattern:{find:"сіль$",modify:"(.{1})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"replace",value:"я"}}],dative:[{0:{action:"replace",value:"ю"}},{0:{action:"replace",value:"еві"}}],accusative:[{0:{action:"replace",value:"я"}}],ablative:[{0:{action:"replace",value:"ем"}}],locative:[{0:{action:"replace",value:"ю"}},{0:{action:"replace",value:"еві"}}],vocative:[{0:{action:"replace",value:"ю"}}]}},{description:"друга відміна / чоловічий рід / тверда група / на -кінь",examples:["кінь"],wordClass:"noun",gender:["masculine"],priority:5,applicationType:[],pattern:{find:"кінь$",modify:"(.{1})(.{1})(.{1})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"replace",value:"о"},2:{action:"replace",value:"я"}}],dative:[{0:{action:"replace",value:"о"},2:{action:"replace",value:"ю"}},{0:{action:"replace",value:"о"},2:{action:"replace",value:"еві"}}],accusative:[{0:{action:"replace",value:"о"},2:{action:"replace",value:"я"}}],ablative:[{0:{action:"replace",value:"о"},2:{action:"replace",value:"ем"}}],locative:[{0:{action:"replace",value:"о"},2:{action:"replace",value:"і"}},{0:{action:"replace",value:"о"},2:{action:"replace",value:"еві"}}],vocative:[{0:{action:"replace",value:"о"},2:{action:"replace",value:"ю"}}]}},{description:"друга відміна / чоловічий рід / тверда група / на -куліш",examples:["куліш"],wordClass:"noun",gender:["masculine"],priority:5,applicationType:[],pattern:{find:"куліш$",modify:"(.{1})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"append",value:"а"}}],dative:[{0:{action:"append",value:"у"}}],accusative:[{0:{action:"append",value:"а"}}],ablative:[{0:{action:"append",value:"ем"}}],locative:[{0:{action:"append",value:"еві"}}],vocative:[{0:{action:"append",value:"е"}}]}},{description:"жіночий рід / на -(твердий приголосний)ька",examples:["ільницька","сумська"],wordClass:"adjective",gender:["feminine"],priority:4,applicationType:["familyName"],pattern:{find:"([бвгґджзклмнпрстфхцчшщ]|дз|дж)ька$",modify:"(.{1})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"replace",value:"ої"}}],dative:[{0:{action:"replace",value:"ій"}}],accusative:[{0:{action:"replace",value:"у"}}],ablative:[{0:{action:"replace",value:"ою"}}],locative:[{0:{action:"replace",value:"ій"}}],vocative:[]}},{description:"жіночий рід / на -ова",examples:["іванова"],wordClass:"adjective",gender:["feminine"],priority:4,applicationType:["familyName"],pattern:{find:"ова$",modify:"(.{1})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"replace",value:"ої"}}],dative:[{0:{action:"replace",value:"ій"}}],accusative:[{0:{action:"replace",value:"у"}}],ablative:[{0:{action:"replace",value:"ою"}}],locative:[{0:{action:"replace",value:"ій"}}],vocative:[]}},{description:"жіночий рід / на -іна",examples:["зеленкіна"],wordClass:"adjective",gender:["feminine"],priority:4,applicationType:["familyName"],pattern:{find:"іна$",modify:"(.{1})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"replace",value:"ої"}}],dative:[{0:{action:"replace",value:"ій"}}],accusative:[{0:{action:"replace",value:"у"}}],ablative:[{0:{action:"replace",value:"ою"}}],locative:[{0:{action:"replace",value:"ій"}}],vocative:[]}},{description:"друга відміна / чоловічий рід / м'яка група / на -(голосний)єць",examples:["заєць"],wordClass:"noun",gender:["masculine"],priority:4,applicationType:[],pattern:{find:"[аеєиіїоуюя]єць$",modify:"(.{1})(.{1})(.{1})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"replace",value:"й"},2:{action:"replace",value:"я"}}],dative:[{0:{action:"replace",value:"й"},2:{action:"replace",value:"ю"}},{0:{action:"replace",value:"й"},2:{action:"replace",value:"еві"}}],accusative:[{0:{action:"replace",value:"й"},2:{action:"replace",value:"я"}}],ablative:[{0:{action:"replace",value:"й"},2:{action:"replace",value:"ем"}}],locative:[{0:{action:"replace",value:"й"},2:{action:"replace",value:"ю"}},{0:{action:"replace",value:"й"},2:{action:"replace",value:"еві"}}],vocative:[{0:{action:"replace",value:"й"},2:{action:"replace",value:"ю"}}]}},{description:"друга відміна / чоловічий рід / тверда група / на -віз",examples:["узвіз"],wordClass:"noun",gender:["masculine"],priority:4,applicationType:[],pattern:{find:"віз$",modify:"(.{1})(.{1})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"replace",value:"о"},1:{action:"append",value:"а"}}],dative:[{0:{action:"replace",value:"о"},1:{action:"append",value:"у"}},{0:{action:"replace",value:"о"},1:{action:"append",value:"ові"}}],accusative:[{0:{action:"replace",value:"о"},1:{action:"append",value:"а"}}],ablative:[{0:{action:"replace",value:"о"},1:{action:"append",value:"ом"}}],locative:[{0:{action:"replace",value:"о"},1:{action:"append",value:"і"}},{0:{action:"replace",value:"о"},1:{action:"append",value:"ові"}}],vocative:[{0:{action:"replace",value:"о"},1:{action:"append",value:"е"}}]}},{description:"друга відміна / чоловічий рід / тверда група / на -ків",examples:["яків"],wordClass:"noun",gender:["masculine"],priority:4,applicationType:["givenName"],pattern:{find:".ків$",modify:"(.{1})(.{1})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"replace",value:"о"},1:{action:"append",value:"а"}}],dative:[{0:{action:"replace",value:"о"},1:{action:"append",value:"у"}},{0:{action:"replace",value:"о"},1:{action:"append",value:"ові"}}],accusative:[{0:{action:"replace",value:"о"},1:{action:"append",value:"а"}}],ablative:[{0:{action:"replace",value:"о"},1:{action:"append",value:"ом"}}],locative:[{0:{action:"replace",value:"о"},1:{action:"append",value:"і"}},{0:{action:"replace",value:"о"},1:{action:"append",value:"ові"}}],vocative:[{0:{action:"replace",value:"о"},1:{action:"append",value:"е"}}]}},{description:"друга відміна / чоловічий рід / тверда група / на -(к|р)іп",examples:["прокіп"],wordClass:"noun",gender:["masculine"],priority:4,applicationType:[],pattern:{find:".(к|р)іп$",modify:"(.{1})(.{1})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"replace",value:"о"},1:{action:"append",value:"а"}}],dative:[{0:{action:"replace",value:"о"},1:{action:"append",value:"у"}},{0:{action:"replace",value:"о"},1:{action:"append",value:"ові"}}],accusative:[{0:{action:"replace",value:"о"},1:{action:"append",value:"а"}}],ablative:[{0:{action:"replace",value:"о"},1:{action:"append",value:"ом"}}],locative:[{0:{action:"replace",value:"о"},1:{action:"append",value:"і"}},{0:{action:"replace",value:"о"},1:{action:"append",value:"ові"}}],vocative:[{0:{action:"replace",value:"о"},1:{action:"append",value:"е"}}]}},{description:"друга відміна / чоловічий рід / тверда група / на -піп",examples:["прокіп"],wordClass:"noun",gender:["masculine"],priority:4,applicationType:[],pattern:{find:"піп$",modify:"(.{1})(.{1})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"replace",value:"о"},1:{action:"append",value:"а"}}],dative:[{0:{action:"replace",value:"о"},1:{action:"append",value:"у"}},{0:{action:"replace",value:"о"},1:{action:"append",value:"ові"}}],accusative:[{0:{action:"replace",value:"о"},1:{action:"append",value:"а"}}],ablative:[{0:{action:"replace",value:"о"},1:{action:"append",value:"ом"}}],locative:[{0:{action:"replace",value:"о"},1:{action:"append",value:"і"}},{0:{action:"replace",value:"о"},1:{action:"append",value:"ові"}}],vocative:[{0:{action:"replace",value:"о"},1:{action:"append",value:"е"}}]}},{description:"друга відміна / чоловічий рід / тверда група / на -ніс",examples:["кривоніс"],wordClass:"noun",gender:["masculine"],priority:4,applicationType:[],pattern:{find:"ніс$",modify:"(.{1})(.{1})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"replace",value:"о"},1:{action:"append",value:"а"}}],dative:[{0:{action:"replace",value:"о"},1:{action:"append",value:"у"}},{0:{action:"replace",value:"о"},1:{action:"append",value:"ові"}}],accusative:[{0:{action:"replace",value:"о"},1:{action:"append",value:"а"}}],ablative:[{0:{action:"replace",value:"о"},1:{action:"append",value:"ом"}}],locative:[{0:{action:"replace",value:"о"},1:{action:"append",value:"і"}},{0:{action:"replace",value:"о"},1:{action:"append",value:"ові"}}],vocative:[{0:{action:"replace",value:"о"},1:{action:"append",value:"е"}}]}},{description:"друга відміна / чоловічий рід / тверда група / на -віл",examples:["рябовіл"],wordClass:"noun",gender:["masculine"],priority:4,applicationType:[],pattern:{find:"віл$",modify:"(.{1})(.{1})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"replace",value:"о"},1:{action:"append",value:"а"}}],dative:[{0:{action:"replace",value:"о"},1:{action:"append",value:"у"}},{0:{action:"replace",value:"о"},1:{action:"append",value:"ові"}}],accusative:[{0:{action:"replace",value:"о"},1:{action:"append",value:"а"}}],ablative:[{0:{action:"replace",value:"о"},1:{action:"append",value:"ом"}}],locative:[{0:{action:"replace",value:"о"},1:{action:"append",value:"і"}},{0:{action:"replace",value:"о"},1:{action:"append",value:"ові"}}],vocative:[{0:{action:"replace",value:"о"},1:{action:"append",value:"е"}}]}},{description:"друга відміна / чоловічий рід / тверда група / на -ріг",examples:["пиріг"],wordClass:"noun",gender:["masculine"],priority:4,applicationType:[],pattern:{find:"ріг$",modify:"(.{1})(.{1})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"replace",value:"о"},1:{action:"append",value:"а"}}],dative:[{0:{action:"replace",value:"о"},1:{action:"append",value:"у"}},{0:{action:"replace",value:"о"},1:{action:"append",value:"ові"}}],accusative:[{0:{action:"replace",value:"о"},1:{action:"append",value:"а"}}],ablative:[{0:{action:"replace",value:"о"},1:{action:"append",value:"ом"}}],locative:[{0:{action:"replace",value:"о"},1:{action:"replace",value:"зі"}},{0:{action:"replace",value:"о"},1:{action:"append",value:"ові"}}],vocative:[{0:{action:"replace",value:"о"},1:{action:"append",value:"у"}}]}},{description:"друга відміна / чоловічий рід / тверда група / на -хід",examples:["прихід"],wordClass:"noun",gender:["masculine"],priority:4,applicationType:[],pattern:{find:"хід$",modify:"(.{1})(.{1})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"replace",value:"о"},1:{action:"append",value:"а"}}],dative:[{0:{action:"replace",value:"о"},1:{action:"append",value:"у"}},{0:{action:"replace",value:"о"},1:{action:"append",value:"ові"}}],accusative:[{0:{action:"replace",value:"о"},1:{action:"append",value:"а"}}],ablative:[{0:{action:"replace",value:"о"},1:{action:"append",value:"ом"}}],locative:[{0:{action:"replace",value:"о"},1:{action:"append",value:"і"}},{0:{action:"replace",value:"о"},1:{action:"append",value:"ові"}}],vocative:[{0:{action:"replace",value:"о"},1:{action:"append",value:"е"}}]}},{description:"друга відміна / жіночий рід / м'яка група / на -(голосний)ль",examples:["мішель","ніколь","cесіль"],wordClass:"noun",gender:["feminine"],priority:4,applicationType:["givenName"],pattern:{find:"[аеєиіїоуюя]ль$",modify:"(.{1})(.{1})$"},grammaticalCases:{nominative:[],genitive:[{1:{action:"replace",value:"і"}}],dative:[{1:{action:"replace",value:"і"}}],accusative:[],ablative:[{0:{action:"replace",value:"лл"},1:{action:"replace",value:"ю"}}],locative:[{1:{action:"replace",value:"і"}}],vocative:[]}},{description:"друга відміна / жіночий рід / м'яка група / на (губний_приголосний)",examples:["зейнаб","руф"],wordClass:"noun",gender:["feminine"],priority:4,applicationType:["givenName"],pattern:{find:"[бпвмф]$",modify:"(.{1})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"append",value:"і"}}],dative:[{0:{action:"append",value:"і"}}],accusative:[{0:{action:"append",value:"і"}}],ablative:[{0:{action:"append",value:"і"}}],locative:[{0:{action:"append",value:"і"}}],vocative:[{0:{action:"append",value:"і"}}]}},{description:"друга відміна / чоловічий рід / тверда група / на -ов, -ев (-єв), -ів (-їв), -ін (-їн)",examples:["павлов","нікітін"],wordClass:"noun",gender:["masculine"],priority:4,applicationType:["familyName"],pattern:{find:"([оеє]в|[ії]в|[ії]н)$",modify:"(.{1})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"append",value:"а"}}],dative:[{0:{action:"append",value:"у"}}],accusative:[{0:{action:"append",value:"а"}}],ablative:[{0:{action:"append",value:"им"}}],locative:[{0:{action:"append",value:"і"}},{0:{action:"append",value:"у"}}],vocative:[{0:{action:"append",value:"е"}}]}},{description:"друга відміна / чоловічий рід / тверда група / на -ишин",examples:["ковалишин"],wordClass:"noun",gender:["masculine"],priority:4,applicationType:[],pattern:{find:"ишин$",modify:"(.{1})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"append",value:"а"}}],dative:[{0:{action:"append",value:"у"}}],accusative:[{0:{action:"append",value:"а"}}],ablative:[{0:{action:"append",value:"им"}}],locative:[{0:{action:"append",value:"у"}}],vocative:[{0:{action:"append",value:"е"}}]}},{description:"друга відміна / чоловічий рід / тверда група / на -(аго|ово)",examples:["живаго"],wordClass:"noun",gender:["masculine"],priority:4,applicationType:[],pattern:{find:"(аго|ово)$",modify:"(.{1})$"},grammaticalCases:{nominative:[],genitive:[],dative:[],accusative:[],ablative:[],locative:[],vocative:[]}},{description:"друга відміна / чоловічий рід / тверда група / на -тер",examples:["вітер","буймистер"],wordClass:"noun",gender:["masculine"],priority:4,applicationType:[],pattern:{find:"[іс]тер$",modify:"(.{1})(.{1})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"replace",value:""},1:{action:"append",value:"а"}}],dative:[{0:{action:"replace",value:""},1:{action:"append",value:"у"}}],accusative:[{0:{action:"replace",value:""},1:{action:"append",value:"а"}}],ablative:[{0:{action:"replace",value:""},1:{action:"append",value:"ом"}}],locative:[{0:{action:"replace",value:""},1:{action:"append",value:"ові"}}],vocative:[{0:{action:"replace",value:""},1:{action:"append",value:"е"}}]}},{description:"друга відміна / чоловічий рід / тверда група / на -єгер",examples:["єгер"],wordClass:"noun",gender:["masculine"],priority:4,applicationType:[],pattern:{find:"єгер$",modify:"(.{1})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"append",value:"я"}}],dative:[{0:{action:"append",value:"ю"}},{0:{action:"append",value:"еві"}}],accusative:[{0:{action:"append",value:"я"}}],ablative:[{0:{action:"append",value:"ем"}}],locative:[{0:{action:"append",value:"еві"}},{0:{action:"append",value:"і"}}],vocative:[{0:{action:"append",value:"ю"}}]}},{description:"перша відміна / чоловічий рід / тверда група / на -світ",examples:["світ"],wordClass:"noun",gender:["masculine"],priority:4,applicationType:[],pattern:{find:"світ$",modify:"(.{1})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"append",value:"а"}}],dative:[{0:{action:"append",value:"у"}}],accusative:[{0:{action:"append",value:"а"}}],ablative:[{0:{action:"append",value:"ом"}}],locative:[{0:{action:"append",value:"ові"}}],vocative:[{0:{action:"append",value:"е"}}]}},{description:"чоловічі імена / на -(в|д)ір",examples:["дір","вір"],wordClass:"noun",gender:["masculine"],priority:4,applicationType:[],pattern:{find:"(в|д)ір$",modify:"(.{1})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"append",value:"а"}}],dative:[{0:{action:"append",value:"у"}},{0:{action:"append",value:"ові"}}],accusative:[{0:{action:"append",value:"а"}}],ablative:[{0:{action:"append",value:"ом"}}],locative:[{0:{action:"append",value:"ові"}},{0:{action:"append",value:"у"}}],vocative:[{0:{action:"append",value:"е"}}]}},{description:"чоловічий рід / на -кій (помилкова транслітерація)",examples:["дідківській"],wordClass:"adjective",gender:["masculine"],priority:3,applicationType:["familyName"],pattern:{find:"кій$",modify:"(.{2})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"replace",value:"ого"}}],dative:[{0:{action:"replace",value:"ому"}}],accusative:[{0:{action:"replace",value:"ого"}}],ablative:[{0:{action:"replace",value:"им"}}],locative:[{0:{action:"replace",value:"ому"}}],vocative:[]}},{description:"множина / на -их",examples:["седих"],wordClass:"adjective",gender:["masculine"],priority:3,applicationType:[],pattern:{find:"их$",modify:"(.{1})$"},grammaticalCases:{nominative:[],genitive:[],dative:[],accusative:[],ablative:[],locative:[],vocative:[]}},{description:"друга відміна / чоловічий рід / тверда група / на -га",examples:["нога"],wordClass:"noun",gender:["masculine"],priority:3,applicationType:[],pattern:{find:"га$",modify:"(.{1})(.{1})$"},grammaticalCases:{nominative:[],genitive:[{1:{action:"replace",value:"и"}}],dative:[{0:{action:"replace",value:"з"},1:{action:"replace",value:"і"}}],accusative:[{1:{action:"replace",value:"у"}}],ablative:[{1:{action:"replace",value:"ою"}}],locative:[{0:{action:"replace",value:"з"},1:{action:"replace",value:"і"}}],vocative:[{1:{action:"replace",value:"о"}}]}},{description:"друга відміна / чоловічий рід / м'яка група / на -окар, -екар, -етар, -зар, -ухар",examples:["токар","пекар","решетар","кожухар","кобзар"],wordClass:"noun",gender:["masculine"],priority:3,applicationType:[],pattern:{find:"(окар|екар|етар|([бвгґджзйклмнпрстфхцчшщ]|дз|дж)зар|ухар)(?<!гузар)$",modify:"(.{1})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"append",value:"я"}}],dative:[{0:{action:"append",value:"ю"}},{0:{action:"append",value:"еві"}}],accusative:[{0:{action:"append",value:"я"}}],ablative:[{0:{action:"append",value:"ем"}}],locative:[{0:{action:"append",value:"еві"}},{0:{action:"append",value:"і"}}],vocative:[{0:{action:"append",value:"ю"}}]}},{description:"друга відміна / чоловічий рід / тверда група / на -кіш",examples:["розкіш"],wordClass:"noun",gender:["masculine"],priority:3,applicationType:[],pattern:{find:"кіш$",modify:"(.{1})(.{1})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"replace",value:"о"},1:{action:"append",value:"а"}}],dative:[{0:{action:"replace",value:"о"},1:{action:"append",value:"еві"}}],accusative:[{0:{action:"replace",value:"о"},1:{action:"append",value:"а"}}],ablative:[{0:{action:"replace",value:"о"},1:{action:"append",value:"ем"}}],locative:[{0:{action:"replace",value:"о"},1:{action:"append",value:"еві"}}],vocative:[{0:{action:"replace",value:"о"},1:{action:"append",value:"е"}}]}},{description:"друга відміна / чоловічий рід / м'яка група / на -ьо",examples:["іваньо","кузьо"],wordClass:"noun",gender:["masculine"],priority:3,applicationType:[],pattern:{find:"ьо$",modify:"(.{2})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"replace",value:"я"}}],dative:[{0:{action:"replace",value:"ю"}}],accusative:[{0:{action:"replace",value:"я"}}],ablative:[{0:{action:"append",value:"м"}}],locative:[{0:{action:"replace",value:"ю"}}],vocative:[]}},{description:"друга відміна / чоловічий рід / тверда група / на -ред",examples:["альфред"],wordClass:"noun",gender:["masculine"],priority:3,applicationType:[],pattern:{find:"ред$",modify:"(.{1})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"append",value:"а"}}],dative:[{0:{action:"append",value:"у"}}],accusative:[{0:{action:"append",value:"а"}}],ablative:[{0:{action:"append",value:"ом"}}],locative:[{0:{action:"append",value:"ові"}}],vocative:[{0:{action:"append",value:"е"}}]}},{description:"друга відміна / чоловічий рід / тверда група / бусел, дятел",examples:["бусел","дятел"],wordClass:"noun",gender:["masculine"],priority:3,applicationType:[],pattern:{find:"(бус|дят)ел$",modify:"(.{1})(.{1})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"replace",value:""},1:{action:"append",value:"а"}}],dative:[{0:{action:"replace",value:""},1:{action:"append",value:"ові"}},{0:{action:"replace",value:""},1:{action:"append",value:"у"}}],accusative:[{0:{action:"replace",value:""},1:{action:"append",value:"а"}}],ablative:[{0:{action:"replace",value:""},1:{action:"append",value:"ом"}}],locative:[{0:{action:"replace",value:""},1:{action:"append",value:"і"}}],vocative:[{0:{action:"replace",value:""},1:{action:"append",value:"е"}}]}},{description:"друга відміна / чоловічий рід / тверда група / на -е[вмн]",examples:["артем","семен","лев"],wordClass:"noun",gender:["masculine"],priority:3,applicationType:[],pattern:{find:"е[вмн]$",modify:"(.{1})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"append",value:"а"}}],dative:[{0:{action:"append",value:"у"}}],accusative:[{0:{action:"append",value:"а"}}],ablative:[{0:{action:"append",value:"ом"}}],locative:[{0:{action:"append",value:"ові"}}],vocative:[{0:{action:"append",value:"е"}}]}},{description:"друга відміна / чоловічий рід / тверда група / на -ер",examples:["ріхтер"],wordClass:"noun",gender:["masculine"],priority:3,applicationType:[],pattern:{find:"ер$",modify:"(.{1})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"append",value:"а"}}],dative:[{0:{action:"append",value:"у"}}],accusative:[{0:{action:"append",value:"а"}}],ablative:[{0:{action:"append",value:"ом"}}],locative:[{0:{action:"append",value:"ові"}}],vocative:[{0:{action:"append",value:"е"}}]}},{description:"друга відміна / чоловічий рід / тверда група / на -пес",examples:["пес"],wordClass:"noun",gender:["masculine"],priority:3,applicationType:[],pattern:{find:"пес$",modify:"(.{1})(.{1})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"replace",value:""},1:{action:"append",value:"а"}}],dative:[{0:{action:"replace",value:""},1:{action:"append",value:"у"}}],accusative:[{0:{action:"replace",value:""},1:{action:"append",value:"а"}}],ablative:[{0:{action:"replace",value:""},1:{action:"append",value:"ом"}}],locative:[{0:{action:"replace",value:""},1:{action:"append",value:"ові"}}],vocative:[{0:{action:"replace",value:""},1:{action:"append",value:"е"}}]}},{description:"друга відміна / чоловічий рід / тверда група / на -ко",examples:["марко"],wordClass:"noun",gender:["masculine"],priority:3,applicationType:[],pattern:{find:"ко$",modify:"(.{1})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"replace",value:"а"}}],dative:[{0:{action:"replace",value:"у"}},{0:{action:"replace",value:"ові"}}],accusative:[{0:{action:"replace",value:"а"}}],ablative:[{0:{action:"replace",value:"ом"}}],locative:[{0:{action:"replace",value:"ові"}},{0:{action:"replace",value:"у"}}],vocative:[{0:{action:"replace",value:"у"}}]}},{description:"друга відміна / чоловічий рід / м'яка група / на -ий",examples:["батий"],wordClass:"noun",gender:["masculine"],priority:3,applicationType:[],pattern:{find:"ий$",modify:"(.{1})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"replace",value:"я"}}],dative:[{0:{action:"replace",value:"ю"}}],accusative:[{0:{action:"replace",value:"я"}}],ablative:[{0:{action:"replace",value:"єм"}}],locative:[{0:{action:"replace",value:"ю"}},{0:{action:"replace",value:"ї"}}],vocative:[{0:{action:"replace",value:"ю"}}]}},{description:"перша відміна / чоловічий рід / тверда група / на -йо",examples:["йойо"],wordClass:"noun",gender:["masculine"],priority:3,applicationType:[],pattern:{find:"йо$",modify:"(.{2})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"replace",value:"я"}}],dative:[{0:{action:"append",value:"ві"}}],accusative:[{0:{action:"replace",value:"я"}}],ablative:[{0:{action:"append",value:"м"}}],locative:[{0:{action:"append",value:"ві"}}],vocative:[]}},{description:"перша відміна / чоловічий рід / тверда група / на -бо",examples:["голембо"],wordClass:"noun",gender:["masculine"],priority:3,applicationType:[],pattern:{find:"бо$",modify:"(.{1})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"replace",value:"и"}}],dative:[{0:{action:"replace",value:"і"}}],accusative:[{0:{action:"replace",value:"у"}}],ablative:[{0:{action:"replace",value:"ою"}}],locative:[{0:{action:"replace",value:"і"}}],vocative:[]}},{description:"чоловічий рід / на -ой, -ий",examples:["толстой","сухомлинський"],wordClass:"adjective",gender:["masculine"],priority:2,applicationType:["familyName"],pattern:{find:"(ой|ий)$",modify:"(.{2})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"replace",value:"ого"}}],dative:[{0:{action:"replace",value:"ому"}}],accusative:[{0:{action:"replace",value:"ого"}}],ablative:[{0:{action:"replace",value:"им"}}],locative:[{0:{action:"replace",value:"ому"}}],vocative:[]}},{description:"чоловічий рід / на -ій",examples:["заболотній"],wordClass:"adjective",gender:["masculine"],priority:2,applicationType:["familyName"],pattern:{find:"ій$",modify:"(.{2})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"replace",value:"ього"}}],dative:[{0:{action:"replace",value:"ьому"}}],accusative:[{0:{action:"replace",value:"ього"}}],ablative:[{0:{action:"replace",value:"ім"}}],locative:[{0:{action:"replace",value:"ьому"}}],vocative:[]}},{description:"жіночий рід / на -(твердий приголосний)а",examples:["зелена"],wordClass:"adjective",gender:["feminine"],priority:2,applicationType:["familyName"],pattern:{find:"([бвгґджзклмнпрстфхцчшщ]|дз|дж)а$",modify:"(.{1})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"replace",value:"ої"}}],dative:[{0:{action:"replace",value:"ій"}}],accusative:[{0:{action:"replace",value:"у"}}],ablative:[{0:{action:"replace",value:"ою"}}],locative:[{0:{action:"replace",value:"ій"}}],vocative:[]}},{description:"жіночий рід / на -(твердий приголосний)я",examples:["задорожня"],wordClass:"adjective",gender:["feminine"],priority:2,applicationType:["familyName"],pattern:{find:"([бвгґджзклмнпрстфхцчшщ]|дз|дж)я$",modify:"(.{1})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"replace",value:"ьої"}}],dative:[{0:{action:"replace",value:"ій"}}],accusative:[{0:{action:"replace",value:"ю"}}],ablative:[{0:{action:"replace",value:"ьою"}}],locative:[{0:{action:"replace",value:"ій"}}],vocative:[]}},{description:"жіночий рід / на -ая",examples:["толстая"],wordClass:"adjective",gender:["feminine"],priority:2,applicationType:["familyName"],pattern:{find:"ая$",modify:"(.{2})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"replace",value:"ої"}}],dative:[{0:{action:"replace",value:"ій"}}],accusative:[{0:{action:"replace",value:"ую"}}],ablative:[{0:{action:"replace",value:"ою"}}],locative:[{0:{action:"replace",value:"ій"}}],vocative:[]}},{description:"жіночий рід / на -яя",examples:["заболотняя"],wordClass:"adjective",gender:["feminine"],priority:2,applicationType:["familyName"],pattern:{find:"яя$",modify:"(.{2})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"replace",value:"ьої"}}],dative:[{0:{action:"replace",value:"ій"}}],accusative:[{0:{action:"replace",value:"ю"}}],ablative:[{0:{action:"replace",value:"ьою"}}],locative:[{0:{action:"replace",value:"ій"}}],vocative:[]}},{description:"чоловічі по батькові та прізвища / на -ич",examples:["валерійович","риндич"],wordClass:"noun",gender:["masculine"],priority:2,applicationType:["patronymicName","familyName"],pattern:{find:"ич$",modify:"(.{1})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"append",value:"а"}}],dative:[{0:{action:"append",value:"у"}}],accusative:[{0:{action:"append",value:"а"}}],ablative:[{0:{action:"append",value:"ем"}}],locative:[{0:{action:"append",value:"у"}}],vocative:[{0:{action:"append",value:"у"}}]}},{description:"чоловічі по батькові та прізвища / на -іч",examples:["ілліч"],wordClass:"noun",gender:["masculine"],priority:2,applicationType:["patronymicName","familyName"],pattern:{find:"іч$",modify:"(.{1})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"append",value:"а"}}],dative:[{0:{action:"append",value:"у"}},{0:{action:"append",value:"еві"}}],accusative:[{0:{action:"append",value:"а"}}],ablative:[{0:{action:"append",value:"ем"}}],locative:[{0:{action:"append",value:"і"}},{0:{action:"append",value:"у"}},{0:{action:"append",value:"еві"}}],vocative:[{0:{action:"append",value:"у"}}]}},{description:"жіночі по батькові / на -на",examples:["юріївна"],wordClass:"noun",gender:["feminine"],priority:2,applicationType:["patronymicName"],pattern:{find:"на$",modify:"(.{1})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"replace",value:"и"}}],dative:[{0:{action:"replace",value:"і"}}],accusative:[{0:{action:"replace",value:"у"}}],ablative:[{0:{action:"replace",value:"ою"}}],locative:[{0:{action:"replace",value:"і"}}],vocative:[{0:{action:"replace",value:"о"}}]}},{description:"жіночі імена / на -(твердий приголосний)я",examples:["неля"],wordClass:"noun",gender:["feminine"],priority:2,applicationType:["givenName"],pattern:{find:"([бвгґджзклмнпрстфхцчшщ]|дз|дж)я$",modify:"(.{1})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"replace",value:"і"}}],dative:[{0:{action:"replace",value:"і"}}],accusative:[{0:{action:"replace",value:"ю"}}],ablative:[{0:{action:"replace",value:"ею"}}],locative:[{0:{action:"replace",value:"і"}}],vocative:[{0:{action:"replace",value:"ю"}}]}},{description:"чоловічі імена / на -ня",examples:["женя"],wordClass:"noun",gender:["masculine"],priority:2,applicationType:["givenName"],pattern:{find:"ня$",modify:"(.{1})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"replace",value:"і"}}],dative:[{0:{action:"replace",value:"і"}}],accusative:[{0:{action:"replace",value:"ю"}}],ablative:[{0:{action:"replace",value:"ею"}}],locative:[{0:{action:"replace",value:"і"}}],vocative:[{0:{action:"replace",value:"ю"}}]}},{description:"друга відміна / чоловічий рід / тверда група / на -уг",examples:["товстолуг"],wordClass:"noun",gender:["masculine"],priority:2,applicationType:["familyName"],pattern:{find:"уг$",modify:"(.{1})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"append",value:"а"}}],dative:[{0:{action:"append",value:"у"}},{0:{action:"append",value:"ові"}}],accusative:[{0:{action:"append",value:"а"}}],ablative:[{0:{action:"append",value:"ом"}}],locative:[{0:{action:"append",value:"ові"}},{0:{action:"append",value:"у"}}],vocative:[{0:{action:"append",value:"у"}}]}},{description:"друга відміна / чоловічий рід / тверда група / на -ин",examples:["гаршин"],wordClass:"noun",gender:["masculine"],priority:2,applicationType:["familyName"],pattern:{find:"(?<!ус|в|н)ин$",modify:"(.{1})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"append",value:"а"}}],dative:[{0:{action:"append",value:"ові"}},{0:{action:"append",value:"у"}}],accusative:[{0:{action:"append",value:"а"}}],ablative:[{0:{action:"append",value:"им"}}],locative:[{0:{action:"append",value:"і"}},{0:{action:"append",value:"у"}}],vocative:[{0:{action:"append",value:"е"}}]}},{description:"друга відміна / чоловічий рід / тверда група / на -яр",examples:["скляр"],wordClass:"noun",gender:["masculine"],priority:2,applicationType:[],pattern:{find:"яр$",modify:"(.{1})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"append",value:"а"}}],dative:[{0:{action:"append",value:"у"}},{0:{action:"append",value:"еві"}}],accusative:[{0:{action:"append",value:"а"}}],ablative:[{0:{action:"append",value:"ем"}}],locative:[{0:{action:"append",value:"еві"}},{0:{action:"append",value:"у"}}],vocative:[{0:{action:"append",value:"е"}}]}},{description:"друга відміна / жіночий рід / тверда, м'яка група / на -(о|ь|твердий приголосний)",examples:["шевченко"],wordClass:"noun",gender:["feminine"],priority:2,applicationType:[],pattern:{find:"(о|ь|([бвгґджзклмнпрстфхцчшщ]|дз|дж))$",modify:"(.{2})$"},grammaticalCases:{nominative:[],genitive:[],dative:[],accusative:[],ablative:[],locative:[],vocative:[]}},{description:"друга відміна / чоловічий рід / тверда група / на -ок",examples:["бурячок"],wordClass:"noun",gender:["masculine"],priority:2,applicationType:[],pattern:{find:"((?<=[аеєиіїоуюя].*[аеєиіїоуюя].*л)|(?<=[аеєиіїоуюя].*[^л]))ок$",modify:"(.{1})(.{1})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"replace",value:""},1:{action:"append",value:"а"}}],dative:[{0:{action:"replace",value:""},1:{action:"append",value:"у"}},{0:{action:"replace",value:""},1:{action:"append",value:"ові"}}],accusative:[{0:{action:"replace",value:""},1:{action:"append",value:"а"}}],ablative:[{0:{action:"replace",value:""},1:{action:"append",value:"ом"}}],locative:[{0:{action:"replace",value:""},1:{action:"append",value:"ові"}}],vocative:[{0:{action:"replace",value:""},1:{action:"append",value:"у"}}]}},{description:"друга відміна / чоловічий рід / тверда група / на -е(тверда_прилосона)",examples:["марек"],wordClass:"noun",gender:["masculine"],priority:2,applicationType:[],pattern:{find:"е([бвгґджзклмнпрстфхцчшщ]|дз|дж)$",modify:"(.{1})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"append",value:"а"}}],dative:[{0:{action:"append",value:"у"}}],accusative:[{0:{action:"append",value:"а"}}],ablative:[{0:{action:"append",value:"ом"}}],locative:[{0:{action:"append",value:"ові"}}],vocative:[{0:{action:"append",value:"у"}}]}},{description:"друга відміна / чоловічий рід / м'яка група / на -(твердий приголосний)я",examples:["гмиря"],wordClass:"noun",gender:["masculine","feminine"],priority:2,applicationType:[],pattern:{find:"([бвгґджзклмнпрстфхцчшщ]|дз|дж)я$",modify:"(.{1})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"replace",value:"і"}}],dative:[{0:{action:"replace",value:"і"}}],accusative:[{0:{action:"replace",value:"ю"}}],ablative:[{0:{action:"replace",value:"ею"}}],locative:[{0:{action:"replace",value:"і"}}],vocative:[{0:{action:"replace",value:"е"}}]}},{description:"друга відміна / чоловічий, жіночий роди / м'яка група / на -(голосний|ь|й)я",examples:["юлія","майя"],wordClass:"noun",gender:["masculine","feminine"],priority:2,applicationType:[],pattern:{find:"([аеєиіїоуюя]|ь|й)я$",modify:"(.{1})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"replace",value:"ї"}}],dative:[{0:{action:"replace",value:"ї"}}],accusative:[{0:{action:"replace",value:"ю"}}],ablative:[{0:{action:"replace",value:"єю"}}],locative:[{0:{action:"replace",value:"ї"}}],vocative:[{0:{action:"replace",value:"є"}}]}},{description:"друга відміна / чоловічий рід / мішана група / на -(дж|ж|ч|ш)",examples:["януш","джордж"],wordClass:"noun",gender:["masculine"],priority:2,applicationType:[],pattern:{find:"(дж|ж|ч|ш)$",modify:"(.{1})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"append",value:"а"}}],dative:[{0:{action:"append",value:"у"}},{0:{action:"append",value:"еві"}}],accusative:[{0:{action:"append",value:"а"}}],ablative:[{0:{action:"append",value:"ем"}}],locative:[{0:{action:"append",value:"еві"}},{0:{action:"append",value:"і"}},{0:{action:"append",value:"у"}}],vocative:[{0:{action:"append",value:"е"}}]}},{description:"друга відміна / чоловічий рід / тверда група / на -н",examples:["міщанин"],wordClass:"noun",gender:["masculine"],priority:2,applicationType:[],pattern:{find:"н$",modify:"(.{1})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"append",value:"а"}}],dative:[{0:{action:"append",value:"у"}},{0:{action:"append",value:"ові"}}],accusative:[{0:{action:"append",value:"а"}}],ablative:[{0:{action:"append",value:"ом"}}],locative:[{0:{action:"append",value:"ові"}},{0:{action:"append",value:"і"}}],vocative:[{0:{action:"append",value:"е"}}]}},{description:"друга відміна / чоловічий рід / тверда група / (свекор|цукор)",examples:["свекор","цукор"],wordClass:"noun",gender:["masculine"],priority:2,applicationType:[],pattern:{find:"(свекор|цукор)$",modify:"(.{1})(.{1})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"replace",value:""},1:{action:"append",value:"а"}}],dative:[{0:{action:"replace",value:""},1:{action:"append",value:"ові"}},{0:{action:"replace",value:""},1:{action:"append",value:"у"}}],accusative:[{0:{action:"replace",value:""},1:{action:"append",value:"а"}}],ablative:[{0:{action:"replace",value:""},1:{action:"append",value:"ом"}}],locative:[{0:{action:"replace",value:""},1:{action:"append",value:"ові"}},{0:{action:"replace",value:""},1:{action:"append",value:"у"}}],vocative:[{0:{action:"replace",value:""},1:{action:"append",value:"е"}}]}},{description:"друга відміна / чоловічий рід / тверда група / снігир",examples:["снігир"],wordClass:"noun",gender:["masculine"],priority:2,applicationType:[],pattern:{find:"снігир$",modify:"(.{1})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"append",value:"я"}}],dative:[{0:{action:"append",value:"еві"}},{0:{action:"append",value:"ю"}}],accusative:[{0:{action:"append",value:"я"}}],ablative:[{0:{action:"append",value:"ем"}}],locative:[{0:{action:"append",value:"еві"}},{0:{action:"append",value:"ю"}}],vocative:[{0:{action:"append",value:"е"}}]}},{description:"друга відміна / чоловічий рід / тверда група / на -к",examples:["кузик","мисяк"],wordClass:"noun",gender:["masculine"],priority:2,applicationType:[],pattern:{find:"к$",modify:"(.{1})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"append",value:"а"}}],dative:[{0:{action:"append",value:"у"}},{0:{action:"append",value:"ові"}}],accusative:[{0:{action:"append",value:"а"}}],ablative:[{0:{action:"append",value:"ом"}}],locative:[{0:{action:"append",value:"ові"}},{0:{action:"append",value:"у"}}],vocative:[{0:{action:"append",value:"у"}}]}},{description:"друга відміна / чоловічий рід / тверда група / на -х",examples:["кожух"],wordClass:"noun",gender:["masculine"],priority:2,applicationType:[],pattern:{find:"х$",modify:"(.{1})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"append",value:"а"}}],dative:[{0:{action:"append",value:"у"}},{0:{action:"append",value:"ові"}}],accusative:[{0:{action:"append",value:"а"}}],ablative:[{0:{action:"append",value:"ом"}}],locative:[{0:{action:"append",value:"ові"}}],vocative:[{0:{action:"append",value:"у"}}]}},{description:"друга відміна / чоловічий рід / м'яка група / соловей",examples:["соловей"],wordClass:"noun",gender:["masculine"],priority:2,applicationType:[],pattern:{find:"соловей$",modify:"(.{1})(.{1})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"replace",value:""},1:{action:"replace",value:"'я"}}],dative:[{0:{action:"replace",value:""},1:{action:"replace",value:"'єві"}},{0:{action:"replace",value:""},1:{action:"replace",value:"'ю"}}],accusative:[{0:{action:"replace",value:""},1:{action:"replace",value:"'я"}}],ablative:[{0:{action:"replace",value:""},1:{action:"replace",value:"'єм"}}],locative:[{0:{action:"replace",value:""},1:{action:"replace",value:"'ї"}},{0:{action:"replace",value:""},1:{action:"replace",value:"'ю"}},{0:{action:"replace",value:""},1:{action:"replace",value:"'єві"}}],vocative:[{0:{action:"replace",value:""},1:{action:"replace",value:"'ю"}}]}},{description:"перша відміна / чоловічий, жіночий роди / тверда група / на -ха",examples:["старуха"],wordClass:"noun",gender:["masculine","feminine"],priority:2,applicationType:[],pattern:{find:"ха$",modify:"(.{1})(.{1})$"},grammaticalCases:{nominative:[],genitive:[{1:{action:"replace",value:"и"}}],dative:[{0:{action:"replace",value:"с"},1:{action:"replace",value:"і"}}],accusative:[{1:{action:"replace",value:"у"}}],ablative:[{1:{action:"replace",value:"ою"}}],locative:[{0:{action:"replace",value:"с"},1:{action:"replace",value:"і"}}],vocative:[{1:{action:"replace",value:"о"}},{1:{action:"replace",value:"а"}}]}},{description:"перша відміна / чоловічий, жіночий роди / тверда група / на -ка",examples:["прилука"],wordClass:"noun",gender:["masculine","feminine"],priority:2,applicationType:[],pattern:{find:"ка$",modify:"(.{1})(.{1})$"},grammaticalCases:{nominative:[],genitive:[{1:{action:"replace",value:"и"}}],dative:[{0:{action:"replace",value:"ц"},1:{action:"replace",value:"і"}}],accusative:[{1:{action:"replace",value:"у"}}],ablative:[{1:{action:"replace",value:"ою"}}],locative:[{0:{action:"replace",value:"ц"},1:{action:"replace",value:"і"}}],vocative:[{1:{action:"replace",value:"о"}},{1:{action:"replace",value:"а"}}]}},{description:"друга відміна / чоловічий рід / м'яка група / журавель",examples:["журавель"],wordClass:"noun",gender:["masculine"],priority:2,applicationType:[],pattern:{find:"журавель$",modify:"(.{3})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"replace",value:"ля"}}],dative:[{0:{action:"replace",value:"леві"}},{0:{action:"replace",value:"лю"}}],accusative:[{0:{action:"replace",value:"ля"}}],ablative:[{0:{action:"replace",value:"лем"}}],locative:[{0:{action:"replace",value:"лю"}},{0:{action:"replace",value:"і"}}],vocative:[{0:{action:"replace",value:"лю"}}]}},{description:"перша відміна / чоловічий рід / тверда група / на -(твердий приголосний)о",examples:["петро","павло"],wordClass:"noun",gender:["masculine"],priority:2,applicationType:[],pattern:{find:"([бвгґджзклмнпрстфхцчшщ]|дз|дж)о$",modify:"(.{1})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"replace",value:"а"}}],dative:[{0:{action:"replace",value:"у"}}],accusative:[{0:{action:"replace",value:"а"}}],ablative:[{0:{action:"replace",value:"ом"}}],locative:[{0:{action:"replace",value:"ові"}}],vocative:[{0:{action:"replace",value:"е"}}]}},{description:"перша відміна / жіночий рід / тверда група / на -(г|ґ)а",examples:["ольга"],wordClass:"noun",gender:["feminine"],priority:2,applicationType:[],pattern:{find:"(г|ґ)а$",modify:"(.{1})(.{1})$"},grammaticalCases:{nominative:[],genitive:[{1:{action:"replace",value:"и"}}],dative:[{0:{action:"replace",value:"з"},1:{action:"replace",value:"і"}}],accusative:[{1:{action:"replace",value:"у"}}],ablative:[{1:{action:"replace",value:"ою"}}],locative:[{0:{action:"replace",value:"з"},1:{action:"replace",value:"і"}}],vocative:[{1:{action:"replace",value:"о"}}]}},{description:"перша відміна / чоловічий рід / тверда група / на -ле",examples:["поле"],wordClass:"noun",gender:["masculine","feminine"],priority:2,applicationType:[],pattern:{find:"ле$",modify:"(.{1})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"replace",value:"я"}}],dative:[{0:{action:"replace",value:"ю"}}],accusative:[{0:{action:"replace",value:"е"}}],ablative:[{0:{action:"replace",value:"ем"}}],locative:[{0:{action:"replace",value:"і"}}],vocative:[]}},{description:"перша відміна / чоловічий, жіночий роди / мішана група / на -а",examples:["мойша"],wordClass:"noun",gender:["masculine","feminine"],priority:2,applicationType:[],pattern:{find:"(дж|ж|ч|ш|щ)а$",modify:"(.{1})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"replace",value:"і"}}],dative:[{0:{action:"replace",value:"і"}}],accusative:[{0:{action:"replace",value:"у"}}],ablative:[{0:{action:"replace",value:"ею"}}],locative:[{0:{action:"replace",value:"і"}}],vocative:[{0:{action:"replace",value:"о"}}]}},{description:"друга відміна / чоловічий рід / тверда група / на -(твердий приголосний)",examples:["олександр"],wordClass:"noun",gender:["masculine"],priority:1,applicationType:[],pattern:{find:"([бвгґджзклмнпрстфхцчшщ]|дз|дж)$",modify:"(.{1})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"append",value:"а"}}],dative:[{0:{action:"append",value:"у"}},{0:{action:"append",value:"ові"}}],accusative:[{0:{action:"append",value:"а"}}],ablative:[{0:{action:"append",value:"ом"}}],locative:[{0:{action:"append",value:"ові"}},{0:{action:"append",value:"у"}}],vocative:[{0:{action:"append",value:"е"}}]}},{description:"перша відміна / чоловічий, жіночий роди / тверда група / на -а",examples:["анна"],wordClass:"noun",gender:["masculine","feminine"],priority:1,applicationType:[],pattern:{find:"а$",modify:"(.{1})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"replace",value:"и"}}],dative:[{0:{action:"replace",value:"і"}}],accusative:[{0:{action:"replace",value:"у"}}],ablative:[{0:{action:"replace",value:"ою"}}],locative:[{0:{action:"replace",value:"і"}}],vocative:[{0:{action:"replace",value:"о"}}]}},{description:"друга відміна / чоловічий рід / м'яка група / на -й",examples:["валерій"],wordClass:"noun",gender:["masculine"],priority:1,applicationType:[],pattern:{find:"й$",modify:"(.{1})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"replace",value:"я"}}],dative:[{0:{action:"replace",value:"ю"}},{0:{action:"replace",value:"єві"}}],accusative:[{0:{action:"replace",value:"я"}}],ablative:[{0:{action:"replace",value:"єм"}}],locative:[{0:{action:"replace",value:"єві"}},{0:{action:"replace",value:"ю"}},{0:{action:"replace",value:"ї"}}],vocative:[{0:{action:"replace",value:"ю"}}]}},{description:"друга відміна / чоловічий рід / м'яка група / на -ь",examples:["петрунь"],wordClass:"noun",gender:["masculine"],priority:1,applicationType:[],pattern:{find:"ь$",modify:"(.{1})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"replace",value:"я"}}],dative:[{0:{action:"replace",value:"ю"}}],accusative:[{0:{action:"replace",value:"я"}}],ablative:[{0:{action:"replace",value:"ем"}}],locative:[{0:{action:"replace",value:"еві"}}],vocative:[{0:{action:"replace",value:"ю"}}]}},{description:"жіночі імена / на -'я",examples:["дар'я","мар'я"],wordClass:"noun",gender:["feminine"],priority:1,applicationType:["givenName"],pattern:{find:"['’ʼ]я$",modify:"(.{1})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"replace",value:"ї"}}],dative:[{0:{action:"replace",value:"ї"}}],accusative:[{0:{action:"replace",value:"ю"}}],ablative:[{0:{action:"replace",value:"єю"}}],locative:[{0:{action:"replace",value:"ї"}}],vocative:[{0:{action:"replace",value:"є"}}]}}]);class v{constructor(e,t){this.backend=e,this.dataMover=t,this.data=new WeakMap,this.dataIdsCount=0}get(e){return this.data.has(e)||this.dataMover.moveData(this.backend,e),this.data.get(e)}set(e,t){this.dataIdsCount++,this.data.set(e,t)}has(e){return this.data.has(e)}delete(e){return this.dataIdsCount--,this.data.delete(e)}numDataIds(){return this.dataIdsCount}}class y{refCount(e){return b("refCount")}incRef(e){return b("incRef")}timerAvailable(){return!0}time(e){return b("time")}read(e){return b("read")}readSync(e){return b("readSync")}readToGPU(e,t){return b("readToGPU")}numDataIds(){return b("numDataIds")}disposeData(e,t){return b("disposeData")}write(e,t,n){return b("write")}move(e,t,n,a,i){return b("move")}createTensorFromGPUData(e,t,n){return b("createTensorFromGPUData")}memory(){return b("memory")}floatPrecision(){return b("floatPrecision")}epsilon(){return 32===this.floatPrecision()?1e-7:1e-4}dispose(){return b("dispose")}}function b(e){throw new Error(`'${e}' not yet implemented or not found in the registry. This kernel may not be supported by the tfjs backend you have chosen`)}
10
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).shevchenko={})}(this,(function(e){"use strict";function t(e,t,n,a){return new(n||(n=Promise))((function(t,i){function s(e){try{o(a.next(e))}catch(e){i(e)}}function r(e){try{o(a.throw(e))}catch(e){i(e)}}function o(e){var a;e.done?t(e.value):(a=e.value,a instanceof n?a:new n((function(e){e(a)}))).then(s,r)}o((a=a.apply(e,[])).next())}))}var n,a;!function(e){e[e["а"]=1]="а",e[e["б"]=2]="б",e[e["в"]=3]="в",e[e["г"]=4]="г",e[e["ґ"]=5]="ґ",e[e["д"]=6]="д",e[e["е"]=7]="е",e[e["є"]=8]="є",e[e["ж"]=9]="ж",e[e["з"]=10]="з",e[e["и"]=11]="и",e[e["і"]=12]="і",e[e["ї"]=13]="ї",e[e["й"]=14]="й",e[e["к"]=15]="к",e[e["л"]=16]="л",e[e["м"]=17]="м",e[e["н"]=18]="н",e[e["о"]=19]="о",e[e["п"]=20]="п",e[e["р"]=21]="р",e[e["с"]=22]="с",e[e["т"]=23]="т",e[e["у"]=24]="у",e[e["ф"]=25]="ф",e[e["х"]=26]="х",e[e["ц"]=27]="ц",e[e["ч"]=28]="ч",e[e["ш"]=29]="ш",e[e["щ"]=30]="щ",e[e["ь"]=31]="ь",e[e["ю"]=32]="ю",e[e["я"]=33]="я"}(n||(n={})),Object.keys(n).length,e.WordClass=void 0,(a=e.WordClass||(e.WordClass={})).NOUN="noun",a.ADJECTIVE="adjective";const i=/[аоуеиіяюєї]/gi;function s(e){return 1===function(e){const t=e.match(i);return null==t?0:t.length}(e)}var r,o,l;function c(e,t=0){const n=e.charAt(t);return n===n.toUpperCase()}function u(e,t=0){const n=e.charAt(t);return n===n.toLowerCase()}e.GrammaticalCase=void 0,(r=e.GrammaticalCase||(e.GrammaticalCase={})).NOMINATIVE="nominative",r.GENITIVE="genitive",r.DATIVE="dative",r.ACCUSATIVE="accusative",r.ABLATIVE="ablative",r.LOCATIVE="locative",r.VOCATIVE="vocative",e.GrammaticalGender=void 0,(o=e.GrammaticalGender||(e.GrammaticalGender={})).MASCULINE="masculine",o.FEMININE="feminine";class h{constructor(e){this.command=e}exec(e){return e+this.command.value}}!function(e){e.REPLACE="replace",e.APPEND="append"}(l||(l={}));class p{constructor(e){this.command=e}exec(){return this.command.value}}class d{make(e){switch(e.action){case l.APPEND:return new h(e);case l.REPLACE:return new p(e);default:throw new TypeError(`Invalid command action: ${e.action}.`)}}}class f{constructor(e){this.rule=e,this.commandRunnerFactory=new d}inflect(e,t){const[n]=this.rule.grammaticalCases[t];if(n){const t=new RegExp(this.rule.pattern.modify,"gi"),a=e.replace(t,((e,...t)=>{let a="";const i=function(e){const t=new RegExp(`${e.toString()}|`).exec("");return null==t?0:t.length-1}(this.rule.pattern.modify);for(let e=0;e<i;e+=1){let i=t[e];const s=n[e];null!=s&&(i=this.commandRunnerFactory.make(s).exec(i)),a+=i}return a}));return function(e,t){let n="";for(let a=0;a<t.length;a+=1){const i=e[a]||e[e.length-1],s=t[a];u(i)?n+=s.toLowerCase():c(i)?n+=s.toUpperCase():n+=s}return n}(e,a)}return e}}class m{constructor(e){this.declensionRules=[...e].sort(((e,t)=>t.priority-e.priority))}inflect(e,n){return t(this,0,void 0,(function*(){const t=e.normalize("NFC"),[a]=yield this.findMatchingRules(t,n);return null==a?t:new f(a).inflect(t,n.grammaticalCase)}))}findMatchingRules(e,n){return t(this,0,void 0,(function*(){const t=this.declensionRules.filter((e=>e.gender.includes(n.gender))).filter((e=>!n.applicationType||0===e.applicationType.length||e.applicationType.includes(n.applicationType))).filter((t=>new RegExp(t.pattern.find,"gi").test(e))).filter((e=>!n.wordClass||e.wordClass===n.wordClass)).filter(((e,t,a)=>!n.customRuleFilter||n.customRuleFilter(e,t,a)));return t}))}}const g=new m([{description:"жіноче ім'я любов",examples:["любов"],wordClass:"noun",gender:["feminine"],priority:6,applicationType:["givenName"],pattern:{find:"^любов$",modify:"(.{1})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"append",value:"і"}}],dative:[{0:{action:"append",value:"і"}}],accusative:[],ablative:[{0:{action:"append",value:"'ю"}}],locative:[{0:{action:"append",value:"і"}}],vocative:[{0:{action:"append",value:"е"}}]}},{description:"чоловічі імена федір, сидір",examples:["федір","сидір"],wordClass:"noun",gender:["masculine"],priority:6,applicationType:["givenName"],pattern:{find:"^(федір|сидір)$",modify:"(.{1})(.{1})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"replace",value:"о"},1:{action:"append",value:"а"}}],dative:[{0:{action:"replace",value:"о"},1:{action:"append",value:"у"}},{0:{action:"replace",value:"о"},1:{action:"append",value:"ові"}}],accusative:[{0:{action:"replace",value:"о"},1:{action:"append",value:"а"}}],ablative:[{0:{action:"replace",value:"о"},1:{action:"append",value:"ом"}}],locative:[{0:{action:"replace",value:"о"},1:{action:"append",value:"ові"}},{0:{action:"replace",value:"о"},1:{action:"append",value:"у"}}],vocative:[{0:{action:"replace",value:"о"},1:{action:"append",value:"е"}}]}},{description:"слово суддя",examples:["суддя"],wordClass:"noun",gender:["masculine","feminine"],priority:6,applicationType:["familyName"],pattern:{find:"^суддя$",modify:"(.{1})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"replace",value:"і"}}],dative:[{0:{action:"replace",value:"і"}}],accusative:[{0:{action:"replace",value:"ю"}}],ablative:[{0:{action:"replace",value:"ею"}}],locative:[{0:{action:"replace",value:"і"}}],vocative:[{0:{action:"replace",value:"е"}}]}},{description:"слово рілля",examples:["рілля"],wordClass:"noun",gender:["masculine","feminine"],priority:6,applicationType:["familyName"],pattern:{find:"^рілля$",modify:"(.{1})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"replace",value:"і"}}],dative:[{0:{action:"replace",value:"і"}}],accusative:[{0:{action:"replace",value:"ю"}}],ablative:[{0:{action:"replace",value:"ею"}}],locative:[{0:{action:"replace",value:"і"}}],vocative:[{0:{action:"replace",value:"е"}}]}},{description:"друга відміна / чоловічий рід / м'яка група / на -(голосний)вень",examples:["півень"],wordClass:"noun",gender:["masculine"],priority:6,applicationType:[],pattern:{find:"[аеєиіїоуюя]вень$",modify:"(.{1})(.{1})(.{1})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"replace",value:""},2:{action:"replace",value:"я"}}],dative:[{0:{action:"replace",value:""},2:{action:"replace",value:"ю"}},{0:{action:"replace",value:""},2:{action:"replace",value:"еві"}}],accusative:[{0:{action:"replace",value:""},2:{action:"replace",value:"я"}}],ablative:[{0:{action:"replace",value:""},2:{action:"replace",value:"ем"}}],locative:[{0:{action:"replace",value:""},2:{action:"replace",value:"еві"}},{0:{action:"replace",value:""},2:{action:"replace",value:"ю"}}],vocative:[{0:{action:"replace",value:""},2:{action:"replace",value:"ю"}}]}},{description:"друга відміна / чоловічий рід / м'яка група / на -(голосний)лець",examples:["стрілець","білець"],wordClass:"noun",gender:["masculine"],priority:6,applicationType:[],pattern:{find:"[аеєиіїоуюя]лець$",modify:"(.{1})(.{1})(.{1})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"replace",value:"ь"},2:{action:"replace",value:"я"}}],dative:[{0:{action:"replace",value:"ь"},2:{action:"replace",value:"ю"}},{0:{action:"replace",value:"ь"},2:{action:"replace",value:"еві"}}],accusative:[{0:{action:"replace",value:"ь"},2:{action:"replace",value:"я"}}],ablative:[{0:{action:"replace",value:"ь"},2:{action:"replace",value:"ем"}}],locative:[{0:{action:"replace",value:"ь"},2:{action:"replace",value:"ю"}},{0:{action:"replace",value:"ь"},2:{action:"replace",value:"еві"}}],vocative:[{0:{action:"replace",value:"ь"},2:{action:"replace",value:"ю"}}]}},{description:"друга відміна / чоловічий рід / тверда група / на -(к|п|кр|пл|др|жив)іт",examples:["кіт","кріт"],wordClass:"noun",gender:["masculine"],priority:6,applicationType:[],pattern:{find:"(к|п|кр|пл|др|жив)іт$",modify:"(.{1})(.{1})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"replace",value:"о"},1:{action:"append",value:"а"}}],dative:[{0:{action:"replace",value:"о"},1:{action:"append",value:"у"}},{0:{action:"replace",value:"о"},1:{action:"append",value:"ові"}}],accusative:[{0:{action:"replace",value:"о"},1:{action:"append",value:"а"}}],ablative:[{0:{action:"replace",value:"о"},1:{action:"append",value:"ом"}}],locative:[{0:{action:"replace",value:"о"},1:{action:"append",value:"ові"}},{0:{action:"replace",value:"о"},1:{action:"append",value:"і"}}],vocative:[{0:{action:"replace",value:"о"},1:{action:"append",value:"е"}}]}},{description:"друга відміна / чоловічий рід / тверда група / на -грім",examples:["грім"],wordClass:"noun",gender:["masculine"],priority:6,applicationType:[],pattern:{find:"грім$",modify:"(.{1})(.{1})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"replace",value:"о"},1:{action:"append",value:"а"}}],dative:[{0:{action:"replace",value:"о"},1:{action:"append",value:"у"}},{0:{action:"replace",value:"о"},1:{action:"append",value:"ові"}}],accusative:[{0:{action:"replace",value:"о"},1:{action:"append",value:"а"}}],ablative:[{0:{action:"replace",value:"о"},1:{action:"append",value:"ом"}}],locative:[{0:{action:"replace",value:"о"},1:{action:"append",value:"і"}},{0:{action:"replace",value:"о"},1:{action:"append",value:"ові"}}],vocative:[{0:{action:"replace",value:"о"},1:{action:"append",value:"е"}}]}},{description:"друга відміна / чоловічий рід / тверда група / на -(дзвін|хрін)",examples:["дзвін"],wordClass:"noun",gender:["masculine"],priority:6,applicationType:[],pattern:{find:"(дзвін|хрін)$",modify:"(.{1})(.{1})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"replace",value:"о"},1:{action:"append",value:"а"}}],dative:[{0:{action:"replace",value:"о"},1:{action:"append",value:"у"}},{0:{action:"replace",value:"о"},1:{action:"append",value:"ові"}}],accusative:[{0:{action:"replace",value:"о"},1:{action:"append",value:"а"}}],ablative:[{0:{action:"replace",value:"о"},1:{action:"append",value:"ом"}}],locative:[{0:{action:"replace",value:"о"},1:{action:"append",value:"ові"}},{0:{action:"replace",value:"о"},1:{action:"append",value:"і"}}],vocative:[{0:{action:"replace",value:"о"},1:{action:"append",value:"е"}}]}},{description:"друга відміна / чоловічий рід / тверда група / на -батіг",examples:["батіг"],wordClass:"noun",gender:["masculine"],priority:6,applicationType:[],pattern:{find:"батіг$",modify:"(.{1})(.{1})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"replace",value:"о"},1:{action:"append",value:"а"}}],dative:[{0:{action:"replace",value:"о"},1:{action:"append",value:"у"}},{0:{action:"replace",value:"о"},1:{action:"append",value:"ові"}}],accusative:[{0:{action:"replace",value:"о"},1:{action:"append",value:"а"}}],ablative:[{0:{action:"replace",value:"о"},1:{action:"append",value:"ом"}}],locative:[{0:{action:"replace",value:"о"},1:{action:"replace",value:"зі"}},{0:{action:"replace",value:"о"},1:{action:"append",value:"ові"}}],vocative:[{0:{action:"replace",value:"о"},1:{action:"replace",value:"гу"}}]}},{description:"друга відміна / чоловічий рід / тверда група / на -сокіл",examples:["сокіл"],wordClass:"noun",gender:["masculine"],priority:6,applicationType:[],pattern:{find:"сокіл$",modify:"(.{1})(.{1})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"replace",value:"о"},1:{action:"append",value:"а"}}],dative:[{0:{action:"replace",value:"о"},1:{action:"append",value:"у"}},{0:{action:"replace",value:"о"},1:{action:"append",value:"ові"}}],accusative:[{0:{action:"replace",value:"о"},1:{action:"append",value:"а"}}],ablative:[{0:{action:"replace",value:"о"},1:{action:"append",value:"ом"}}],locative:[{0:{action:"replace",value:"о"},1:{action:"append",value:"ові"}}],vocative:[{0:{action:"replace",value:"о"},1:{action:"append",value:"е"}}]}},{description:"друга відміна / чоловічий рід / м'яка група / на -кріль",examples:["кріль"],wordClass:"noun",gender:["masculine"],priority:6,applicationType:[],pattern:{find:"кріль$",modify:"(.{1})(.{1})(.{1})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"replace",value:"о"},2:{action:"replace",value:"я"}}],dative:[{0:{action:"replace",value:"о"},2:{action:"replace",value:"ю"}},{0:{action:"replace",value:"о"},2:{action:"replace",value:"еві"}}],accusative:[{0:{action:"replace",value:"о"},2:{action:"replace",value:"я"}}],ablative:[{0:{action:"replace",value:"о"},2:{action:"replace",value:"ем"}}],locative:[{0:{action:"replace",value:"о"},2:{action:"replace",value:"ю"}},{0:{action:"replace",value:"о"},2:{action:"replace",value:"еві"}}],vocative:[{0:{action:"replace",value:"о"},2:{action:"replace",value:"ю"}}]}},{description:"чоловічі імена ігор, лазар",examples:["ігор","лазар"],wordClass:"noun",gender:["masculine"],priority:5,applicationType:[],pattern:{find:"^(ігор|лазар)$",modify:"(.{1})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"append",value:"я"}}],dative:[{0:{action:"append",value:"ю"}},{0:{action:"append",value:"еві"}}],accusative:[{0:{action:"append",value:"я"}}],ablative:[{0:{action:"append",value:"ем"}}],locative:[{0:{action:"append",value:"ю"}},{0:{action:"append",value:"еві"}}],vocative:[{0:{action:"append",value:"ю"}}]}},{description:"слово сіль",examples:["сіль"],wordClass:"noun",gender:["masculine"],priority:5,applicationType:["familyName"],pattern:{find:"^сіль$",modify:"(.{1})(.{1})(.{1})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"replace",value:"о"},2:{action:"replace",value:"і"}}],dative:[{0:{action:"replace",value:"о"},2:{action:"replace",value:"і"}}],accusative:[],ablative:[{2:{action:"replace",value:"лю"}}],locative:[{0:{action:"replace",value:"о"},2:{action:"replace",value:"і"}}],vocative:[{0:{action:"replace",value:"о"},2:{action:"replace",value:"е"}}]}},{description:"друга відміна / чоловічий рід / м'яка група / на -(голосний)(твердий приголосний)е(ц|н)ь",examples:["половець"],wordClass:"noun",gender:["masculine"],priority:5,applicationType:[],pattern:{find:"[аеєиіїоуюя]([бвгґджзклмнпрстфхцчшщ]|дз|дж)е(ц|н)ь$",modify:"(.{1})(.{1})(.{1})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"replace",value:""},2:{action:"replace",value:"я"}}],dative:[{0:{action:"replace",value:""},2:{action:"replace",value:"ю"}},{0:{action:"replace",value:""},2:{action:"replace",value:"еві"}}],accusative:[{0:{action:"replace",value:""},2:{action:"replace",value:"я"}}],ablative:[{0:{action:"replace",value:""},2:{action:"replace",value:"ем"}}],locative:[{0:{action:"replace",value:""},2:{action:"replace",value:"ю"}},{0:{action:"replace",value:""},2:{action:"replace",value:"еві"}}],vocative:[{0:{action:"replace",value:""},2:{action:"replace",value:"ю"}}]}},{description:"друга відміна / чоловічий рід / м'яка група / на -(твердий приголосний)(твердий приголосний)е(ц|н)ь",examples:["жнець"],wordClass:"noun",gender:["masculine"],priority:5,applicationType:[],pattern:{find:"([бвгґджзклмнпрстфхцчшщ]|дз|дж)([бвгґджзклмнпрстфхцчшщ]|дз|дж)е(ц|н)ь$",modify:"(.{1})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"replace",value:"я"}}],dative:[{0:{action:"replace",value:"ю"}},{0:{action:"replace",value:"еві"}}],accusative:[{0:{action:"replace",value:"я"}}],ablative:[{0:{action:"replace",value:"ем"}}],locative:[{0:{action:"replace",value:"ю"}},{0:{action:"replace",value:"еві"}}],vocative:[{0:{action:"replace",value:"ю"}}]}},{description:"друга відміна / чоловічий рід / тверда група / на -(рід|плід)",examples:["рід","плід"],wordClass:"noun",gender:["masculine"],priority:5,applicationType:[],pattern:{find:"(рід|плід)$",modify:"(.{1})(.{1})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"replace",value:"о"},1:{action:"append",value:"а"}}],dative:[{0:{action:"replace",value:"о"},1:{action:"append",value:"у"}},{0:{action:"replace",value:"о"},1:{action:"append",value:"ові"}}],accusative:[{0:{action:"replace",value:"о"},1:{action:"append",value:"а"}}],ablative:[{0:{action:"replace",value:"о"},1:{action:"append",value:"ом"}}],locative:[{0:{action:"replace",value:"о"},1:{action:"append",value:"ові"}},{0:{action:"replace",value:"о"},1:{action:"append",value:"і"}}],vocative:[{0:{action:"replace",value:"о"},1:{action:"append",value:"е"}}]}},{description:"друга відміна / чоловічий рід / тверда група / чоловічі прізвища на -ніс, без чергування",examples:["іваніс","ханіс","деніс","маніс"],wordClass:"noun",gender:["masculine"],priority:5,applicationType:[],pattern:{find:"^([аеєиіїоуюя])?([бвгґджзйклмнпрстфхцчшщ]|дз|дж)[аеєиіїоуюя]ніс$",modify:"(.{1})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"append",value:"а"}}],dative:[{0:{action:"append",value:"у"}},{0:{action:"append",value:"ові"}}],accusative:[{0:{action:"append",value:"а"}}],ablative:[{0:{action:"append",value:"ом"}}],locative:[{0:{action:"append",value:"ові"}},{0:{action:"append",value:"і"}}],vocative:[{0:{action:"append",value:"е"}}]}},{description:"друга відміна / чоловічий рід / тверда група / на -(з|яв)ір",examples:["дивозір","явір"],wordClass:"noun",gender:["masculine"],priority:5,applicationType:[],pattern:{find:"(з|яв|г)ір$",modify:"(.{1})(.{1})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"replace",value:"о"},1:{action:"append",value:"а"}}],dative:[{0:{action:"replace",value:"о"},1:{action:"append",value:"у"}},{0:{action:"replace",value:"о"},1:{action:"append",value:"ові"}}],accusative:[{0:{action:"replace",value:"о"},1:{action:"append",value:"а"}}],ablative:[{0:{action:"replace",value:"о"},1:{action:"append",value:"ом"}}],locative:[{0:{action:"replace",value:"о"},1:{action:"append",value:"ові"}},{0:{action:"replace",value:"о"},1:{action:"append",value:"і"}}],vocative:[{0:{action:"replace",value:"о"},1:{action:"append",value:"е"}}]}},{description:"друга відміна / чоловічий рід / тверда група / на -якір",examples:["якір"],wordClass:"noun",gender:["masculine"],priority:5,applicationType:[],pattern:{find:"якір$",modify:"(.{1})(.{1})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"replace",value:"о"},1:{action:"append",value:"я"}}],dative:[{0:{action:"replace",value:"о"},1:{action:"append",value:"ю"}},{0:{action:"replace",value:"о"},1:{action:"append",value:"еві"}}],accusative:[{0:{action:"replace",value:"о"},1:{action:"append",value:"я"}}],ablative:[{0:{action:"replace",value:"о"},1:{action:"append",value:"ем"}}],locative:[{0:{action:"replace",value:"о"},1:{action:"append",value:"еві"}},{0:{action:"replace",value:"о"},1:{action:"append",value:"і"}},{0:{action:"replace",value:"о"},1:{action:"append",value:"ю"}}],vocative:[{0:{action:"replace",value:"о"},1:{action:"append",value:"ю"}}]}},{description:"друга відміна / чоловічий рід / м'яка група / на -бідь",examples:["лебідь"],wordClass:"noun",gender:["masculine"],priority:5,applicationType:[],pattern:{find:".бідь$",modify:"(.{1})(.{1})(.{1})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"replace",value:"е"},2:{action:"replace",value:"я"}}],dative:[{0:{action:"replace",value:"е"},2:{action:"replace",value:"ю"}},{0:{action:"replace",value:"е"},2:{action:"replace",value:"еві"}}],accusative:[{0:{action:"replace",value:"е"},2:{action:"replace",value:"я"}}],ablative:[{0:{action:"replace",value:"е"},2:{action:"replace",value:"ем"}}],locative:[{0:{action:"replace",value:"е"},2:{action:"replace",value:"ю"}},{0:{action:"replace",value:"е"},2:{action:"replace",value:"еві"}}],vocative:[{0:{action:"replace",value:"е"},2:{action:"replace",value:"ю"}}]}},{description:"друга відміна / чоловічий рід / м'яка група / на -мінь",examples:["кремінь"],wordClass:"noun",gender:["masculine"],priority:5,applicationType:[],pattern:{find:".мінь$",modify:"(.{1})(.{1})(.{1})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"replace",value:"е"},2:{action:"replace",value:"я"}}],dative:[{0:{action:"replace",value:"е"},2:{action:"replace",value:"ю"}},{0:{action:"replace",value:"е"},2:{action:"replace",value:"еві"}}],accusative:[{0:{action:"replace",value:"е"},2:{action:"replace",value:"я"}}],ablative:[{0:{action:"replace",value:"е"},2:{action:"replace",value:"ем"}}],locative:[{0:{action:"replace",value:"е"},2:{action:"replace",value:"ю"}},{0:{action:"replace",value:"е"},2:{action:"replace",value:"еві"}}],vocative:[{0:{action:"replace",value:"е"},2:{action:"replace",value:"ю"}}]}},{description:"друга відміна / чоловічий рід / м'яка група / на -сіль",examples:["кисіль"],wordClass:"noun",gender:["masculine"],priority:5,applicationType:[],pattern:{find:"сіль$",modify:"(.{1})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"replace",value:"я"}}],dative:[{0:{action:"replace",value:"ю"}},{0:{action:"replace",value:"еві"}}],accusative:[{0:{action:"replace",value:"я"}}],ablative:[{0:{action:"replace",value:"ем"}}],locative:[{0:{action:"replace",value:"ю"}},{0:{action:"replace",value:"еві"}}],vocative:[{0:{action:"replace",value:"ю"}}]}},{description:"друга відміна / чоловічий рід / тверда група / на -кінь",examples:["кінь"],wordClass:"noun",gender:["masculine"],priority:5,applicationType:[],pattern:{find:"кінь$",modify:"(.{1})(.{1})(.{1})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"replace",value:"о"},2:{action:"replace",value:"я"}}],dative:[{0:{action:"replace",value:"о"},2:{action:"replace",value:"ю"}},{0:{action:"replace",value:"о"},2:{action:"replace",value:"еві"}}],accusative:[{0:{action:"replace",value:"о"},2:{action:"replace",value:"я"}}],ablative:[{0:{action:"replace",value:"о"},2:{action:"replace",value:"ем"}}],locative:[{0:{action:"replace",value:"о"},2:{action:"replace",value:"і"}},{0:{action:"replace",value:"о"},2:{action:"replace",value:"еві"}}],vocative:[{0:{action:"replace",value:"о"},2:{action:"replace",value:"ю"}}]}},{description:"друга відміна / чоловічий рід / тверда група / на -куліш",examples:["куліш"],wordClass:"noun",gender:["masculine"],priority:5,applicationType:[],pattern:{find:"куліш$",modify:"(.{1})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"append",value:"а"}}],dative:[{0:{action:"append",value:"у"}}],accusative:[{0:{action:"append",value:"а"}}],ablative:[{0:{action:"append",value:"ем"}}],locative:[{0:{action:"append",value:"еві"}}],vocative:[{0:{action:"append",value:"е"}}]}},{description:"жіночий рід / на -(твердий приголосний)ька",examples:["ільницька","сумська"],wordClass:"adjective",gender:["feminine"],priority:4,applicationType:["familyName"],pattern:{find:"([бвгґджзклмнпрстфхцчшщ]|дз|дж)ька$",modify:"(.{1})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"replace",value:"ої"}}],dative:[{0:{action:"replace",value:"ій"}}],accusative:[{0:{action:"replace",value:"у"}}],ablative:[{0:{action:"replace",value:"ою"}}],locative:[{0:{action:"replace",value:"ій"}}],vocative:[]}},{description:"жіночий рід / на -ова",examples:["іванова"],wordClass:"adjective",gender:["feminine"],priority:4,applicationType:["familyName"],pattern:{find:"ова$",modify:"(.{1})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"replace",value:"ої"}}],dative:[{0:{action:"replace",value:"ій"}}],accusative:[{0:{action:"replace",value:"у"}}],ablative:[{0:{action:"replace",value:"ою"}}],locative:[{0:{action:"replace",value:"ій"}}],vocative:[]}},{description:"жіночий рід / на -іна",examples:["зеленкіна"],wordClass:"adjective",gender:["feminine"],priority:4,applicationType:["familyName"],pattern:{find:"іна$",modify:"(.{1})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"replace",value:"ої"}}],dative:[{0:{action:"replace",value:"ій"}}],accusative:[{0:{action:"replace",value:"у"}}],ablative:[{0:{action:"replace",value:"ою"}}],locative:[{0:{action:"replace",value:"ій"}}],vocative:[]}},{description:"друга відміна / чоловічий рід / м'яка група / на -(голосний)єць",examples:["заєць"],wordClass:"noun",gender:["masculine"],priority:4,applicationType:[],pattern:{find:"[аеєиіїоуюя]єць$",modify:"(.{1})(.{1})(.{1})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"replace",value:"й"},2:{action:"replace",value:"я"}}],dative:[{0:{action:"replace",value:"й"},2:{action:"replace",value:"ю"}},{0:{action:"replace",value:"й"},2:{action:"replace",value:"еві"}}],accusative:[{0:{action:"replace",value:"й"},2:{action:"replace",value:"я"}}],ablative:[{0:{action:"replace",value:"й"},2:{action:"replace",value:"ем"}}],locative:[{0:{action:"replace",value:"й"},2:{action:"replace",value:"ю"}},{0:{action:"replace",value:"й"},2:{action:"replace",value:"еві"}}],vocative:[{0:{action:"replace",value:"й"},2:{action:"replace",value:"ю"}}]}},{description:"друга відміна / чоловічий рід / тверда група / на -віз",examples:["узвіз"],wordClass:"noun",gender:["masculine"],priority:4,applicationType:[],pattern:{find:"віз$",modify:"(.{1})(.{1})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"replace",value:"о"},1:{action:"append",value:"а"}}],dative:[{0:{action:"replace",value:"о"},1:{action:"append",value:"у"}},{0:{action:"replace",value:"о"},1:{action:"append",value:"ові"}}],accusative:[{0:{action:"replace",value:"о"},1:{action:"append",value:"а"}}],ablative:[{0:{action:"replace",value:"о"},1:{action:"append",value:"ом"}}],locative:[{0:{action:"replace",value:"о"},1:{action:"append",value:"і"}},{0:{action:"replace",value:"о"},1:{action:"append",value:"ові"}}],vocative:[{0:{action:"replace",value:"о"},1:{action:"append",value:"е"}}]}},{description:"друга відміна / чоловічий рід / тверда група / на -ків",examples:["яків"],wordClass:"noun",gender:["masculine"],priority:4,applicationType:["givenName"],pattern:{find:".ків$",modify:"(.{1})(.{1})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"replace",value:"о"},1:{action:"append",value:"а"}}],dative:[{0:{action:"replace",value:"о"},1:{action:"append",value:"у"}},{0:{action:"replace",value:"о"},1:{action:"append",value:"ові"}}],accusative:[{0:{action:"replace",value:"о"},1:{action:"append",value:"а"}}],ablative:[{0:{action:"replace",value:"о"},1:{action:"append",value:"ом"}}],locative:[{0:{action:"replace",value:"о"},1:{action:"append",value:"і"}},{0:{action:"replace",value:"о"},1:{action:"append",value:"ові"}}],vocative:[{0:{action:"replace",value:"о"},1:{action:"append",value:"е"}}]}},{description:"друга відміна / чоловічий рід / тверда група / на -(к|р)іп",examples:["прокіп"],wordClass:"noun",gender:["masculine"],priority:4,applicationType:[],pattern:{find:".(к|р)іп$",modify:"(.{1})(.{1})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"replace",value:"о"},1:{action:"append",value:"а"}}],dative:[{0:{action:"replace",value:"о"},1:{action:"append",value:"у"}},{0:{action:"replace",value:"о"},1:{action:"append",value:"ові"}}],accusative:[{0:{action:"replace",value:"о"},1:{action:"append",value:"а"}}],ablative:[{0:{action:"replace",value:"о"},1:{action:"append",value:"ом"}}],locative:[{0:{action:"replace",value:"о"},1:{action:"append",value:"і"}},{0:{action:"replace",value:"о"},1:{action:"append",value:"ові"}}],vocative:[{0:{action:"replace",value:"о"},1:{action:"append",value:"е"}}]}},{description:"друга відміна / чоловічий рід / тверда група / на -піп",examples:["прокіп"],wordClass:"noun",gender:["masculine"],priority:4,applicationType:[],pattern:{find:"піп$",modify:"(.{1})(.{1})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"replace",value:"о"},1:{action:"append",value:"а"}}],dative:[{0:{action:"replace",value:"о"},1:{action:"append",value:"у"}},{0:{action:"replace",value:"о"},1:{action:"append",value:"ові"}}],accusative:[{0:{action:"replace",value:"о"},1:{action:"append",value:"а"}}],ablative:[{0:{action:"replace",value:"о"},1:{action:"append",value:"ом"}}],locative:[{0:{action:"replace",value:"о"},1:{action:"append",value:"і"}},{0:{action:"replace",value:"о"},1:{action:"append",value:"ові"}}],vocative:[{0:{action:"replace",value:"о"},1:{action:"append",value:"е"}}]}},{description:"друга відміна / чоловічий рід / тверда група / на -ніс",examples:["кривоніс"],wordClass:"noun",gender:["masculine"],priority:4,applicationType:[],pattern:{find:"ніс$",modify:"(.{1})(.{1})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"replace",value:"о"},1:{action:"append",value:"а"}}],dative:[{0:{action:"replace",value:"о"},1:{action:"append",value:"у"}},{0:{action:"replace",value:"о"},1:{action:"append",value:"ові"}}],accusative:[{0:{action:"replace",value:"о"},1:{action:"append",value:"а"}}],ablative:[{0:{action:"replace",value:"о"},1:{action:"append",value:"ом"}}],locative:[{0:{action:"replace",value:"о"},1:{action:"append",value:"і"}},{0:{action:"replace",value:"о"},1:{action:"append",value:"ові"}}],vocative:[{0:{action:"replace",value:"о"},1:{action:"append",value:"е"}}]}},{description:"друга відміна / чоловічий рід / тверда група / на -віл",examples:["рябовіл"],wordClass:"noun",gender:["masculine"],priority:4,applicationType:[],pattern:{find:"віл$",modify:"(.{1})(.{1})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"replace",value:"о"},1:{action:"append",value:"а"}}],dative:[{0:{action:"replace",value:"о"},1:{action:"append",value:"у"}},{0:{action:"replace",value:"о"},1:{action:"append",value:"ові"}}],accusative:[{0:{action:"replace",value:"о"},1:{action:"append",value:"а"}}],ablative:[{0:{action:"replace",value:"о"},1:{action:"append",value:"ом"}}],locative:[{0:{action:"replace",value:"о"},1:{action:"append",value:"і"}},{0:{action:"replace",value:"о"},1:{action:"append",value:"ові"}}],vocative:[{0:{action:"replace",value:"о"},1:{action:"append",value:"е"}}]}},{description:"друга відміна / чоловічий рід / тверда група / на -ріг",examples:["пиріг"],wordClass:"noun",gender:["masculine"],priority:4,applicationType:[],pattern:{find:"ріг$",modify:"(.{1})(.{1})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"replace",value:"о"},1:{action:"append",value:"а"}}],dative:[{0:{action:"replace",value:"о"},1:{action:"append",value:"у"}},{0:{action:"replace",value:"о"},1:{action:"append",value:"ові"}}],accusative:[{0:{action:"replace",value:"о"},1:{action:"append",value:"а"}}],ablative:[{0:{action:"replace",value:"о"},1:{action:"append",value:"ом"}}],locative:[{0:{action:"replace",value:"о"},1:{action:"replace",value:"зі"}},{0:{action:"replace",value:"о"},1:{action:"append",value:"ові"}}],vocative:[{0:{action:"replace",value:"о"},1:{action:"append",value:"у"}}]}},{description:"друга відміна / чоловічий рід / тверда група / на -хід",examples:["прихід"],wordClass:"noun",gender:["masculine"],priority:4,applicationType:[],pattern:{find:"хід$",modify:"(.{1})(.{1})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"replace",value:"о"},1:{action:"append",value:"а"}}],dative:[{0:{action:"replace",value:"о"},1:{action:"append",value:"у"}},{0:{action:"replace",value:"о"},1:{action:"append",value:"ові"}}],accusative:[{0:{action:"replace",value:"о"},1:{action:"append",value:"а"}}],ablative:[{0:{action:"replace",value:"о"},1:{action:"append",value:"ом"}}],locative:[{0:{action:"replace",value:"о"},1:{action:"append",value:"і"}},{0:{action:"replace",value:"о"},1:{action:"append",value:"ові"}}],vocative:[{0:{action:"replace",value:"о"},1:{action:"append",value:"е"}}]}},{description:"друга відміна / жіночий рід / м'яка група / на -(голосний)ль",examples:["мішель","ніколь","cесіль"],wordClass:"noun",gender:["feminine"],priority:4,applicationType:["givenName"],pattern:{find:"[аеєиіїоуюя]ль$",modify:"(.{1})(.{1})$"},grammaticalCases:{nominative:[],genitive:[{1:{action:"replace",value:"і"}}],dative:[{1:{action:"replace",value:"і"}}],accusative:[],ablative:[{0:{action:"replace",value:"лл"},1:{action:"replace",value:"ю"}}],locative:[{1:{action:"replace",value:"і"}}],vocative:[]}},{description:"друга відміна / жіночий рід / м'яка група / на (губний_приголосний)",examples:["зейнаб","руф"],wordClass:"noun",gender:["feminine"],priority:4,applicationType:["givenName"],pattern:{find:"[бпвмф]$",modify:"(.{1})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"append",value:"і"}}],dative:[{0:{action:"append",value:"і"}}],accusative:[{0:{action:"append",value:"і"}}],ablative:[{0:{action:"append",value:"і"}}],locative:[{0:{action:"append",value:"і"}}],vocative:[{0:{action:"append",value:"і"}}]}},{description:"друга відміна / чоловічий рід / тверда група / на -ов, -ев (-єв), -ів (-їв), -ін (-їн)",examples:["павлов","нікітін"],wordClass:"noun",gender:["masculine"],priority:4,applicationType:["familyName"],pattern:{find:"([оеє]в|[ії]в|[ії]н)$",modify:"(.{1})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"append",value:"а"}}],dative:[{0:{action:"append",value:"у"}}],accusative:[{0:{action:"append",value:"а"}}],ablative:[{0:{action:"append",value:"им"}}],locative:[{0:{action:"append",value:"і"}},{0:{action:"append",value:"у"}}],vocative:[{0:{action:"append",value:"е"}}]}},{description:"друга відміна / чоловічий рід / тверда група / на -ишин",examples:["ковалишин"],wordClass:"noun",gender:["masculine"],priority:4,applicationType:[],pattern:{find:"ишин$",modify:"(.{1})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"append",value:"а"}}],dative:[{0:{action:"append",value:"у"}}],accusative:[{0:{action:"append",value:"а"}}],ablative:[{0:{action:"append",value:"им"}}],locative:[{0:{action:"append",value:"у"}}],vocative:[{0:{action:"append",value:"е"}}]}},{description:"друга відміна / чоловічий рід / тверда група / на -(аго|ово)",examples:["живаго"],wordClass:"noun",gender:["masculine"],priority:4,applicationType:[],pattern:{find:"(аго|ово)$",modify:"(.{1})$"},grammaticalCases:{nominative:[],genitive:[],dative:[],accusative:[],ablative:[],locative:[],vocative:[]}},{description:"друга відміна / чоловічий рід / тверда група / на -тер",examples:["вітер","буймистер"],wordClass:"noun",gender:["masculine"],priority:4,applicationType:[],pattern:{find:"[іс]тер$",modify:"(.{1})(.{1})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"replace",value:""},1:{action:"append",value:"а"}}],dative:[{0:{action:"replace",value:""},1:{action:"append",value:"у"}}],accusative:[{0:{action:"replace",value:""},1:{action:"append",value:"а"}}],ablative:[{0:{action:"replace",value:""},1:{action:"append",value:"ом"}}],locative:[{0:{action:"replace",value:""},1:{action:"append",value:"ові"}}],vocative:[{0:{action:"replace",value:""},1:{action:"append",value:"е"}}]}},{description:"друга відміна / чоловічий рід / тверда група / на -єгер",examples:["єгер"],wordClass:"noun",gender:["masculine"],priority:4,applicationType:[],pattern:{find:"єгер$",modify:"(.{1})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"append",value:"я"}}],dative:[{0:{action:"append",value:"ю"}},{0:{action:"append",value:"еві"}}],accusative:[{0:{action:"append",value:"я"}}],ablative:[{0:{action:"append",value:"ем"}}],locative:[{0:{action:"append",value:"еві"}},{0:{action:"append",value:"і"}}],vocative:[{0:{action:"append",value:"ю"}}]}},{description:"перша відміна / чоловічий рід / тверда група / на -світ",examples:["світ"],wordClass:"noun",gender:["masculine"],priority:4,applicationType:[],pattern:{find:"світ$",modify:"(.{1})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"append",value:"а"}}],dative:[{0:{action:"append",value:"у"}}],accusative:[{0:{action:"append",value:"а"}}],ablative:[{0:{action:"append",value:"ом"}}],locative:[{0:{action:"append",value:"ові"}}],vocative:[{0:{action:"append",value:"е"}}]}},{description:"чоловічі імена / на -(в|д)ір",examples:["дір","вір"],wordClass:"noun",gender:["masculine"],priority:4,applicationType:[],pattern:{find:"(в|д)ір$",modify:"(.{1})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"append",value:"а"}}],dative:[{0:{action:"append",value:"у"}},{0:{action:"append",value:"ові"}}],accusative:[{0:{action:"append",value:"а"}}],ablative:[{0:{action:"append",value:"ом"}}],locative:[{0:{action:"append",value:"ові"}},{0:{action:"append",value:"у"}}],vocative:[{0:{action:"append",value:"е"}}]}},{description:"чоловічий рід / на -кій (помилкова транслітерація)",examples:["дідківській"],wordClass:"adjective",gender:["masculine"],priority:3,applicationType:["familyName"],pattern:{find:"кій$",modify:"(.{2})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"replace",value:"ого"}}],dative:[{0:{action:"replace",value:"ому"}}],accusative:[{0:{action:"replace",value:"ого"}}],ablative:[{0:{action:"replace",value:"им"}}],locative:[{0:{action:"replace",value:"ому"}}],vocative:[]}},{description:"множина / на -их",examples:["седих"],wordClass:"adjective",gender:["masculine"],priority:3,applicationType:[],pattern:{find:"их$",modify:"(.{1})$"},grammaticalCases:{nominative:[],genitive:[],dative:[],accusative:[],ablative:[],locative:[],vocative:[]}},{description:"друга відміна / чоловічий рід / тверда група / на -га",examples:["нога"],wordClass:"noun",gender:["masculine"],priority:3,applicationType:[],pattern:{find:"га$",modify:"(.{1})(.{1})$"},grammaticalCases:{nominative:[],genitive:[{1:{action:"replace",value:"и"}}],dative:[{0:{action:"replace",value:"з"},1:{action:"replace",value:"і"}}],accusative:[{1:{action:"replace",value:"у"}}],ablative:[{1:{action:"replace",value:"ою"}}],locative:[{0:{action:"replace",value:"з"},1:{action:"replace",value:"і"}}],vocative:[{1:{action:"replace",value:"о"}}]}},{description:"друга відміна / чоловічий рід / м'яка група / на -окар, -екар, -етар, -зар, -ухар",examples:["токар","пекар","решетар","кожухар","кобзар"],wordClass:"noun",gender:["masculine"],priority:3,applicationType:[],pattern:{find:"(окар|екар|етар|([бвгґджзйклмнпрстфхцчшщ]|дз|дж)зар|ухар)(?<!гузар)$",modify:"(.{1})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"append",value:"я"}}],dative:[{0:{action:"append",value:"ю"}},{0:{action:"append",value:"еві"}}],accusative:[{0:{action:"append",value:"я"}}],ablative:[{0:{action:"append",value:"ем"}}],locative:[{0:{action:"append",value:"еві"}},{0:{action:"append",value:"і"}}],vocative:[{0:{action:"append",value:"ю"}}]}},{description:"друга відміна / чоловічий рід / тверда група / на -кіш",examples:["розкіш"],wordClass:"noun",gender:["masculine"],priority:3,applicationType:[],pattern:{find:"кіш$",modify:"(.{1})(.{1})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"replace",value:"о"},1:{action:"append",value:"а"}}],dative:[{0:{action:"replace",value:"о"},1:{action:"append",value:"еві"}}],accusative:[{0:{action:"replace",value:"о"},1:{action:"append",value:"а"}}],ablative:[{0:{action:"replace",value:"о"},1:{action:"append",value:"ем"}}],locative:[{0:{action:"replace",value:"о"},1:{action:"append",value:"еві"}}],vocative:[{0:{action:"replace",value:"о"},1:{action:"append",value:"е"}}]}},{description:"друга відміна / чоловічий рід / м'яка група / на -ьо",examples:["іваньо","кузьо"],wordClass:"noun",gender:["masculine"],priority:3,applicationType:[],pattern:{find:"ьо$",modify:"(.{2})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"replace",value:"я"}}],dative:[{0:{action:"replace",value:"ю"}}],accusative:[{0:{action:"replace",value:"я"}}],ablative:[{0:{action:"append",value:"м"}}],locative:[{0:{action:"replace",value:"ю"}}],vocative:[]}},{description:"друга відміна / чоловічий рід / тверда група / на -ред",examples:["альфред"],wordClass:"noun",gender:["masculine"],priority:3,applicationType:[],pattern:{find:"ред$",modify:"(.{1})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"append",value:"а"}}],dative:[{0:{action:"append",value:"у"}}],accusative:[{0:{action:"append",value:"а"}}],ablative:[{0:{action:"append",value:"ом"}}],locative:[{0:{action:"append",value:"ові"}}],vocative:[{0:{action:"append",value:"е"}}]}},{description:"друга відміна / чоловічий рід / тверда група / бусел, дятел, орел",examples:["бусел","дятел","орел"],wordClass:"noun",gender:["masculine"],priority:3,applicationType:[],pattern:{find:"(бус|дят|ор)ел$",modify:"(.{1})(.{1})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"replace",value:""},1:{action:"append",value:"а"}}],dative:[{0:{action:"replace",value:""},1:{action:"append",value:"ові"}},{0:{action:"replace",value:""},1:{action:"append",value:"у"}}],accusative:[{0:{action:"replace",value:""},1:{action:"append",value:"а"}}],ablative:[{0:{action:"replace",value:""},1:{action:"append",value:"ом"}}],locative:[{0:{action:"replace",value:""},1:{action:"append",value:"і"}}],vocative:[{0:{action:"replace",value:""},1:{action:"append",value:"е"}}]}},{description:"друга відміна / чоловічий рід / тверда група / на -е[вмн]",examples:["артем","семен","лев"],wordClass:"noun",gender:["masculine"],priority:3,applicationType:[],pattern:{find:"е[вмн]$",modify:"(.{1})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"append",value:"а"}}],dative:[{0:{action:"append",value:"у"}}],accusative:[{0:{action:"append",value:"а"}}],ablative:[{0:{action:"append",value:"ом"}}],locative:[{0:{action:"append",value:"ові"}}],vocative:[{0:{action:"append",value:"е"}}]}},{description:"друга відміна / чоловічий рід / тверда група / на -ер",examples:["ріхтер"],wordClass:"noun",gender:["masculine"],priority:3,applicationType:[],pattern:{find:"ер$",modify:"(.{1})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"append",value:"а"}}],dative:[{0:{action:"append",value:"у"}}],accusative:[{0:{action:"append",value:"а"}}],ablative:[{0:{action:"append",value:"ом"}}],locative:[{0:{action:"append",value:"ові"}}],vocative:[{0:{action:"append",value:"е"}}]}},{description:"друга відміна / чоловічий рід / тверда група / на -пес",examples:["пес"],wordClass:"noun",gender:["masculine"],priority:3,applicationType:[],pattern:{find:"пес$",modify:"(.{1})(.{1})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"replace",value:""},1:{action:"append",value:"а"}}],dative:[{0:{action:"replace",value:""},1:{action:"append",value:"у"}}],accusative:[{0:{action:"replace",value:""},1:{action:"append",value:"а"}}],ablative:[{0:{action:"replace",value:""},1:{action:"append",value:"ом"}}],locative:[{0:{action:"replace",value:""},1:{action:"append",value:"ові"}}],vocative:[{0:{action:"replace",value:""},1:{action:"append",value:"е"}}]}},{description:"друга відміна / чоловічий рід / тверда група / на -ко",examples:["марко"],wordClass:"noun",gender:["masculine"],priority:3,applicationType:[],pattern:{find:"ко$",modify:"(.{1})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"replace",value:"а"}}],dative:[{0:{action:"replace",value:"у"}},{0:{action:"replace",value:"ові"}}],accusative:[{0:{action:"replace",value:"а"}}],ablative:[{0:{action:"replace",value:"ом"}}],locative:[{0:{action:"replace",value:"ові"}},{0:{action:"replace",value:"у"}}],vocative:[{0:{action:"replace",value:"у"}}]}},{description:"друга відміна / чоловічий рід / м'яка група / на -ий",examples:["батий"],wordClass:"noun",gender:["masculine"],priority:3,applicationType:[],pattern:{find:"ий$",modify:"(.{1})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"replace",value:"я"}}],dative:[{0:{action:"replace",value:"ю"}}],accusative:[{0:{action:"replace",value:"я"}}],ablative:[{0:{action:"replace",value:"єм"}}],locative:[{0:{action:"replace",value:"ю"}},{0:{action:"replace",value:"ї"}}],vocative:[{0:{action:"replace",value:"ю"}}]}},{description:"перша відміна / чоловічий рід / тверда група / на -йо",examples:["йойо"],wordClass:"noun",gender:["masculine"],priority:3,applicationType:[],pattern:{find:"йо$",modify:"(.{2})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"replace",value:"я"}}],dative:[{0:{action:"append",value:"ві"}}],accusative:[{0:{action:"replace",value:"я"}}],ablative:[{0:{action:"append",value:"м"}}],locative:[{0:{action:"append",value:"ві"}}],vocative:[]}},{description:"перша відміна / чоловічий рід / тверда група / на -бо",examples:["голембо"],wordClass:"noun",gender:["masculine"],priority:3,applicationType:[],pattern:{find:"бо$",modify:"(.{1})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"replace",value:"и"}}],dative:[{0:{action:"replace",value:"і"}}],accusative:[{0:{action:"replace",value:"у"}}],ablative:[{0:{action:"replace",value:"ою"}}],locative:[{0:{action:"replace",value:"і"}}],vocative:[]}},{description:"чоловічий рід / на -ой, -ий",examples:["толстой","сухомлинський"],wordClass:"adjective",gender:["masculine"],priority:2,applicationType:["familyName"],pattern:{find:"(ой|ий)$",modify:"(.{2})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"replace",value:"ого"}}],dative:[{0:{action:"replace",value:"ому"}}],accusative:[{0:{action:"replace",value:"ого"}}],ablative:[{0:{action:"replace",value:"им"}}],locative:[{0:{action:"replace",value:"ому"}}],vocative:[]}},{description:"чоловічий рід / на -ій",examples:["заболотній"],wordClass:"adjective",gender:["masculine"],priority:2,applicationType:["familyName"],pattern:{find:"ій$",modify:"(.{2})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"replace",value:"ього"}}],dative:[{0:{action:"replace",value:"ьому"}}],accusative:[{0:{action:"replace",value:"ього"}}],ablative:[{0:{action:"replace",value:"ім"}}],locative:[{0:{action:"replace",value:"ьому"}}],vocative:[]}},{description:"жіночий рід / на -(твердий приголосний)а",examples:["зелена"],wordClass:"adjective",gender:["feminine"],priority:2,applicationType:["familyName"],pattern:{find:"([бвгґджзклмнпрстфхцчшщ]|дз|дж)а$",modify:"(.{1})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"replace",value:"ої"}}],dative:[{0:{action:"replace",value:"ій"}}],accusative:[{0:{action:"replace",value:"у"}}],ablative:[{0:{action:"replace",value:"ою"}}],locative:[{0:{action:"replace",value:"ій"}}],vocative:[]}},{description:"жіночий рід / на -(твердий приголосний)я",examples:["задорожня"],wordClass:"adjective",gender:["feminine"],priority:2,applicationType:["familyName"],pattern:{find:"([бвгґджзклмнпрстфхцчшщ]|дз|дж)я$",modify:"(.{1})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"replace",value:"ьої"}}],dative:[{0:{action:"replace",value:"ій"}}],accusative:[{0:{action:"replace",value:"ю"}}],ablative:[{0:{action:"replace",value:"ьою"}}],locative:[{0:{action:"replace",value:"ій"}}],vocative:[]}},{description:"жіночий рід / на -ая",examples:["толстая"],wordClass:"adjective",gender:["feminine"],priority:2,applicationType:["familyName"],pattern:{find:"ая$",modify:"(.{2})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"replace",value:"ої"}}],dative:[{0:{action:"replace",value:"ій"}}],accusative:[{0:{action:"replace",value:"ую"}}],ablative:[{0:{action:"replace",value:"ою"}}],locative:[{0:{action:"replace",value:"ій"}}],vocative:[]}},{description:"жіночий рід / на -яя",examples:["заболотняя"],wordClass:"adjective",gender:["feminine"],priority:2,applicationType:["familyName"],pattern:{find:"яя$",modify:"(.{2})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"replace",value:"ьої"}}],dative:[{0:{action:"replace",value:"ій"}}],accusative:[{0:{action:"replace",value:"ю"}}],ablative:[{0:{action:"replace",value:"ьою"}}],locative:[{0:{action:"replace",value:"ій"}}],vocative:[]}},{description:"чоловічі по батькові та прізвища / на -ич",examples:["валерійович","риндич"],wordClass:"noun",gender:["masculine"],priority:2,applicationType:["patronymicName","familyName"],pattern:{find:"ич$",modify:"(.{1})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"append",value:"а"}}],dative:[{0:{action:"append",value:"у"}}],accusative:[{0:{action:"append",value:"а"}}],ablative:[{0:{action:"append",value:"ем"}}],locative:[{0:{action:"append",value:"у"}}],vocative:[{0:{action:"append",value:"у"}}]}},{description:"чоловічі по батькові та прізвища / на -іч",examples:["ілліч"],wordClass:"noun",gender:["masculine"],priority:2,applicationType:["patronymicName","familyName"],pattern:{find:"іч$",modify:"(.{1})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"append",value:"а"}}],dative:[{0:{action:"append",value:"у"}},{0:{action:"append",value:"еві"}}],accusative:[{0:{action:"append",value:"а"}}],ablative:[{0:{action:"append",value:"ем"}}],locative:[{0:{action:"append",value:"і"}},{0:{action:"append",value:"у"}},{0:{action:"append",value:"еві"}}],vocative:[{0:{action:"append",value:"у"}}]}},{description:"жіночі по батькові / на -на",examples:["юріївна"],wordClass:"noun",gender:["feminine"],priority:2,applicationType:["patronymicName"],pattern:{find:"на$",modify:"(.{1})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"replace",value:"и"}}],dative:[{0:{action:"replace",value:"і"}}],accusative:[{0:{action:"replace",value:"у"}}],ablative:[{0:{action:"replace",value:"ою"}}],locative:[{0:{action:"replace",value:"і"}}],vocative:[{0:{action:"replace",value:"о"}}]}},{description:"жіночі імена / на -(твердий приголосний)я",examples:["неля"],wordClass:"noun",gender:["feminine"],priority:2,applicationType:["givenName"],pattern:{find:"([бвгґджзклмнпрстфхцчшщ]|дз|дж)я$",modify:"(.{1})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"replace",value:"і"}}],dative:[{0:{action:"replace",value:"і"}}],accusative:[{0:{action:"replace",value:"ю"}}],ablative:[{0:{action:"replace",value:"ею"}}],locative:[{0:{action:"replace",value:"і"}}],vocative:[{0:{action:"replace",value:"ю"}}]}},{description:"чоловічі імена / на -ня",examples:["женя"],wordClass:"noun",gender:["masculine"],priority:2,applicationType:["givenName"],pattern:{find:"ня$",modify:"(.{1})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"replace",value:"і"}}],dative:[{0:{action:"replace",value:"і"}}],accusative:[{0:{action:"replace",value:"ю"}}],ablative:[{0:{action:"replace",value:"ею"}}],locative:[{0:{action:"replace",value:"і"}}],vocative:[{0:{action:"replace",value:"ю"}}]}},{description:"друга відміна / чоловічий рід / тверда група / на -уг",examples:["товстолуг"],wordClass:"noun",gender:["masculine"],priority:2,applicationType:["familyName"],pattern:{find:"уг$",modify:"(.{1})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"append",value:"а"}}],dative:[{0:{action:"append",value:"у"}},{0:{action:"append",value:"ові"}}],accusative:[{0:{action:"append",value:"а"}}],ablative:[{0:{action:"append",value:"ом"}}],locative:[{0:{action:"append",value:"ові"}},{0:{action:"append",value:"у"}}],vocative:[{0:{action:"append",value:"у"}}]}},{description:"друга відміна / чоловічий рід / тверда група / на -ин",examples:["гаршин"],wordClass:"noun",gender:["masculine"],priority:2,applicationType:["familyName"],pattern:{find:"(?<!ус|в|н)ин$",modify:"(.{1})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"append",value:"а"}}],dative:[{0:{action:"append",value:"ові"}},{0:{action:"append",value:"у"}}],accusative:[{0:{action:"append",value:"а"}}],ablative:[{0:{action:"append",value:"им"}}],locative:[{0:{action:"append",value:"і"}},{0:{action:"append",value:"у"}}],vocative:[{0:{action:"append",value:"е"}}]}},{description:"друга відміна / чоловічий рід / тверда група / на -яр",examples:["скляр"],wordClass:"noun",gender:["masculine"],priority:2,applicationType:[],pattern:{find:"яр$",modify:"(.{1})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"append",value:"а"}}],dative:[{0:{action:"append",value:"у"}},{0:{action:"append",value:"еві"}}],accusative:[{0:{action:"append",value:"а"}}],ablative:[{0:{action:"append",value:"ем"}}],locative:[{0:{action:"append",value:"еві"}},{0:{action:"append",value:"у"}}],vocative:[{0:{action:"append",value:"е"}}]}},{description:"друга відміна / жіночий рід / тверда, м'яка група / на -(о|ь|твердий приголосний)",examples:["шевченко"],wordClass:"noun",gender:["feminine"],priority:2,applicationType:[],pattern:{find:"(о|ь|([бвгґджзклмнпрстфхцчшщ]|дз|дж))$",modify:"(.{2})$"},grammaticalCases:{nominative:[],genitive:[],dative:[],accusative:[],ablative:[],locative:[],vocative:[]}},{description:"друга відміна / чоловічий рід / тверда група / на -ок",examples:["бурячок"],wordClass:"noun",gender:["masculine"],priority:2,applicationType:[],pattern:{find:"((?<=[аеєиіїоуюя].*[аеєиіїоуюя].*л)|(?<=[аеєиіїоуюя].*[^л]))ок$",modify:"(.{1})(.{1})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"replace",value:""},1:{action:"append",value:"а"}}],dative:[{0:{action:"replace",value:""},1:{action:"append",value:"у"}},{0:{action:"replace",value:""},1:{action:"append",value:"ові"}}],accusative:[{0:{action:"replace",value:""},1:{action:"append",value:"а"}}],ablative:[{0:{action:"replace",value:""},1:{action:"append",value:"ом"}}],locative:[{0:{action:"replace",value:""},1:{action:"append",value:"ові"}}],vocative:[{0:{action:"replace",value:""},1:{action:"append",value:"у"}}]}},{description:"друга відміна / чоловічий рід / тверда група / на -е(тверда_прилосона)",examples:["марек"],wordClass:"noun",gender:["masculine"],priority:2,applicationType:[],pattern:{find:"е([бвгґджзклмнпрстфхцчшщ]|дз|дж)$",modify:"(.{1})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"append",value:"а"}}],dative:[{0:{action:"append",value:"у"}}],accusative:[{0:{action:"append",value:"а"}}],ablative:[{0:{action:"append",value:"ом"}}],locative:[{0:{action:"append",value:"ові"}}],vocative:[{0:{action:"append",value:"у"}}]}},{description:"друга відміна / чоловічий рід / м'яка група / на -(твердий приголосний)я",examples:["гмиря"],wordClass:"noun",gender:["masculine","feminine"],priority:2,applicationType:[],pattern:{find:"([бвгґджзклмнпрстфхцчшщ]|дз|дж)я$",modify:"(.{1})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"replace",value:"і"}}],dative:[{0:{action:"replace",value:"і"}}],accusative:[{0:{action:"replace",value:"ю"}}],ablative:[{0:{action:"replace",value:"ею"}}],locative:[{0:{action:"replace",value:"і"}}],vocative:[{0:{action:"replace",value:"е"}}]}},{description:"друга відміна / чоловічий, жіночий роди / м'яка група / на -(голосний|ь|й)я",examples:["юлія","майя"],wordClass:"noun",gender:["masculine","feminine"],priority:2,applicationType:[],pattern:{find:"([аеєиіїоуюя]|ь|й)я$",modify:"(.{1})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"replace",value:"ї"}}],dative:[{0:{action:"replace",value:"ї"}}],accusative:[{0:{action:"replace",value:"ю"}}],ablative:[{0:{action:"replace",value:"єю"}}],locative:[{0:{action:"replace",value:"ї"}}],vocative:[{0:{action:"replace",value:"є"}}]}},{description:"друга відміна / чоловічий рід / мішана група / на -(дж|ж|ч|ш)",examples:["януш","джордж"],wordClass:"noun",gender:["masculine"],priority:2,applicationType:[],pattern:{find:"(дж|ж|ч|ш)$",modify:"(.{1})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"append",value:"а"}}],dative:[{0:{action:"append",value:"у"}},{0:{action:"append",value:"еві"}}],accusative:[{0:{action:"append",value:"а"}}],ablative:[{0:{action:"append",value:"ем"}}],locative:[{0:{action:"append",value:"еві"}},{0:{action:"append",value:"і"}},{0:{action:"append",value:"у"}}],vocative:[{0:{action:"append",value:"е"}}]}},{description:"друга відміна / чоловічий рід / тверда група / на -н",examples:["міщанин"],wordClass:"noun",gender:["masculine"],priority:2,applicationType:[],pattern:{find:"н$",modify:"(.{1})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"append",value:"а"}}],dative:[{0:{action:"append",value:"у"}},{0:{action:"append",value:"ові"}}],accusative:[{0:{action:"append",value:"а"}}],ablative:[{0:{action:"append",value:"ом"}}],locative:[{0:{action:"append",value:"ові"}},{0:{action:"append",value:"і"}}],vocative:[{0:{action:"append",value:"е"}}]}},{description:"друга відміна / чоловічий рід / тверда група / (свекор|цукор)",examples:["свекор","цукор"],wordClass:"noun",gender:["masculine"],priority:2,applicationType:[],pattern:{find:"(свекор|цукор)$",modify:"(.{1})(.{1})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"replace",value:""},1:{action:"append",value:"а"}}],dative:[{0:{action:"replace",value:""},1:{action:"append",value:"ові"}},{0:{action:"replace",value:""},1:{action:"append",value:"у"}}],accusative:[{0:{action:"replace",value:""},1:{action:"append",value:"а"}}],ablative:[{0:{action:"replace",value:""},1:{action:"append",value:"ом"}}],locative:[{0:{action:"replace",value:""},1:{action:"append",value:"ові"}},{0:{action:"replace",value:""},1:{action:"append",value:"у"}}],vocative:[{0:{action:"replace",value:""},1:{action:"append",value:"е"}}]}},{description:"друга відміна / чоловічий рід / тверда група / снігир",examples:["снігир"],wordClass:"noun",gender:["masculine"],priority:2,applicationType:[],pattern:{find:"снігир$",modify:"(.{1})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"append",value:"я"}}],dative:[{0:{action:"append",value:"еві"}},{0:{action:"append",value:"ю"}}],accusative:[{0:{action:"append",value:"я"}}],ablative:[{0:{action:"append",value:"ем"}}],locative:[{0:{action:"append",value:"еві"}},{0:{action:"append",value:"ю"}}],vocative:[{0:{action:"append",value:"е"}}]}},{description:"друга відміна / чоловічий рід / тверда група / на -к",examples:["кузик","мисяк"],wordClass:"noun",gender:["masculine"],priority:2,applicationType:[],pattern:{find:"к$",modify:"(.{1})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"append",value:"а"}}],dative:[{0:{action:"append",value:"у"}},{0:{action:"append",value:"ові"}}],accusative:[{0:{action:"append",value:"а"}}],ablative:[{0:{action:"append",value:"ом"}}],locative:[{0:{action:"append",value:"ові"}},{0:{action:"append",value:"у"}}],vocative:[{0:{action:"append",value:"у"}}]}},{description:"друга відміна / чоловічий рід / тверда група / на -х",examples:["кожух"],wordClass:"noun",gender:["masculine"],priority:2,applicationType:[],pattern:{find:"х$",modify:"(.{1})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"append",value:"а"}}],dative:[{0:{action:"append",value:"у"}},{0:{action:"append",value:"ові"}}],accusative:[{0:{action:"append",value:"а"}}],ablative:[{0:{action:"append",value:"ом"}}],locative:[{0:{action:"append",value:"ові"}}],vocative:[{0:{action:"append",value:"у"}}]}},{description:"друга відміна / чоловічий рід / м'яка група / соловей",examples:["соловей"],wordClass:"noun",gender:["masculine"],priority:2,applicationType:[],pattern:{find:"соловей$",modify:"(.{1})(.{1})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"replace",value:""},1:{action:"replace",value:"'я"}}],dative:[{0:{action:"replace",value:""},1:{action:"replace",value:"'єві"}},{0:{action:"replace",value:""},1:{action:"replace",value:"'ю"}}],accusative:[{0:{action:"replace",value:""},1:{action:"replace",value:"'я"}}],ablative:[{0:{action:"replace",value:""},1:{action:"replace",value:"'єм"}}],locative:[{0:{action:"replace",value:""},1:{action:"replace",value:"'ї"}},{0:{action:"replace",value:""},1:{action:"replace",value:"'ю"}},{0:{action:"replace",value:""},1:{action:"replace",value:"'єві"}}],vocative:[{0:{action:"replace",value:""},1:{action:"replace",value:"'ю"}}]}},{description:"перша відміна / чоловічий, жіночий роди / тверда група / на -ха",examples:["старуха"],wordClass:"noun",gender:["masculine","feminine"],priority:2,applicationType:[],pattern:{find:"ха$",modify:"(.{1})(.{1})$"},grammaticalCases:{nominative:[],genitive:[{1:{action:"replace",value:"и"}}],dative:[{0:{action:"replace",value:"с"},1:{action:"replace",value:"і"}}],accusative:[{1:{action:"replace",value:"у"}}],ablative:[{1:{action:"replace",value:"ою"}}],locative:[{0:{action:"replace",value:"с"},1:{action:"replace",value:"і"}}],vocative:[{1:{action:"replace",value:"о"}},{1:{action:"replace",value:"а"}}]}},{description:"перша відміна / чоловічий, жіночий роди / тверда група / на -ка",examples:["прилука"],wordClass:"noun",gender:["masculine","feminine"],priority:2,applicationType:[],pattern:{find:"ка$",modify:"(.{1})(.{1})$"},grammaticalCases:{nominative:[],genitive:[{1:{action:"replace",value:"и"}}],dative:[{0:{action:"replace",value:"ц"},1:{action:"replace",value:"і"}}],accusative:[{1:{action:"replace",value:"у"}}],ablative:[{1:{action:"replace",value:"ою"}}],locative:[{0:{action:"replace",value:"ц"},1:{action:"replace",value:"і"}}],vocative:[{1:{action:"replace",value:"о"}},{1:{action:"replace",value:"а"}}]}},{description:"друга відміна / чоловічий рід / м'яка група / журавель",examples:["журавель"],wordClass:"noun",gender:["masculine"],priority:2,applicationType:[],pattern:{find:"журавель$",modify:"(.{3})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"replace",value:"ля"}}],dative:[{0:{action:"replace",value:"леві"}},{0:{action:"replace",value:"лю"}}],accusative:[{0:{action:"replace",value:"ля"}}],ablative:[{0:{action:"replace",value:"лем"}}],locative:[{0:{action:"replace",value:"лю"}},{0:{action:"replace",value:"і"}}],vocative:[{0:{action:"replace",value:"лю"}}]}},{description:"перша відміна / чоловічий рід / тверда група / на -(твердий приголосний)о",examples:["петро","павло"],wordClass:"noun",gender:["masculine"],priority:2,applicationType:[],pattern:{find:"([бвгґджзклмнпрстфхцчшщ]|дз|дж)о$",modify:"(.{1})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"replace",value:"а"}}],dative:[{0:{action:"replace",value:"у"}}],accusative:[{0:{action:"replace",value:"а"}}],ablative:[{0:{action:"replace",value:"ом"}}],locative:[{0:{action:"replace",value:"ові"}}],vocative:[{0:{action:"replace",value:"е"}}]}},{description:"перша відміна / жіночий рід / тверда група / на -(г|ґ)а",examples:["ольга"],wordClass:"noun",gender:["feminine"],priority:2,applicationType:[],pattern:{find:"(г|ґ)а$",modify:"(.{1})(.{1})$"},grammaticalCases:{nominative:[],genitive:[{1:{action:"replace",value:"и"}}],dative:[{0:{action:"replace",value:"з"},1:{action:"replace",value:"і"}}],accusative:[{1:{action:"replace",value:"у"}}],ablative:[{1:{action:"replace",value:"ою"}}],locative:[{0:{action:"replace",value:"з"},1:{action:"replace",value:"і"}}],vocative:[{1:{action:"replace",value:"о"}}]}},{description:"перша відміна / чоловічий рід / тверда група / на -ле",examples:["поле"],wordClass:"noun",gender:["masculine","feminine"],priority:2,applicationType:[],pattern:{find:"ле$",modify:"(.{1})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"replace",value:"я"}}],dative:[{0:{action:"replace",value:"ю"}}],accusative:[{0:{action:"replace",value:"е"}}],ablative:[{0:{action:"replace",value:"ем"}}],locative:[{0:{action:"replace",value:"і"}}],vocative:[]}},{description:"перша відміна / чоловічий, жіночий роди / мішана група / на -а",examples:["мойша"],wordClass:"noun",gender:["masculine","feminine"],priority:2,applicationType:[],pattern:{find:"(дж|ж|ч|ш|щ)а$",modify:"(.{1})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"replace",value:"і"}}],dative:[{0:{action:"replace",value:"і"}}],accusative:[{0:{action:"replace",value:"у"}}],ablative:[{0:{action:"replace",value:"ею"}}],locative:[{0:{action:"replace",value:"і"}}],vocative:[{0:{action:"replace",value:"о"}}]}},{description:"друга відміна / чоловічий рід / тверда група / на -(твердий приголосний)",examples:["олександр"],wordClass:"noun",gender:["masculine"],priority:1,applicationType:[],pattern:{find:"([бвгґджзклмнпрстфхцчшщ]|дз|дж)$",modify:"(.{1})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"append",value:"а"}}],dative:[{0:{action:"append",value:"у"}},{0:{action:"append",value:"ові"}}],accusative:[{0:{action:"append",value:"а"}}],ablative:[{0:{action:"append",value:"ом"}}],locative:[{0:{action:"append",value:"ові"}},{0:{action:"append",value:"у"}}],vocative:[{0:{action:"append",value:"е"}}]}},{description:"перша відміна / чоловічий, жіночий роди / тверда група / на -а",examples:["анна"],wordClass:"noun",gender:["masculine","feminine"],priority:1,applicationType:[],pattern:{find:"а$",modify:"(.{1})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"replace",value:"и"}}],dative:[{0:{action:"replace",value:"і"}}],accusative:[{0:{action:"replace",value:"у"}}],ablative:[{0:{action:"replace",value:"ою"}}],locative:[{0:{action:"replace",value:"і"}}],vocative:[{0:{action:"replace",value:"о"}}]}},{description:"друга відміна / чоловічий рід / м'яка група / на -й",examples:["валерій"],wordClass:"noun",gender:["masculine"],priority:1,applicationType:[],pattern:{find:"й$",modify:"(.{1})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"replace",value:"я"}}],dative:[{0:{action:"replace",value:"ю"}},{0:{action:"replace",value:"єві"}}],accusative:[{0:{action:"replace",value:"я"}}],ablative:[{0:{action:"replace",value:"єм"}}],locative:[{0:{action:"replace",value:"єві"}},{0:{action:"replace",value:"ю"}},{0:{action:"replace",value:"ї"}}],vocative:[{0:{action:"replace",value:"ю"}}]}},{description:"друга відміна / чоловічий рід / м'яка група / на -ь",examples:["петрунь"],wordClass:"noun",gender:["masculine"],priority:1,applicationType:[],pattern:{find:"ь$",modify:"(.{1})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"replace",value:"я"}}],dative:[{0:{action:"replace",value:"ю"}}],accusative:[{0:{action:"replace",value:"я"}}],ablative:[{0:{action:"replace",value:"ем"}}],locative:[{0:{action:"replace",value:"еві"}}],vocative:[{0:{action:"replace",value:"ю"}}]}},{description:"жіночі імена / на -'я",examples:["дар'я","мар'я"],wordClass:"noun",gender:["feminine"],priority:1,applicationType:["givenName"],pattern:{find:"['’ʼ]я$",modify:"(.{1})$"},grammaticalCases:{nominative:[],genitive:[{0:{action:"replace",value:"ї"}}],dative:[{0:{action:"replace",value:"ї"}}],accusative:[{0:{action:"replace",value:"ю"}}],ablative:[{0:{action:"replace",value:"єю"}}],locative:[{0:{action:"replace",value:"ї"}}],vocative:[{0:{action:"replace",value:"є"}}]}}]);class v{constructor(e,t){this.backend=e,this.dataMover=t,this.data=new WeakMap,this.dataIdsCount=0}get(e){return this.data.has(e)||this.dataMover.moveData(this.backend,e),this.data.get(e)}set(e,t){this.dataIdsCount++,this.data.set(e,t)}has(e){return this.data.has(e)}delete(e){return this.dataIdsCount--,this.data.delete(e)}numDataIds(){return this.dataIdsCount}}class y{refCount(e){return b("refCount")}incRef(e){return b("incRef")}timerAvailable(){return!0}time(e){return b("time")}read(e){return b("read")}readSync(e){return b("readSync")}readToGPU(e,t){return b("readToGPU")}numDataIds(){return b("numDataIds")}disposeData(e,t){return b("disposeData")}write(e,t,n){return b("write")}move(e,t,n,a,i){return b("move")}createTensorFromGPUData(e,t,n){return b("createTensorFromGPUData")}memory(){return b("memory")}floatPrecision(){return b("floatPrecision")}epsilon(){return 32===this.floatPrecision()?1e-7:1e-4}dispose(){return b("dispose")}}function b(e){throw new Error(`'${e}' not yet implemented or not found in the registry. This kernel may not be supported by the tfjs backend you have chosen`)}
11
11
  /**
12
12
  * @license
13
13
  * Copyright 2020 Google LLC. All Rights Reserved.
@@ -23,7 +23,7 @@
23
23
  * See the License for the specific language governing permissions and
24
24
  * limitations under the License.
25
25
  * =============================================================================
26
- */function w(e){let t=e.length,n=0;for(;t>0;)n=Math.random()*t|0,t--,k(e,t,n)}function k(e,t,n){const a=e[t];e[t]=e[n],e[n]=a}function x(e,t){if(!e)throw new Error("string"==typeof t?t:t())}function S(e){x(null!=e,(()=>"The input to the tensor constructor must be a non-null value."))}function N(e){if(0===e.length)return 1;let t=e[0];for(let n=1;n<e.length;n++)t*=e[n];return t}function T(e,t){if(e===t)return!0;if(null==e||null==t)return!1;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function I(e){return e%1==0}function $(e,t){return t<=e.length?e:e+" ".repeat(t-e.length)}function C(e,t){const n=t.length;return x((e=null==e?t.map(((e,t)=>t)):[].concat(e)).every((e=>e>=-n&&e<n)),(()=>`All values in axis param must be in range [-${n}, ${n}) but got axis ${e}`)),x(e.every((e=>I(e))),(()=>`All values in axis param must be integers but got axis ${e}`)),e.map((e=>e<0?n+e:e))}function A(e,t){return E(e,t)}function E(e,t){let n=null;if(null==e||"float32"===e)n=new Float32Array(t);else if("int32"===e)n=new Int32Array(t);else if("bool"===e)n=new Uint8Array(t);else{if("string"!==e)throw new Error(`Unknown data type ${e}`);n=new Array(t)}return n}function j(e){if("float32"===e||"int32"===e)return 4;if("complex64"===e)return 8;if("bool"===e)return 1;throw new Error(`Unknown dtype ${e}`)}function z(e){return"string"==typeof e||e instanceof String}function D(e){return"number"==typeof e}function F(e){return Array.isArray(e)?F(e[0]):e instanceof Float32Array?"float32":e instanceof Int32Array||e instanceof Uint8Array||e instanceof Uint8ClampedArray?"int32":D(e)?"float32":z(e)?"string":"boolean"==typeof e?"bool":"float32"}function _(e){return!!(e&&e.constructor&&e.call&&e.apply)}function R(e){const t=e.length;if(t<2)return[];const n=new Array(t-1);n[t-2]=e[t-1];for(let a=t-3;a>=0;--a)n[a]=n[a+1]*e[a+1];return n}function L(e,t,n,a=!1){const i=new Array;if(1===t.length){const s=t[0]*(a?2:1);for(let t=0;t<s;t++)i[t]=n[e+t]}else{const s=t[0],r=t.slice(1),o=r.reduce(((e,t)=>e*t))*(a?2:1);for(let t=0;t<s;t++)i[t]=L(e+t*o,r,n,a)}return i}function M(e,t,n=!1){if(0===e.length)return t[0];const a=e.reduce(((e,t)=>e*t))*(n?2:1);if(0===a)return[];if(a!==t.length)throw new Error(`[${e}] does not match the input size ${t.length}${n?" for a complex tensor":""}.`);return L(0,e,t,n)}function O(e,t){const n=P(e,t);for(let e=0;e<n.length;e++)n[e]=1;return n}function P(e,t){if(null==t||"float32"===t||"complex64"===t)return new Float32Array(e);if("int32"===t)return new Int32Array(e);if("bool"===t)return new Uint8Array(e);throw new Error(`Unknown data type ${t}`)}function B(e){e.forEach((t=>{x(Number.isInteger(t)&&t>=0,(()=>`Tensor must have a shape comprised of positive integers but got shape [${e}].`))}))}function U(e,t,n){if(0===t)return 0;if(1===t)return e[0];let a=e[e.length-1];for(let t=0;t<e.length-1;++t)a+=n[t]*e[t];return a}function W(e,t,n){if(0===t)return[];if(1===t)return[e];const a=new Array(t);for(let t=0;t<a.length-1;++t)a[t]=Math.floor(e/n[t]),e-=a[t]*n[t];return a[a.length-1]=e,a}function G(e){return e&&e.then&&"function"==typeof e.then}
26
+ */function w(e){let t=e.length,n=0;for(;t>0;)n=Math.random()*t|0,t--,k(e,t,n)}function k(e,t,n){const a=e[t];e[t]=e[n],e[n]=a}function x(e,t){if(!e)throw new Error("string"==typeof t?t:t())}function S(e){x(null!=e,(()=>"The input to the tensor constructor must be a non-null value."))}function N(e){if(0===e.length)return 1;let t=e[0];for(let n=1;n<e.length;n++)t*=e[n];return t}function T(e,t){if(e===t)return!0;if(null==e||null==t)return!1;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function I(e){return e%1==0}function C(e,t){return t<=e.length?e:e+" ".repeat(t-e.length)}function $(e,t){const n=t.length;return x((e=null==e?t.map(((e,t)=>t)):[].concat(e)).every((e=>e>=-n&&e<n)),(()=>`All values in axis param must be in range [-${n}, ${n}) but got axis ${e}`)),x(e.every((e=>I(e))),(()=>`All values in axis param must be integers but got axis ${e}`)),e.map((e=>e<0?n+e:e))}function A(e,t){return E(e,t)}function E(e,t){let n=null;if(null==e||"float32"===e)n=new Float32Array(t);else if("int32"===e)n=new Int32Array(t);else if("bool"===e)n=new Uint8Array(t);else{if("string"!==e)throw new Error(`Unknown data type ${e}`);n=new Array(t)}return n}function j(e){if("float32"===e||"int32"===e)return 4;if("complex64"===e)return 8;if("bool"===e)return 1;throw new Error(`Unknown dtype ${e}`)}function z(e){return"string"==typeof e||e instanceof String}function D(e){return"number"==typeof e}function F(e){return Array.isArray(e)?F(e[0]):e instanceof Float32Array?"float32":e instanceof Int32Array||e instanceof Uint8Array||e instanceof Uint8ClampedArray?"int32":D(e)?"float32":z(e)?"string":"boolean"==typeof e?"bool":"float32"}function _(e){return!!(e&&e.constructor&&e.call&&e.apply)}function R(e){const t=e.length;if(t<2)return[];const n=new Array(t-1);n[t-2]=e[t-1];for(let a=t-3;a>=0;--a)n[a]=n[a+1]*e[a+1];return n}function L(e,t,n,a=!1){const i=new Array;if(1===t.length){const s=t[0]*(a?2:1);for(let t=0;t<s;t++)i[t]=n[e+t]}else{const s=t[0],r=t.slice(1),o=r.reduce(((e,t)=>e*t))*(a?2:1);for(let t=0;t<s;t++)i[t]=L(e+t*o,r,n,a)}return i}function M(e,t,n=!1){if(0===e.length)return t[0];const a=e.reduce(((e,t)=>e*t))*(n?2:1);if(0===a)return[];if(a!==t.length)throw new Error(`[${e}] does not match the input size ${t.length}${n?" for a complex tensor":""}.`);return L(0,e,t,n)}function O(e,t){const n=P(e,t);for(let e=0;e<n.length;e++)n[e]=1;return n}function P(e,t){if(null==t||"float32"===t||"complex64"===t)return new Float32Array(e);if("int32"===t)return new Int32Array(e);if("bool"===t)return new Uint8Array(e);throw new Error(`Unknown data type ${t}`)}function B(e){e.forEach((t=>{x(Number.isInteger(t)&&t>=0,(()=>`Tensor must have a shape comprised of positive integers but got shape [${e}].`))}))}function U(e,t,n){if(0===t)return 0;if(1===t)return e[0];let a=e[e.length-1];for(let t=0;t<e.length-1;++t)a+=n[t]*e[t];return a}function W(e,t,n){if(0===t)return[];if(1===t)return[e];const a=new Array(t);for(let t=0;t<a.length-1;++t)a[t]=Math.floor(e/n[t]),e-=a[t]*n[t];return a[a.length-1]=e,a}function G(e){return e&&e.then&&"function"==typeof e.then}
27
27
  /**
28
28
  * @license
29
29
  * Copyright 2017 Google LLC. All Rights Reserved.
@@ -39,7 +39,7 @@
39
39
  * See the License for the specific language governing permissions and
40
40
  * limitations under the License.
41
41
  * =============================================================================
42
- */const V="tfjsflags";class K{constructor(e){this.global=e,this.flags={},this.flagRegistry={},this.urlFlags={},this.getQueryParams=q,this.populateURLFlags()}setPlatform(e,t){null!=this.platform&&(H().getBool("IS_TEST")||H().getBool("PROD")||console.warn(`Platform ${this.platformName} has already been set. Overwriting the platform with ${e}.`)),this.platformName=e,this.platform=t}registerFlag(e,t,n){if(this.flagRegistry[e]={evaluationFn:t,setHook:n},null!=this.urlFlags[e]){const t=this.urlFlags[e];H().getBool("IS_TEST")||H().getBool("PROD")||console.warn(`Setting feature override from URL ${e}: ${t}.`),this.set(e,t)}}async getAsync(e){return e in this.flags||(this.flags[e]=await this.evaluateFlag(e)),this.flags[e]}get(e){if(e in this.flags)return this.flags[e];const t=this.evaluateFlag(e);if(G(t))throw new Error(`Flag ${e} cannot be synchronously evaluated. Please use getAsync() instead.`);return this.flags[e]=t,this.flags[e]}getNumber(e){return this.get(e)}getBool(e){return this.get(e)}getString(e){return this.get(e)}getFlags(){return this.flags}get features(){return this.flags}set(e,t){if(null==this.flagRegistry[e])throw new Error(`Cannot set flag ${e} as it has not been registered.`);this.flags[e]=t,null!=this.flagRegistry[e].setHook&&this.flagRegistry[e].setHook(t)}evaluateFlag(e){if(null==this.flagRegistry[e])throw new Error(`Cannot evaluate flag '${e}': no evaluation function found.`);return this.flagRegistry[e].evaluationFn()}setFlags(e){this.flags=Object.assign({},e)}reset(){this.flags={},this.urlFlags={},this.populateURLFlags()}populateURLFlags(){if(void 0===this.global||void 0===this.global.location||void 0===this.global.location.search)return;const e=this.getQueryParams(this.global.location.search);if(V in e){e[V].split(",").forEach((e=>{const[t,n]=e.split(":");this.urlFlags[t]=function(e,t){const n=t.toLowerCase();return"true"===n||"false"===n?"true"===n:""+ +n===n?+n:t}(0,n)}))}}}function q(e){const t={};return e.replace(/[?&]([^=?&]+)(?:=([^&]*))?/g,((e,...n)=>(function(e,t,n){e[decodeURIComponent(t)]=decodeURIComponent(n||"")}(t,n[0],n[1]),n.join("=")))),t}function H(){return Z}let J,Z=null;function Y(){if(null==J){let e;if("undefined"!=typeof window)e=window;else if("undefined"!=typeof global)e=global;else if("undefined"!=typeof process)e=process;else{if("undefined"==typeof self)throw new Error("Could not find a global object");e=self}J=e}return J}function Q(e,t){const n=function(){const e=Y();return null==e._tfGlobals&&(e._tfGlobals=new Map),e._tfGlobals}();if(n.has(e))return n.get(e);{const a=t();return n.set(e,a),n.get(e)}}const X="Add",ee="ArgMax",te="AvgPool",ne="AvgPool3D",ae="BatchMatMul",ie="BatchToSpaceND",se="Cast",re="ClipByValue",oe="ComplexAbs",le="Concat",ce="Conv2D",ue="Conv2DBackpropInput",he="Conv3D",pe="Cosh",de="Cumsum",fe="DepthwiseConv2dNative",me="RealDiv",ge="Elu",ve="ExpandDims",ye="Floor",be="FloorDiv",we="FusedBatchNorm",ke="GatherV2",xe="GreaterEqual",Se="Identity",Ne="LeakyRelu",Te="Log1p",Ie="Maximum",$e="MaxPool",Ce="MaxPool3D",Ae="Mean",Ee="Minimum",je="Multiply",ze="OnesLike",De="OneHot",Fe="Pack",_e="PadV2",Re="Prelu",Le="Relu",Me="Reshape",Oe="ResizeNearestNeighbor",Pe="ResizeBilinear",Be="Relu6",Ue="Reverse",We="Round",Ge="Rsqrt",Ve="Select",Ke="Selu",qe="Slice",He="Sinh",Je="Sigmoid",Ze="Softplus",Ye="Sqrt",Qe="Sum",Xe="SpaceToBatchND",et="SplitV",tt="Softmax",nt="Tanh",at="Tile",it="Transpose",st="Unpack",rt="UnsortedSegmentSum",ot="ZerosLike",lt="Step",ct="_FusedMatMul",ut="FusedConv2D";
42
+ */const V="tfjsflags";class K{constructor(e){this.global=e,this.flags={},this.flagRegistry={},this.urlFlags={},this.getQueryParams=q,this.populateURLFlags()}setPlatform(e,t){null!=this.platform&&(H().getBool("IS_TEST")||H().getBool("PROD")||console.warn(`Platform ${this.platformName} has already been set. Overwriting the platform with ${e}.`)),this.platformName=e,this.platform=t}registerFlag(e,t,n){if(this.flagRegistry[e]={evaluationFn:t,setHook:n},null!=this.urlFlags[e]){const t=this.urlFlags[e];H().getBool("IS_TEST")||H().getBool("PROD")||console.warn(`Setting feature override from URL ${e}: ${t}.`),this.set(e,t)}}async getAsync(e){return e in this.flags||(this.flags[e]=await this.evaluateFlag(e)),this.flags[e]}get(e){if(e in this.flags)return this.flags[e];const t=this.evaluateFlag(e);if(G(t))throw new Error(`Flag ${e} cannot be synchronously evaluated. Please use getAsync() instead.`);return this.flags[e]=t,this.flags[e]}getNumber(e){return this.get(e)}getBool(e){return this.get(e)}getString(e){return this.get(e)}getFlags(){return this.flags}get features(){return this.flags}set(e,t){if(null==this.flagRegistry[e])throw new Error(`Cannot set flag ${e} as it has not been registered.`);this.flags[e]=t,null!=this.flagRegistry[e].setHook&&this.flagRegistry[e].setHook(t)}evaluateFlag(e){if(null==this.flagRegistry[e])throw new Error(`Cannot evaluate flag '${e}': no evaluation function found.`);return this.flagRegistry[e].evaluationFn()}setFlags(e){this.flags=Object.assign({},e)}reset(){this.flags={},this.urlFlags={},this.populateURLFlags()}populateURLFlags(){if(void 0===this.global||void 0===this.global.location||void 0===this.global.location.search)return;const e=this.getQueryParams(this.global.location.search);if(V in e){e[V].split(",").forEach((e=>{const[t,n]=e.split(":");this.urlFlags[t]=function(e,t){const n=t.toLowerCase();return"true"===n||"false"===n?"true"===n:""+ +n===n?+n:t}(0,n)}))}}}function q(e){const t={};return e.replace(/[?&]([^=?&]+)(?:=([^&]*))?/g,((e,...n)=>(function(e,t,n){e[decodeURIComponent(t)]=decodeURIComponent(n||"")}(t,n[0],n[1]),n.join("=")))),t}function H(){return Z}let J,Z=null;function Y(){if(null==J){let e;if("undefined"!=typeof window)e=window;else if("undefined"!=typeof global)e=global;else if("undefined"!=typeof process)e=process;else{if("undefined"==typeof self)throw new Error("Could not find a global object");e=self}J=e}return J}function Q(e,t){const n=function(){const e=Y();return null==e._tfGlobals&&(e._tfGlobals=new Map),e._tfGlobals}();if(n.has(e))return n.get(e);{const a=t();return n.set(e,a),n.get(e)}}const X="Add",ee="ArgMax",te="AvgPool",ne="AvgPool3D",ae="BatchMatMul",ie="BatchToSpaceND",se="Cast",re="ClipByValue",oe="ComplexAbs",le="Concat",ce="Conv2D",ue="Conv2DBackpropInput",he="Conv3D",pe="Cosh",de="Cumsum",fe="DepthwiseConv2dNative",me="RealDiv",ge="Elu",ve="ExpandDims",ye="Floor",be="FloorDiv",we="FusedBatchNorm",ke="GatherV2",xe="GreaterEqual",Se="Identity",Ne="LeakyRelu",Te="Log1p",Ie="Maximum",Ce="MaxPool",$e="MaxPool3D",Ae="Mean",Ee="Minimum",je="Multiply",ze="OnesLike",De="OneHot",Fe="Pack",_e="PadV2",Re="Prelu",Le="Relu",Me="Reshape",Oe="ResizeNearestNeighbor",Pe="ResizeBilinear",Be="Relu6",Ue="Reverse",We="Round",Ge="Rsqrt",Ve="Select",Ke="Selu",qe="Slice",He="Sinh",Je="Sigmoid",Ze="Softplus",Ye="Sqrt",Qe="Sum",Xe="SpaceToBatchND",et="SplitV",tt="Softmax",nt="Tanh",at="Tile",it="Transpose",st="Unpack",rt="UnsortedSegmentSum",ot="ZerosLike",lt="Step",ct="_FusedMatMul",ut="FusedConv2D";
43
43
  /**
44
44
  * @license
45
45
  * Copyright 2018 Google LLC. All Rights Reserved.
@@ -120,7 +120,7 @@ function ht(...e){H().getBool("IS_TEST")||H().getBool("PROD")||console.warn(...e
120
120
  * See the License for the specific language governing permissions and
121
121
  * limitations under the License.
122
122
  * =============================================================================
123
- */class $t{constructor(e,t){this.backendTimer=e,this.logger=t,null==t&&(this.logger=new At)}profileKernel(e,t,n){let a;const i=()=>{a=n()};let s;const r=xt();if(this.backendTimer.timerAvailable())s=this.backendTimer.time(i);else{i();for(const e of a)e.dataSync();s=Promise.resolve({kernelMs:xt()-r})}if(H().getBool("CHECK_COMPUTATION_FOR_ERRORS"))for(let t=0;t<a.length;t++){const n=a[t];n.data().then((t=>{Ct(t,n.dtype,e)}))}return{kernelName:e,outputs:a,inputs:t,timeMs:s.then((e=>e.kernelMs)),extraInfo:s.then((e=>null!=e.getExtraProfileInfo?e.getExtraProfileInfo():""))}}logKernelProfile(e){const{kernelName:t,outputs:n,timeMs:a,inputs:i,extraInfo:s}=e;n.forEach((e=>{Promise.all([e.data(),a,s]).then((n=>{this.logger.logKernelProfile(t,e,n[0],n[1],i,n[2])}))}))}}function Ct(e,t,n){if("float32"!==t)return!1;for(let t=0;t<e.length;t++){const a=e[t];if(isNaN(a)||!isFinite(a))return console.warn(`Found ${a} in the result of '${n}'`),!0}return!1}class At{logKernelProfile(e,t,n,a,i,s){const r="number"==typeof a?$(`${a}ms`,9):a.error,o=$(e,25),l=t.rank,c=t.size,u=$(t.shape.toString(),14);let h="";for(const e in i){const n=i[e];if(null!=n){const a=n.shape||t.shape,i=a.length;h+=`${e}: ${i}D ${i>0?a:""} `}}console.log(`%c${o}\t%c${r}\t%c${l}D ${u}\t%c${c}\t%c${h}\t%c${s}`,"font-weight:bold","color:red","color:blue","color: orange","color: green","color: steelblue")}}
123
+ */class Ct{constructor(e,t){this.backendTimer=e,this.logger=t,null==t&&(this.logger=new At)}profileKernel(e,t,n){let a;const i=()=>{a=n()};let s;const r=xt();if(this.backendTimer.timerAvailable())s=this.backendTimer.time(i);else{i();for(const e of a)e.dataSync();s=Promise.resolve({kernelMs:xt()-r})}if(H().getBool("CHECK_COMPUTATION_FOR_ERRORS"))for(let t=0;t<a.length;t++){const n=a[t];n.data().then((t=>{$t(t,n.dtype,e)}))}return{kernelName:e,outputs:a,inputs:t,timeMs:s.then((e=>e.kernelMs)),extraInfo:s.then((e=>null!=e.getExtraProfileInfo?e.getExtraProfileInfo():""))}}logKernelProfile(e){const{kernelName:t,outputs:n,timeMs:a,inputs:i,extraInfo:s}=e;n.forEach((e=>{Promise.all([e.data(),a,s]).then((n=>{this.logger.logKernelProfile(t,e,n[0],n[1],i,n[2])}))}))}}function $t(e,t,n){if("float32"!==t)return!1;for(let t=0;t<e.length;t++){const a=e[t];if(isNaN(a)||!isFinite(a))return console.warn(`Found ${a} in the result of '${n}'`),!0}return!1}class At{logKernelProfile(e,t,n,a,i,s){const r="number"==typeof a?C(`${a}ms`,9):a.error,o=C(e,25),l=t.rank,c=t.size,u=C(t.shape.toString(),14);let h="";for(const e in i){const n=i[e];if(null!=n){const a=n.shape||t.shape,i=a.length;h+=`${e}: ${i}D ${i>0?a:""} `}}console.log(`%c${o}\t%c${r}\t%c${l}D ${u}\t%c${c}\t%c${h}\t%c${s}`,"font-weight:bold","color:red","color:blue","color: orange","color: green","color: steelblue")}}
124
124
  /**
125
125
  * @license
126
126
  * Copyright 2017 Google LLC. All Rights Reserved.
@@ -136,7 +136,7 @@ function ht(...e){H().getBool("IS_TEST")||H().getBool("PROD")||console.warn(...e
136
136
  * See the License for the specific language governing permissions and
137
137
  * limitations under the License.
138
138
  * =============================================================================
139
- */function Et(e,t,n,a){const i=R(t),s=function(e,t,n,a){const i=N(t),s=a[a.length-1],r=new Array(s).fill(0),o=t.length,l="complex64"===n?Ft(e):e;if(o>1)for(let e=0;e<i/s;e++){const t=e*s;for(let e=0;e<s;e++)r[e]=Math.max(r[e],jt(l[t+e],0,n).length)}return r}(e,t,n,i),r=t.length,o=Dt(e,t,n,i,s),l=["Tensor"];return a&&(l.push(` dtype: ${n}`),l.push(` rank: ${r}`),l.push(` shape: [${t}]`),l.push(" values:")),l.push(o.map((e=>" "+e)).join("\n")),l.join("\n")}function jt(e,t,n){let a;return a=Array.isArray(e)?`${parseFloat(e[0].toFixed(7))} + ${parseFloat(e[1].toFixed(7))}j`:z(e)?`'${e}'`:"bool"===n?zt(e):parseFloat(e.toFixed(7)).toString(),$(a,t)}function zt(e){return 0===e?"false":"true"}function Dt(e,t,n,a,i,s=!0){const r="complex64"===n?2:1,o=t[0],l=t.length;if(0===l){if("complex64"===n){return[jt(Ft(e)[0],0,n)]}return"bool"===n?[zt(e[0])]:[e[0].toString()]}if(1===l){if(o>20){const t=3*r;let a=Array.from(e.slice(0,t)),s=Array.from(e.slice((o-3)*r,o*r));return"complex64"===n&&(a=Ft(a),s=Ft(s)),["["+a.map(((e,t)=>jt(e,i[t],n))).join(", ")+", ..., "+s.map(((e,t)=>jt(e,i[o-3+t],n))).join(", ")+"]"]}return["["+("complex64"===n?Ft(e):Array.from(e)).map(((e,t)=>jt(e,i[t],n))).join(", ")+"]"]}const c=t.slice(1),u=a.slice(1),h=a[0]*r,p=[];if(o>20){for(let t=0;t<3;t++){const a=t*h,s=a+h;p.push(...Dt(e.slice(a,s),c,n,u,i,!1))}p.push("...");for(let t=o-3;t<o;t++){const a=t*h,s=a+h;p.push(...Dt(e.slice(a,s),c,n,u,i,t===o-1))}}else for(let t=0;t<o;t++){const a=t*h,s=a+h;p.push(...Dt(e.slice(a,s),c,n,u,i,t===o-1))}const d=2===l?",":"";p[0]="["+(o>0?p[0]+d:"");for(let e=1;e<p.length-1;e++)p[e]=" "+p[e]+d;let f=",\n";for(let e=2;e<l;e++)f+="\n";return p[p.length-1]=" "+p[p.length-1]+"]"+(s?"":f),p}function Ft(e){const t=[];for(let n=0;n<e.length;n+=2)t.push([e[n],e[n+1]]);return t}
139
+ */function Et(e,t,n,a){const i=R(t),s=function(e,t,n,a){const i=N(t),s=a[a.length-1],r=new Array(s).fill(0),o=t.length,l="complex64"===n?Ft(e):e;if(o>1)for(let e=0;e<i/s;e++){const t=e*s;for(let e=0;e<s;e++)r[e]=Math.max(r[e],jt(l[t+e],0,n).length)}return r}(e,t,n,i),r=t.length,o=Dt(e,t,n,i,s),l=["Tensor"];return a&&(l.push(` dtype: ${n}`),l.push(` rank: ${r}`),l.push(` shape: [${t}]`),l.push(" values:")),l.push(o.map((e=>" "+e)).join("\n")),l.join("\n")}function jt(e,t,n){let a;return a=Array.isArray(e)?`${parseFloat(e[0].toFixed(7))} + ${parseFloat(e[1].toFixed(7))}j`:z(e)?`'${e}'`:"bool"===n?zt(e):parseFloat(e.toFixed(7)).toString(),C(a,t)}function zt(e){return 0===e?"false":"true"}function Dt(e,t,n,a,i,s=!0){const r="complex64"===n?2:1,o=t[0],l=t.length;if(0===l){if("complex64"===n){return[jt(Ft(e)[0],0,n)]}return"bool"===n?[zt(e[0])]:[e[0].toString()]}if(1===l){if(o>20){const t=3*r;let a=Array.from(e.slice(0,t)),s=Array.from(e.slice((o-3)*r,o*r));return"complex64"===n&&(a=Ft(a),s=Ft(s)),["["+a.map(((e,t)=>jt(e,i[t],n))).join(", ")+", ..., "+s.map(((e,t)=>jt(e,i[o-3+t],n))).join(", ")+"]"]}return["["+("complex64"===n?Ft(e):Array.from(e)).map(((e,t)=>jt(e,i[t],n))).join(", ")+"]"]}const c=t.slice(1),u=a.slice(1),h=a[0]*r,p=[];if(o>20){for(let t=0;t<3;t++){const a=t*h,s=a+h;p.push(...Dt(e.slice(a,s),c,n,u,i,!1))}p.push("...");for(let t=o-3;t<o;t++){const a=t*h,s=a+h;p.push(...Dt(e.slice(a,s),c,n,u,i,t===o-1))}}else for(let t=0;t<o;t++){const a=t*h,s=a+h;p.push(...Dt(e.slice(a,s),c,n,u,i,t===o-1))}const d=2===l?",":"";p[0]="["+(o>0?p[0]+d:"");for(let e=1;e<p.length-1;e++)p[e]=" "+p[e]+d;let f=",\n";for(let e=2;e<l;e++)f+="\n";return p[p.length-1]=" "+p[p.length-1]+"]"+(s?"":f),p}function Ft(e){const t=[];for(let n=0;n<e.length;n+=2)t.push([e[n],e[n+1]]);return t}
140
140
  /**
141
141
  * @license
142
142
  * Copyright 2017 Google LLC. All Rights Reserved.
@@ -201,7 +201,7 @@ var Bt,Ut,Wt,Gt,Vt;Object.defineProperty(Pt,Symbol.hasInstance,{value:e=>e insta
201
201
  * See the License for the specific language governing permissions and
202
202
  * limitations under the License.
203
203
  * =============================================================================
204
- */const i=e;for(const e in i){const a=i[e];n.has(a)||(n.add(a),Qt(a,t,n))}}function Xt(e){return null!=e.kernelName}class en{constructor(){this.registeredVariables={},this.nextTapeNodeId=0,this.numBytes=0,this.numTensors=0,this.numStringTensors=0,this.numDataBuffers=0,this.gradientDepth=0,this.kernelDepth=0,this.scopeStack=[],this.numDataMovesStack=[],this.nextScopeId=0,this.tensorInfo=new WeakMap,this.profiling=!1,this.activeProfile={newBytes:0,newTensors:0,peakBytes:0,kernels:[],result:null,get kernelNames(){return Array.from(new Set(this.kernels.map((e=>e.name))))}}}dispose(){for(const e in this.registeredVariables)this.registeredVariables[e].dispose()}}class tn{constructor(e){this.ENV=e,this.registry={},this.registryFactory={},this.pendingBackendInitId=0,this.state=new en}async ready(){if(null!=this.pendingBackendInit)return this.pendingBackendInit.then((()=>{}));if(null!=this.backendInstance)return;const e=this.getSortedBackends();for(let t=0;t<e.length;t++){const n=e[t];if(await this.initializeBackend(n).success)return void await this.setBackend(n)}throw new Error("Could not initialize any backends, all backend initializations failed.")}get backend(){if(null!=this.pendingBackendInit)throw new Error(`Backend '${this.backendName}' has not yet been initialized. Make sure to await tf.ready() or await tf.setBackend() before calling other methods`);if(null==this.backendInstance){const{name:e,asyncInit:t}=this.initializeBackendsAndReturnBest();if(t)throw new Error(`The highest priority backend '${e}' has not yet been initialized. Make sure to await tf.ready() or await tf.setBackend() before calling other methods`);this.setBackend(e)}return this.backendInstance}backendNames(){return Object.keys(this.registryFactory)}findBackend(e){if(!(e in this.registry)){if(!(e in this.registryFactory))return null;{const{asyncInit:t}=this.initializeBackend(e);if(t)return null}}return this.registry[e]}findBackendFactory(e){return e in this.registryFactory?this.registryFactory[e].factory:null}registerBackend(e,t,n=1){return e in this.registryFactory?(ht(`${e} backend was already registered. Reusing existing backend factory.`),!1):(this.registryFactory[e]={factory:t,priority:n},!0)}async setBackend(e){if(null==this.registryFactory[e])throw new Error(`Backend name '${e}' not found in registry`);if(this.backendName=e,null==this.registry[e]){this.backendInstance=null;const{success:t,asyncInit:n}=this.initializeBackend(e);if(!(n?await t:t))return!1}return this.backendInstance=this.registry[e],this.setupRegisteredKernels(),this.profiler=new $t(this.backendInstance),!0}setupRegisteredKernels(){gt(this.backendName).forEach((e=>{null!=e.setupFunc&&e.setupFunc(this.backendInstance)}))}disposeRegisteredKernels(e){gt(e).forEach((t=>{null!=t.disposeFunc&&t.disposeFunc(this.registry[e])}))}initializeBackend(e){const t=this.registryFactory[e];if(null==t)throw new Error(`Cannot initialize backend ${e}, no registration found.`);try{const n=t.factory();if(!n||n instanceof y||"function"!=typeof n.then)return this.registry[e]=n,{success:!0,asyncInit:!1};{const t=++this.pendingBackendInitId,a=n.then((n=>!(t<this.pendingBackendInitId)&&(this.registry[e]=n,this.pendingBackendInit=null,!0))).catch((n=>(t<this.pendingBackendInitId||(this.pendingBackendInit=null,ht(`Initialization of backend ${e} failed`),ht(n.stack||n.message)),!1)));return this.pendingBackendInit=a,{success:a,asyncInit:!0}}}catch(t){return ht(`Initialization of backend ${e} failed`),ht(t.stack||t.message),{success:!1,asyncInit:!1}}}removeBackend(e){if(!(e in this.registryFactory))throw new Error(`${e} backend not found in registry`);this.backendName===e&&null!=this.pendingBackendInit&&this.pendingBackendInitId++,e in this.registry&&(this.disposeRegisteredKernels(e),this.registry[e].dispose(),delete this.registry[e]),delete this.registryFactory[e],this.backendName===e&&(this.pendingBackendInit=null,this.backendName=null,this.backendInstance=null)}getSortedBackends(){if(0===Object.keys(this.registryFactory).length)throw new Error("No backend found in registry.");return Object.keys(this.registryFactory).sort(((e,t)=>this.registryFactory[t].priority-this.registryFactory[e].priority))}initializeBackendsAndReturnBest(){const e=this.getSortedBackends();for(let t=0;t<e.length;t++){const n=e[t],{success:a,asyncInit:i}=this.initializeBackend(n);if(i||a)return{name:n,asyncInit:i}}throw new Error("Could not initialize any backends, all backend initializations failed.")}moveData(e,t){const n=this.state.tensorInfo.get(t),a=n.backend,i=this.readSync(t),s=a.refCount(t);a.disposeData(t,!0),n.backend=e,e.move(t,i,n.shape,n.dtype,s),this.shouldCheckForMemLeaks()&&this.state.numDataMovesStack[this.state.numDataMovesStack.length-1]++}tidy(e,t){let n,a=null;if(null==t){if("function"!=typeof e)throw new Error("Please provide a function to tidy()");t=e}else{if("string"!=typeof e&&!(e instanceof String))throw new Error("When calling with two arguments, the first argument to tidy() must be a string");if("function"!=typeof t)throw new Error("When calling with two arguments, the 2nd argument to tidy() must be a function");a=e}return this.scopedRun((()=>this.startScope(a)),(()=>this.endScope(n)),(()=>(n=t(),n instanceof Promise&&console.error("Cannot return a Promise inside of tidy."),n)))}scopedRun(e,t,n){e();try{const e=n();return t(),e}catch(e){throw t(),e}}nextTensorId(){return tn.nextTensorId++}nextVariableId(){return tn.nextVariableId++}clone(e){const t=an.runKernel(Se,{x:e}),n={x:e};return this.addTapeNode(this.state.activeScope.name,n,[t],(e=>({x:()=>{const t={x:e},n={dtype:"float32"};return an.runKernel(se,t,n)}})),[],{}),t}runKernel(e,t,n){null==this.backendName&&this.backend;if(!(null!=ft(e,this.backendName)))throw new Error(`Kernel '${e}' not registered for backend '${this.backendName}'`);return this.runKernelFunc({kernelName:e,inputs:t,attrs:n})}shouldCheckForMemLeaks(){return this.ENV.getBool("IS_TEST")}checkKernelForMemLeak(e,t,n){const a=this.backend.numDataIds();let i=0;n.forEach((e=>{i+="complex64"===e.dtype?3:1}));const s=this.state.numDataMovesStack[this.state.numDataMovesStack.length-1],r=a-t-i-s;if(r>0)throw new Error(`Backend '${this.backendName}' has an internal memory leak (${r} data ids) after running '${e}'`)}runKernelFunc(e){let t,n=[];const a=this.isTapeOn(),i=this.state.numBytes,s=this.state.numTensors;let r,o;this.shouldCheckForMemLeaks()&&this.state.numDataMovesStack.push(0),null==this.backendName&&this.backend;const l=Xt(e)?e.kernelName:null!=this.state.activeScope?this.state.activeScope.name:"";if(Xt(e)){const{kernelName:t,inputs:i,attrs:s}=e;null==this.backendName&&this.backend;const l=ft(t,this.backendName);x(null!=l,(()=>`Cannot find registered kernel '${t}' for backend '${this.backendName}'`)),r=()=>{const e=this.backend.numDataIds();o=l.kernelFunc({inputs:i,attrs:s,backend:this.backend});const r=Array.isArray(o)?o:[o];this.shouldCheckForMemLeaks()&&this.checkKernelForMemLeak(t,e,r);const c=r.map((e=>null!=e.rank?e:this.makeTensorFromTensorInfo(e)));if(a){const e=this.getTensorsForGradient(t,i,c);n=this.saveTensorsForBackwardMode(e)}return c}}else{const{forwardFunc:t}=e,i=e=>{a&&(n=e.map((e=>this.keep(this.clone(e)))))};r=()=>{const e=this.backend.numDataIds();o=this.tidy((()=>t(this.backend,i)));const n=Array.isArray(o)?o:[o];return this.shouldCheckForMemLeaks()&&this.checkKernelForMemLeak(l,e,n),n}}const{inputs:c,attrs:u}=e,h=Xt(e)?null:e.backwardsFunc;let p;return this.scopedRun((()=>this.state.kernelDepth++),(()=>this.state.kernelDepth--),(()=>{this.ENV.getBool("DEBUG")||this.state.profiling?(p=this.profiler.profileKernel(l,c,(()=>r())),this.ENV.getBool("DEBUG")&&this.profiler.logKernelProfile(p),t=p.outputs):t=r()})),a&&this.addTapeNode(l,c,t,h,n,u),this.state.profiling&&this.state.activeProfile.kernels.push({name:l,bytesAdded:this.state.numBytes-i,totalBytesSnapshot:this.state.numBytes,tensorsAdded:this.state.numTensors-s,totalTensorsSnapshot:this.state.numTensors,inputShapes:Object.keys(c).map((e=>null!=c[e]?c[e].shape:null)),outputShapes:t.map((e=>e.shape)),kernelTimeMs:p.timeMs,extraInfo:p.extraInfo}),Array.isArray(o)?t:t[0]}saveTensorsForBackwardMode(e){const t=e.map((e=>this.keep(this.clone(e))));return t}getTensorsForGradient(e,t,n){const a=mt(e);if(null!=a){const e=a.inputsToSave||[],i=a.outputsToSave||[];let s;a.saveAllInputs?(x(Array.isArray(t),(()=>"saveAllInputs is true, expected inputs to be an array.")),s=Object.keys(t).map((e=>t[e]))):s=e.map((e=>t[e]));const r=n.filter(((e,t)=>i[t]));return s.concat(r)}return[]}makeTensor(e,t,n,a){if(null==e)throw new Error("Values passed to engine.makeTensor() are null");n=n||"float32",a=a||this.backend;let i=e;"string"===n&&z(e[0])&&(i=e.map((e=>St(e))));const s=a.write(i,t,n),r=new Mt(t,n,s,this.nextTensorId());if(this.trackTensor(r,a),"string"===n){const e=this.state.tensorInfo.get(s),t=function(e){if(null==e)return 0;let t=0;return e.forEach((e=>t+=e.length)),t}(i);this.state.numBytes+=t-e.bytes,e.bytes=t}return r}makeTensorFromDataId(e,t,n,a){const i={dataId:e,shape:t,dtype:n=n||"float32"};return this.makeTensorFromTensorInfo(i,a)}makeTensorFromTensorInfo(e,t){const{dataId:n,shape:a,dtype:i}=e,s=new Mt(a,i,n,this.nextTensorId());return this.trackTensor(s,t),s}makeVariable(e,t=!0,n,a){n=n||this.nextVariableId().toString(),null!=a&&a!==e.dtype&&(e=e.cast(a));const i=new Pt(e,t,n,this.nextTensorId());if(null!=this.state.registeredVariables[i.name])throw new Error(`Variable with name ${i.name} was already registered`);return this.state.registeredVariables[i.name]=i,this.incRef(i,this.backend),i}trackTensor(e,t){this.state.numTensors++,"string"===e.dtype&&this.state.numStringTensors++;let n=0;"complex64"!==e.dtype&&"string"!==e.dtype&&(n=e.size*j(e.dtype)),this.state.numBytes+=n,this.state.tensorInfo.has(e.dataId)||(this.state.numDataBuffers++,this.state.tensorInfo.set(e.dataId,{backend:t||this.backend,dtype:e.dtype,shape:e.shape,bytes:n})),e instanceof Pt||this.track(e)}incRef(e,t){this.trackTensor(e,t),this.backend.incRef(e.dataId)}removeDataId(e,t){this.state.tensorInfo.has(e)&&this.state.tensorInfo.get(e).backend===t&&(this.state.tensorInfo.delete(e),this.state.numDataBuffers--)}disposeTensor(e){if(!this.state.tensorInfo.has(e.dataId))return;const t=this.state.tensorInfo.get(e.dataId);if(this.state.numTensors--,"string"===e.dtype&&(this.state.numStringTensors--,this.state.numBytes-=t.bytes),"complex64"!==e.dtype&&"string"!==e.dtype){const t=e.size*j(e.dtype);this.state.numBytes-=t}t.backend.disposeData(e.dataId)&&this.removeDataId(e.dataId,t.backend)}disposeVariables(){for(const e in this.state.registeredVariables){const t=this.state.registeredVariables[e];this.disposeVariable(t)}}disposeVariable(e){this.disposeTensor(e),null!=this.state.registeredVariables[e.name]&&delete this.state.registeredVariables[e.name]}memory(){const e=this.backend.memory();return e.numTensors=this.state.numTensors,e.numDataBuffers=this.state.numDataBuffers,e.numBytes=this.state.numBytes,this.state.numStringTensors>0&&(e.unreliable=!0,null==e.reasons&&(e.reasons=[]),e.reasons.push("Memory usage by string tensors is approximate (2 bytes per character)")),e}async profile(e){this.state.profiling=!0;const t=this.state.numBytes,n=this.state.numTensors;this.state.activeProfile.kernels=[],this.state.activeProfile.result=await e(),this.state.profiling=!1,this.state.activeProfile.peakBytes=Math.max(...this.state.activeProfile.kernels.map((e=>e.totalBytesSnapshot))),this.state.activeProfile.newBytes=this.state.numBytes-t,this.state.activeProfile.newTensors=this.state.numTensors-n;for(const e of this.state.activeProfile.kernels)e.kernelTimeMs=await e.kernelTimeMs,e.extraInfo=await e.extraInfo;return this.state.activeProfile}isTapeOn(){return this.state.gradientDepth>0&&0===this.state.kernelDepth}addTapeNode(e,t,n,a,i,s){const r={id:this.state.nextTapeNodeId++,kernelName:e,inputs:t,outputs:n,saved:i},o=mt(e);null!=o&&(a=o.gradFunc),null!=a&&(r.gradient=e=>(e=e.map(((e,t)=>{if(null==e){const e=n[t],a=P(e.size,e.dtype);return this.makeTensor(a,e.shape,e.dtype)}return e})),a(e.length>1?e:e[0],i,s))),this.state.activeTape.push(r)}keep(e){return e.kept=!0,e}startTape(){0===this.state.gradientDepth&&(this.state.activeTape=[]),this.state.gradientDepth++}endTape(){this.state.gradientDepth--}startScope(e){const t={track:[],name:"unnamed scope",id:this.state.nextScopeId++};e&&(t.name=e),this.state.scopeStack.push(t),this.state.activeScope=t}endScope(e){const t=Yt(e),n=new Set(t.map((e=>e.id)));for(let e=0;e<this.state.activeScope.track.length;e++){const t=this.state.activeScope.track[e];t.kept||n.has(t.id)||t.dispose()}const a=this.state.scopeStack.pop();this.state.activeScope=0===this.state.scopeStack.length?null:this.state.scopeStack[this.state.scopeStack.length-1],t.forEach((e=>{e.kept||e.scopeId!==a.id||this.track(e)}))}gradients(e,t,n,a=!1){if(x(t.length>0,(()=>"gradients() received an empty list of xs.")),null!=n&&"float32"!==n.dtype)throw new Error(`dy must have 'float32' dtype, but has '${n.dtype}'`);const i=this.scopedRun((()=>this.startTape()),(()=>this.endTape()),(()=>this.tidy("forward",e)));x(i instanceof Mt,(()=>"The result y returned by f() must be a tensor."));const s=function(e,t,n){const a={},i={};for(let e=0;e<t.length;e++)a[t[e].id]=!0;for(let n=0;n<e.length;n++){const s=e[n],r=s.inputs;for(const e in r){const n=r[e];let o=!1;for(let e=0;e<t.length;e++)if(a[n.id]){s.outputs.forEach((e=>a[e.id]=!0)),o=!0,i[s.id]=!0;break}if(o)break}}const s={};s[n.id]=!0;const r={};for(let t=e.length-1;t>=0;t--){const n=e[t],a=n.inputs;for(let e=0;e<n.outputs.length;e++)if(s[n.outputs[e].id]){for(const e in a)s[a[e].id]=!0,r[n.id]=!0;break}}const o=[];for(let t=0;t<e.length;t++){const n=e[t];if(i[n.id]&&r[n.id]){const e={};for(const t in n.inputs){const i=n.inputs[t];a[i.id]&&(e[t]=i)}const t=Object.assign({},n);t.inputs=e,t.outputs=n.outputs,o.push(t)}}return o}(this.state.activeTape,t,i);if(!a&&0===s.length&&t.length>0)throw new Error("Cannot compute gradient of y=f(x) with respect to x. Make sure that the f you passed encloses all operations that lead from x to y.");return this.tidy("backward",(()=>{const e={};e[i.id]=null==n?function(e){const t=O(N(e),"float32");return an.makeTensor(t,e,"float32")}(i.shape):n,function(e,t,n,a){for(let i=t.length-1;i>=0;i--){const s=t[i],r=[];if(s.outputs.forEach((t=>{const n=e[t.id];null!=n?r.push(n):r.push(null)})),null==s.gradient)throw new Error(`Cannot compute gradient: gradient function not found for ${s.kernelName}.`);const o=s.gradient(r);for(const t in s.inputs){if(!(t in o))throw new Error(`Cannot backprop through input ${t}. Available gradients found: ${Object.keys(o)}.`);const i=n((()=>o[t]()));if("float32"!==i.dtype)throw new Error(`Error in gradient for op ${s.kernelName}. The gradient of input ${t} must have 'float32' dtype, but has '${i.dtype}'`);const r=s.inputs[t];if(!T(i.shape,r.shape))throw new Error(`Error in gradient for op ${s.kernelName}. The gradient of input '${t}' has shape '${i.shape}', which does not match the shape of the input '${r.shape}'`);if(null==e[r.id])e[r.id]=i;else{const t=e[r.id];e[r.id]=a(t,i),t.dispose()}}}}
204
+ */const i=e;for(const e in i){const a=i[e];n.has(a)||(n.add(a),Qt(a,t,n))}}function Xt(e){return null!=e.kernelName}class en{constructor(){this.registeredVariables={},this.nextTapeNodeId=0,this.numBytes=0,this.numTensors=0,this.numStringTensors=0,this.numDataBuffers=0,this.gradientDepth=0,this.kernelDepth=0,this.scopeStack=[],this.numDataMovesStack=[],this.nextScopeId=0,this.tensorInfo=new WeakMap,this.profiling=!1,this.activeProfile={newBytes:0,newTensors:0,peakBytes:0,kernels:[],result:null,get kernelNames(){return Array.from(new Set(this.kernels.map((e=>e.name))))}}}dispose(){for(const e in this.registeredVariables)this.registeredVariables[e].dispose()}}class tn{constructor(e){this.ENV=e,this.registry={},this.registryFactory={},this.pendingBackendInitId=0,this.state=new en}async ready(){if(null!=this.pendingBackendInit)return this.pendingBackendInit.then((()=>{}));if(null!=this.backendInstance)return;const e=this.getSortedBackends();for(let t=0;t<e.length;t++){const n=e[t];if(await this.initializeBackend(n).success)return void await this.setBackend(n)}throw new Error("Could not initialize any backends, all backend initializations failed.")}get backend(){if(null!=this.pendingBackendInit)throw new Error(`Backend '${this.backendName}' has not yet been initialized. Make sure to await tf.ready() or await tf.setBackend() before calling other methods`);if(null==this.backendInstance){const{name:e,asyncInit:t}=this.initializeBackendsAndReturnBest();if(t)throw new Error(`The highest priority backend '${e}' has not yet been initialized. Make sure to await tf.ready() or await tf.setBackend() before calling other methods`);this.setBackend(e)}return this.backendInstance}backendNames(){return Object.keys(this.registryFactory)}findBackend(e){if(!(e in this.registry)){if(!(e in this.registryFactory))return null;{const{asyncInit:t}=this.initializeBackend(e);if(t)return null}}return this.registry[e]}findBackendFactory(e){return e in this.registryFactory?this.registryFactory[e].factory:null}registerBackend(e,t,n=1){return e in this.registryFactory?(ht(`${e} backend was already registered. Reusing existing backend factory.`),!1):(this.registryFactory[e]={factory:t,priority:n},!0)}async setBackend(e){if(null==this.registryFactory[e])throw new Error(`Backend name '${e}' not found in registry`);if(this.backendName=e,null==this.registry[e]){this.backendInstance=null;const{success:t,asyncInit:n}=this.initializeBackend(e);if(!(n?await t:t))return!1}return this.backendInstance=this.registry[e],this.setupRegisteredKernels(),this.profiler=new Ct(this.backendInstance),!0}setupRegisteredKernels(){gt(this.backendName).forEach((e=>{null!=e.setupFunc&&e.setupFunc(this.backendInstance)}))}disposeRegisteredKernels(e){gt(e).forEach((t=>{null!=t.disposeFunc&&t.disposeFunc(this.registry[e])}))}initializeBackend(e){const t=this.registryFactory[e];if(null==t)throw new Error(`Cannot initialize backend ${e}, no registration found.`);try{const n=t.factory();if(!n||n instanceof y||"function"!=typeof n.then)return this.registry[e]=n,{success:!0,asyncInit:!1};{const t=++this.pendingBackendInitId,a=n.then((n=>!(t<this.pendingBackendInitId)&&(this.registry[e]=n,this.pendingBackendInit=null,!0))).catch((n=>(t<this.pendingBackendInitId||(this.pendingBackendInit=null,ht(`Initialization of backend ${e} failed`),ht(n.stack||n.message)),!1)));return this.pendingBackendInit=a,{success:a,asyncInit:!0}}}catch(t){return ht(`Initialization of backend ${e} failed`),ht(t.stack||t.message),{success:!1,asyncInit:!1}}}removeBackend(e){if(!(e in this.registryFactory))throw new Error(`${e} backend not found in registry`);this.backendName===e&&null!=this.pendingBackendInit&&this.pendingBackendInitId++,e in this.registry&&(this.disposeRegisteredKernels(e),this.registry[e].dispose(),delete this.registry[e]),delete this.registryFactory[e],this.backendName===e&&(this.pendingBackendInit=null,this.backendName=null,this.backendInstance=null)}getSortedBackends(){if(0===Object.keys(this.registryFactory).length)throw new Error("No backend found in registry.");return Object.keys(this.registryFactory).sort(((e,t)=>this.registryFactory[t].priority-this.registryFactory[e].priority))}initializeBackendsAndReturnBest(){const e=this.getSortedBackends();for(let t=0;t<e.length;t++){const n=e[t],{success:a,asyncInit:i}=this.initializeBackend(n);if(i||a)return{name:n,asyncInit:i}}throw new Error("Could not initialize any backends, all backend initializations failed.")}moveData(e,t){const n=this.state.tensorInfo.get(t),a=n.backend,i=this.readSync(t),s=a.refCount(t);a.disposeData(t,!0),n.backend=e,e.move(t,i,n.shape,n.dtype,s),this.shouldCheckForMemLeaks()&&this.state.numDataMovesStack[this.state.numDataMovesStack.length-1]++}tidy(e,t){let n,a=null;if(null==t){if("function"!=typeof e)throw new Error("Please provide a function to tidy()");t=e}else{if("string"!=typeof e&&!(e instanceof String))throw new Error("When calling with two arguments, the first argument to tidy() must be a string");if("function"!=typeof t)throw new Error("When calling with two arguments, the 2nd argument to tidy() must be a function");a=e}return this.scopedRun((()=>this.startScope(a)),(()=>this.endScope(n)),(()=>(n=t(),n instanceof Promise&&console.error("Cannot return a Promise inside of tidy."),n)))}scopedRun(e,t,n){e();try{const e=n();return t(),e}catch(e){throw t(),e}}nextTensorId(){return tn.nextTensorId++}nextVariableId(){return tn.nextVariableId++}clone(e){const t=an.runKernel(Se,{x:e}),n={x:e};return this.addTapeNode(this.state.activeScope.name,n,[t],(e=>({x:()=>{const t={x:e},n={dtype:"float32"};return an.runKernel(se,t,n)}})),[],{}),t}runKernel(e,t,n){null==this.backendName&&this.backend;if(!(null!=ft(e,this.backendName)))throw new Error(`Kernel '${e}' not registered for backend '${this.backendName}'`);return this.runKernelFunc({kernelName:e,inputs:t,attrs:n})}shouldCheckForMemLeaks(){return this.ENV.getBool("IS_TEST")}checkKernelForMemLeak(e,t,n){const a=this.backend.numDataIds();let i=0;n.forEach((e=>{i+="complex64"===e.dtype?3:1}));const s=this.state.numDataMovesStack[this.state.numDataMovesStack.length-1],r=a-t-i-s;if(r>0)throw new Error(`Backend '${this.backendName}' has an internal memory leak (${r} data ids) after running '${e}'`)}runKernelFunc(e){let t,n=[];const a=this.isTapeOn(),i=this.state.numBytes,s=this.state.numTensors;let r,o;this.shouldCheckForMemLeaks()&&this.state.numDataMovesStack.push(0),null==this.backendName&&this.backend;const l=Xt(e)?e.kernelName:null!=this.state.activeScope?this.state.activeScope.name:"";if(Xt(e)){const{kernelName:t,inputs:i,attrs:s}=e;null==this.backendName&&this.backend;const l=ft(t,this.backendName);x(null!=l,(()=>`Cannot find registered kernel '${t}' for backend '${this.backendName}'`)),r=()=>{const e=this.backend.numDataIds();o=l.kernelFunc({inputs:i,attrs:s,backend:this.backend});const r=Array.isArray(o)?o:[o];this.shouldCheckForMemLeaks()&&this.checkKernelForMemLeak(t,e,r);const c=r.map((e=>null!=e.rank?e:this.makeTensorFromTensorInfo(e)));if(a){const e=this.getTensorsForGradient(t,i,c);n=this.saveTensorsForBackwardMode(e)}return c}}else{const{forwardFunc:t}=e,i=e=>{a&&(n=e.map((e=>this.keep(this.clone(e)))))};r=()=>{const e=this.backend.numDataIds();o=this.tidy((()=>t(this.backend,i)));const n=Array.isArray(o)?o:[o];return this.shouldCheckForMemLeaks()&&this.checkKernelForMemLeak(l,e,n),n}}const{inputs:c,attrs:u}=e,h=Xt(e)?null:e.backwardsFunc;let p;return this.scopedRun((()=>this.state.kernelDepth++),(()=>this.state.kernelDepth--),(()=>{this.ENV.getBool("DEBUG")||this.state.profiling?(p=this.profiler.profileKernel(l,c,(()=>r())),this.ENV.getBool("DEBUG")&&this.profiler.logKernelProfile(p),t=p.outputs):t=r()})),a&&this.addTapeNode(l,c,t,h,n,u),this.state.profiling&&this.state.activeProfile.kernels.push({name:l,bytesAdded:this.state.numBytes-i,totalBytesSnapshot:this.state.numBytes,tensorsAdded:this.state.numTensors-s,totalTensorsSnapshot:this.state.numTensors,inputShapes:Object.keys(c).map((e=>null!=c[e]?c[e].shape:null)),outputShapes:t.map((e=>e.shape)),kernelTimeMs:p.timeMs,extraInfo:p.extraInfo}),Array.isArray(o)?t:t[0]}saveTensorsForBackwardMode(e){const t=e.map((e=>this.keep(this.clone(e))));return t}getTensorsForGradient(e,t,n){const a=mt(e);if(null!=a){const e=a.inputsToSave||[],i=a.outputsToSave||[];let s;a.saveAllInputs?(x(Array.isArray(t),(()=>"saveAllInputs is true, expected inputs to be an array.")),s=Object.keys(t).map((e=>t[e]))):s=e.map((e=>t[e]));const r=n.filter(((e,t)=>i[t]));return s.concat(r)}return[]}makeTensor(e,t,n,a){if(null==e)throw new Error("Values passed to engine.makeTensor() are null");n=n||"float32",a=a||this.backend;let i=e;"string"===n&&z(e[0])&&(i=e.map((e=>St(e))));const s=a.write(i,t,n),r=new Mt(t,n,s,this.nextTensorId());if(this.trackTensor(r,a),"string"===n){const e=this.state.tensorInfo.get(s),t=function(e){if(null==e)return 0;let t=0;return e.forEach((e=>t+=e.length)),t}(i);this.state.numBytes+=t-e.bytes,e.bytes=t}return r}makeTensorFromDataId(e,t,n,a){const i={dataId:e,shape:t,dtype:n=n||"float32"};return this.makeTensorFromTensorInfo(i,a)}makeTensorFromTensorInfo(e,t){const{dataId:n,shape:a,dtype:i}=e,s=new Mt(a,i,n,this.nextTensorId());return this.trackTensor(s,t),s}makeVariable(e,t=!0,n,a){n=n||this.nextVariableId().toString(),null!=a&&a!==e.dtype&&(e=e.cast(a));const i=new Pt(e,t,n,this.nextTensorId());if(null!=this.state.registeredVariables[i.name])throw new Error(`Variable with name ${i.name} was already registered`);return this.state.registeredVariables[i.name]=i,this.incRef(i,this.backend),i}trackTensor(e,t){this.state.numTensors++,"string"===e.dtype&&this.state.numStringTensors++;let n=0;"complex64"!==e.dtype&&"string"!==e.dtype&&(n=e.size*j(e.dtype)),this.state.numBytes+=n,this.state.tensorInfo.has(e.dataId)||(this.state.numDataBuffers++,this.state.tensorInfo.set(e.dataId,{backend:t||this.backend,dtype:e.dtype,shape:e.shape,bytes:n})),e instanceof Pt||this.track(e)}incRef(e,t){this.trackTensor(e,t),this.backend.incRef(e.dataId)}removeDataId(e,t){this.state.tensorInfo.has(e)&&this.state.tensorInfo.get(e).backend===t&&(this.state.tensorInfo.delete(e),this.state.numDataBuffers--)}disposeTensor(e){if(!this.state.tensorInfo.has(e.dataId))return;const t=this.state.tensorInfo.get(e.dataId);if(this.state.numTensors--,"string"===e.dtype&&(this.state.numStringTensors--,this.state.numBytes-=t.bytes),"complex64"!==e.dtype&&"string"!==e.dtype){const t=e.size*j(e.dtype);this.state.numBytes-=t}t.backend.disposeData(e.dataId)&&this.removeDataId(e.dataId,t.backend)}disposeVariables(){for(const e in this.state.registeredVariables){const t=this.state.registeredVariables[e];this.disposeVariable(t)}}disposeVariable(e){this.disposeTensor(e),null!=this.state.registeredVariables[e.name]&&delete this.state.registeredVariables[e.name]}memory(){const e=this.backend.memory();return e.numTensors=this.state.numTensors,e.numDataBuffers=this.state.numDataBuffers,e.numBytes=this.state.numBytes,this.state.numStringTensors>0&&(e.unreliable=!0,null==e.reasons&&(e.reasons=[]),e.reasons.push("Memory usage by string tensors is approximate (2 bytes per character)")),e}async profile(e){this.state.profiling=!0;const t=this.state.numBytes,n=this.state.numTensors;this.state.activeProfile.kernels=[],this.state.activeProfile.result=await e(),this.state.profiling=!1,this.state.activeProfile.peakBytes=Math.max(...this.state.activeProfile.kernels.map((e=>e.totalBytesSnapshot))),this.state.activeProfile.newBytes=this.state.numBytes-t,this.state.activeProfile.newTensors=this.state.numTensors-n;for(const e of this.state.activeProfile.kernels)e.kernelTimeMs=await e.kernelTimeMs,e.extraInfo=await e.extraInfo;return this.state.activeProfile}isTapeOn(){return this.state.gradientDepth>0&&0===this.state.kernelDepth}addTapeNode(e,t,n,a,i,s){const r={id:this.state.nextTapeNodeId++,kernelName:e,inputs:t,outputs:n,saved:i},o=mt(e);null!=o&&(a=o.gradFunc),null!=a&&(r.gradient=e=>(e=e.map(((e,t)=>{if(null==e){const e=n[t],a=P(e.size,e.dtype);return this.makeTensor(a,e.shape,e.dtype)}return e})),a(e.length>1?e:e[0],i,s))),this.state.activeTape.push(r)}keep(e){return e.kept=!0,e}startTape(){0===this.state.gradientDepth&&(this.state.activeTape=[]),this.state.gradientDepth++}endTape(){this.state.gradientDepth--}startScope(e){const t={track:[],name:"unnamed scope",id:this.state.nextScopeId++};e&&(t.name=e),this.state.scopeStack.push(t),this.state.activeScope=t}endScope(e){const t=Yt(e),n=new Set(t.map((e=>e.id)));for(let e=0;e<this.state.activeScope.track.length;e++){const t=this.state.activeScope.track[e];t.kept||n.has(t.id)||t.dispose()}const a=this.state.scopeStack.pop();this.state.activeScope=0===this.state.scopeStack.length?null:this.state.scopeStack[this.state.scopeStack.length-1],t.forEach((e=>{e.kept||e.scopeId!==a.id||this.track(e)}))}gradients(e,t,n,a=!1){if(x(t.length>0,(()=>"gradients() received an empty list of xs.")),null!=n&&"float32"!==n.dtype)throw new Error(`dy must have 'float32' dtype, but has '${n.dtype}'`);const i=this.scopedRun((()=>this.startTape()),(()=>this.endTape()),(()=>this.tidy("forward",e)));x(i instanceof Mt,(()=>"The result y returned by f() must be a tensor."));const s=function(e,t,n){const a={},i={};for(let e=0;e<t.length;e++)a[t[e].id]=!0;for(let n=0;n<e.length;n++){const s=e[n],r=s.inputs;for(const e in r){const n=r[e];let o=!1;for(let e=0;e<t.length;e++)if(a[n.id]){s.outputs.forEach((e=>a[e.id]=!0)),o=!0,i[s.id]=!0;break}if(o)break}}const s={};s[n.id]=!0;const r={};for(let t=e.length-1;t>=0;t--){const n=e[t],a=n.inputs;for(let e=0;e<n.outputs.length;e++)if(s[n.outputs[e].id]){for(const e in a)s[a[e].id]=!0,r[n.id]=!0;break}}const o=[];for(let t=0;t<e.length;t++){const n=e[t];if(i[n.id]&&r[n.id]){const e={};for(const t in n.inputs){const i=n.inputs[t];a[i.id]&&(e[t]=i)}const t=Object.assign({},n);t.inputs=e,t.outputs=n.outputs,o.push(t)}}return o}(this.state.activeTape,t,i);if(!a&&0===s.length&&t.length>0)throw new Error("Cannot compute gradient of y=f(x) with respect to x. Make sure that the f you passed encloses all operations that lead from x to y.");return this.tidy("backward",(()=>{const e={};e[i.id]=null==n?function(e){const t=O(N(e),"float32");return an.makeTensor(t,e,"float32")}(i.shape):n,function(e,t,n,a){for(let i=t.length-1;i>=0;i--){const s=t[i],r=[];if(s.outputs.forEach((t=>{const n=e[t.id];null!=n?r.push(n):r.push(null)})),null==s.gradient)throw new Error(`Cannot compute gradient: gradient function not found for ${s.kernelName}.`);const o=s.gradient(r);for(const t in s.inputs){if(!(t in o))throw new Error(`Cannot backprop through input ${t}. Available gradients found: ${Object.keys(o)}.`);const i=n((()=>o[t]()));if("float32"!==i.dtype)throw new Error(`Error in gradient for op ${s.kernelName}. The gradient of input ${t} must have 'float32' dtype, but has '${i.dtype}'`);const r=s.inputs[t];if(!T(i.shape,r.shape))throw new Error(`Error in gradient for op ${s.kernelName}. The gradient of input '${t}' has shape '${i.shape}', which does not match the shape of the input '${r.shape}'`);if(null==e[r.id])e[r.id]=i;else{const t=e[r.id];e[r.id]=a(t,i),t.dispose()}}}}
205
205
  /**
206
206
  * @license
207
207
  * Copyright 2018 Google LLC. All Rights Reserved.
@@ -395,7 +395,7 @@ function on(e,t){let n=e;if(Tt(e))return"string"===t?[]:[e.length];if(Ht(e)){con
395
395
  * See the License for the specific language governing permissions and
396
396
  * limitations under the License.
397
397
  * =============================================================================
398
- */();r=e(c)}}else{if("int32"!==a)throw new Error(`Unsupported dtype in weight '${n}': ${a}`);if("uint8"!==i.dtype&&"uint16"!==i.dtype)throw new Error(`Unsupported quantization type ${i.dtype} for weight type int32.`);r=new Int32Array(c.length);for(let e=0;e<c.length;e++){const t=c[e];r[e]=Math.round(t*i.scale+i.min)}}o+=s*l}else if("string"===a){const n=N(e.shape);r=[];for(let e=0;e<n;e++){const e=new Uint32Array(t.slice(o,o+4))[0];o+=4;const n=new Uint8Array(t.slice(o,o+e));r.push(n),o+=e}}else{const e=gn[a];if("float32"===a)r=new Float32Array(t);else if("int32"===a)r=new Int32Array(t);else{if("bool"!==a){if("complex64"===a){r=new Float32Array(t);const e=new Float32Array(r.length/2),n=new Float32Array(r.length/2);for(let t=0;t<e.length;t++)e[t]=r[2*t],n[t]=r[2*t+1];const a=mn(e,i,"float32"),s=mn(n,i,"float32"),o=dn(a,s);return a.dispose(),s.dispose(),o}throw new Error(`Unsupported dtype in weight '${n}': ${a}`)}r=new Uint8Array(t)}o+=s*e}return mn(r,i,a)}function In(e){if(null===e)throw new Error(`Invalid input value: ${JSON.stringify(e)}`);let t=0;const n=[];e.forEach((e=>{if(t+=e.byteLength,n.push(e.byteLength===e.buffer.byteLength?e:new e.constructor(e)),!(e instanceof Float32Array||e instanceof Int32Array||e instanceof Uint8Array))throw new Error(`Unsupported TypedArray subtype: ${e.constructor.name}`)}));const a=new Uint8Array(t);let i=0;return n.forEach((e=>{a.set(new Uint8Array(e.buffer),i),i+=e.byteLength})),a.buffer}const $n="undefined"!=typeof Buffer&&("undefined"==typeof Blob||"undefined"==typeof atob||"undefined"==typeof btoa);function Cn(e){return $n?Buffer.byteLength(e,"utf8"):new Blob([e]).size}async function An(e,t){let n,a;return null!=e.weightsManifest&&([n,a]=await t(e.weightsManifest)),function(e,t,n){const a={modelTopology:e.modelTopology,format:e.format,generatedBy:e.generatedBy,convertedBy:e.convertedBy};if(null!=e.trainingConfig&&(a.trainingConfig=e.trainingConfig),null!=e.weightsManifest){if(!t)throw new Error("modelJSON has weightsManifest but weightSpecs is null");if(!n)throw new Error("modelJSON has weightsManifest but weightData is null");a.weightSpecs=t,a.weightData=n}return null!=e.signature&&(a.signature=e.signature),null!=e.userDefinedMetadata&&(a.userDefinedMetadata=e.userDefinedMetadata),null!=e.modelInitializer&&(a.modelInitializer=e.modelInitializer),null!=e.initializerSignature&&(a.initializerSignature=e.initializerSignature),a}(e,n,a)}function En(e){if(e.modelTopology instanceof ArrayBuffer)throw new Error("Expected JSON model topology, received ArrayBuffer.");return{dateSaved:new Date,modelTopologyType:"JSON",modelTopologyBytes:null==e.modelTopology?0:Cn(JSON.stringify(e.modelTopology)),weightSpecsBytes:null==e.weightSpecs?0:Cn(JSON.stringify(e.weightSpecs)),weightDataBytes:null==e.weightData?0:new vn(e.weightData).byteLength}}function jn(e){const t=[];for(const n of e)t.push(...n.weights);return t}class zn{constructor(){this.saveRouters=[],this.loadRouters=[]}static getInstance(){return null==zn.instance&&(zn.instance=new zn),zn.instance}static registerSaveRouter(e){zn.getInstance().saveRouters.push(e)}static registerLoadRouter(e){zn.getInstance().loadRouters.push(e)}static getSaveHandlers(e){return zn.getHandlers(e,"save")}static getLoadHandlers(e,t){return zn.getHandlers(e,"load",t)}static getHandlers(e,t,n){const a=[];return("load"===t?zn.getInstance().loadRouters:zn.getInstance().saveRouters).forEach((t=>{const i=t(e,n);null!==i&&a.push(i)})),a}}const Dn="tensorflowjs",Fn="models_store",_n="model_info_store";function Rn(){if(!H().getBool("IS_BROWSER"))throw new Error("Failed to obtain IndexedDB factory because the current environmentis not a web browser.");const e="undefined"==typeof window?self:window,t=e.indexedDB||e.mozIndexedDB||e.webkitIndexedDB||e.msIndexedDB||e.shimIndexedDB;if(null==t)throw new Error("The current browser does not appear to support IndexedDB.");return t}function Ln(e){const t=e.result;t.createObjectStore(Fn,{keyPath:"modelPath"}),t.createObjectStore(_n,{keyPath:"modelPath"})}class Mn{constructor(e){if(this.indexedDB=Rn(),null==e||!e)throw new Error("For IndexedDB, modelPath must not be null, undefined or empty.");this.modelPath=e}async save(e){if(e.modelTopology instanceof ArrayBuffer)throw new Error("BrowserLocalStorage.save() does not support saving model topology in binary formats yet.");return this.databaseAction(this.modelPath,e)}async load(){return this.databaseAction(this.modelPath)}databaseAction(e,t){return new Promise(((e,n)=>{const a=this.indexedDB.open(Dn,1);a.onupgradeneeded=()=>Ln(a),a.onsuccess=()=>{const i=a.result;if(null==t){const t=i.transaction(Fn,"readonly"),a=t.objectStore(Fn).get(this.modelPath);a.onsuccess=()=>{if(null==a.result)return i.close(),n(new Error(`Cannot find model with path '${this.modelPath}' in IndexedDB.`));e(a.result.modelArtifacts)},a.onerror=e=>(i.close(),n(a.error)),t.oncomplete=()=>i.close()}else{t.weightData=vn.join(t.weightData);const a=En(t),s=i.transaction(_n,"readwrite");let r,o,l=s.objectStore(_n);try{r=l.put({modelPath:this.modelPath,modelArtifactsInfo:a})}catch(e){return n(e)}r.onsuccess=()=>{o=i.transaction(Fn,"readwrite");const r=o.objectStore(Fn);let c;try{c=r.put({modelPath:this.modelPath,modelArtifacts:t,modelArtifactsInfo:a})}catch(e){return n(e)}c.onsuccess=()=>e({modelArtifactsInfo:a}),c.onerror=e=>{l=s.objectStore(_n);const t=l.delete(this.modelPath);t.onsuccess=()=>(i.close(),n(c.error)),t.onerror=e=>(i.close(),n(c.error))}},r.onerror=e=>(i.close(),n(r.error)),s.oncomplete=()=>{null==o?i.close():o.oncomplete=()=>i.close()}}},a.onerror=e=>n(a.error)}))}}Mn.URL_SCHEME="indexeddb://";const On=e=>{return H().getBool("IS_BROWSER")&&!Array.isArray(e)&&e.startsWith(Mn.URL_SCHEME)?(t=e.slice(Mn.URL_SCHEME.length),new Mn(t)):null;var t};zn.registerSaveRouter(On),zn.registerLoadRouter(On);class Pn{constructor(){this.indexedDB=Rn()}async listModels(){return new Promise(((e,t)=>{const n=this.indexedDB.open(Dn,1);n.onupgradeneeded=()=>Ln(n),n.onsuccess=()=>{const a=n.result,i=a.transaction(_n,"readonly"),s=i.objectStore(_n).getAll();s.onsuccess=()=>{const t={};for(const e of s.result)t[e.modelPath]=e.modelArtifactsInfo;e(t)},s.onerror=e=>(a.close(),t(s.error)),i.oncomplete=()=>a.close()},n.onerror=e=>t(n.error)}))}async removeModel(e){var t;return e=(t=e).startsWith(Mn.URL_SCHEME)?t.slice(Mn.URL_SCHEME.length):t,new Promise(((t,n)=>{const a=this.indexedDB.open(Dn,1);a.onupgradeneeded=()=>Ln(a),a.onsuccess=()=>{const i=a.result,s=i.transaction(_n,"readwrite"),r=s.objectStore(_n),o=r.get(e);let l;o.onsuccess=()=>{if(null==o.result)return i.close(),n(new Error(`Cannot find model with path '${e}' in IndexedDB.`));{const a=r.delete(e),s=()=>{l=i.transaction(Fn,"readwrite");const a=l.objectStore(Fn).delete(e);a.onsuccess=()=>t(o.result.modelArtifactsInfo),a.onerror=e=>n(o.error)};a.onsuccess=s,a.onerror=e=>(s(),i.close(),n(o.error))}},o.onerror=e=>(i.close(),n(o.error)),s.oncomplete=()=>{null==l?i.close():l.oncomplete=()=>i.close()}},a.onerror=e=>n(a.error)}))}}
398
+ */();r=e(c)}}else{if("int32"!==a)throw new Error(`Unsupported dtype in weight '${n}': ${a}`);if("uint8"!==i.dtype&&"uint16"!==i.dtype)throw new Error(`Unsupported quantization type ${i.dtype} for weight type int32.`);r=new Int32Array(c.length);for(let e=0;e<c.length;e++){const t=c[e];r[e]=Math.round(t*i.scale+i.min)}}o+=s*l}else if("string"===a){const n=N(e.shape);r=[];for(let e=0;e<n;e++){const e=new Uint32Array(t.slice(o,o+4))[0];o+=4;const n=new Uint8Array(t.slice(o,o+e));r.push(n),o+=e}}else{const e=gn[a];if("float32"===a)r=new Float32Array(t);else if("int32"===a)r=new Int32Array(t);else{if("bool"!==a){if("complex64"===a){r=new Float32Array(t);const e=new Float32Array(r.length/2),n=new Float32Array(r.length/2);for(let t=0;t<e.length;t++)e[t]=r[2*t],n[t]=r[2*t+1];const a=mn(e,i,"float32"),s=mn(n,i,"float32"),o=dn(a,s);return a.dispose(),s.dispose(),o}throw new Error(`Unsupported dtype in weight '${n}': ${a}`)}r=new Uint8Array(t)}o+=s*e}return mn(r,i,a)}function In(e){if(null===e)throw new Error(`Invalid input value: ${JSON.stringify(e)}`);let t=0;const n=[];e.forEach((e=>{if(t+=e.byteLength,n.push(e.byteLength===e.buffer.byteLength?e:new e.constructor(e)),!(e instanceof Float32Array||e instanceof Int32Array||e instanceof Uint8Array))throw new Error(`Unsupported TypedArray subtype: ${e.constructor.name}`)}));const a=new Uint8Array(t);let i=0;return n.forEach((e=>{a.set(new Uint8Array(e.buffer),i),i+=e.byteLength})),a.buffer}const Cn="undefined"!=typeof Buffer&&("undefined"==typeof Blob||"undefined"==typeof atob||"undefined"==typeof btoa);function $n(e){return Cn?Buffer.byteLength(e,"utf8"):new Blob([e]).size}async function An(e,t){let n,a;return null!=e.weightsManifest&&([n,a]=await t(e.weightsManifest)),function(e,t,n){const a={modelTopology:e.modelTopology,format:e.format,generatedBy:e.generatedBy,convertedBy:e.convertedBy};if(null!=e.trainingConfig&&(a.trainingConfig=e.trainingConfig),null!=e.weightsManifest){if(!t)throw new Error("modelJSON has weightsManifest but weightSpecs is null");if(!n)throw new Error("modelJSON has weightsManifest but weightData is null");a.weightSpecs=t,a.weightData=n}return null!=e.signature&&(a.signature=e.signature),null!=e.userDefinedMetadata&&(a.userDefinedMetadata=e.userDefinedMetadata),null!=e.modelInitializer&&(a.modelInitializer=e.modelInitializer),null!=e.initializerSignature&&(a.initializerSignature=e.initializerSignature),a}(e,n,a)}function En(e){if(e.modelTopology instanceof ArrayBuffer)throw new Error("Expected JSON model topology, received ArrayBuffer.");return{dateSaved:new Date,modelTopologyType:"JSON",modelTopologyBytes:null==e.modelTopology?0:$n(JSON.stringify(e.modelTopology)),weightSpecsBytes:null==e.weightSpecs?0:$n(JSON.stringify(e.weightSpecs)),weightDataBytes:null==e.weightData?0:new vn(e.weightData).byteLength}}function jn(e){const t=[];for(const n of e)t.push(...n.weights);return t}class zn{constructor(){this.saveRouters=[],this.loadRouters=[]}static getInstance(){return null==zn.instance&&(zn.instance=new zn),zn.instance}static registerSaveRouter(e){zn.getInstance().saveRouters.push(e)}static registerLoadRouter(e){zn.getInstance().loadRouters.push(e)}static getSaveHandlers(e){return zn.getHandlers(e,"save")}static getLoadHandlers(e,t){return zn.getHandlers(e,"load",t)}static getHandlers(e,t,n){const a=[];return("load"===t?zn.getInstance().loadRouters:zn.getInstance().saveRouters).forEach((t=>{const i=t(e,n);null!==i&&a.push(i)})),a}}const Dn="tensorflowjs",Fn="models_store",_n="model_info_store";function Rn(){if(!H().getBool("IS_BROWSER"))throw new Error("Failed to obtain IndexedDB factory because the current environmentis not a web browser.");const e="undefined"==typeof window?self:window,t=e.indexedDB||e.mozIndexedDB||e.webkitIndexedDB||e.msIndexedDB||e.shimIndexedDB;if(null==t)throw new Error("The current browser does not appear to support IndexedDB.");return t}function Ln(e){const t=e.result;t.createObjectStore(Fn,{keyPath:"modelPath"}),t.createObjectStore(_n,{keyPath:"modelPath"})}class Mn{constructor(e){if(this.indexedDB=Rn(),null==e||!e)throw new Error("For IndexedDB, modelPath must not be null, undefined or empty.");this.modelPath=e}async save(e){if(e.modelTopology instanceof ArrayBuffer)throw new Error("BrowserLocalStorage.save() does not support saving model topology in binary formats yet.");return this.databaseAction(this.modelPath,e)}async load(){return this.databaseAction(this.modelPath)}databaseAction(e,t){return new Promise(((e,n)=>{const a=this.indexedDB.open(Dn,1);a.onupgradeneeded=()=>Ln(a),a.onsuccess=()=>{const i=a.result;if(null==t){const t=i.transaction(Fn,"readonly"),a=t.objectStore(Fn).get(this.modelPath);a.onsuccess=()=>{if(null==a.result)return i.close(),n(new Error(`Cannot find model with path '${this.modelPath}' in IndexedDB.`));e(a.result.modelArtifacts)},a.onerror=e=>(i.close(),n(a.error)),t.oncomplete=()=>i.close()}else{t.weightData=vn.join(t.weightData);const a=En(t),s=i.transaction(_n,"readwrite");let r,o,l=s.objectStore(_n);try{r=l.put({modelPath:this.modelPath,modelArtifactsInfo:a})}catch(e){return n(e)}r.onsuccess=()=>{o=i.transaction(Fn,"readwrite");const r=o.objectStore(Fn);let c;try{c=r.put({modelPath:this.modelPath,modelArtifacts:t,modelArtifactsInfo:a})}catch(e){return n(e)}c.onsuccess=()=>e({modelArtifactsInfo:a}),c.onerror=e=>{l=s.objectStore(_n);const t=l.delete(this.modelPath);t.onsuccess=()=>(i.close(),n(c.error)),t.onerror=e=>(i.close(),n(c.error))}},r.onerror=e=>(i.close(),n(r.error)),s.oncomplete=()=>{null==o?i.close():o.oncomplete=()=>i.close()}}},a.onerror=e=>n(a.error)}))}}Mn.URL_SCHEME="indexeddb://";const On=e=>{return H().getBool("IS_BROWSER")&&!Array.isArray(e)&&e.startsWith(Mn.URL_SCHEME)?(t=e.slice(Mn.URL_SCHEME.length),new Mn(t)):null;var t};zn.registerSaveRouter(On),zn.registerLoadRouter(On);class Pn{constructor(){this.indexedDB=Rn()}async listModels(){return new Promise(((e,t)=>{const n=this.indexedDB.open(Dn,1);n.onupgradeneeded=()=>Ln(n),n.onsuccess=()=>{const a=n.result,i=a.transaction(_n,"readonly"),s=i.objectStore(_n).getAll();s.onsuccess=()=>{const t={};for(const e of s.result)t[e.modelPath]=e.modelArtifactsInfo;e(t)},s.onerror=e=>(a.close(),t(s.error)),i.oncomplete=()=>a.close()},n.onerror=e=>t(n.error)}))}async removeModel(e){var t;return e=(t=e).startsWith(Mn.URL_SCHEME)?t.slice(Mn.URL_SCHEME.length):t,new Promise(((t,n)=>{const a=this.indexedDB.open(Dn,1);a.onupgradeneeded=()=>Ln(a),a.onsuccess=()=>{const i=a.result,s=i.transaction(_n,"readwrite"),r=s.objectStore(_n),o=r.get(e);let l;o.onsuccess=()=>{if(null==o.result)return i.close(),n(new Error(`Cannot find model with path '${e}' in IndexedDB.`));{const a=r.delete(e),s=()=>{l=i.transaction(Fn,"readwrite");const a=l.objectStore(Fn).delete(e);a.onsuccess=()=>t(o.result.modelArtifactsInfo),a.onerror=e=>n(o.error)};a.onsuccess=s,a.onerror=e=>(s(),i.close(),n(o.error))}},o.onerror=e=>(i.close(),n(o.error)),s.oncomplete=()=>{null==l?i.close():l.oncomplete=()=>i.close()}},a.onerror=e=>n(a.error)}))}}
399
399
  /**
400
400
  * @license
401
401
  * Copyright 2018 Google LLC. All Rights Reserved.
@@ -411,7 +411,7 @@ function on(e,t){let n=e;if(Tt(e))return"string"===t?[]:[e.length];if(Ht(e)){con
411
411
  * See the License for the specific language governing permissions and
412
412
  * limitations under the License.
413
413
  * =============================================================================
414
- */const Bn="/",Un="tensorflowjs_models",Wn="info",Gn="model_topology",Vn="weight_specs",Kn="weight_data",qn="model_metadata";function Hn(e){return{info:[Un,e,Wn].join(Bn),topology:[Un,e,Gn].join(Bn),weightSpecs:[Un,e,Vn].join(Bn),weightData:[Un,e,Kn].join(Bn),modelMetadata:[Un,e,qn].join(Bn)}}function Jn(e){for(const t of Object.values(e))window.localStorage.removeItem(t)}function Zn(e){const t=e.split(Bn);if(t.length<3)throw new Error(`Invalid key format: ${e}`);return t.slice(1,t.length-1).join(Bn)}class Yn{constructor(e){if(!H().getBool("IS_BROWSER")||"undefined"==typeof window||void 0===window.localStorage)throw new Error("The current environment does not support local storage.");if(this.LS=window.localStorage,null==e||!e)throw new Error("For local storage, modelPath must not be null, undefined or empty.");this.modelPath=e,this.keys=Hn(this.modelPath)}async save(e){if(e.modelTopology instanceof ArrayBuffer)throw new Error("BrowserLocalStorage.save() does not support saving model topology in binary formats yet.");{const t=JSON.stringify(e.modelTopology),n=JSON.stringify(e.weightSpecs),a=En(e),i=vn.join(e.weightData);try{this.LS.setItem(this.keys.info,JSON.stringify(a)),this.LS.setItem(this.keys.topology,t),this.LS.setItem(this.keys.weightSpecs,n),this.LS.setItem(this.keys.weightData,function(e){if($n)return Buffer.from(e).toString("base64");const t=new Uint8Array(e);let n="";for(let e=0,a=t.length;e<a;e++)n+=String.fromCharCode(t[e]);return btoa(n)}(i));const s={format:e.format,generatedBy:e.generatedBy,convertedBy:e.convertedBy,signature:null!=e.signature?e.signature:void 0,userDefinedMetadata:null!=e.userDefinedMetadata?e.userDefinedMetadata:void 0,modelInitializer:null!=e.modelInitializer?e.modelInitializer:void 0,initializerSignature:null!=e.initializerSignature?e.initializerSignature:void 0,trainingConfig:null!=e.trainingConfig?e.trainingConfig:void 0};return this.LS.setItem(this.keys.modelMetadata,JSON.stringify(s)),{modelArtifactsInfo:a}}catch(e){throw Jn(this.keys),new Error(`Failed to save model '${this.modelPath}' to local storage: size quota being exceeded is a possible cause of this failure: modelTopologyBytes=${a.modelTopologyBytes}, weightSpecsBytes=${a.weightSpecsBytes}, weightDataBytes=${a.weightDataBytes}.`)}}}async load(){const e=JSON.parse(this.LS.getItem(this.keys.info));if(null==e)throw new Error(`In local storage, there is no model with name '${this.modelPath}'`);if("JSON"!==e.modelTopologyType)throw new Error("BrowserLocalStorage does not support loading non-JSON model topology yet.");const t={},n=JSON.parse(this.LS.getItem(this.keys.topology));if(null==n)throw new Error(`In local storage, the topology of model '${this.modelPath}' is missing.`);t.modelTopology=n;const a=JSON.parse(this.LS.getItem(this.keys.weightSpecs));if(null==a)throw new Error(`In local storage, the weight specs of model '${this.modelPath}' are missing.`);t.weightSpecs=a;const i=this.LS.getItem(this.keys.modelMetadata);if(null!=i){const e=JSON.parse(i);t.format=e.format,t.generatedBy=e.generatedBy,t.convertedBy=e.convertedBy,null!=e.signature&&(t.signature=e.signature),null!=e.userDefinedMetadata&&(t.userDefinedMetadata=e.userDefinedMetadata),null!=e.modelInitializer&&(t.modelInitializer=e.modelInitializer),null!=e.initializerSignature&&(t.initializerSignature=e.initializerSignature),null!=e.trainingConfig&&(t.trainingConfig=e.trainingConfig)}const s=this.LS.getItem(this.keys.weightData);if(null==s)throw new Error(`In local storage, the binary weight values of model '${this.modelPath}' are missing.`);return t.weightData=function(e){if($n){const t=Buffer.from(e,"base64");return t.buffer.slice(t.byteOffset,t.byteOffset+t.byteLength)}const t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;++e)n.set([t.charCodeAt(e)],e);return n.buffer}(s),t}}Yn.URL_SCHEME="localstorage://";const Qn=e=>{return H().getBool("IS_BROWSER")&&!Array.isArray(e)&&e.startsWith(Yn.URL_SCHEME)?(t=e.slice(Yn.URL_SCHEME.length),new Yn(t)):null;var t};zn.registerSaveRouter(Qn),zn.registerLoadRouter(Qn);class Xn{constructor(){x(H().getBool("IS_BROWSER"),(()=>"Current environment is not a web browser")),x("undefined"==typeof window||void 0!==window.localStorage,(()=>"Current browser does not appear to support localStorage")),this.LS=window.localStorage}async listModels(){const e={},t=Un+Bn,n=Bn+Wn;for(let a=0;a<this.LS.length;++a){const i=this.LS.key(a);if(i.startsWith(t)&&i.endsWith(n)){e[Zn(i)]=JSON.parse(this.LS.getItem(i))}}return e}async removeModel(e){var t;const n=Hn(e=(t=e).startsWith(Yn.URL_SCHEME)?t.slice(Yn.URL_SCHEME.length):t);if(null==this.LS.getItem(n.info))throw new Error(`Cannot find model at path '${e}'`);const a=JSON.parse(this.LS.getItem(n.info));return Jn(n),a}}
414
+ */const Bn="/",Un="tensorflowjs_models",Wn="info",Gn="model_topology",Vn="weight_specs",Kn="weight_data",qn="model_metadata";function Hn(e){return{info:[Un,e,Wn].join(Bn),topology:[Un,e,Gn].join(Bn),weightSpecs:[Un,e,Vn].join(Bn),weightData:[Un,e,Kn].join(Bn),modelMetadata:[Un,e,qn].join(Bn)}}function Jn(e){for(const t of Object.values(e))window.localStorage.removeItem(t)}function Zn(e){const t=e.split(Bn);if(t.length<3)throw new Error(`Invalid key format: ${e}`);return t.slice(1,t.length-1).join(Bn)}class Yn{constructor(e){if(!H().getBool("IS_BROWSER")||"undefined"==typeof window||void 0===window.localStorage)throw new Error("The current environment does not support local storage.");if(this.LS=window.localStorage,null==e||!e)throw new Error("For local storage, modelPath must not be null, undefined or empty.");this.modelPath=e,this.keys=Hn(this.modelPath)}async save(e){if(e.modelTopology instanceof ArrayBuffer)throw new Error("BrowserLocalStorage.save() does not support saving model topology in binary formats yet.");{const t=JSON.stringify(e.modelTopology),n=JSON.stringify(e.weightSpecs),a=En(e),i=vn.join(e.weightData);try{this.LS.setItem(this.keys.info,JSON.stringify(a)),this.LS.setItem(this.keys.topology,t),this.LS.setItem(this.keys.weightSpecs,n),this.LS.setItem(this.keys.weightData,function(e){if(Cn)return Buffer.from(e).toString("base64");const t=new Uint8Array(e);let n="";for(let e=0,a=t.length;e<a;e++)n+=String.fromCharCode(t[e]);return btoa(n)}(i));const s={format:e.format,generatedBy:e.generatedBy,convertedBy:e.convertedBy,signature:null!=e.signature?e.signature:void 0,userDefinedMetadata:null!=e.userDefinedMetadata?e.userDefinedMetadata:void 0,modelInitializer:null!=e.modelInitializer?e.modelInitializer:void 0,initializerSignature:null!=e.initializerSignature?e.initializerSignature:void 0,trainingConfig:null!=e.trainingConfig?e.trainingConfig:void 0};return this.LS.setItem(this.keys.modelMetadata,JSON.stringify(s)),{modelArtifactsInfo:a}}catch(e){throw Jn(this.keys),new Error(`Failed to save model '${this.modelPath}' to local storage: size quota being exceeded is a possible cause of this failure: modelTopologyBytes=${a.modelTopologyBytes}, weightSpecsBytes=${a.weightSpecsBytes}, weightDataBytes=${a.weightDataBytes}.`)}}}async load(){const e=JSON.parse(this.LS.getItem(this.keys.info));if(null==e)throw new Error(`In local storage, there is no model with name '${this.modelPath}'`);if("JSON"!==e.modelTopologyType)throw new Error("BrowserLocalStorage does not support loading non-JSON model topology yet.");const t={},n=JSON.parse(this.LS.getItem(this.keys.topology));if(null==n)throw new Error(`In local storage, the topology of model '${this.modelPath}' is missing.`);t.modelTopology=n;const a=JSON.parse(this.LS.getItem(this.keys.weightSpecs));if(null==a)throw new Error(`In local storage, the weight specs of model '${this.modelPath}' are missing.`);t.weightSpecs=a;const i=this.LS.getItem(this.keys.modelMetadata);if(null!=i){const e=JSON.parse(i);t.format=e.format,t.generatedBy=e.generatedBy,t.convertedBy=e.convertedBy,null!=e.signature&&(t.signature=e.signature),null!=e.userDefinedMetadata&&(t.userDefinedMetadata=e.userDefinedMetadata),null!=e.modelInitializer&&(t.modelInitializer=e.modelInitializer),null!=e.initializerSignature&&(t.initializerSignature=e.initializerSignature),null!=e.trainingConfig&&(t.trainingConfig=e.trainingConfig)}const s=this.LS.getItem(this.keys.weightData);if(null==s)throw new Error(`In local storage, the binary weight values of model '${this.modelPath}' are missing.`);return t.weightData=function(e){if(Cn){const t=Buffer.from(e,"base64");return t.buffer.slice(t.byteOffset,t.byteOffset+t.byteLength)}const t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;++e)n.set([t.charCodeAt(e)],e);return n.buffer}(s),t}}Yn.URL_SCHEME="localstorage://";const Qn=e=>{return H().getBool("IS_BROWSER")&&!Array.isArray(e)&&e.startsWith(Yn.URL_SCHEME)?(t=e.slice(Yn.URL_SCHEME.length),new Yn(t)):null;var t};zn.registerSaveRouter(Qn),zn.registerLoadRouter(Qn);class Xn{constructor(){x(H().getBool("IS_BROWSER"),(()=>"Current environment is not a web browser")),x("undefined"==typeof window||void 0!==window.localStorage,(()=>"Current browser does not appear to support localStorage")),this.LS=window.localStorage}async listModels(){const e={},t=Un+Bn,n=Bn+Wn;for(let a=0;a<this.LS.length;++a){const i=this.LS.key(a);if(i.startsWith(t)&&i.endsWith(n)){e[Zn(i)]=JSON.parse(this.LS.getItem(i))}}return e}async removeModel(e){var t;const n=Hn(e=(t=e).startsWith(Yn.URL_SCHEME)?t.slice(Yn.URL_SCHEME.length):t);if(null==this.LS.getItem(n.info))throw new Error(`Cannot find model at path '${e}'`);const a=JSON.parse(this.LS.getItem(n.info));return Jn(n),a}}
415
415
  /**
416
416
  * @license
417
417
  * Copyright 2019 Google LLC. All Rights Reserved.
@@ -715,7 +715,7 @@ function on(e,t){let n=e;if(Tt(e))return"string"===t?[]:[e.length];if(Ht(e)){con
715
715
  * See the License for the specific language governing permissions and
716
716
  * limitations under the License.
717
717
  * =============================================================================
718
- */const $a=pn({all_:function(e,t=null,n=!1){const a={x:un(e,"x","all","bool")},i={axis:t,keepDims:n};return an.runKernel("All",a,i)}});
718
+ */const Ca=pn({all_:function(e,t=null,n=!1){const a={x:un(e,"x","all","bool")},i={axis:t,keepDims:n};return an.runKernel("All",a,i)}});
719
719
  /**
720
720
  * @license
721
721
  * Copyright 2020 Google LLC. All Rights Reserved.
@@ -731,7 +731,7 @@ function on(e,t){let n=e;if(Tt(e))return"string"===t?[]:[e.length];if(Ht(e)){con
731
731
  * See the License for the specific language governing permissions and
732
732
  * limitations under the License.
733
733
  * =============================================================================
734
- */const Ca=pn({any_:function(e,t=null,n=!1){const a={x:un(e,"x","any","bool")},i={axis:t,keepDims:n};return an.runKernel("Any",a,i)}});
734
+ */const $a=pn({any_:function(e,t=null,n=!1){const a={x:un(e,"x","any","bool")},i={axis:t,keepDims:n};return an.runKernel("Any",a,i)}});
735
735
  /**
736
736
  * @license
737
737
  * Copyright 2020 Google Inc. All Rights Reserved.
@@ -1276,7 +1276,7 @@ function(e,t,n,a,i,s){null==s&&(s=.001);const r=un(e,"x","batchNorm"),o=un(t,"me
1276
1276
  * See the License for the specific language governing permissions and
1277
1277
  * limitations under the License.
1278
1278
  * =============================================================================
1279
- */function Ti(e,t){for(let n=0;n<e.length;++n)if(e[e.length-n-1]!==t-1-n)return!1;return!0}function Ii(e,t){const n=[],a=e.length;for(let i=0;i<a;i++)-1===t.indexOf(i)&&n.push(e[i]);return[n,t.map((t=>e[t]))]}function $i(e,t){return function(e,t,n){const a=e.length+t.length,i=[];let s=0,r=0;for(let o=0;o<a;o++)-1===n.indexOf(o)?i.push(e[s++]):i.push(t[r++]);return i}(e,t.map((e=>1)),t)}function Ci(e,t){if(Ti(e,t))return null;const n=[];for(let a=0;a<t;++a)-1===e.indexOf(a)&&n.push(a);return e.forEach((e=>n.push(e))),n}function Ai(e){return e.map(((e,t)=>[t,e])).sort(((e,t)=>e[1]-t[1])).map((e=>e[0]))}const Ei=pn({max_:
1279
+ */function Ti(e,t){for(let n=0;n<e.length;++n)if(e[e.length-n-1]!==t-1-n)return!1;return!0}function Ii(e,t){const n=[],a=e.length;for(let i=0;i<a;i++)-1===t.indexOf(i)&&n.push(e[i]);return[n,t.map((t=>e[t]))]}function Ci(e,t){return function(e,t,n){const a=e.length+t.length,i=[];let s=0,r=0;for(let o=0;o<a;o++)-1===n.indexOf(o)?i.push(e[s++]):i.push(t[r++]);return i}(e,t.map((e=>1)),t)}function $i(e,t){if(Ti(e,t))return null;const n=[];for(let a=0;a<t;++a)-1===e.indexOf(a)&&n.push(a);return e.forEach((e=>n.push(e))),n}function Ai(e){return e.map(((e,t)=>[t,e])).sort(((e,t)=>e[1]-t[1])).map((e=>e[0]))}const Ei=pn({max_:
1280
1280
  /**
1281
1281
  * @license
1282
1282
  * Copyright 2020 Google LLC. All Rights Reserved.
@@ -1405,7 +1405,7 @@ function(e,t=null,n=!1){const a={x:un(e,"x","max")},i={reductionIndices:t,keepDi
1405
1405
  * See the License for the specific language governing permissions and
1406
1406
  * limitations under the License.
1407
1407
  * =============================================================================
1408
- */function Li(e,t,n=null){if(0===e.rank)return Ia(e);if(1!==e.rank&&null===n)return Li(Ma(e,[-1]),t,n);if(1===e.rank||"number"==typeof n||Array.isArray(n)&&1===n.length){if(1===t)return Ri(Ia(e),n);if(t===1/0)return Ei(Ia(e),n);if(t===-1/0)return ji(Ia(e),n);if("euclidean"===t||2===t)return Fi(Ri(zi(Ia(e),Di(2,"int32")),n));throw new Error(`Error in norm: invalid ord value: ${t}`)}if(Array.isArray(n)&&2===n.length){if(1===t)return Ei(Ri(Ia(e),n[0]),n[1]-1);if(t===1/0)return Ei(Ri(Ia(e),n[1]),n[0]);if(t===-1/0)return ji(Ri(Ia(e),n[1]),n[0]);if("fro"===t||"euclidean"===t)return Fi(Ri(_i(e),n));throw new Error(`Error in norm: invalid ord value: ${t}`)}throw new Error(`Error in norm: invalid axis: ${n}`)}const Mi=pn({norm_:function(e,t="euclidean",n=null,a=!1){const i=Li(e=un(e,"x","norm"),t,n);let s=i.shape;if(a){const t=C(n,e.shape);s=$i(i.shape,t)}return Ma(i,s)}});
1408
+ */function Li(e,t,n=null){if(0===e.rank)return Ia(e);if(1!==e.rank&&null===n)return Li(Ma(e,[-1]),t,n);if(1===e.rank||"number"==typeof n||Array.isArray(n)&&1===n.length){if(1===t)return Ri(Ia(e),n);if(t===1/0)return Ei(Ia(e),n);if(t===-1/0)return ji(Ia(e),n);if("euclidean"===t||2===t)return Fi(Ri(zi(Ia(e),Di(2,"int32")),n));throw new Error(`Error in norm: invalid ord value: ${t}`)}if(Array.isArray(n)&&2===n.length){if(1===t)return Ei(Ri(Ia(e),n[0]),n[1]-1);if(t===1/0)return Ei(Ri(Ia(e),n[1]),n[0]);if(t===-1/0)return ji(Ri(Ia(e),n[1]),n[0]);if("fro"===t||"euclidean"===t)return Fi(Ri(_i(e),n));throw new Error(`Error in norm: invalid ord value: ${t}`)}throw new Error(`Error in norm: invalid axis: ${n}`)}const Mi=pn({norm_:function(e,t="euclidean",n=null,a=!1){const i=Li(e=un(e,"x","norm"),t,n);let s=i.shape;if(a){const t=$(n,e.shape);s=Ci(i.shape,t)}return Ma(i,s)}});
1409
1409
  /**
1410
1410
  * @license
1411
1411
  * Copyright 2018 Google LLC. All Rights Reserved.
@@ -1693,7 +1693,7 @@ function(e,t=null,n=!1){const a={x:un(e,"x","max")},i={reductionIndices:t,keepDi
1693
1693
  * See the License for the specific language governing permissions and
1694
1694
  * limitations under the License.
1695
1695
  * =============================================================================
1696
- */const ns=pn({logSumExp_:function(e,t=null,n=!1){const a=un(e,"x","logSumExp"),i=C(t,a.shape),s=Ei(a,i,!0),r=es(a,s),o=Oi(r),l=Ri(o,i),c=Zi(l),u=xa(Ma(s,c.shape),c);if(n){const e=$i(u.shape,i);return Ma(u,e)}return u}});
1696
+ */const ns=pn({logSumExp_:function(e,t=null,n=!1){const a=un(e,"x","logSumExp"),i=$(t,a.shape),s=Ei(a,i,!0),r=es(a,s),o=Oi(r),l=Ri(o,i),c=Zi(l),u=xa(Ma(s,c.shape),c);if(n){const e=Ci(u.shape,i);return Ma(u,e)}return u}});
1697
1697
  /**
1698
1698
  * @license
1699
1699
  * Copyright 2020 Google LLC. All Rights Reserved.
@@ -1741,7 +1741,7 @@ function(e,t=null,n=!1){const a={x:un(e,"x","max")},i={reductionIndices:t,keepDi
1741
1741
  * See the License for the specific language governing permissions and
1742
1742
  * limitations under the License.
1743
1743
  * =============================================================================
1744
- */const ss=pn({maxPool_:function(e,t,n,a,i){const s=un(e,"x","maxPool");let r=s,o=!1;3===s.rank&&(o=!0,r=Ma(s,[1,s.shape[0],s.shape[1],s.shape[2]])),x(4===r.rank,(()=>`Error in maxPool: input must be rank 4 but got rank ${r.rank}.`)),x(_a(n,1),(()=>`Error in maxPool: Either strides or dilations must be 1. Got strides ${n} and dilations '1'`)),La("maxPool",a,i);const l={x:r},c={filterSize:t,strides:n,pad:a,dimRoundingMode:i},u=an.runKernel($e,l,c);return o?Ma(u,[u.shape[1],u.shape[2],u.shape[3]]):u}});
1744
+ */const ss=pn({maxPool_:function(e,t,n,a,i){const s=un(e,"x","maxPool");let r=s,o=!1;3===s.rank&&(o=!0,r=Ma(s,[1,s.shape[0],s.shape[1],s.shape[2]])),x(4===r.rank,(()=>`Error in maxPool: input must be rank 4 but got rank ${r.rank}.`)),x(_a(n,1),(()=>`Error in maxPool: Either strides or dilations must be 1. Got strides ${n} and dilations '1'`)),La("maxPool",a,i);const l={x:r},c={filterSize:t,strides:n,pad:a,dimRoundingMode:i},u=an.runKernel(Ce,l,c);return o?Ma(u,[u.shape[1],u.shape[2],u.shape[3]]):u}});
1745
1745
  /**
1746
1746
  * @license
1747
1747
  * Copyright 2020 Google LLC. All Rights Reserved.
@@ -1757,7 +1757,7 @@ function(e,t=null,n=!1){const a={x:un(e,"x","max")},i={reductionIndices:t,keepDi
1757
1757
  * See the License for the specific language governing permissions and
1758
1758
  * limitations under the License.
1759
1759
  * =============================================================================
1760
- */const rs=pn({maxPool3d_:function(e,t=[1,1,1],n,a,i,s="NDHWC"){const r=un(e,"x","maxPool3d");let o=r,l=!1;4===r.rank&&(l=!0,o=Ma(r,[1,r.shape[0],r.shape[1],r.shape[2],r.shape[3]])),x(5===o.rank,(()=>`Error in maxPool3d: x must be rank 5 but got rank ${o.rank}.`)),x("NDHWC"===s,(()=>`Error in maxPool3d: Only NDHWC is currently supported, but got dataFormat of ${s}`)),La("maxPool3d",a,i);const c={x:o},u={filterSize:t,strides:n,pad:a,dimRoundingMode:i,dataFormat:s},h=an.runKernel(Ce,c,u);return l?Ma(h,[h.shape[1],h.shape[2],h.shape[3],h.shape[4]]):h}});
1760
+ */const rs=pn({maxPool3d_:function(e,t=[1,1,1],n,a,i,s="NDHWC"){const r=un(e,"x","maxPool3d");let o=r,l=!1;4===r.rank&&(l=!0,o=Ma(r,[1,r.shape[0],r.shape[1],r.shape[2],r.shape[3]])),x(5===o.rank,(()=>`Error in maxPool3d: x must be rank 5 but got rank ${o.rank}.`)),x("NDHWC"===s,(()=>`Error in maxPool3d: Only NDHWC is currently supported, but got dataFormat of ${s}`)),La("maxPool3d",a,i);const c={x:o},u={filterSize:t,strides:n,pad:a,dimRoundingMode:i,dataFormat:s},h=an.runKernel($e,c,u);return l?Ma(h,[h.shape[1],h.shape[2],h.shape[3],h.shape[4]]):h}});
1761
1761
  /**
1762
1762
  * @license
1763
1763
  * Copyright 2020 Google LLC. All Rights Reserved.
@@ -1853,7 +1853,7 @@ function(e,t=null,n=!1){const a={x:un(e,"x","max")},i={reductionIndices:t,keepDi
1853
1853
  * See the License for the specific language governing permissions and
1854
1854
  * limitations under the License.
1855
1855
  * =============================================================================
1856
- */const ps=pn({moments_:function(e,t=null,n=!1){const a=C(t,(e=un(e,"x","moments")).shape),i=ls(e,a,n);let s=i.shape;n||(s=$i(i.shape,a));const r=_i(es(ra(e,"float32"),Ma(i,s)));return{mean:i,variance:ls(r,a,n)}}});
1856
+ */const ps=pn({moments_:function(e,t=null,n=!1){const a=$(t,(e=un(e,"x","moments")).shape),i=ls(e,a,n);let s=i.shape;n||(s=Ci(i.shape,a));const r=_i(es(ra(e,"float32"),Ma(i,s)));return{mean:i,variance:ls(r,a,n)}}});
1857
1857
  /**
1858
1858
  * @license
1859
1859
  * Copyright 2020 Google LLC. All Rights Reserved.
@@ -1949,7 +1949,7 @@ function(e,t=null,n=!1){const a={x:un(e,"x","max")},i={reductionIndices:t,keepDi
1949
1949
  * See the License for the specific language governing permissions and
1950
1950
  * limitations under the License.
1951
1951
  * =============================================================================
1952
- */var ys,bs={exports:{}};function ws(){return ys||(ys=1,function(e){!function(e,t){function n(e){var t=this,n=function(){var e=4022871197,t=function(t){t=String(t);for(var n=0;n<t.length;n++){var a=.02519603282416938*(e+=t.charCodeAt(n));a-=e=a>>>0,e=(a*=e)>>>0,e+=4294967296*(a-=e)}return 2.3283064365386963e-10*(e>>>0)};return t}();t.next=function(){var e=2091639*t.s0+2.3283064365386963e-10*t.c;return t.s0=t.s1,t.s1=t.s2,t.s2=e-(t.c=0|e)},t.c=1,t.s0=n(" "),t.s1=n(" "),t.s2=n(" "),t.s0-=n(e),t.s0<0&&(t.s0+=1),t.s1-=n(e),t.s1<0&&(t.s1+=1),t.s2-=n(e),t.s2<0&&(t.s2+=1),n=null}function a(e,t){return t.c=e.c,t.s0=e.s0,t.s1=e.s1,t.s2=e.s2,t}function i(e,t){var i=new n(e),s=t&&t.state,r=i.next;return r.int32=function(){return 4294967296*i.next()|0},r.double=function(){return r()+11102230246251565e-32*(2097152*r()|0)},r.quick=r,s&&("object"==typeof s&&a(s,i),r.state=function(){return a(i,{})}),r}t&&t.exports?t.exports=i:this.alea=i}(0,e)}(bs)),bs.exports}var ks,xs={exports:{}};function Ss(){return ks||(ks=1,function(e){!function(e,t){function n(e){var t=this,n="";t.x=0,t.y=0,t.z=0,t.w=0,t.next=function(){var e=t.x^t.x<<11;return t.x=t.y,t.y=t.z,t.z=t.w,t.w^=t.w>>>19^e^e>>>8},e===(0|e)?t.x=e:n+=e;for(var a=0;a<n.length+64;a++)t.x^=0|n.charCodeAt(a),t.next()}function a(e,t){return t.x=e.x,t.y=e.y,t.z=e.z,t.w=e.w,t}function i(e,t){var i=new n(e),s=t&&t.state,r=function(){return(i.next()>>>0)/4294967296};return r.double=function(){do{var e=((i.next()>>>11)+(i.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},r.int32=i.next,r.quick=r,s&&("object"==typeof s&&a(s,i),r.state=function(){return a(i,{})}),r}t&&t.exports?t.exports=i:this.xor128=i}(0,e)}(xs)),xs.exports}var Ns,Ts={exports:{}};function Is(){return Ns||(Ns=1,function(e){!function(e,t){function n(e){var t=this,n="";t.next=function(){var e=t.x^t.x>>>2;return t.x=t.y,t.y=t.z,t.z=t.w,t.w=t.v,(t.d=t.d+362437|0)+(t.v=t.v^t.v<<4^e^e<<1)|0},t.x=0,t.y=0,t.z=0,t.w=0,t.v=0,e===(0|e)?t.x=e:n+=e;for(var a=0;a<n.length+64;a++)t.x^=0|n.charCodeAt(a),a==n.length&&(t.d=t.x<<10^t.x>>>4),t.next()}function a(e,t){return t.x=e.x,t.y=e.y,t.z=e.z,t.w=e.w,t.v=e.v,t.d=e.d,t}function i(e,t){var i=new n(e),s=t&&t.state,r=function(){return(i.next()>>>0)/4294967296};return r.double=function(){do{var e=((i.next()>>>11)+(i.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},r.int32=i.next,r.quick=r,s&&("object"==typeof s&&a(s,i),r.state=function(){return a(i,{})}),r}t&&t.exports?t.exports=i:this.xorwow=i}(0,e)}(Ts)),Ts.exports}var $s,Cs={exports:{}};function As(){return $s||($s=1,function(e){!function(e,t){function n(e){var t=this;t.next=function(){var e,n,a=t.x,i=t.i;return e=a[i],n=(e^=e>>>7)^e<<24,n^=(e=a[i+1&7])^e>>>10,n^=(e=a[i+3&7])^e>>>3,n^=(e=a[i+4&7])^e<<7,e=a[i+7&7],n^=(e^=e<<13)^e<<9,a[i]=n,t.i=i+1&7,n},function(e,t){var n,a=[];if(t===(0|t))a[0]=t;else for(t=""+t,n=0;n<t.length;++n)a[7&n]=a[7&n]<<15^t.charCodeAt(n)+a[n+1&7]<<13;for(;a.length<8;)a.push(0);for(n=0;n<8&&0===a[n];++n);for(8==n?a[7]=-1:a[n],e.x=a,e.i=0,n=256;n>0;--n)e.next()}(t,e)}function a(e,t){return t.x=e.x.slice(),t.i=e.i,t}function i(e,t){null==e&&(e=+new Date);var i=new n(e),s=t&&t.state,r=function(){return(i.next()>>>0)/4294967296};return r.double=function(){do{var e=((i.next()>>>11)+(i.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},r.int32=i.next,r.quick=r,s&&(s.x&&a(s,i),r.state=function(){return a(i,{})}),r}t&&t.exports?t.exports=i:this.xorshift7=i}(0,e)}(Cs)),Cs.exports}var Es,js={exports:{}};function zs(){return Es||(Es=1,function(e){!function(e,t){function n(e){var t=this;t.next=function(){var e,n,a=t.w,i=t.X,s=t.i;return t.w=a=a+1640531527|0,n=i[s+34&127],e=i[s=s+1&127],n^=n<<13,e^=e<<17,n^=n>>>15,e^=e>>>12,n=i[s]=n^e,t.i=s,n+(a^a>>>16)|0},function(e,t){var n,a,i,s,r,o=[],l=128;for(t===(0|t)?(a=t,t=null):(t+="\0",a=0,l=Math.max(l,t.length)),i=0,s=-32;s<l;++s)t&&(a^=t.charCodeAt((s+32)%t.length)),0===s&&(r=a),a^=a<<10,a^=a>>>15,a^=a<<4,a^=a>>>13,s>=0&&(r=r+1640531527|0,i=0==(n=o[127&s]^=a+r)?i+1:0);for(i>=128&&(o[127&(t&&t.length||0)]=-1),i=127,s=512;s>0;--s)a=o[i+34&127],n=o[i=i+1&127],a^=a<<13,n^=n<<17,a^=a>>>15,n^=n>>>12,o[i]=a^n;e.w=r,e.X=o,e.i=i}(t,e)}function a(e,t){return t.i=e.i,t.w=e.w,t.X=e.X.slice(),t}function i(e,t){null==e&&(e=+new Date);var i=new n(e),s=t&&t.state,r=function(){return(i.next()>>>0)/4294967296};return r.double=function(){do{var e=((i.next()>>>11)+(i.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},r.int32=i.next,r.quick=r,s&&(s.X&&a(s,i),r.state=function(){return a(i,{})}),r}t&&t.exports?t.exports=i:this.xor4096=i}(0,e)}(js)),js.exports}var Ds,Fs={exports:{}};function _s(){return Ds||(Ds=1,function(e){!function(e,t){function n(e){var t=this,n="";t.next=function(){var e=t.b,n=t.c,a=t.d,i=t.a;return e=e<<25^e>>>7^n,n=n-a|0,a=a<<24^a>>>8^i,i=i-e|0,t.b=e=e<<20^e>>>12^n,t.c=n=n-a|0,t.d=a<<16^n>>>16^i,t.a=i-e|0},t.a=0,t.b=0,t.c=-1640531527,t.d=1367130551,e===Math.floor(e)?(t.a=e/4294967296|0,t.b=0|e):n+=e;for(var a=0;a<n.length+20;a++)t.b^=0|n.charCodeAt(a),t.next()}function a(e,t){return t.a=e.a,t.b=e.b,t.c=e.c,t.d=e.d,t}function i(e,t){var i=new n(e),s=t&&t.state,r=function(){return(i.next()>>>0)/4294967296};return r.double=function(){do{var e=((i.next()>>>11)+(i.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},r.int32=i.next,r.quick=r,s&&("object"==typeof s&&a(s,i),r.state=function(){return a(i,{})}),r}t&&t.exports?t.exports=i:this.tychei=i}(0,e)}(Fs)),Fs.exports}var Rs,Ls,Ms,Os={exports:{}},Ps=Os.exports;function Bs(){return Rs||(Rs=1,function(e){!function(t,n,a){var i,s=256,r="random",o=a.pow(s,6),l=a.pow(2,52),c=2*l,u=255;function h(e,u,h){var v=[],y=m(f((u=1==u?{entropy:!0}:u||{}).entropy?[e,g(n)]:null==e?function(){try{var e;return i&&(e=i.randomBytes)?e=e(s):(e=new Uint8Array(s),(t.crypto||t.msCrypto).getRandomValues(e)),g(e)}catch(e){var a=t.navigator,r=a&&a.plugins;return[+new Date,t,r,t.screen,g(n)]}}():e,3),v),b=new p(v),w=function(){for(var e=b.g(6),t=o,n=0;e<l;)e=(e+n)*s,t*=s,n=b.g(1);for(;e>=c;)e/=2,t/=2,n>>>=1;return(e+n)/t};return w.int32=function(){return 0|b.g(4)},w.quick=function(){return b.g(4)/4294967296},w.double=w,m(g(b.S),n),(u.pass||h||function(e,t,n,i){return i&&(i.S&&d(i,b),e.state=function(){return d(b,{})}),n?(a[r]=e,t):e})(w,y,"global"in u?u.global:this==a,u.state)}function p(e){var t,n=e.length,a=this,i=0,r=a.i=a.j=0,o=a.S=[];for(n||(e=[n++]);i<s;)o[i]=i++;for(i=0;i<s;i++)o[i]=o[r=u&r+e[i%n]+(t=o[i])],o[r]=t;(a.g=function(e){for(var t,n=0,i=a.i,r=a.j,o=a.S;e--;)t=o[i=u&i+1],n=n*s+o[u&(o[i]=o[r=u&r+t])+(o[r]=t)];return a.i=i,a.j=r,n})(s)}function d(e,t){return t.i=e.i,t.j=e.j,t.S=e.S.slice(),t}function f(e,t){var n,a=[],i=typeof e;if(t&&"object"==i)for(n in e)try{a.push(f(e[n],t-1))}catch(e){}return a.length?a:"string"==i?e:e+"\0"}function m(e,t){for(var n,a=e+"",i=0;i<a.length;)t[u&i]=u&(n^=19*t[u&i])+a.charCodeAt(i++);return g(t)}function g(e){return String.fromCharCode.apply(0,e)}if(m(a.random(),n),e.exports){e.exports=h;try{i=require("crypto")}catch(e){}}else a["seed"+r]=h}("undefined"!=typeof self?self:Ps,[],Math)}(Os)),Os.exports}var Us=function(){if(Ms)return Ls;Ms=1;var e=ws(),t=Ss(),n=Is(),a=As(),i=zs(),s=_s(),r=Bs();return r.alea=e,r.xor128=t,r.xorwow=n,r.xorshift7=a,r.xor4096=i,r.tychei=s,Ls=r}();
1952
+ */var ys,bs={exports:{}};function ws(){return ys||(ys=1,function(e){!function(e,t){function n(e){var t=this,n=function(){var e=4022871197,t=function(t){t=String(t);for(var n=0;n<t.length;n++){var a=.02519603282416938*(e+=t.charCodeAt(n));a-=e=a>>>0,e=(a*=e)>>>0,e+=4294967296*(a-=e)}return 2.3283064365386963e-10*(e>>>0)};return t}();t.next=function(){var e=2091639*t.s0+2.3283064365386963e-10*t.c;return t.s0=t.s1,t.s1=t.s2,t.s2=e-(t.c=0|e)},t.c=1,t.s0=n(" "),t.s1=n(" "),t.s2=n(" "),t.s0-=n(e),t.s0<0&&(t.s0+=1),t.s1-=n(e),t.s1<0&&(t.s1+=1),t.s2-=n(e),t.s2<0&&(t.s2+=1),n=null}function a(e,t){return t.c=e.c,t.s0=e.s0,t.s1=e.s1,t.s2=e.s2,t}function i(e,t){var i=new n(e),s=t&&t.state,r=i.next;return r.int32=function(){return 4294967296*i.next()|0},r.double=function(){return r()+11102230246251565e-32*(2097152*r()|0)},r.quick=r,s&&("object"==typeof s&&a(s,i),r.state=function(){return a(i,{})}),r}t&&t.exports?t.exports=i:this.alea=i}(0,e)}(bs)),bs.exports}var ks,xs={exports:{}};function Ss(){return ks||(ks=1,function(e){!function(e,t){function n(e){var t=this,n="";t.x=0,t.y=0,t.z=0,t.w=0,t.next=function(){var e=t.x^t.x<<11;return t.x=t.y,t.y=t.z,t.z=t.w,t.w^=t.w>>>19^e^e>>>8},e===(0|e)?t.x=e:n+=e;for(var a=0;a<n.length+64;a++)t.x^=0|n.charCodeAt(a),t.next()}function a(e,t){return t.x=e.x,t.y=e.y,t.z=e.z,t.w=e.w,t}function i(e,t){var i=new n(e),s=t&&t.state,r=function(){return(i.next()>>>0)/4294967296};return r.double=function(){do{var e=((i.next()>>>11)+(i.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},r.int32=i.next,r.quick=r,s&&("object"==typeof s&&a(s,i),r.state=function(){return a(i,{})}),r}t&&t.exports?t.exports=i:this.xor128=i}(0,e)}(xs)),xs.exports}var Ns,Ts={exports:{}};function Is(){return Ns||(Ns=1,function(e){!function(e,t){function n(e){var t=this,n="";t.next=function(){var e=t.x^t.x>>>2;return t.x=t.y,t.y=t.z,t.z=t.w,t.w=t.v,(t.d=t.d+362437|0)+(t.v=t.v^t.v<<4^e^e<<1)|0},t.x=0,t.y=0,t.z=0,t.w=0,t.v=0,e===(0|e)?t.x=e:n+=e;for(var a=0;a<n.length+64;a++)t.x^=0|n.charCodeAt(a),a==n.length&&(t.d=t.x<<10^t.x>>>4),t.next()}function a(e,t){return t.x=e.x,t.y=e.y,t.z=e.z,t.w=e.w,t.v=e.v,t.d=e.d,t}function i(e,t){var i=new n(e),s=t&&t.state,r=function(){return(i.next()>>>0)/4294967296};return r.double=function(){do{var e=((i.next()>>>11)+(i.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},r.int32=i.next,r.quick=r,s&&("object"==typeof s&&a(s,i),r.state=function(){return a(i,{})}),r}t&&t.exports?t.exports=i:this.xorwow=i}(0,e)}(Ts)),Ts.exports}var Cs,$s={exports:{}};function As(){return Cs||(Cs=1,function(e){!function(e,t){function n(e){var t=this;t.next=function(){var e,n,a=t.x,i=t.i;return e=a[i],n=(e^=e>>>7)^e<<24,n^=(e=a[i+1&7])^e>>>10,n^=(e=a[i+3&7])^e>>>3,n^=(e=a[i+4&7])^e<<7,e=a[i+7&7],n^=(e^=e<<13)^e<<9,a[i]=n,t.i=i+1&7,n},function(e,t){var n,a=[];if(t===(0|t))a[0]=t;else for(t=""+t,n=0;n<t.length;++n)a[7&n]=a[7&n]<<15^t.charCodeAt(n)+a[n+1&7]<<13;for(;a.length<8;)a.push(0);for(n=0;n<8&&0===a[n];++n);for(8==n?a[7]=-1:a[n],e.x=a,e.i=0,n=256;n>0;--n)e.next()}(t,e)}function a(e,t){return t.x=e.x.slice(),t.i=e.i,t}function i(e,t){null==e&&(e=+new Date);var i=new n(e),s=t&&t.state,r=function(){return(i.next()>>>0)/4294967296};return r.double=function(){do{var e=((i.next()>>>11)+(i.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},r.int32=i.next,r.quick=r,s&&(s.x&&a(s,i),r.state=function(){return a(i,{})}),r}t&&t.exports?t.exports=i:this.xorshift7=i}(0,e)}($s)),$s.exports}var Es,js={exports:{}};function zs(){return Es||(Es=1,function(e){!function(e,t){function n(e){var t=this;t.next=function(){var e,n,a=t.w,i=t.X,s=t.i;return t.w=a=a+1640531527|0,n=i[s+34&127],e=i[s=s+1&127],n^=n<<13,e^=e<<17,n^=n>>>15,e^=e>>>12,n=i[s]=n^e,t.i=s,n+(a^a>>>16)|0},function(e,t){var n,a,i,s,r,o=[],l=128;for(t===(0|t)?(a=t,t=null):(t+="\0",a=0,l=Math.max(l,t.length)),i=0,s=-32;s<l;++s)t&&(a^=t.charCodeAt((s+32)%t.length)),0===s&&(r=a),a^=a<<10,a^=a>>>15,a^=a<<4,a^=a>>>13,s>=0&&(r=r+1640531527|0,i=0==(n=o[127&s]^=a+r)?i+1:0);for(i>=128&&(o[127&(t&&t.length||0)]=-1),i=127,s=512;s>0;--s)a=o[i+34&127],n=o[i=i+1&127],a^=a<<13,n^=n<<17,a^=a>>>15,n^=n>>>12,o[i]=a^n;e.w=r,e.X=o,e.i=i}(t,e)}function a(e,t){return t.i=e.i,t.w=e.w,t.X=e.X.slice(),t}function i(e,t){null==e&&(e=+new Date);var i=new n(e),s=t&&t.state,r=function(){return(i.next()>>>0)/4294967296};return r.double=function(){do{var e=((i.next()>>>11)+(i.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},r.int32=i.next,r.quick=r,s&&(s.X&&a(s,i),r.state=function(){return a(i,{})}),r}t&&t.exports?t.exports=i:this.xor4096=i}(0,e)}(js)),js.exports}var Ds,Fs={exports:{}};function _s(){return Ds||(Ds=1,function(e){!function(e,t){function n(e){var t=this,n="";t.next=function(){var e=t.b,n=t.c,a=t.d,i=t.a;return e=e<<25^e>>>7^n,n=n-a|0,a=a<<24^a>>>8^i,i=i-e|0,t.b=e=e<<20^e>>>12^n,t.c=n=n-a|0,t.d=a<<16^n>>>16^i,t.a=i-e|0},t.a=0,t.b=0,t.c=-1640531527,t.d=1367130551,e===Math.floor(e)?(t.a=e/4294967296|0,t.b=0|e):n+=e;for(var a=0;a<n.length+20;a++)t.b^=0|n.charCodeAt(a),t.next()}function a(e,t){return t.a=e.a,t.b=e.b,t.c=e.c,t.d=e.d,t}function i(e,t){var i=new n(e),s=t&&t.state,r=function(){return(i.next()>>>0)/4294967296};return r.double=function(){do{var e=((i.next()>>>11)+(i.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},r.int32=i.next,r.quick=r,s&&("object"==typeof s&&a(s,i),r.state=function(){return a(i,{})}),r}t&&t.exports?t.exports=i:this.tychei=i}(0,e)}(Fs)),Fs.exports}var Rs,Ls,Ms,Os={exports:{}},Ps=Os.exports;function Bs(){return Rs||(Rs=1,function(e){!function(t,n,a){var i,s=256,r="random",o=a.pow(s,6),l=a.pow(2,52),c=2*l,u=255;function h(e,u,h){var v=[],y=m(f((u=1==u?{entropy:!0}:u||{}).entropy?[e,g(n)]:null==e?function(){try{var e;return i&&(e=i.randomBytes)?e=e(s):(e=new Uint8Array(s),(t.crypto||t.msCrypto).getRandomValues(e)),g(e)}catch(e){var a=t.navigator,r=a&&a.plugins;return[+new Date,t,r,t.screen,g(n)]}}():e,3),v),b=new p(v),w=function(){for(var e=b.g(6),t=o,n=0;e<l;)e=(e+n)*s,t*=s,n=b.g(1);for(;e>=c;)e/=2,t/=2,n>>>=1;return(e+n)/t};return w.int32=function(){return 0|b.g(4)},w.quick=function(){return b.g(4)/4294967296},w.double=w,m(g(b.S),n),(u.pass||h||function(e,t,n,i){return i&&(i.S&&d(i,b),e.state=function(){return d(b,{})}),n?(a[r]=e,t):e})(w,y,"global"in u?u.global:this==a,u.state)}function p(e){var t,n=e.length,a=this,i=0,r=a.i=a.j=0,o=a.S=[];for(n||(e=[n++]);i<s;)o[i]=i++;for(i=0;i<s;i++)o[i]=o[r=u&r+e[i%n]+(t=o[i])],o[r]=t;(a.g=function(e){for(var t,n=0,i=a.i,r=a.j,o=a.S;e--;)t=o[i=u&i+1],n=n*s+o[u&(o[i]=o[r=u&r+t])+(o[r]=t)];return a.i=i,a.j=r,n})(s)}function d(e,t){return t.i=e.i,t.j=e.j,t.S=e.S.slice(),t}function f(e,t){var n,a=[],i=typeof e;if(t&&"object"==i)for(n in e)try{a.push(f(e[n],t-1))}catch(e){}return a.length?a:"string"==i?e:e+"\0"}function m(e,t){for(var n,a=e+"",i=0;i<a.length;)t[u&i]=u&(n^=19*t[u&i])+a.charCodeAt(i++);return g(t)}function g(e){return String.fromCharCode.apply(0,e)}if(m(a.random(),n),e.exports){e.exports=h;try{i=require("crypto")}catch(e){}}else a["seed"+r]=h}("undefined"!=typeof self?self:Ps,[],Math)}(Os)),Os.exports}var Us=function(){if(Ms)return Ls;Ms=1;var e=ws(),t=Ss(),n=Is(),a=As(),i=zs(),s=_s(),r=Bs();return r.alea=e,r.xor128=t,r.xorwow=n,r.xorshift7=a,r.xor4096=i,r.tychei=s,Ls=r}();
1953
1953
  /**
1954
1954
  * @license
1955
1955
  * Copyright 2018 Google LLC. All Rights Reserved.
@@ -2253,7 +2253,7 @@ function(e,t=null,n=!1){const a={x:un(e,"x","max")},i={reductionIndices:t,keepDi
2253
2253
  * See the License for the specific language governing permissions and
2254
2254
  * limitations under the License.
2255
2255
  * =============================================================================
2256
- */const cr=pn({squeeze_:function(e,t){const n=un(e,"x","squeeze","string_or_numeric");return Ma(n,function(e,t){const n=[],a=[],i=null!=t&&Array.isArray(t)&&0===t.length,s=null==t||i?null:C(t,e).sort();let r=0;for(let t=0;t<e.length;++t){if(null!=s){if(s[r]===t&&1!==e[t])throw new Error(`Can't squeeze axis ${t} since its dim '${e[t]}' is not 1`);(null==s[r]||s[r]>t)&&1===e[t]&&(n.push(e[t]),a.push(t)),s[r]<=t&&r++}1!==e[t]&&(n.push(e[t]),a.push(t))}return{newShape:n,keptDims:a}}(n.shape,t).newShape)}});
2256
+ */const cr=pn({squeeze_:function(e,t){const n=un(e,"x","squeeze","string_or_numeric");return Ma(n,function(e,t){const n=[],a=[],i=null!=t&&Array.isArray(t)&&0===t.length,s=null==t||i?null:$(t,e).sort();let r=0;for(let t=0;t<e.length;++t){if(null!=s){if(s[r]===t&&1!==e[t])throw new Error(`Can't squeeze axis ${t} since its dim '${e[t]}' is not 1`);(null==s[r]||s[r]>t)&&1===e[t]&&(n.push(e[t]),a.push(t)),s[r]<=t&&r++}1!==e[t]&&(n.push(e[t]),a.push(t))}return{newShape:n,keptDims:a}}(n.shape,t).newShape)}});
2257
2257
  /**
2258
2258
  * @license
2259
2259
  * Copyright 2020 Google LLC. All Rights Reserved.
@@ -2511,7 +2511,7 @@ function(e,t){if(null==t)return e.shape.slice();if(T(e.shape,t))return t;if(e.sh
2511
2511
  * See the License for the specific language governing permissions and
2512
2512
  * limitations under the License.
2513
2513
  * =============================================================================
2514
- */const Ir=pn({fusedMatMul_:function({a:e,b:t,transposeA:n=!1,transposeB:a=!1,bias:i,activation:s="linear",preluActivationWeights:r,leakyreluAlpha:o=.2}){if(!1===xr(an.state.gradientDepth,s)){let l=oa(e,t,n,a);return null!=i&&(l=xa(l,i)),kr(l,s,r,o)}let l=un(e,"a","fused matMul"),c=un(t,"b","fused matMul");[l,c]=Zt(l,c);const u=n?l.shape[l.rank-2]:l.shape[l.rank-1],h=a?c.shape[c.rank-1]:c.shape[c.rank-2],p=n?l.shape[l.rank-1]:l.shape[l.rank-2],d=a?c.shape[c.rank-2]:c.shape[c.rank-1],f=l.shape.slice(0,-2),m=c.shape.slice(0,-2),g=N(f),v=N(m);x(u===h,(()=>`Error in fused matMul: inner shapes (${u}) and (${h}) of Tensors with shapes ${l.shape} and ${c.shape} and transposeA=${n} and transposeB=${a} must match.`));const y=ma(l.shape.slice(0,-2),c.shape.slice(0,-2)).concat([p,d]),b=Ma(l,n?[g,u,p]:[g,p,u]),w=Ma(c,a?[v,d,h]:[v,h,d]);let k,S;null!=i&&(k=un(i,"bias","fused matMul"),[k]=Zt(k,l),ma(y,k.shape)),null!=r&&(S=un(r,"prelu weights","fused matMul"));const T=(e,t)=>{const[r,o,l,c]=t,u=br(Ma(e,l.shape),l,s);let h,p;if(n||a?!n&&a?(h=oa(u,o,!1,!1),p=oa(u,r,!0,!1)):n&&!a?(h=oa(o,u,!1,!0),p=oa(r,u,!1,!1)):(h=oa(o,u,!0,!0),p=oa(u,r,!0,!0)):(h=oa(u,o,!1,!0),p=oa(r,u,!0,!1)),null!=i){return[h,p,wr(c,u)]}return[h,p]},I={a:b,b:w,bias:k,preluActivationWeights:S},$={transposeA:n,transposeB:a,activation:s,leakyreluAlpha:o};if(null==i){const e=Qi(((e,t,n)=>{const a=an.runKernel(ct,I,$);return n([e,t,a]),{value:Ma(a,y),gradFunc:T}}));return e(b,w)}{const e=Qi(((e,t,n,a)=>{const i=an.runKernel(ct,I,$);return a([e,t,i,n]),{value:Ma(i,y),gradFunc:T}}));return e(b,w,k)}}});
2514
+ */const Ir=pn({fusedMatMul_:function({a:e,b:t,transposeA:n=!1,transposeB:a=!1,bias:i,activation:s="linear",preluActivationWeights:r,leakyreluAlpha:o=.2}){if(!1===xr(an.state.gradientDepth,s)){let l=oa(e,t,n,a);return null!=i&&(l=xa(l,i)),kr(l,s,r,o)}let l=un(e,"a","fused matMul"),c=un(t,"b","fused matMul");[l,c]=Zt(l,c);const u=n?l.shape[l.rank-2]:l.shape[l.rank-1],h=a?c.shape[c.rank-1]:c.shape[c.rank-2],p=n?l.shape[l.rank-1]:l.shape[l.rank-2],d=a?c.shape[c.rank-2]:c.shape[c.rank-1],f=l.shape.slice(0,-2),m=c.shape.slice(0,-2),g=N(f),v=N(m);x(u===h,(()=>`Error in fused matMul: inner shapes (${u}) and (${h}) of Tensors with shapes ${l.shape} and ${c.shape} and transposeA=${n} and transposeB=${a} must match.`));const y=ma(l.shape.slice(0,-2),c.shape.slice(0,-2)).concat([p,d]),b=Ma(l,n?[g,u,p]:[g,p,u]),w=Ma(c,a?[v,d,h]:[v,h,d]);let k,S;null!=i&&(k=un(i,"bias","fused matMul"),[k]=Zt(k,l),ma(y,k.shape)),null!=r&&(S=un(r,"prelu weights","fused matMul"));const T=(e,t)=>{const[r,o,l,c]=t,u=br(Ma(e,l.shape),l,s);let h,p;if(n||a?!n&&a?(h=oa(u,o,!1,!1),p=oa(u,r,!0,!1)):n&&!a?(h=oa(o,u,!1,!0),p=oa(r,u,!1,!1)):(h=oa(o,u,!0,!0),p=oa(u,r,!0,!0)):(h=oa(u,o,!1,!0),p=oa(r,u,!0,!1)),null!=i){return[h,p,wr(c,u)]}return[h,p]},I={a:b,b:w,bias:k,preluActivationWeights:S},C={transposeA:n,transposeB:a,activation:s,leakyreluAlpha:o};if(null==i){const e=Qi(((e,t,n)=>{const a=an.runKernel(ct,I,C);return n([e,t,a]),{value:Ma(a,y),gradFunc:T}}));return e(b,w)}{const e=Qi(((e,t,n,a)=>{const i=an.runKernel(ct,I,C);return a([e,t,i,n]),{value:Ma(i,y),gradFunc:T}}));return e(b,w,k)}}});
2515
2515
  /**
2516
2516
  * @license
2517
2517
  * Copyright 2020 Google LLC. All Rights Reserved.
@@ -2527,7 +2527,7 @@ function(e,t){if(null==t)return e.shape.slice();if(T(e.shape,t))return t;if(e.sh
2527
2527
  * See the License for the specific language governing permissions and
2528
2528
  * limitations under the License.
2529
2529
  * =============================================================================
2530
- */const $r=pn({cropAndResize_:function(e,t,n,a,i="bilinear",s=0){const r=un(e,"image","cropAndResize"),o=un(t,"boxes","cropAndResize","float32"),l=un(n,"boxInd","cropAndResize","int32"),c=o.shape[0];x(4===r.rank,(()=>`Error in cropAndResize: image must be rank 4,but got rank ${r.rank}.`)),x(2===o.rank&&4===o.shape[1],(()=>`Error in cropAndResize: boxes must be have size [${c},4] but had shape ${o.shape}.`)),x(1===l.rank&&l.shape[0]===c,(()=>`Error in cropAndResize: boxInd must be have size [${c}] but had shape ${o.shape}.`)),x(2===a.length,(()=>`Error in cropAndResize: cropSize must be of length 2, but got length ${a.length}.`)),x(a[0]>=1&&a[1]>=1,(()=>`cropSize must be atleast [1,1], but was ${a}`)),x("bilinear"===i||"nearest"===i,(()=>`method must be bilinear or nearest, but was ${i}`));const u={image:r,boxes:o,boxInd:l},h={method:i,extrapolationValue:s,cropSize:a};return an.runKernel("CropAndResize",u,h)}});
2530
+ */const Cr=pn({cropAndResize_:function(e,t,n,a,i="bilinear",s=0){const r=un(e,"image","cropAndResize"),o=un(t,"boxes","cropAndResize","float32"),l=un(n,"boxInd","cropAndResize","int32"),c=o.shape[0];x(4===r.rank,(()=>`Error in cropAndResize: image must be rank 4,but got rank ${r.rank}.`)),x(2===o.rank&&4===o.shape[1],(()=>`Error in cropAndResize: boxes must be have size [${c},4] but had shape ${o.shape}.`)),x(1===l.rank&&l.shape[0]===c,(()=>`Error in cropAndResize: boxInd must be have size [${c}] but had shape ${o.shape}.`)),x(2===a.length,(()=>`Error in cropAndResize: cropSize must be of length 2, but got length ${a.length}.`)),x(a[0]>=1&&a[1]>=1,(()=>`cropSize must be atleast [1,1], but was ${a}`)),x("bilinear"===i||"nearest"===i,(()=>`method must be bilinear or nearest, but was ${i}`));const u={image:r,boxes:o,boxInd:l},h={method:i,extrapolationValue:s,cropSize:a};return an.runKernel("CropAndResize",u,h)}});
2531
2531
  /**
2532
2532
  * @license
2533
2533
  * Copyright 2020 Google LLC. All Rights Reserved.
@@ -2543,7 +2543,7 @@ function(e,t){if(null==t)return e.shape.slice();if(T(e.shape,t))return t;if(e.sh
2543
2543
  * See the License for the specific language governing permissions and
2544
2544
  * limitations under the License.
2545
2545
  * =============================================================================
2546
- */const Cr=pn({flipLeftRight_:function(e){const t=un(e,"image","flipLeftRight","float32");x(4===t.rank,(()=>`Error in flipLeftRight: image must be rank 4,but got rank ${t.rank}.`));const n={image:t};return an.runKernel("FlipLeftRight",n,{})}});
2546
+ */const $r=pn({flipLeftRight_:function(e){const t=un(e,"image","flipLeftRight","float32");x(4===t.rank,(()=>`Error in flipLeftRight: image must be rank 4,but got rank ${t.rank}.`));const n={image:t};return an.runKernel("FlipLeftRight",n,{})}});
2547
2547
  /**
2548
2548
  * @license
2549
2549
  * Copyright 2021 Google LLC. All Rights Reserved.
@@ -2815,7 +2815,7 @@ function(e,t){if(null==t)return e.shape.slice();if(T(e.shape,t))return t;if(e.sh
2815
2815
  * See the License for the specific language governing permissions and
2816
2816
  * limitations under the License.
2817
2817
  * =============================================================================
2818
- */function Jr(e,t=!1){return an.tidy((()=>{x(2===e.shape.length,(()=>`qr2d() requires a 2D Tensor, but got a ${e.shape.length}D Tensor.`));const n=e.shape[0],a=e.shape[1];let i=Ui(n),s=Ba(e);const r=dr([[1]],[1,1]);let o=Ba(r);const l=n>=a?a:n;for(let e=0;e<l;++e){const t=s,l=o,c=i;[o,s,i]=an.tidy((()=>{const t=Ga(s,[e,e],[n-e,1]),l=Mi(t),c=Ga(s,[e,e],[1,1]),u=wi(Vi(c,0),dr([[-1]]),dr([[1]])),h=es(c,Ta(u,l)),p=Na(t,h);o=1===p.shape[0]?Ba(r):Ua([r,Ga(p,[1,0],[p.shape[0]-1,p.shape[1]])],0);const d=ua(Na(oa(u,h),l)),f=Ga(s,[e,0],[n-e,a]),m=Ta(d,o),g=pa(o);if(0===e)s=es(f,oa(m,oa(g,f)));else{const t=es(f,oa(m,oa(g,f)));s=Ua([Ga(s,[0,0],[e,a]),t],0)}const v=pa(m),y=Ga(i,[0,e],[n,i.shape[1]-e]);if(0===e)i=es(y,oa(oa(y,o),v));else{const t=es(y,oa(oa(y,o),v));i=Ua([Ga(i,[0,0],[n,e]),t],1)}return[o,s,i]})),kn([t,l,c])}return!t&&n>a&&(i=Ga(i,[0,0],[n,a]),s=Ga(s,[0,0],[a,a])),[i,s]}))}const Zr={flipLeftRight:Cr,grayscaleToRGB:Ar,resizeNearestNeighbor:Kr,resizeBilinear:Vr,rgbToGrayscale:Er,rotateWithOffset:jr,cropAndResize:$r,nonMaxSuppression:Dr,nonMaxSuppressionAsync:Pr,nonMaxSuppressionWithScore:Br,nonMaxSuppressionWithScoreAsync:Ur,nonMaxSuppressionPadded:Wr,nonMaxSuppressionPaddedAsync:Gr,threshold:qr,transform:Hr},Yr={bandPart:pn({bandPart_:function(e,t,n){const a=un(e,"a","bandPart");x(a.rank>=2,(()=>`bandPart(): Rank must be at least 2, got ${a.rank}.`));const i=a.shape,[s,r]=a.shape.slice(-2);let o,l;"number"==typeof t?(x(t%1==0,(()=>`bandPart(): numLower must be an integer, got ${t}.`)),x(t<=s,(()=>`bandPart(): numLower (${t}) must not be greater than the number of rows (${s}).`)),o=un(t<0?s:t,"numLower","bandPart")):(x("int32"===t.dtype,(()=>"bandPart(): numLower's dtype must be an int32.")),o=wi(Hi(t,0),s,hs(t,s))),"number"==typeof n?(x(n%1==0,(()=>`bandPart(): numUpper must be an integer, got ${n}.`)),x(n<=r,(()=>`bandPart(): numUpper (${n}) must not be greater than the number of columns (${r}).`)),l=un(n<0?r:n,"numUpper","bandPart")):(x("int32"===n.dtype,(()=>"bandPart(): numUpper's dtype must be an int32.")),l=wi(Hi(n,0),r,hs(n,r)));const c=Ma(qs(0,s,1,"int32"),[-1,1]),u=qs(0,r,1,"int32"),h=es(c,u),p=as(Ji(h,o),Ki(h,ua(l))),d=cs([s,r],a.dtype);return Ma(ur(gr(Ma(a,[-1,s,r])).map((e=>wi(p,e,d)))),i)}}),gramSchmidt:pn({gramSchmidt_:
2818
+ */function Jr(e,t=!1){return an.tidy((()=>{x(2===e.shape.length,(()=>`qr2d() requires a 2D Tensor, but got a ${e.shape.length}D Tensor.`));const n=e.shape[0],a=e.shape[1];let i=Ui(n),s=Ba(e);const r=dr([[1]],[1,1]);let o=Ba(r);const l=n>=a?a:n;for(let e=0;e<l;++e){const t=s,l=o,c=i;[o,s,i]=an.tidy((()=>{const t=Ga(s,[e,e],[n-e,1]),l=Mi(t),c=Ga(s,[e,e],[1,1]),u=wi(Vi(c,0),dr([[-1]]),dr([[1]])),h=es(c,Ta(u,l)),p=Na(t,h);o=1===p.shape[0]?Ba(r):Ua([r,Ga(p,[1,0],[p.shape[0]-1,p.shape[1]])],0);const d=ua(Na(oa(u,h),l)),f=Ga(s,[e,0],[n-e,a]),m=Ta(d,o),g=pa(o);if(0===e)s=es(f,oa(m,oa(g,f)));else{const t=es(f,oa(m,oa(g,f)));s=Ua([Ga(s,[0,0],[e,a]),t],0)}const v=pa(m),y=Ga(i,[0,e],[n,i.shape[1]-e]);if(0===e)i=es(y,oa(oa(y,o),v));else{const t=es(y,oa(oa(y,o),v));i=Ua([Ga(i,[0,0],[n,e]),t],1)}return[o,s,i]})),kn([t,l,c])}return!t&&n>a&&(i=Ga(i,[0,0],[n,a]),s=Ga(s,[0,0],[a,a])),[i,s]}))}const Zr={flipLeftRight:$r,grayscaleToRGB:Ar,resizeNearestNeighbor:Kr,resizeBilinear:Vr,rgbToGrayscale:Er,rotateWithOffset:jr,cropAndResize:Cr,nonMaxSuppression:Dr,nonMaxSuppressionAsync:Pr,nonMaxSuppressionWithScore:Br,nonMaxSuppressionWithScoreAsync:Ur,nonMaxSuppressionPadded:Wr,nonMaxSuppressionPaddedAsync:Gr,threshold:qr,transform:Hr},Yr={bandPart:pn({bandPart_:function(e,t,n){const a=un(e,"a","bandPart");x(a.rank>=2,(()=>`bandPart(): Rank must be at least 2, got ${a.rank}.`));const i=a.shape,[s,r]=a.shape.slice(-2);let o,l;"number"==typeof t?(x(t%1==0,(()=>`bandPart(): numLower must be an integer, got ${t}.`)),x(t<=s,(()=>`bandPart(): numLower (${t}) must not be greater than the number of rows (${s}).`)),o=un(t<0?s:t,"numLower","bandPart")):(x("int32"===t.dtype,(()=>"bandPart(): numLower's dtype must be an int32.")),o=wi(Hi(t,0),s,hs(t,s))),"number"==typeof n?(x(n%1==0,(()=>`bandPart(): numUpper must be an integer, got ${n}.`)),x(n<=r,(()=>`bandPart(): numUpper (${n}) must not be greater than the number of columns (${r}).`)),l=un(n<0?r:n,"numUpper","bandPart")):(x("int32"===n.dtype,(()=>"bandPart(): numUpper's dtype must be an int32.")),l=wi(Hi(n,0),r,hs(n,r)));const c=Ma(qs(0,s,1,"int32"),[-1,1]),u=qs(0,r,1,"int32"),h=es(c,u),p=as(Ji(h,o),Ki(h,ua(l))),d=cs([s,r],a.dtype);return Ma(ur(gr(Ma(a,[-1,s,r])).map((e=>wi(p,e,d)))),i)}}),gramSchmidt:pn({gramSchmidt_:
2819
2819
  /**
2820
2820
  * @license
2821
2821
  * Copyright 2020 Google LLC. All Rights Reserved.
@@ -3325,7 +3325,7 @@ function ko(e){return(t,n,a,i,s)=>{const r=ma(t,n),o=r.length,l=R(r),c=A(s,N(r))
3325
3325
  * See the License for the specific language governing permissions and
3326
3326
  * limitations under the License.
3327
3327
  * =============================================================================
3328
- */({inputs:{input:i},backend:n}),t=Io({inputs:{x:e},backend:n,attrs:{dtype:s}});return n.disposeIntermediateTensorInfo(e),t}if(r=i.dtype,"complex64"===(o=s)||"float32"===o&&"complex64"!==r||"int32"===o&&"float32"!==r&&"complex64"!==r||"bool"===o&&"bool"===r){const e=No({inputs:{x:i},backend:n});return{dataId:e.dataId,shape:e.shape,dtype:s}}var r,o;const l=n.data.get(i.dataId).values,[c,u,h]=function(e,t,n,a){if("int32"===a)return[t,"int32",Int32Array.from(e)];if("bool"===a){const a=kt([0],n),[i,s]=ko(((e,t)=>e!==t?1:0))(t,[],e,a,"bool");return[s,"bool",i]}throw new Error(`Error in Cast: failed to cast ${n} to ${a}`)}(l,i.shape,i.dtype,s);return n.makeTensorInfo(c,u,h)}const $o={kernelName:se,backendName:"cpu",kernelFunc:Io};
3328
+ */({inputs:{input:i},backend:n}),t=Io({inputs:{x:e},backend:n,attrs:{dtype:s}});return n.disposeIntermediateTensorInfo(e),t}if(r=i.dtype,"complex64"===(o=s)||"float32"===o&&"complex64"!==r||"int32"===o&&"float32"!==r&&"complex64"!==r||"bool"===o&&"bool"===r){const e=No({inputs:{x:i},backend:n});return{dataId:e.dataId,shape:e.shape,dtype:s}}var r,o;const l=n.data.get(i.dataId).values,[c,u,h]=function(e,t,n,a){if("int32"===a)return[t,"int32",Int32Array.from(e)];if("bool"===a){const a=kt([0],n),[i,s]=ko(((e,t)=>e!==t?1:0))(t,[],e,a,"bool");return[s,"bool",i]}throw new Error(`Error in Cast: failed to cast ${n} to ${a}`)}(l,i.shape,i.dtype,s);return n.makeTensorInfo(c,u,h)}const Co={kernelName:se,backendName:"cpu",kernelFunc:Io};
3329
3329
  /**
3330
3330
  * @license
3331
3331
  * Copyright 2020 Google LLC. All Rights Reserved.
@@ -3358,7 +3358,7 @@ function ko(e){return(t,n,a,i,s)=>{const r=ma(t,n),o=r.length,l=R(r),c=A(s,N(r))
3358
3358
  * limitations under the License.
3359
3359
  * =============================================================================
3360
3360
  */
3361
- const Co=ko(((e,t)=>e+t)),Ao=function(e){return(t,n,a,i,s,r)=>{const o=ma(t,n),l=N(o),c=o.length,u=R(o),h=A("float32",l),p=A("float32",l),d=da(t,o),f=da(n,o),m=co(a,i),g=co(s,r),v=t.length,y=R(t),b=n.length,w=R(n);if(d.length+f.length===0)for(let t=0;t<h.length;t++){const n=t%m.length,a=t%g.length,i=e(m[2*n],m[2*n+1],g[2*a],g[2*a+1]);h[t]=i.real,p[t]=i.imag}else for(let t=0;t<h.length;t++){const n=W(t,c,u),a=n.slice(-v);d.forEach((e=>a[e]=0));const i=U(a,v,y),s=n.slice(-b);f.forEach((e=>s[e]=0));const r=U(s,b,w),o=e(m[2*i],m[2*i+1],g[2*r],g[2*r+1]);h[t]=o.real,p[t]=o.imag}return[h,p,o]}}(((e,t,n,a)=>({real:e+n,imag:t+a}))),Eo=(jo=X,zo=Co,null==(Do=Ao)?({inputs:e,backend:t})=>{const{a:n,b:a}=e,i=t;yo([n,a],jo);const s=i.data.get(n.dataId).values,r=i.data.get(a.dataId).values,o="string"===n.dtype?uo(s):s,l="string"===n.dtype?uo(r):r,c=n.dtype,[u,h]=zo(n.shape,a.shape,o,l,c);return i.makeTensorInfo(h,c,u)}:({inputs:e,backend:t})=>{const{a:n,b:a}=e,i=t;if("complex64"===n.dtype||"complex64"===a.dtype){const e=Io({inputs:{x:n},backend:i,attrs:{dtype:"complex64"}}),t=i.data.get(e.dataId),s=t.complexTensorInfos.real,r=t.complexTensorInfos.imag,o=i.data.get(s.dataId).values,l=i.data.get(r.dataId).values,c=Io({inputs:{x:a},backend:i,attrs:{dtype:"complex64"}}),u=i.data.get(c.dataId),h=u.complexTensorInfos.real,p=u.complexTensorInfos.imag,d=i.data.get(h.dataId).values,f=i.data.get(p.dataId).values,[m,g,v]=Do(n.shape,a.shape,o,l,d,f),y=i.makeTensorInfo(v,"float32",m),b=i.makeTensorInfo(v,"float32",g),w=xo({inputs:{real:y,imag:b},backend:i});return i.disposeIntermediateTensorInfo(e),i.disposeIntermediateTensorInfo(c),i.disposeIntermediateTensorInfo(y),i.disposeIntermediateTensorInfo(b),w}{const e=i.data.get(n.dataId).values,t=i.data.get(a.dataId).values,s=n.dtype,[r,o]=zo(n.shape,a.shape,e,t,s);return i.makeTensorInfo(o,s,r)}});var jo,zo,Do;const Fo={kernelName:X,backendName:"cpu",kernelFunc:Eo};
3361
+ const $o=ko(((e,t)=>e+t)),Ao=function(e){return(t,n,a,i,s,r)=>{const o=ma(t,n),l=N(o),c=o.length,u=R(o),h=A("float32",l),p=A("float32",l),d=da(t,o),f=da(n,o),m=co(a,i),g=co(s,r),v=t.length,y=R(t),b=n.length,w=R(n);if(d.length+f.length===0)for(let t=0;t<h.length;t++){const n=t%m.length,a=t%g.length,i=e(m[2*n],m[2*n+1],g[2*a],g[2*a+1]);h[t]=i.real,p[t]=i.imag}else for(let t=0;t<h.length;t++){const n=W(t,c,u),a=n.slice(-v);d.forEach((e=>a[e]=0));const i=U(a,v,y),s=n.slice(-b);f.forEach((e=>s[e]=0));const r=U(s,b,w),o=e(m[2*i],m[2*i+1],g[2*r],g[2*r+1]);h[t]=o.real,p[t]=o.imag}return[h,p,o]}}(((e,t,n,a)=>({real:e+n,imag:t+a}))),Eo=(jo=X,zo=$o,null==(Do=Ao)?({inputs:e,backend:t})=>{const{a:n,b:a}=e,i=t;yo([n,a],jo);const s=i.data.get(n.dataId).values,r=i.data.get(a.dataId).values,o="string"===n.dtype?uo(s):s,l="string"===n.dtype?uo(r):r,c=n.dtype,[u,h]=zo(n.shape,a.shape,o,l,c);return i.makeTensorInfo(h,c,u)}:({inputs:e,backend:t})=>{const{a:n,b:a}=e,i=t;if("complex64"===n.dtype||"complex64"===a.dtype){const e=Io({inputs:{x:n},backend:i,attrs:{dtype:"complex64"}}),t=i.data.get(e.dataId),s=t.complexTensorInfos.real,r=t.complexTensorInfos.imag,o=i.data.get(s.dataId).values,l=i.data.get(r.dataId).values,c=Io({inputs:{x:a},backend:i,attrs:{dtype:"complex64"}}),u=i.data.get(c.dataId),h=u.complexTensorInfos.real,p=u.complexTensorInfos.imag,d=i.data.get(h.dataId).values,f=i.data.get(p.dataId).values,[m,g,v]=Do(n.shape,a.shape,o,l,d,f),y=i.makeTensorInfo(v,"float32",m),b=i.makeTensorInfo(v,"float32",g),w=xo({inputs:{real:y,imag:b},backend:i});return i.disposeIntermediateTensorInfo(e),i.disposeIntermediateTensorInfo(c),i.disposeIntermediateTensorInfo(y),i.disposeIntermediateTensorInfo(b),w}{const e=i.data.get(n.dataId).values,t=i.data.get(a.dataId).values,s=n.dtype,[r,o]=zo(n.shape,a.shape,e,t,s);return i.makeTensorInfo(o,s,r)}});var jo,zo,Do;const Fo={kernelName:X,backendName:"cpu",kernelFunc:Eo};
3362
3362
  /**
3363
3363
  * @license
3364
3364
  * Copyright 2020 Google LLC. All Rights Reserved.
@@ -3540,7 +3540,7 @@ function Wo(e){const{inputs:t,backend:n,attrs:a}=e,{x:i}=t,{shape:s}=a,r=N(i.sha
3540
3540
  * See the License for the specific language governing permissions and
3541
3541
  * limitations under the License.
3542
3542
  * =============================================================================
3543
- */const Vo={kernelName:ke,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:a}=e,{x:i,indices:s}=t,{axis:r,batchDims:o}=a;yo([i,s],"gatherV2");const l=C(r,i.shape)[0],c=n.data.get(s.dataId).values,u=i.shape[l];for(let e=0;e<c.length;++e){const t=c[e];x(t<=u-1&&t>=0,(()=>`GatherV2: the index value ${t} is not in [0, ${u-1}]`))}let h=o;null==o&&(h=0);const p=N(s.shape),d=function(e,t,n,a){const i=t.shape.length,s=e.shape.length;if(0!==a&&(a<-i||a>i))throw new Error(`Expect batchDims in the range of [-${i}, ${i}], but got ${a}`);if(a<0&&(a+=i),a>s)throw new Error(`batchDims (${a}) must be less than rank(x) (\n ${s}).`);if(n<a)throw new Error(`batchDims (${a}) must be less than or equal to axis (${n}).`);for(let n=0;n<a;++n)if(e.shape[n]!==t.shape[n])throw new Error(`x.shape[${n}]: ${e.shape[n]} should be equal to indices.shape[${n}]: ${t.shape[n]}.`);const r=e.shape[n],o=[];let l=1,c=1,u=1;for(let t=0;t<a;++t)o.push(e.shape[t]),l*=e.shape[t];for(let t=a;t<n;t++)o.push(e.shape[t]),c*=e.shape[t];for(let e=a;e<i;e++)o.push(t.shape[e]);for(let t=n+1;t<s;t++)o.push(e.shape[t]),u*=e.shape[t];return{batchSize:l,sliceSize:u,outerSize:c,dimSize:r,outputShape:o}}(i,s,l,h),f=Wo({inputs:{x:i},backend:n,attrs:{shape:[d.batchSize,d.outerSize,d.dimSize,d.sliceSize]}}),m=Wo({inputs:{x:s},backend:n,attrs:{shape:[d.batchSize,p/d.batchSize]}}),g=[d.batchSize,d.outerSize,p/d.batchSize,d.sliceSize],v=n.bufferSync(m),y=function(e,t,n){const a=Xa(n,e.dtype);for(let n=0;n<a.size;++n){const i=a.indexToLoc(n).slice(),s=i[0],r=i[2],o=t.locToIndex([s,r]);i[2]=t.values[o];const l=e.locToIndex(i);0<=l&&l<e.values.length&&(a.values[n]=e.values[l])}return a}(n.bufferSync(f),v,g);return n.disposeIntermediateTensorInfo(f),n.disposeIntermediateTensorInfo(m),n.makeTensorInfo(d.outputShape,y.dtype,y.values)}};
3543
+ */const Vo={kernelName:ke,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:a}=e,{x:i,indices:s}=t,{axis:r,batchDims:o}=a;yo([i,s],"gatherV2");const l=$(r,i.shape)[0],c=n.data.get(s.dataId).values,u=i.shape[l];for(let e=0;e<c.length;++e){const t=c[e];x(t<=u-1&&t>=0,(()=>`GatherV2: the index value ${t} is not in [0, ${u-1}]`))}let h=o;null==o&&(h=0);const p=N(s.shape),d=function(e,t,n,a){const i=t.shape.length,s=e.shape.length;if(0!==a&&(a<-i||a>i))throw new Error(`Expect batchDims in the range of [-${i}, ${i}], but got ${a}`);if(a<0&&(a+=i),a>s)throw new Error(`batchDims (${a}) must be less than rank(x) (\n ${s}).`);if(n<a)throw new Error(`batchDims (${a}) must be less than or equal to axis (${n}).`);for(let n=0;n<a;++n)if(e.shape[n]!==t.shape[n])throw new Error(`x.shape[${n}]: ${e.shape[n]} should be equal to indices.shape[${n}]: ${t.shape[n]}.`);const r=e.shape[n],o=[];let l=1,c=1,u=1;for(let t=0;t<a;++t)o.push(e.shape[t]),l*=e.shape[t];for(let t=a;t<n;t++)o.push(e.shape[t]),c*=e.shape[t];for(let e=a;e<i;e++)o.push(t.shape[e]);for(let t=n+1;t<s;t++)o.push(e.shape[t]),u*=e.shape[t];return{batchSize:l,sliceSize:u,outerSize:c,dimSize:r,outputShape:o}}(i,s,l,h),f=Wo({inputs:{x:i},backend:n,attrs:{shape:[d.batchSize,d.outerSize,d.dimSize,d.sliceSize]}}),m=Wo({inputs:{x:s},backend:n,attrs:{shape:[d.batchSize,p/d.batchSize]}}),g=[d.batchSize,d.outerSize,p/d.batchSize,d.sliceSize],v=n.bufferSync(m),y=function(e,t,n){const a=Xa(n,e.dtype);for(let n=0;n<a.size;++n){const i=a.indexToLoc(n).slice(),s=i[0],r=i[2],o=t.locToIndex([s,r]);i[2]=t.values[o];const l=e.locToIndex(i);0<=l&&l<e.values.length&&(a.values[n]=e.values[l])}return a}(n.bufferSync(f),v,g);return n.disposeIntermediateTensorInfo(f),n.disposeIntermediateTensorInfo(m),n.makeTensorInfo(d.outputShape,y.dtype,y.values)}};
3544
3544
  /**
3545
3545
  * @license
3546
3546
  * Copyright 2020 Google LLC. All Rights Reserved.
@@ -3556,7 +3556,7 @@ function Wo(e){const{inputs:t,backend:n,attrs:a}=e,{x:i}=t,{shape:s}=a,r=N(i.sha
3556
3556
  * See the License for the specific language governing permissions and
3557
3557
  * limitations under the License.
3558
3558
  * =============================================================================
3559
- */const Ko={kernelName:Qe,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:a}=e,{x:i}=t,{axis:s,keepDims:r}=a;let o;yo(i,"sum"),o="bool"===i.dtype?Io({inputs:{x:i},backend:n,attrs:{dtype:"int32"}}):No({inputs:{x:i},backend:n});const l=o.shape.length,c=C(s,o.shape),u=Ci(c,l);let h=c,p=o;null!=u&&(p=Ro({inputs:{x:o},backend:n,attrs:{perm:u}}),h=function(e,t){const n=[];for(let a=t-e;a<t;++a)n.push(a);return n}(h.length,l)),function(e,t,n){x(Ti(t,n),(()=>`${e} supports only inner-most axes for now. Got axes ${t} and rank-${n} input.`))}("sum",h,p.shape.length);const[d,f]=Ii(p.shape,h);let m=So(n,d,qt(p.dtype,"int32"));const g=N(f),v=n.data.get(m.dataId).values,y=n.data.get(p.dataId).values;for(let e=0;e<v.length;++e){const t=e*g;let n=0;for(let e=0;e<g;++e)n+=y[t+e];v[e]=n}if(r){const e=m;m=Wo({inputs:{x:m},backend:n,attrs:{shape:$i(m.shape,c)}}),n.disposeIntermediateTensorInfo(e)}return n.disposeIntermediateTensorInfo(o),null!=u&&n.disposeIntermediateTensorInfo(p),m}};
3559
+ */const Ko={kernelName:Qe,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:a}=e,{x:i}=t,{axis:s,keepDims:r}=a;let o;yo(i,"sum"),o="bool"===i.dtype?Io({inputs:{x:i},backend:n,attrs:{dtype:"int32"}}):No({inputs:{x:i},backend:n});const l=o.shape.length,c=$(s,o.shape),u=$i(c,l);let h=c,p=o;null!=u&&(p=Ro({inputs:{x:o},backend:n,attrs:{perm:u}}),h=function(e,t){const n=[];for(let a=t-e;a<t;++a)n.push(a);return n}(h.length,l)),function(e,t,n){x(Ti(t,n),(()=>`${e} supports only inner-most axes for now. Got axes ${t} and rank-${n} input.`))}("sum",h,p.shape.length);const[d,f]=Ii(p.shape,h);let m=So(n,d,qt(p.dtype,"int32"));const g=N(f),v=n.data.get(m.dataId).values,y=n.data.get(p.dataId).values;for(let e=0;e<v.length;++e){const t=e*g;let n=0;for(let e=0;e<g;++e)n+=y[t+e];v[e]=n}if(r){const e=m;m=Wo({inputs:{x:m},backend:n,attrs:{shape:Ci(m.shape,c)}}),n.disposeIntermediateTensorInfo(e)}return n.disposeIntermediateTensorInfo(o),null!=u&&n.disposeIntermediateTensorInfo(p),m}};
3560
3560
  /**
3561
3561
  * @license
3562
3562
  * Copyright 2020 Google LLC. All Rights Reserved.
@@ -3705,7 +3705,7 @@ return function(e){const{inputs:t,backend:n,attrs:a}=e,{x:i}=t,{alpha:s}=a;yo([i
3705
3705
  * limitations under the License.
3706
3706
  * =============================================================================
3707
3707
  */
3708
- function(e){const{inputs:t,backend:n,attrs:a}=e,{a:i,b:s,bias:r,preluActivationWeights:o}=t,{transposeA:l,transposeB:c,activation:u,leakyreluAlpha:h}=a;let p,d,f;const m=[],g=function(e){const{inputs:t,backend:n,attrs:a}=e,{a:i,b:s}=t,{transposeA:r,transposeB:o}=a;yo([i,s],"matMul");const l=i.shape.length,c=s.shape.length,u=r?i.shape[l-2]:i.shape[l-1],h=o?s.shape[c-1]:s.shape[c-2],p=r?i.shape[l-1]:i.shape[l-2],d=o?s.shape[c-2]:s.shape[c-1],f=i.shape.slice(0,-2),m=s.shape.slice(0,-2),g=N(f),v=N(m),y=ma(i.shape.slice(0,-2),s.shape.slice(0,-2)).concat([p,d]);x(u===h,(()=>`Error in matMul: inner shapes (${u}) and (${h}) of Tensors with shapes ${i.shape} and ${s.shape} and transposeA=${r} and transposeB=${o} must match.`));const b=o?[v,d,h]:[v,h,d],w=Wo({inputs:{x:i},backend:n,attrs:{shape:r?[g,u,p]:[g,p,u]}}),k=Wo({inputs:{x:s},backend:n,attrs:{shape:b}}),S=r?w.shape[1]:w.shape[2],T=r?w.shape[2]:w.shape[1],I=o?k.shape[1]:k.shape[2],$=Math.max(g,v),C=n.data.get(w.dataId).values,A=n.data.get(k.dataId).values,E=R(w.shape),j=R(k.shape),[z,D,F]=r?[E[0],1,E[1]]:[E[0],E[1],1],[_,L,M]=o?[1,j[1],j[0]]:[j[1],1,j[0]],O=T*I,P=Xa([$,T,I],w.dtype),B=P.values,U=n.blockSize;for(let e=0;e<$;e++){const t=e%g,n=e%v;for(let a=0;a<T;a+=U){const i=Math.min(a+U,T);for(let s=0;s<I;s+=U){const r=Math.min(s+U,I);for(let o=0;o<S;o+=U){const l=Math.min(o+U,S);for(let c=a;c<i;c++)for(let a=s;a<r;a++){let i=0;for(let e=o;e<l;e++)i+=C[t*z+c*D+e*F]*A[e*_+a*L+n*M];B[e*O+(c*I+a)]+=i}}}}}return n.disposeIntermediateTensorInfo(w),n.disposeIntermediateTensorInfo(k),n.makeTensorInfo(y,P.dtype,P.values)}({inputs:{a:i,b:s},attrs:{transposeA:l,transposeB:c},backend:n});p=g,r&&(d=Eo({inputs:{a:p,b:r},backend:n}),m.push(p),p=d),u&&(f=el(n,p,u,o,h),m.push(p),p=f);for(const e of m)n.disposeIntermediateTensorInfo(e);return p}};
3708
+ function(e){const{inputs:t,backend:n,attrs:a}=e,{a:i,b:s,bias:r,preluActivationWeights:o}=t,{transposeA:l,transposeB:c,activation:u,leakyreluAlpha:h}=a;let p,d,f;const m=[],g=function(e){const{inputs:t,backend:n,attrs:a}=e,{a:i,b:s}=t,{transposeA:r,transposeB:o}=a;yo([i,s],"matMul");const l=i.shape.length,c=s.shape.length,u=r?i.shape[l-2]:i.shape[l-1],h=o?s.shape[c-1]:s.shape[c-2],p=r?i.shape[l-1]:i.shape[l-2],d=o?s.shape[c-2]:s.shape[c-1],f=i.shape.slice(0,-2),m=s.shape.slice(0,-2),g=N(f),v=N(m),y=ma(i.shape.slice(0,-2),s.shape.slice(0,-2)).concat([p,d]);x(u===h,(()=>`Error in matMul: inner shapes (${u}) and (${h}) of Tensors with shapes ${i.shape} and ${s.shape} and transposeA=${r} and transposeB=${o} must match.`));const b=o?[v,d,h]:[v,h,d],w=Wo({inputs:{x:i},backend:n,attrs:{shape:r?[g,u,p]:[g,p,u]}}),k=Wo({inputs:{x:s},backend:n,attrs:{shape:b}}),S=r?w.shape[1]:w.shape[2],T=r?w.shape[2]:w.shape[1],I=o?k.shape[1]:k.shape[2],C=Math.max(g,v),$=n.data.get(w.dataId).values,A=n.data.get(k.dataId).values,E=R(w.shape),j=R(k.shape),[z,D,F]=r?[E[0],1,E[1]]:[E[0],E[1],1],[_,L,M]=o?[1,j[1],j[0]]:[j[1],1,j[0]],O=T*I,P=Xa([C,T,I],w.dtype),B=P.values,U=n.blockSize;for(let e=0;e<C;e++){const t=e%g,n=e%v;for(let a=0;a<T;a+=U){const i=Math.min(a+U,T);for(let s=0;s<I;s+=U){const r=Math.min(s+U,I);for(let o=0;o<S;o+=U){const l=Math.min(o+U,S);for(let c=a;c<i;c++)for(let a=s;a<r;a++){let i=0;for(let e=o;e<l;e++)i+=$[t*z+c*D+e*F]*A[e*_+a*L+n*M];B[e*O+(c*I+a)]+=i}}}}}return n.disposeIntermediateTensorInfo(w),n.disposeIntermediateTensorInfo(k),n.makeTensorInfo(y,P.dtype,P.values)}({inputs:{a:i,b:s},attrs:{transposeA:l,transposeB:c},backend:n});p=g,r&&(d=Eo({inputs:{a:p,b:r},backend:n}),m.push(p),p=d),u&&(f=el(n,p,u,o,h),m.push(p),p=f);for(const e of m)n.disposeIntermediateTensorInfo(e);return p}};
3709
3709
  /**
3710
3710
  * @license
3711
3711
  * Copyright 2018 Google LLC
@@ -3741,7 +3741,7 @@ function(e){const{inputs:t,backend:n,attrs:a}=e,{a:i,b:s,bias:r,preluActivationW
3741
3741
  * license that can be found in the LICENSE file or at
3742
3742
  * https://opensource.org/licenses/MIT.
3743
3743
  * =============================================================================
3744
- */let $l=0;function Cl(){return $l++}const Al={};function El(e=""){return e in Al||(Al[e]=0),Al[e]+=1,e+Al[e].toString()}
3744
+ */let Cl=0;function $l(){return Cl++}const Al={};function El(e=""){return e in Al||(Al[e]=0),Al[e]+=1,e+Al[e].toString()}
3745
3745
  /**
3746
3746
  * @license
3747
3747
  * Copyright 2018 Google LLC
@@ -3797,7 +3797,7 @@ function Ql(e,t){return ra(e,t)}function Xl(e,t=-1){const n=e.shape.slice();retu
3797
3797
  * https://opensource.org/licenses/MIT.
3798
3798
  * =============================================================================
3799
3799
  */
3800
- var t;this.scale=null==e.scale?1:e.scale,this.mode=null==e.mode?"fanIn":e.mode,t=this.mode,xl(fc,"FanMode",t),this.distribution=null==e.distribution?"normal":e.distribution,function(e){xl(mc,"Distribution",e)}(this.distribution),this.seed=e.seed}apply(e,t){const n=function(e,t="channelsLast"){let n,a;if(Ll(t),2===e.length)n=e[0],a=e[1];else if(-1!==[3,4,5].indexOf(e.length)){if("channelsFirst"===t){const t=Kl(e,2);n=e[1]*t,a=e[0]*t}else if("channelsLast"===t){const t=Kl(e,0,e.length-2);n=e[e.length-2]*t,a=e[e.length-1]*t}}else{const t=Kl(e);n=Math.sqrt(t),a=Math.sqrt(t)}return[n,a]}(e),a=n[0],i=n[1];let s=this.scale;if("fanIn"===this.mode?s/=Math.max(1,a):"fanOut"===this.mode?s/=Math.max(1,i):s/=Math.max(1,(a+i)/2),"normal"===this.distribution){const n=Math.sqrt(s);if("float32"!==(t=t||"float32")&&"int32"!==t)throw new sl(`${this.getClassName()} does not support dType ${t}.`);return fr(e,0,n,t,this.seed)}{const n=Math.sqrt(3*s);return Ks(e,-n,n,t,this.seed)}}getConfig(){return{scale:this.scale,mode:this.mode,distribution:this.distribution,seed:this.seed}}}Nc.className="VarianceScaling",ka(Nc);class Tc extends Nc{constructor(e){super({scale:1,mode:"fanAvg",distribution:"uniform",seed:null==e?null:e.seed})}getClassName(){return Nc.className}}Tc.className="GlorotUniform",ka(Tc);class Ic extends Nc{constructor(e){super({scale:1,mode:"fanAvg",distribution:"normal",seed:null==e?null:e.seed})}getClassName(){return Nc.className}}Ic.className="GlorotNormal",ka(Ic);class $c extends Nc{constructor(e){super({scale:2,mode:"fanIn",distribution:"normal",seed:null==e?null:e.seed})}getClassName(){return Nc.className}}$c.className="HeNormal",ka($c);class Cc extends Nc{constructor(e){super({scale:2,mode:"fanIn",distribution:"uniform",seed:null==e?null:e.seed})}getClassName(){return Nc.className}}Cc.className="HeUniform",ka(Cc);class Ac extends Nc{constructor(e){super({scale:1,mode:"fanIn",distribution:"normal",seed:null==e?null:e.seed})}getClassName(){return Nc.className}}Ac.className="LeCunNormal",ka(Ac);class Ec extends Nc{constructor(e){super({scale:1,mode:"fanIn",distribution:"uniform",seed:null==e?null:e.seed})}getClassName(){return Nc.className}}Ec.className="LeCunUniform",ka(Ec);class jc extends gc{constructor(e){super(),this.DEFAULT_GAIN=1,this.ELEMENTS_WARN_SLOW=2e3,this.gain=null==e.gain?this.DEFAULT_GAIN:e.gain,this.seed=e.seed}apply(e,t){return wn((()=>{if(e.length<2)throw new sl("Shape must be at least 2D.");if("int32"!==t&&"float32"!==t&&void 0!==t)throw new TypeError(`Unsupported data type ${t}.`);const n=N(e.slice(0,-1)),a=e[e.length-1],i=n*a;i>this.ELEMENTS_WARN_SLOW&&console.warn(`Orthogonal initializer is being called on a matrix with more than ${this.ELEMENTS_WARN_SLOW} (${i}) elements: Slowness may result.`);const s=rc([Math.max(a,n),Math.min(a,n)],0,1,t,this.seed),r=Yr.qr(s,!1);let o=r[0];const l=r[1].flatten().stridedSlice([0],[Math.min(a,n)*Math.min(a,n)],[Math.min(a,n)+1]);return o=Ta(o,l.sign()),n<a&&(o=o.transpose()),Ta(Di(this.gain),o.reshape(e))}))}getConfig(){return{gain:this.gain,seed:this.seed}}}jc.className="Orthogonal",ka(jc);const zc={constant:"Constant",glorotNormal:"GlorotNormal",glorotUniform:"GlorotUniform",heNormal:"HeNormal",heUniform:"HeUniform",identity:"Identity",leCunNormal:"LeCunNormal",leCunUniform:"LeCunUniform",ones:"Ones",orthogonal:"Orthogonal",randomNormal:"RandomNormal",randomUniform:"RandomUniform",truncatedNormal:"TruncatedNormal",varianceScaling:"VarianceScaling",zeros:"Zeros"};function Dc(e,t={}){return yl(e,wa.getMap().classNameMap,t,"initializer")}function Fc(e){return gl(e)}function _c(e){if("string"==typeof e){const t=e in zc?zc[e]:e;if("GlorotNormal"===t)return new Ic;if("GlorotUniform"===t)return new Tc;if("HeNormal"===t)return new $c;if("HeUniform"===t)return new Cc;if("LeCunNormal"===t)return new Ac;if("LeCunUniform"===t)return new Ec;{const e={};return e.className=t,e.config={},Dc(e)}}return e instanceof gc?e:Dc(e)}
3800
+ var t;this.scale=null==e.scale?1:e.scale,this.mode=null==e.mode?"fanIn":e.mode,t=this.mode,xl(fc,"FanMode",t),this.distribution=null==e.distribution?"normal":e.distribution,function(e){xl(mc,"Distribution",e)}(this.distribution),this.seed=e.seed}apply(e,t){const n=function(e,t="channelsLast"){let n,a;if(Ll(t),2===e.length)n=e[0],a=e[1];else if(-1!==[3,4,5].indexOf(e.length)){if("channelsFirst"===t){const t=Kl(e,2);n=e[1]*t,a=e[0]*t}else if("channelsLast"===t){const t=Kl(e,0,e.length-2);n=e[e.length-2]*t,a=e[e.length-1]*t}}else{const t=Kl(e);n=Math.sqrt(t),a=Math.sqrt(t)}return[n,a]}(e),a=n[0],i=n[1];let s=this.scale;if("fanIn"===this.mode?s/=Math.max(1,a):"fanOut"===this.mode?s/=Math.max(1,i):s/=Math.max(1,(a+i)/2),"normal"===this.distribution){const n=Math.sqrt(s);if("float32"!==(t=t||"float32")&&"int32"!==t)throw new sl(`${this.getClassName()} does not support dType ${t}.`);return fr(e,0,n,t,this.seed)}{const n=Math.sqrt(3*s);return Ks(e,-n,n,t,this.seed)}}getConfig(){return{scale:this.scale,mode:this.mode,distribution:this.distribution,seed:this.seed}}}Nc.className="VarianceScaling",ka(Nc);class Tc extends Nc{constructor(e){super({scale:1,mode:"fanAvg",distribution:"uniform",seed:null==e?null:e.seed})}getClassName(){return Nc.className}}Tc.className="GlorotUniform",ka(Tc);class Ic extends Nc{constructor(e){super({scale:1,mode:"fanAvg",distribution:"normal",seed:null==e?null:e.seed})}getClassName(){return Nc.className}}Ic.className="GlorotNormal",ka(Ic);class Cc extends Nc{constructor(e){super({scale:2,mode:"fanIn",distribution:"normal",seed:null==e?null:e.seed})}getClassName(){return Nc.className}}Cc.className="HeNormal",ka(Cc);class $c extends Nc{constructor(e){super({scale:2,mode:"fanIn",distribution:"uniform",seed:null==e?null:e.seed})}getClassName(){return Nc.className}}$c.className="HeUniform",ka($c);class Ac extends Nc{constructor(e){super({scale:1,mode:"fanIn",distribution:"normal",seed:null==e?null:e.seed})}getClassName(){return Nc.className}}Ac.className="LeCunNormal",ka(Ac);class Ec extends Nc{constructor(e){super({scale:1,mode:"fanIn",distribution:"uniform",seed:null==e?null:e.seed})}getClassName(){return Nc.className}}Ec.className="LeCunUniform",ka(Ec);class jc extends gc{constructor(e){super(),this.DEFAULT_GAIN=1,this.ELEMENTS_WARN_SLOW=2e3,this.gain=null==e.gain?this.DEFAULT_GAIN:e.gain,this.seed=e.seed}apply(e,t){return wn((()=>{if(e.length<2)throw new sl("Shape must be at least 2D.");if("int32"!==t&&"float32"!==t&&void 0!==t)throw new TypeError(`Unsupported data type ${t}.`);const n=N(e.slice(0,-1)),a=e[e.length-1],i=n*a;i>this.ELEMENTS_WARN_SLOW&&console.warn(`Orthogonal initializer is being called on a matrix with more than ${this.ELEMENTS_WARN_SLOW} (${i}) elements: Slowness may result.`);const s=rc([Math.max(a,n),Math.min(a,n)],0,1,t,this.seed),r=Yr.qr(s,!1);let o=r[0];const l=r[1].flatten().stridedSlice([0],[Math.min(a,n)*Math.min(a,n)],[Math.min(a,n)+1]);return o=Ta(o,l.sign()),n<a&&(o=o.transpose()),Ta(Di(this.gain),o.reshape(e))}))}getConfig(){return{gain:this.gain,seed:this.seed}}}jc.className="Orthogonal",ka(jc);const zc={constant:"Constant",glorotNormal:"GlorotNormal",glorotUniform:"GlorotUniform",heNormal:"HeNormal",heUniform:"HeUniform",identity:"Identity",leCunNormal:"LeCunNormal",leCunUniform:"LeCunUniform",ones:"Ones",orthogonal:"Orthogonal",randomNormal:"RandomNormal",randomUniform:"RandomUniform",truncatedNormal:"TruncatedNormal",varianceScaling:"VarianceScaling",zeros:"Zeros"};function Dc(e,t={}){return yl(e,wa.getMap().classNameMap,t,"initializer")}function Fc(e){return gl(e)}function _c(e){if("string"==typeof e){const t=e in zc?zc[e]:e;if("GlorotNormal"===t)return new Ic;if("GlorotUniform"===t)return new Tc;if("HeNormal"===t)return new Cc;if("HeUniform"===t)return new $c;if("LeCunNormal"===t)return new Ac;if("LeCunUniform"===t)return new Ec;{const e={};return e.className=t,e.config={},Dc(e)}}return e instanceof gc?e:Dc(e)}
3801
3801
  /**
3802
3802
  * @license
3803
3803
  * Copyright 2018 Google LLC
@@ -3824,7 +3824,7 @@ var t;this.scale=null==e.scale?1:e.scale,this.mode=null==e.mode?"fanIn":e.mode,t
3824
3824
  * license that can be found in the LICENSE file or at
3825
3825
  * https://opensource.org/licenses/MIT.
3826
3826
  * =============================================================================
3827
- */const Bc="Variable";class Uc{constructor(e,t="float32",n=Bc,a=!0,i=null){this.dtype=null==t?"float32":t,this.shape=e.shape,this.id=Cl(),n=null==n?Bc:n,this.originalName=Ul(n),this.name=Wl(this.originalName),this.trainable_=a,this.constraint=i,this.val=function(e,t=!0,n,a){return an.makeVariable(e,t,n,a)}(e,this.trainable_,this.name,this.dtype)}read(){return this.assertNotDisposed(),this.val}write(e){return this.assertNotDisposed(),function(e,t){if(e.shape.toString()!==t.shape.toString())throw new Error("Shape mismatch: "+JSON.stringify(e.shape)+" vs. "+JSON.stringify(t.shape))}(this.val,e),this.val.id!==e.id&&(this.val.assign(e),null!=this.constraint&&this.val.assign(this.constraint.apply(this.val))),this}dispose(){this.assertNotDisposed(),this.val.dispose()}assertNotDisposed(){if(this.val.isDisposed)throw new Error(`LayersVariable ${this.name} is already disposed.`)}get trainable(){return this.trainable_}set trainable(e){this.trainable_=e,this.val.trainable=e}}function Wc(e){return e.map((e=>e.read()))}function Gc(e){e.forEach((e=>{e[0].write(e[1])}))}
3827
+ */const Bc="Variable";class Uc{constructor(e,t="float32",n=Bc,a=!0,i=null){this.dtype=null==t?"float32":t,this.shape=e.shape,this.id=$l(),n=null==n?Bc:n,this.originalName=Ul(n),this.name=Wl(this.originalName),this.trainable_=a,this.constraint=i,this.val=function(e,t=!0,n,a){return an.makeVariable(e,t,n,a)}(e,this.trainable_,this.name,this.dtype)}read(){return this.assertNotDisposed(),this.val}write(e){return this.assertNotDisposed(),function(e,t){if(e.shape.toString()!==t.shape.toString())throw new Error("Shape mismatch: "+JSON.stringify(e.shape)+" vs. "+JSON.stringify(t.shape))}(this.val,e),this.val.id!==e.id&&(this.val.assign(e),null!=this.constraint&&this.val.assign(this.constraint.apply(this.val))),this}dispose(){this.assertNotDisposed(),this.val.dispose()}assertNotDisposed(){if(this.val.isDisposed)throw new Error(`LayersVariable ${this.name} is already disposed.`)}get trainable(){return this.trainable_}set trainable(e){this.trainable_=e,this.val.trainable=e}}function Wc(e){return e.map((e=>e.read()))}function Gc(e){e.forEach((e=>{e[0].write(e[1])}))}
3828
3828
  /**
3829
3829
  * @license
3830
3830
  * Copyright 2018 Google LLC
@@ -3833,7 +3833,7 @@ var t;this.scale=null==e.scale?1:e.scale,this.mode=null==e.mode?"fanIn":e.mode,t
3833
3833
  * license that can be found in the LICENSE file or at
3834
3834
  * https://opensource.org/licenses/MIT.
3835
3835
  * =============================================================================
3836
- */class Vc{constructor(e){this.dtype=e.dtype,this.shape=e.shape,null!=e.shape?this.ndim=e.shape.length:this.ndim=e.ndim,this.maxNDim=e.maxNDim,this.minNDim=e.minNDim,this.axes=e.axes||{}}}class Kc{constructor(e,t,n,a,i,s,r){this.dtype=e,this.shape=t,this.sourceLayer=n,this.inputs=a,this.callArgs=i,this.outputTensorIndex=r,this.id=Cl(),null!=s&&(this.originalName=Ul(s),this.name=Wl(this.originalName)),this.rank=t.length}}let qc=0;class Hc{constructor(e,t){this.callArgs=t,this.id=qc++,this.outboundLayer=e.outboundLayer,this.inboundLayers=e.inboundLayers,this.nodeIndices=e.nodeIndices,this.tensorIndices=e.tensorIndices,this.inputTensors=e.inputTensors,this.outputTensors=e.outputTensors,this.inputMasks=e.inputMasks,this.outputMasks=e.outputMasks,this.inputShapes=e.inputShapes,this.outputShapes=e.outputShapes;for(const t of e.inboundLayers)null!=t&&t.outboundNodes.push(this);e.outboundLayer.inboundNodes.push(this)}getConfig(){const e=[];for(const t of this.inboundLayers)null!=t?e.push(t.name):e.push(null);return{outboundLayer:this.outboundLayer?this.outboundLayer.name:null,inboundLayers:e,nodeIndices:this.nodeIndices,tensorIndices:this.tensorIndices}}}let Jc=0;class Zc extends ba{constructor(e={}){super(),this._callHook=null,this._addedWeightNames=[],this._stateful=!1,this.id=Jc++,this.activityRegularizer=null,this.inputSpec=null,this.supportsMasking=!1,this._trainableWeights=[],this._nonTrainableWeights=[],this._losses=[],this._updates=[],this._built=!1,this.inboundNodes=[],this.outboundNodes=[];let t=e.name;if(!t){const e=this.getClassName();t=dl(e)+"_"+El(e)}if(this.name=t,this.trainable_=null==e.trainable||e.trainable,null!=e.inputShape||null!=e.batchInputShape){let t;if(null!=e.batchInputShape)t=e.batchInputShape;else if(null!=e.inputShape){let n=null;null!=e.batchSize&&(n=e.batchSize),t=[n].concat(e.inputShape)}this.batchInputShape=t;let n=e.dtype;null==n&&(n=e.inputDType),null==n&&(n="float32"),this.dtype=n}null!=e.weights?this.initialWeights=e.weights:this.initialWeights=null,this._refCount=null,this.fastWeightInitDuringBuild=!1}static nodeKey(e,t){return e.name+"_ib-"+t.toString()}getNodeAtIndex(e,t){if(0===this.inboundNodes.length)throw new al(`The layer has never been called and thus has no defined ${t}.`);if(this.inboundNodes.length<=e)throw new il(`Asked to get ${t} at node ${e}, but the layer has only ${this.inboundNodes.length} inbound nodes.`);return this.inboundNodes[e]}getInputAt(e){return hl(this.getNodeAtIndex(e,"input").inputTensors)}getOutputAt(e){return hl(this.getNodeAtIndex(e,"output").outputTensors)}get input(){if(this.inboundNodes.length>1)throw new nl(`Layer ${this.name} has multiple inbound nodes, hence the notion of "layer input" is ill-defined. Use \`getInputAt(nodeIndex)\` instead.`);if(0===this.inboundNodes.length)throw new nl(`Layer ${this.name} is not connected, no input to return.`);return hl(this.getNodeAtIndex(0,"input").inputTensors)}get output(){if(0===this.inboundNodes.length)throw new nl(`Layer ${this.name} has no inbound nodes.`);if(this.inboundNodes.length>1)throw new nl(`Layer ${this.name} has multiple inbound nodes, hence the notion of "layer output" is ill-defined. Use \`getOutputAt(nodeIndex)\` instead.`);return hl(this.getNodeAtIndex(0,"output").outputTensors)}get losses(){return this._losses}calculateLosses(){return this.losses.map((e=>e()))}get updates(){return this._updates}get built(){return this._built}set built(e){this._built=e}get trainable(){return this.trainable_}set trainable(e){this._trainableWeights.forEach((t=>t.trainable=e)),this.trainable_=e}get trainableWeights(){return this.trainable_?this._trainableWeights.filter((e=>e.trainable)):[]}set trainableWeights(e){this._trainableWeights=e}get nonTrainableWeights(){return this.trainable?this._trainableWeights.filter((e=>!e.trainable)).concat(this._nonTrainableWeights):this._trainableWeights.concat(this._nonTrainableWeights)}set nonTrainableWeights(e){this._nonTrainableWeights=e}get weights(){return this.trainableWeights.concat(this.nonTrainableWeights)}get stateful(){return this._stateful}resetStates(){if(!this.stateful)throw new Error("Cannot call the resetStates() method of a non-stateful Layer object.")}assertInputCompatibility(e){const t=pl(e);if(null==this.inputSpec||0===this.inputSpec.length)return;const n=pl(this.inputSpec);if(t.length!==n.length)throw new il(`Layer ${this.name} expects ${n.length} inputs, but it received ${t.length} input tensors. Input received: ${e}`);for(let e=0;e<t.length;e++){const a=t[e],i=n[e];if(null==i)continue;const s=a.rank;if(null!=i.ndim&&s!==i.ndim)throw new il(`Input ${e} is incompatible with layer ${this.name}: expected ndim=${i.ndim}, found ndim=${s}`);if(null!=i.maxNDim&&s>i.maxNDim)throw new il(`Input ${e} is incompatible with layer ${this.name}: expected max_ndim=${i.maxNDim}, found ndim=${s}`);if(null!=i.minNDim&&s<i.minNDim)throw new il(`Input ${e} is incompatible with layer ${this.name}: expected min_ndim=${i.minNDim}, found ndim=${s}.`);if(null!=i.dtype&&a.dtype!==i.dtype)throw new il(`Input ${e} is incompatible with layer ${this.name} : expected dtype=${i.dtype}, found dtype=${a.dtype}.`);if(i.axes){const t=a.shape;for(const n in i.axes){const a=Number(n),s=i.axes[n],r=a>=0?t[a]:t[t.length+a];if(null!=s&&-1===[s,null].indexOf(r))throw new il(`Input ${e} is incompatible with layer ${this.name}: expected axis ${a} of input shape to have value ${s} but got shape ${t}.`)}}if(null!=i.shape)for(let t=0;t<i.shape.length;++t){const n=i.shape[t],s=a.shape[t];if(null!=n&&null!=s&&n!==s)throw new il(`Input ${e} is incompatible with layer ${this.name}: expected shape=${i.shape}, found shape=${a.shape}.`)}}}call(e,t){return e}invokeCallHook(e,t){null!=this._callHook&&this._callHook(e,t)}setCallHook(e){this._callHook=e}clearCallHook(){this._callHook=null}apply(e,t){t=t||{},this.assertNotDisposed();const n=pl(e),a=function(e){let t=!0;for(const n of pl(e))if(!(n instanceof Kc)){t=!1;break}return t}(e),i=function(e){let t=!0;for(const n of pl(e))if(n instanceof Kc){t=!1;break}return t}
3836
+ */class Vc{constructor(e){this.dtype=e.dtype,this.shape=e.shape,null!=e.shape?this.ndim=e.shape.length:this.ndim=e.ndim,this.maxNDim=e.maxNDim,this.minNDim=e.minNDim,this.axes=e.axes||{}}}class Kc{constructor(e,t,n,a,i,s,r){this.dtype=e,this.shape=t,this.sourceLayer=n,this.inputs=a,this.callArgs=i,this.outputTensorIndex=r,this.id=$l(),null!=s&&(this.originalName=Ul(s),this.name=Wl(this.originalName)),this.rank=t.length}}let qc=0;class Hc{constructor(e,t){this.callArgs=t,this.id=qc++,this.outboundLayer=e.outboundLayer,this.inboundLayers=e.inboundLayers,this.nodeIndices=e.nodeIndices,this.tensorIndices=e.tensorIndices,this.inputTensors=e.inputTensors,this.outputTensors=e.outputTensors,this.inputMasks=e.inputMasks,this.outputMasks=e.outputMasks,this.inputShapes=e.inputShapes,this.outputShapes=e.outputShapes;for(const t of e.inboundLayers)null!=t&&t.outboundNodes.push(this);e.outboundLayer.inboundNodes.push(this)}getConfig(){const e=[];for(const t of this.inboundLayers)null!=t?e.push(t.name):e.push(null);return{outboundLayer:this.outboundLayer?this.outboundLayer.name:null,inboundLayers:e,nodeIndices:this.nodeIndices,tensorIndices:this.tensorIndices}}}let Jc=0;class Zc extends ba{constructor(e={}){super(),this._callHook=null,this._addedWeightNames=[],this._stateful=!1,this.id=Jc++,this.activityRegularizer=null,this.inputSpec=null,this.supportsMasking=!1,this._trainableWeights=[],this._nonTrainableWeights=[],this._losses=[],this._updates=[],this._built=!1,this.inboundNodes=[],this.outboundNodes=[];let t=e.name;if(!t){const e=this.getClassName();t=dl(e)+"_"+El(e)}if(this.name=t,this.trainable_=null==e.trainable||e.trainable,null!=e.inputShape||null!=e.batchInputShape){let t;if(null!=e.batchInputShape)t=e.batchInputShape;else if(null!=e.inputShape){let n=null;null!=e.batchSize&&(n=e.batchSize),t=[n].concat(e.inputShape)}this.batchInputShape=t;let n=e.dtype;null==n&&(n=e.inputDType),null==n&&(n="float32"),this.dtype=n}null!=e.weights?this.initialWeights=e.weights:this.initialWeights=null,this._refCount=null,this.fastWeightInitDuringBuild=!1}static nodeKey(e,t){return e.name+"_ib-"+t.toString()}getNodeAtIndex(e,t){if(0===this.inboundNodes.length)throw new al(`The layer has never been called and thus has no defined ${t}.`);if(this.inboundNodes.length<=e)throw new il(`Asked to get ${t} at node ${e}, but the layer has only ${this.inboundNodes.length} inbound nodes.`);return this.inboundNodes[e]}getInputAt(e){return hl(this.getNodeAtIndex(e,"input").inputTensors)}getOutputAt(e){return hl(this.getNodeAtIndex(e,"output").outputTensors)}get input(){if(this.inboundNodes.length>1)throw new nl(`Layer ${this.name} has multiple inbound nodes, hence the notion of "layer input" is ill-defined. Use \`getInputAt(nodeIndex)\` instead.`);if(0===this.inboundNodes.length)throw new nl(`Layer ${this.name} is not connected, no input to return.`);return hl(this.getNodeAtIndex(0,"input").inputTensors)}get output(){if(0===this.inboundNodes.length)throw new nl(`Layer ${this.name} has no inbound nodes.`);if(this.inboundNodes.length>1)throw new nl(`Layer ${this.name} has multiple inbound nodes, hence the notion of "layer output" is ill-defined. Use \`getOutputAt(nodeIndex)\` instead.`);return hl(this.getNodeAtIndex(0,"output").outputTensors)}get losses(){return this._losses}calculateLosses(){return this.losses.map((e=>e()))}get updates(){return this._updates}get built(){return this._built}set built(e){this._built=e}get trainable(){return this.trainable_}set trainable(e){this._trainableWeights.forEach((t=>t.trainable=e)),this.trainable_=e}get trainableWeights(){return this.trainable_?this._trainableWeights.filter((e=>e.trainable)):[]}set trainableWeights(e){this._trainableWeights=e}get nonTrainableWeights(){return this.trainable?this._trainableWeights.filter((e=>!e.trainable)).concat(this._nonTrainableWeights):this._trainableWeights.concat(this._nonTrainableWeights)}set nonTrainableWeights(e){this._nonTrainableWeights=e}get weights(){return this.trainableWeights.concat(this.nonTrainableWeights)}get stateful(){return this._stateful}resetStates(){if(!this.stateful)throw new Error("Cannot call the resetStates() method of a non-stateful Layer object.")}assertInputCompatibility(e){const t=pl(e);if(null==this.inputSpec||0===this.inputSpec.length)return;const n=pl(this.inputSpec);if(t.length!==n.length)throw new il(`Layer ${this.name} expects ${n.length} inputs, but it received ${t.length} input tensors. Input received: ${e}`);for(let e=0;e<t.length;e++){const a=t[e],i=n[e];if(null==i)continue;const s=a.rank;if(null!=i.ndim&&s!==i.ndim)throw new il(`Input ${e} is incompatible with layer ${this.name}: expected ndim=${i.ndim}, found ndim=${s}`);if(null!=i.maxNDim&&s>i.maxNDim)throw new il(`Input ${e} is incompatible with layer ${this.name}: expected max_ndim=${i.maxNDim}, found ndim=${s}`);if(null!=i.minNDim&&s<i.minNDim)throw new il(`Input ${e} is incompatible with layer ${this.name}: expected min_ndim=${i.minNDim}, found ndim=${s}.`);if(null!=i.dtype&&a.dtype!==i.dtype)throw new il(`Input ${e} is incompatible with layer ${this.name} : expected dtype=${i.dtype}, found dtype=${a.dtype}.`);if(i.axes){const t=a.shape;for(const n in i.axes){const a=Number(n),s=i.axes[n],r=a>=0?t[a]:t[t.length+a];if(null!=s&&-1===[s,null].indexOf(r))throw new il(`Input ${e} is incompatible with layer ${this.name}: expected axis ${a} of input shape to have value ${s} but got shape ${t}.`)}}if(null!=i.shape)for(let t=0;t<i.shape.length;++t){const n=i.shape[t],s=a.shape[t];if(null!=n&&null!=s&&n!==s)throw new il(`Input ${e} is incompatible with layer ${this.name}: expected shape=${i.shape}, found shape=${a.shape}.`)}}}call(e,t){return e}invokeCallHook(e,t){null!=this._callHook&&this._callHook(e,t)}setCallHook(e){this._callHook=e}clearCallHook(){this._callHook=null}apply(e,t){t=t||{},this.assertNotDisposed();const n=pl(e),a=function(e){let t=!0;for(const n of pl(e))if(!(n instanceof Kc)){t=!1;break}return t}(e),i=function(e){let t=!0;for(const n of pl(e))if(n instanceof Kc){t=!1;break}return t}
3837
3837
  /**
3838
3838
  * @license
3839
3839
  * Copyright 2018 Google LLC
@@ -3951,7 +3951,7 @@ function(e,t,n,a,i,s){const r=un(e,"dy","avgPool3dGrad"),o=un(t,"input","avgPool
3951
3951
  * limitations under the License.
3952
3952
  * =============================================================================
3953
3953
  */
3954
- function(e,t,n,a,i){const s=un(e,"dy","avgPoolGrad"),r=un(t,"input","avgPoolGrad");x(r.rank===s.rank,(()=>`Rank of input (${r.rank}) does not match rank of dy (${s.rank})`));let o=r,l=s,c=!1;3===r.rank&&(c=!0,o=Ma(r,[1,r.shape[0],r.shape[1],r.shape[2]]),l=Ma(s,[1,s.shape[0],s.shape[1],s.shape[2]])),x(4===l.rank,(()=>`Error in avgPoolGrad: dy must be rank 4 but got rank ${l.rank}.`)),x(4===o.rank,(()=>`Error in avgPoolGrad: input must be rank 4 but got rank ${o.rank}.`));const u={dy:l,input:o},h={filterSize:n,strides:a,pad:i},p=an.runKernel("AvgPoolGrad",u,h);return c?Ma(p,[p.shape[1],p.shape[2],p.shape[3]]):p}}),ku={kernelName:te,inputsToSave:["x"],gradFunc:(e,t,n)=>{const[a]=t,{filterSize:i,strides:s,pad:r}=n;return{x:()=>wu(e,a,i,s,r)}}},xu={kernelName:ae,inputsToSave:["a","b"],gradFunc:(e,t,n)=>{const[a,i]=t,{transposeA:s,transposeB:r}=n;return s||r?!s&&r?{a:()=>oa(e,i,!1,!1),b:()=>oa(e,a,!0,!1)}:s&&!r?{a:()=>oa(i,e,!1,!0),b:()=>oa(a,e,!1,!1)}:{a:()=>oa(i,e,!0,!0),b:()=>oa(e,a,!0,!0)}:{a:()=>oa(e,i,!1,!0),b:()=>oa(a,e,!0,!1)}}},Su={kernelName:ie,gradFunc:(e,t,n)=>{const{blockShape:a,crops:i}=n;return{x:()=>gs(e,a,i)}}},Nu={kernelName:"BroadcastTo",gradFunc:(e,t,n)=>{const a=n,i=a.inputShape,s=a.shape,r=Array.from(s);for(let e=i.length-1;e>=0;e--)if(i[e]===s[e])r[e]=1;else if(1!==i[e])throw new Error(`broadcastTo(): [${i}] cannot be broadcast to [${s}].`);const o=[];for(let e=0;e<r.length;e++)r[e]>1&&o.push(e);return{x:()=>Ri(e,o,!0)}}},Tu={kernelName:se,gradFunc:e=>({x:()=>e.clone()})},Iu={kernelName:"Ceil",gradFunc:e=>({x:()=>ki(e)})},$u={kernelName:re,inputsToSave:["x"],gradFunc:(e,t,n)=>{const[a]=t,{clipValueMin:i,clipValueMax:s}=n;return{x:()=>wi(as(Ki(a,i),Ji(a,s)),e,ki(e))}}},Cu={kernelName:oe,inputsToSave:["x"],gradFunc:ru.gradFunc},Au={kernelName:le,saveAllInputs:!0,gradFunc:(e,t,n)=>{const a=t.map((e=>e.shape)),{axis:i}=n,s=C(i,t[0].shape)[0],r=a.map((e=>e[s]));return lr(e,r,s).map((e=>()=>e))}},Eu={kernelName:ce,inputsToSave:["x","filter"],gradFunc:(e,t,n)=>{const[a,i]=t,{dilations:s,strides:r,pad:o,dataFormat:l}=n;return x(Fa(s),(()=>`Error in gradient of conv2D: dilation rates greater than 1 are not yet supported in gradients. Got dilations '${s}'`)),{x:()=>li(a.shape,e,i,r,o,l),filter:()=>yr(a,e,i.shape,r,o,l)}}},ju={kernelName:ue,inputsToSave:["dy","filter"],gradFunc:(e,t,n)=>{const[a,i]=t,{strides:s,pad:r,dataFormat:o,dimRoundingMode:l}=n;return{dy:()=>ri(e,i,s,r,o,1,l),filter:()=>yr(e,a,i.shape,s,r,o,l)}}};
3954
+ function(e,t,n,a,i){const s=un(e,"dy","avgPoolGrad"),r=un(t,"input","avgPoolGrad");x(r.rank===s.rank,(()=>`Rank of input (${r.rank}) does not match rank of dy (${s.rank})`));let o=r,l=s,c=!1;3===r.rank&&(c=!0,o=Ma(r,[1,r.shape[0],r.shape[1],r.shape[2]]),l=Ma(s,[1,s.shape[0],s.shape[1],s.shape[2]])),x(4===l.rank,(()=>`Error in avgPoolGrad: dy must be rank 4 but got rank ${l.rank}.`)),x(4===o.rank,(()=>`Error in avgPoolGrad: input must be rank 4 but got rank ${o.rank}.`));const u={dy:l,input:o},h={filterSize:n,strides:a,pad:i},p=an.runKernel("AvgPoolGrad",u,h);return c?Ma(p,[p.shape[1],p.shape[2],p.shape[3]]):p}}),ku={kernelName:te,inputsToSave:["x"],gradFunc:(e,t,n)=>{const[a]=t,{filterSize:i,strides:s,pad:r}=n;return{x:()=>wu(e,a,i,s,r)}}},xu={kernelName:ae,inputsToSave:["a","b"],gradFunc:(e,t,n)=>{const[a,i]=t,{transposeA:s,transposeB:r}=n;return s||r?!s&&r?{a:()=>oa(e,i,!1,!1),b:()=>oa(e,a,!0,!1)}:s&&!r?{a:()=>oa(i,e,!1,!0),b:()=>oa(a,e,!1,!1)}:{a:()=>oa(i,e,!0,!0),b:()=>oa(e,a,!0,!0)}:{a:()=>oa(e,i,!1,!0),b:()=>oa(a,e,!0,!1)}}},Su={kernelName:ie,gradFunc:(e,t,n)=>{const{blockShape:a,crops:i}=n;return{x:()=>gs(e,a,i)}}},Nu={kernelName:"BroadcastTo",gradFunc:(e,t,n)=>{const a=n,i=a.inputShape,s=a.shape,r=Array.from(s);for(let e=i.length-1;e>=0;e--)if(i[e]===s[e])r[e]=1;else if(1!==i[e])throw new Error(`broadcastTo(): [${i}] cannot be broadcast to [${s}].`);const o=[];for(let e=0;e<r.length;e++)r[e]>1&&o.push(e);return{x:()=>Ri(e,o,!0)}}},Tu={kernelName:se,gradFunc:e=>({x:()=>e.clone()})},Iu={kernelName:"Ceil",gradFunc:e=>({x:()=>ki(e)})},Cu={kernelName:re,inputsToSave:["x"],gradFunc:(e,t,n)=>{const[a]=t,{clipValueMin:i,clipValueMax:s}=n;return{x:()=>wi(as(Ki(a,i),Ji(a,s)),e,ki(e))}}},$u={kernelName:oe,inputsToSave:["x"],gradFunc:ru.gradFunc},Au={kernelName:le,saveAllInputs:!0,gradFunc:(e,t,n)=>{const a=t.map((e=>e.shape)),{axis:i}=n,s=$(i,t[0].shape)[0],r=a.map((e=>e[s]));return lr(e,r,s).map((e=>()=>e))}},Eu={kernelName:ce,inputsToSave:["x","filter"],gradFunc:(e,t,n)=>{const[a,i]=t,{dilations:s,strides:r,pad:o,dataFormat:l}=n;return x(Fa(s),(()=>`Error in gradient of conv2D: dilation rates greater than 1 are not yet supported in gradients. Got dilations '${s}'`)),{x:()=>li(a.shape,e,i,r,o,l),filter:()=>yr(a,e,i.shape,r,o,l)}}},ju={kernelName:ue,inputsToSave:["dy","filter"],gradFunc:(e,t,n)=>{const[a,i]=t,{strides:s,pad:r,dataFormat:o,dimRoundingMode:l}=n;return{dy:()=>ri(e,i,s,r,o,1,l),filter:()=>yr(e,a,i.shape,s,r,o,l)}}};
3955
3955
  /**
3956
3956
  * @license
3957
3957
  * Copyright 2020 Google LLC. All Rights Reserved.
@@ -3984,7 +3984,7 @@ function(e,t,n,a,i){const s=un(e,"dy","avgPoolGrad"),r=un(t,"input","avgPoolGrad
3984
3984
  * limitations under the License.
3985
3985
  * =============================================================================
3986
3986
  */
3987
- function(e,t,n,a,i){let s=e;4===e.rank&&(s=Ma(e,[1,e.shape[0],e.shape[1],e.shape[2],e.shape[3]]));let r=t;4===r.rank&&(r=Ma(t,[1,t.shape[0],t.shape[1],t.shape[2],t.shape[3]])),x(5===s.rank,(()=>`Error in conv3dDerFilter: input must be rank 5, but got shape ${s.shape}.`)),x(5===r.rank,(()=>`Error in conv3dDerFilter: dy must be rank 5, but got shape ${r.shape}.`)),x(5===n.length,(()=>`Error in conv3dDerFilter: filterShape must be length 5, but got ${n}.`)),x(s.shape[4]===n[3],(()=>`Error in conv3dDerFilter: depth of input ${s.shape[4]}) must match input depth in filter (${n[3]}.`)),x(r.shape[4]===n[4],(()=>`Error in conv3dDerFilter: depth of dy (${r.shape[4]}) must match output depth for filter (${n[4]}).`));const o={x:s,dy:r},l={strides:a,pad:i,filterShape:n};return an.runKernel("Conv3DBackpropFilterV2",o,l)}}),Du={kernelName:he,inputsToSave:["x","filter"],gradFunc:(e,t,n)=>{const{dilations:a,strides:i,pad:s}=n;x(Fa(a),(()=>`Error in gradient of conv3D: dilation rates greater than 1 are not yet supported in gradients. Got dilations '${a}'`));const[r,o]=t;return{x:()=>hi(r.shape,e,o,i,s),filter:()=>zu(r,e,o.shape,i,s)}}},Fu={kernelName:"Cos",inputsToSave:["x"],gradFunc:(e,t)=>{const[n]=t;return{x:()=>Ta(ua(tr(ra(n,"float32"))),e)}}},_u={kernelName:pe,inputsToSave:["x"],gradFunc:(e,t)=>{const[n]=t;return{x:()=>Ta(nr(ra(n,"float32")),e)}}},Ru={kernelName:de,inputsToSave:["x"],gradFunc:(e,t,n)=>{const[a]=t,{axis:i,exclusive:s,reverse:r}=n;return{x:()=>{const t=Ci([i],a.rank);let n=gi(e,i,s,!r);return null!=t&&(n=pa(n,t)),n}}}},Lu={kernelName:fe,inputsToSave:["x","filter"],gradFunc:(e,t,n)=>{const{dilations:a,strides:i,pad:s,dimRoundingMode:r}=n,o=null==a?[1,1]:a;x(Fa(o),(()=>`Error in gradient of depthwiseConv2dNative: dilation rates greater than 1 are not yet supported. Got dilations '${o}'`));const[l,c]=t;return x(4===l.rank,(()=>`Error in gradient of depthwiseConv2dNative: input must be rank 4, but got rank ${l.rank}.`)),x(4===c.rank,(()=>`Error in gradient of depthwiseConv2dNative: filter must be rank 4, but got rank ${c.rank}.`)),x(l.shape[3]===c.shape[2],(()=>`Error in gradient of depthwiseConv2d: number of input channels (${l.shape[3]}) must match the inChannels dimension in filter ${c.shape[2]}.`)),x(_a(i,o),(()=>`Error in gradient of depthwiseConv2d: Either strides or dilations must be 1. Got strides ${i} and dilations '${o}'.`)),La("depthwiseConv2d",s,r),{x:()=>Tr(l.shape,e,c,i,s,o,r),filter:()=>Nr(l,e,c.shape,i,s,o,r)}}},Mu={kernelName:"Dilation2D",inputsToSave:["x","filter"],gradFunc:(e,t,n)=>{const[a,i]=t,s={x:a,filter:i,dy:e},r={x:a,filter:i,dy:e};return{x:()=>an.runKernel("Dilation2DBackpropInput",s,n),filter:()=>an.runKernel("Dilation2DBackpropFilter",r,n)}}},Ou={kernelName:ge,outputsToSave:[!0],gradFunc:(e,t)=>{const[n]=t,a={dy:e,y:n};return{x:()=>an.runKernel("EluGrad",a)}}},Pu={kernelName:"Erf",inputsToSave:["x"],gradFunc:(e,t)=>{const[n]=t,a=Ta(Oi(ua(_i(n))),2/Math.sqrt(Math.PI));return{x:()=>Ta(e,a)}}},Bu={kernelName:"Exp",outputsToSave:[!0],gradFunc:(e,t)=>{const[n]=t;return{x:()=>Ta(e,n)}}},Uu={kernelName:ve,inputsToSave:["input"],gradFunc:(e,t)=>{const[n]=t;return{input:()=>Ma(e,n.shape)}}},Wu={kernelName:"Expm1",inputsToSave:["x"],gradFunc:(e,t)=>{const[n]=t;return{x:()=>Ta(e,Oi(n))}}},Gu={kernelName:ye,gradFunc:e=>({x:()=>ki(e)})},Vu={kernelName:be,inputsToSave:["a","b"],gradFunc:(e,t)=>{const[n,a]=t,i=ma(n.shape,a.shape);return{a:()=>{const t=Na(e,ra(a,"float32")),s=fa(n.shape,i);return s.length>0?Ma(Ri(t,s),n.shape):t},b:()=>{let t=Ta(e,ra(n,"float32"));const s=fa(a.shape,i);s.length>0&&(t=Ma(Ri(t,s),a.shape));const r=_i(a);return ua(Na(t,ra(r,"float32")))}}}},Ku={kernelName:we,inputsToSave:["x","mean","variance","scale"],gradFunc:(e,t,n)=>{const{varianceEpsilon:a}=n,[i,s,r,o]=t,l=null==o?Di(1):o,c=fa(s.shape,i.shape),u=[];if(1===s.rank){for(let e=0;e<i.shape.length-1;++e)u.push(i.shape[e]);u.push(1)}const h=es(i,s),p=Ta(e,l),d=Qs(xa(r,Di(a))),f=Ta(Ta(Ta(d,d),d),Di(-.5));return{x:()=>1===s.rank?Ma(Ta(Ta(e,Bi(Ma(d,[1,1,1,s.shape[0]]),u)),l),i.shape):Ma(Ta(Ta(e,d),l),i.shape),mean:()=>{let e=Ta(Ta(d,Di(-1)),p);return 1===s.rank&&(e=Ri(e,c)),Ma(e,s.shape)},variance:()=>{let e=Ta(Ta(f,h),p);return 1===s.rank&&(e=Ri(e,c)),Ma(e,s.shape)},scale:()=>{const t=Ta(h,d);let n=Ta(e,t);return 1===s.rank&&(n=Ri(n,c)),Ma(n,s.shape)},offset:()=>{let t=e;return 1===s.rank&&(t=Ri(t,c)),Ma(t,s.shape)}}}},qu={kernelName:ke,inputsToSave:["x","indices"],gradFunc:(e,t,n)=>{const[a,i]=t,{axis:s,batchDims:r}=n,o=C(s,a.shape)[0],l=(e,t,n)=>()=>{const a=e.shape,i=t.size,r=a.slice(0,o),l=r.length,c=a.slice(s,a.length).slice(1),u=c.length,h=Hu(0,l),p=Hu(l+1,l+1+u),d=Ju([r,[i],c]),f=Ma(n,d),m=Ma(t,[i]),g=Ju([[l],h,p]),v=pa(f,g);let y=mr(v,m,e.shape[o]);const b=Ai(g);return y=pa(y,b),y};if(1===r){const t=a.shape[0],n=a.split(t,0);return{x:()=>{const t=ur(n.map(((t,n)=>l(t,i.slice(n,1),e.slice(n,1))())));return t.reshape(a.shape)},indices:()=>i}}return{x:l(a,i,e),indices:()=>i}}};
3987
+ function(e,t,n,a,i){let s=e;4===e.rank&&(s=Ma(e,[1,e.shape[0],e.shape[1],e.shape[2],e.shape[3]]));let r=t;4===r.rank&&(r=Ma(t,[1,t.shape[0],t.shape[1],t.shape[2],t.shape[3]])),x(5===s.rank,(()=>`Error in conv3dDerFilter: input must be rank 5, but got shape ${s.shape}.`)),x(5===r.rank,(()=>`Error in conv3dDerFilter: dy must be rank 5, but got shape ${r.shape}.`)),x(5===n.length,(()=>`Error in conv3dDerFilter: filterShape must be length 5, but got ${n}.`)),x(s.shape[4]===n[3],(()=>`Error in conv3dDerFilter: depth of input ${s.shape[4]}) must match input depth in filter (${n[3]}.`)),x(r.shape[4]===n[4],(()=>`Error in conv3dDerFilter: depth of dy (${r.shape[4]}) must match output depth for filter (${n[4]}).`));const o={x:s,dy:r},l={strides:a,pad:i,filterShape:n};return an.runKernel("Conv3DBackpropFilterV2",o,l)}}),Du={kernelName:he,inputsToSave:["x","filter"],gradFunc:(e,t,n)=>{const{dilations:a,strides:i,pad:s}=n;x(Fa(a),(()=>`Error in gradient of conv3D: dilation rates greater than 1 are not yet supported in gradients. Got dilations '${a}'`));const[r,o]=t;return{x:()=>hi(r.shape,e,o,i,s),filter:()=>zu(r,e,o.shape,i,s)}}},Fu={kernelName:"Cos",inputsToSave:["x"],gradFunc:(e,t)=>{const[n]=t;return{x:()=>Ta(ua(tr(ra(n,"float32"))),e)}}},_u={kernelName:pe,inputsToSave:["x"],gradFunc:(e,t)=>{const[n]=t;return{x:()=>Ta(nr(ra(n,"float32")),e)}}},Ru={kernelName:de,inputsToSave:["x"],gradFunc:(e,t,n)=>{const[a]=t,{axis:i,exclusive:s,reverse:r}=n;return{x:()=>{const t=$i([i],a.rank);let n=gi(e,i,s,!r);return null!=t&&(n=pa(n,t)),n}}}},Lu={kernelName:fe,inputsToSave:["x","filter"],gradFunc:(e,t,n)=>{const{dilations:a,strides:i,pad:s,dimRoundingMode:r}=n,o=null==a?[1,1]:a;x(Fa(o),(()=>`Error in gradient of depthwiseConv2dNative: dilation rates greater than 1 are not yet supported. Got dilations '${o}'`));const[l,c]=t;return x(4===l.rank,(()=>`Error in gradient of depthwiseConv2dNative: input must be rank 4, but got rank ${l.rank}.`)),x(4===c.rank,(()=>`Error in gradient of depthwiseConv2dNative: filter must be rank 4, but got rank ${c.rank}.`)),x(l.shape[3]===c.shape[2],(()=>`Error in gradient of depthwiseConv2d: number of input channels (${l.shape[3]}) must match the inChannels dimension in filter ${c.shape[2]}.`)),x(_a(i,o),(()=>`Error in gradient of depthwiseConv2d: Either strides or dilations must be 1. Got strides ${i} and dilations '${o}'.`)),La("depthwiseConv2d",s,r),{x:()=>Tr(l.shape,e,c,i,s,o,r),filter:()=>Nr(l,e,c.shape,i,s,o,r)}}},Mu={kernelName:"Dilation2D",inputsToSave:["x","filter"],gradFunc:(e,t,n)=>{const[a,i]=t,s={x:a,filter:i,dy:e},r={x:a,filter:i,dy:e};return{x:()=>an.runKernel("Dilation2DBackpropInput",s,n),filter:()=>an.runKernel("Dilation2DBackpropFilter",r,n)}}},Ou={kernelName:ge,outputsToSave:[!0],gradFunc:(e,t)=>{const[n]=t,a={dy:e,y:n};return{x:()=>an.runKernel("EluGrad",a)}}},Pu={kernelName:"Erf",inputsToSave:["x"],gradFunc:(e,t)=>{const[n]=t,a=Ta(Oi(ua(_i(n))),2/Math.sqrt(Math.PI));return{x:()=>Ta(e,a)}}},Bu={kernelName:"Exp",outputsToSave:[!0],gradFunc:(e,t)=>{const[n]=t;return{x:()=>Ta(e,n)}}},Uu={kernelName:ve,inputsToSave:["input"],gradFunc:(e,t)=>{const[n]=t;return{input:()=>Ma(e,n.shape)}}},Wu={kernelName:"Expm1",inputsToSave:["x"],gradFunc:(e,t)=>{const[n]=t;return{x:()=>Ta(e,Oi(n))}}},Gu={kernelName:ye,gradFunc:e=>({x:()=>ki(e)})},Vu={kernelName:be,inputsToSave:["a","b"],gradFunc:(e,t)=>{const[n,a]=t,i=ma(n.shape,a.shape);return{a:()=>{const t=Na(e,ra(a,"float32")),s=fa(n.shape,i);return s.length>0?Ma(Ri(t,s),n.shape):t},b:()=>{let t=Ta(e,ra(n,"float32"));const s=fa(a.shape,i);s.length>0&&(t=Ma(Ri(t,s),a.shape));const r=_i(a);return ua(Na(t,ra(r,"float32")))}}}},Ku={kernelName:we,inputsToSave:["x","mean","variance","scale"],gradFunc:(e,t,n)=>{const{varianceEpsilon:a}=n,[i,s,r,o]=t,l=null==o?Di(1):o,c=fa(s.shape,i.shape),u=[];if(1===s.rank){for(let e=0;e<i.shape.length-1;++e)u.push(i.shape[e]);u.push(1)}const h=es(i,s),p=Ta(e,l),d=Qs(xa(r,Di(a))),f=Ta(Ta(Ta(d,d),d),Di(-.5));return{x:()=>1===s.rank?Ma(Ta(Ta(e,Bi(Ma(d,[1,1,1,s.shape[0]]),u)),l),i.shape):Ma(Ta(Ta(e,d),l),i.shape),mean:()=>{let e=Ta(Ta(d,Di(-1)),p);return 1===s.rank&&(e=Ri(e,c)),Ma(e,s.shape)},variance:()=>{let e=Ta(Ta(f,h),p);return 1===s.rank&&(e=Ri(e,c)),Ma(e,s.shape)},scale:()=>{const t=Ta(h,d);let n=Ta(e,t);return 1===s.rank&&(n=Ri(n,c)),Ma(n,s.shape)},offset:()=>{let t=e;return 1===s.rank&&(t=Ri(t,c)),Ma(t,s.shape)}}}},qu={kernelName:ke,inputsToSave:["x","indices"],gradFunc:(e,t,n)=>{const[a,i]=t,{axis:s,batchDims:r}=n,o=$(s,a.shape)[0],l=(e,t,n)=>()=>{const a=e.shape,i=t.size,r=a.slice(0,o),l=r.length,c=a.slice(s,a.length).slice(1),u=c.length,h=Hu(0,l),p=Hu(l+1,l+1+u),d=Ju([r,[i],c]),f=Ma(n,d),m=Ma(t,[i]),g=Ju([[l],h,p]),v=pa(f,g);let y=mr(v,m,e.shape[o]);const b=Ai(g);return y=pa(y,b),y};if(1===r){const t=a.shape[0],n=a.split(t,0);return{x:()=>{const t=ur(n.map(((t,n)=>l(t,i.slice(n,1),e.slice(n,1))())));return t.reshape(a.shape)},indices:()=>i}}return{x:l(a,i,e),indices:()=>i}}};
3988
3988
  /**
3989
3989
  * @license
3990
3990
  * Copyright 2020 Google LLC. All Rights Reserved.
@@ -4082,7 +4082,7 @@ function(e,t,n,a=5,i=1,s=1,r=.5){const o={x:e,y:t,dy:n},l={depthRadius:a,bias:i,
4082
4082
  * limitations under the License.
4083
4083
  * =============================================================================
4084
4084
  */
4085
- function oh(e,t,n,a){return t.rank<n.rank&&(t=Ma(t,$i(t.shape,a))),e.rank<n.rank&&(e=Ma(e,$i(e.shape,a))),{x:()=>Ta(e,ra(bi(n,t),e.dtype))}}
4085
+ function oh(e,t,n,a){return t.rank<n.rank&&(t=Ma(t,Ci(t.shape,a))),e.rank<n.rank&&(e=Ma(e,Ci(e.shape,a))),{x:()=>Ta(e,ra(bi(n,t),e.dtype))}}
4086
4086
  /**
4087
4087
  * @license
4088
4088
  * Copyright 2020 Google LLC. All Rights Reserved.
@@ -4098,7 +4098,7 @@ function oh(e,t,n,a){return t.rank<n.rank&&(t=Ma(t,$i(t.shape,a))),e.rank<n.rank
4098
4098
  * See the License for the specific language governing permissions and
4099
4099
  * limitations under the License.
4100
4100
  * =============================================================================
4101
- */const lh={kernelName:"Max",inputsToSave:["x"],outputsToSave:[!0],gradFunc:(e,t,n)=>{const a=n,{reductionIndices:i}=a,s=t[0],r=oh(e,t[1],s,C(i,s.shape));return{x:()=>r.x()}}},ch={kernelName:Ie,inputsToSave:["a","b"],gradFunc:(e,t)=>{const[n,a]=t;return{a:()=>Ta(e,ra(Ki(n,a),"float32")),b:()=>Ta(e,ra(Hi(n,a),"float32"))}}};
4101
+ */const lh={kernelName:"Max",inputsToSave:["x"],outputsToSave:[!0],gradFunc:(e,t,n)=>{const a=n,{reductionIndices:i}=a,s=t[0],r=oh(e,t[1],s,$(i,s.shape));return{x:()=>r.x()}}},ch={kernelName:Ie,inputsToSave:["a","b"],gradFunc:(e,t)=>{const[n,a]=t;return{a:()=>Ta(e,ra(Ki(n,a),"float32")),b:()=>Ta(e,ra(Hi(n,a),"float32"))}}};
4102
4102
  /**
4103
4103
  * @license
4104
4104
  * Copyright 2020 Google LLC. All Rights Reserved.
@@ -4131,7 +4131,7 @@ function oh(e,t,n,a){return t.rank<n.rank&&(t=Ma(t,$i(t.shape,a))),e.rank<n.rank
4131
4131
  * limitations under the License.
4132
4132
  * =============================================================================
4133
4133
  */
4134
- function(e,t,n,a,i,s,r){const o=un(e,"dy","maxPool3dGrad"),l=un(t,"input","maxPool3dGrad"),c=un(n,"output","maxPool3dGrad");let u=o,h=l,p=c,d=!1;4===l.rank&&(d=!0,u=Ma(o,[1,o.shape[0],o.shape[1],o.shape[2],o.shape[3]]),h=Ma(l,[1,l.shape[0],l.shape[1],l.shape[2],l.shape[3]]),p=Ma(c,[1,c.shape[0],c.shape[1],c.shape[2],c.shape[3]])),x(5===u.rank,(()=>`Error in maxPool3dGrad: dy must be rank 5 but got rank ${u.rank}.`)),x(5===h.rank,(()=>`Error in maxPool3dGrad: input must be rank 5 but got rank ${h.rank}.`)),x(5===p.rank,(()=>`Error in maxPool3dGrad: output must be rank 5 but got rank ${p.rank}.`)),La("maxPool3dGrad",s,r);const f={dy:u,input:h,output:p},m={filterSize:a,strides:i,pad:s,dimRoundingMode:r},g=an.runKernel("MaxPool3DGrad",f,m);return d?Ma(g,[g.shape[1],g.shape[2],g.shape[3],g.shape[4]]):g}}),hh={kernelName:Ce,inputsToSave:["x"],outputsToSave:[!0],gradFunc:(e,t,n)=>{const[a,i]=t,{filterSize:s,strides:r,pad:o,dimRoundingMode:l}=n;return{x:()=>uh(e,a,i,s,r,o,l)}}};
4134
+ function(e,t,n,a,i,s,r){const o=un(e,"dy","maxPool3dGrad"),l=un(t,"input","maxPool3dGrad"),c=un(n,"output","maxPool3dGrad");let u=o,h=l,p=c,d=!1;4===l.rank&&(d=!0,u=Ma(o,[1,o.shape[0],o.shape[1],o.shape[2],o.shape[3]]),h=Ma(l,[1,l.shape[0],l.shape[1],l.shape[2],l.shape[3]]),p=Ma(c,[1,c.shape[0],c.shape[1],c.shape[2],c.shape[3]])),x(5===u.rank,(()=>`Error in maxPool3dGrad: dy must be rank 5 but got rank ${u.rank}.`)),x(5===h.rank,(()=>`Error in maxPool3dGrad: input must be rank 5 but got rank ${h.rank}.`)),x(5===p.rank,(()=>`Error in maxPool3dGrad: output must be rank 5 but got rank ${p.rank}.`)),La("maxPool3dGrad",s,r);const f={dy:u,input:h,output:p},m={filterSize:a,strides:i,pad:s,dimRoundingMode:r},g=an.runKernel("MaxPool3DGrad",f,m);return d?Ma(g,[g.shape[1],g.shape[2],g.shape[3],g.shape[4]]):g}}),hh={kernelName:$e,inputsToSave:["x"],outputsToSave:[!0],gradFunc:(e,t,n)=>{const[a,i]=t,{filterSize:s,strides:r,pad:o,dimRoundingMode:l}=n;return{x:()=>uh(e,a,i,s,r,o,l)}}};
4135
4135
  /**
4136
4136
  * @license
4137
4137
  * Copyright 2020 Google LLC. All Rights Reserved.
@@ -4164,7 +4164,7 @@ function(e,t,n,a,i,s,r){const o=un(e,"dy","maxPool3dGrad"),l=un(t,"input","maxPo
4164
4164
  * limitations under the License.
4165
4165
  * =============================================================================
4166
4166
  */
4167
- function(e,t,n,a,i,s,r){const o=un(e,"dy","maxPoolGrad"),l=un(t,"input","maxPoolGrad"),c=un(n,"output","maxPoolGrad");x(l.rank===o.rank,(()=>`Rank of input (${l.rank}) does not match rank of dy (${o.rank})`)),x(4===o.rank,(()=>`Error in maxPoolGrad: dy must be rank 4 but got rank ${o.rank}.`)),x(4===l.rank,(()=>`Error in maxPoolGrad: input must be rank 4 but got rank ${l.rank}.`)),La("maxPoolGrad",s,r);const u={dy:o,input:l,output:c},h={filterSize:a,strides:i,pad:s,dimRoundingMode:r};return an.runKernel("MaxPoolGrad",u,h)}}),dh={kernelName:$e,inputsToSave:["x"],outputsToSave:[!0],gradFunc:(e,t,n)=>{const[a,i]=t,{filterSize:s,strides:r,pad:o}=n;return{x:()=>ph(e,a,i,s,r,o)}}},fh={kernelName:_e,inputsToSave:["x"],gradFunc:(e,t,n)=>{const a=t[0],{paddings:i}=n,s=i.map((e=>e[0]));return{x:()=>Ga(e,s,a.shape)}}},mh={kernelName:"Pow",inputsToSave:["a","b"],outputsToSave:[!0],gradFunc:(e,t)=>{const[n,a,i]=t,s=n,r=a,o=ma(s.shape,r.shape);return{a:()=>{const t=ra(r,"float32");let n=Ta(e,Ta(t,zi(s,es(t,Di(1)))));const a=fa(s.shape,o);return a.length>0&&(n=Ri(n,a)),Ma(n,s.shape)},b:()=>{const t=Vi(s,0),n=wi(t,Zi(s),ki(s));let a=Ta(e,Ta(i,n));const l=fa(r.shape,o);return l.length>0&&(a=Ri(a,l)),Ma(a,r.shape)}}}};
4167
+ function(e,t,n,a,i,s,r){const o=un(e,"dy","maxPoolGrad"),l=un(t,"input","maxPoolGrad"),c=un(n,"output","maxPoolGrad");x(l.rank===o.rank,(()=>`Rank of input (${l.rank}) does not match rank of dy (${o.rank})`)),x(4===o.rank,(()=>`Error in maxPoolGrad: dy must be rank 4 but got rank ${o.rank}.`)),x(4===l.rank,(()=>`Error in maxPoolGrad: input must be rank 4 but got rank ${l.rank}.`)),La("maxPoolGrad",s,r);const u={dy:o,input:l,output:c},h={filterSize:a,strides:i,pad:s,dimRoundingMode:r};return an.runKernel("MaxPoolGrad",u,h)}}),dh={kernelName:Ce,inputsToSave:["x"],outputsToSave:[!0],gradFunc:(e,t,n)=>{const[a,i]=t,{filterSize:s,strides:r,pad:o}=n;return{x:()=>ph(e,a,i,s,r,o)}}},fh={kernelName:_e,inputsToSave:["x"],gradFunc:(e,t,n)=>{const a=t[0],{paddings:i}=n,s=i.map((e=>e[0]));return{x:()=>Ga(e,s,a.shape)}}},mh={kernelName:"Pow",inputsToSave:["a","b"],outputsToSave:[!0],gradFunc:(e,t)=>{const[n,a,i]=t,s=n,r=a,o=ma(s.shape,r.shape);return{a:()=>{const t=ra(r,"float32");let n=Ta(e,Ta(t,zi(s,es(t,Di(1)))));const a=fa(s.shape,o);return a.length>0&&(n=Ri(n,a)),Ma(n,s.shape)},b:()=>{const t=Vi(s,0),n=wi(t,Zi(s),ki(s));let a=Ta(e,Ta(i,n));const l=fa(r.shape,o);return l.length>0&&(a=Ri(a,l)),Ma(a,r.shape)}}}};
4168
4168
  /**
4169
4169
  * @license
4170
4170
  * Copyright 2020 Google LLC. All Rights Reserved.
@@ -4180,7 +4180,7 @@ function(e,t,n,a,i,s,r){const o=un(e,"dy","maxPoolGrad"),l=un(t,"input","maxPool
4180
4180
  * See the License for the specific language governing permissions and
4181
4181
  * limitations under the License.
4182
4182
  * =============================================================================
4183
- */function gh(e,t,n){const a=e.shape.length,i=a-n.length,s=Ci(n,a);let r=e;null!=s&&(r=pa(e,s));const o=r.shape.slice(),l=o.splice(a-n.length,n.length).reduce(((e,t)=>e*t),1);o.push(l);let c=
4183
+ */function gh(e,t,n){const a=e.shape.length,i=a-n.length,s=$i(n,a);let r=e;null!=s&&(r=pa(e,s));const o=r.shape.slice(),l=o.splice(a-n.length,n.length).reduce(((e,t)=>e*t),1);o.push(l);let c=
4184
4184
  /**
4185
4185
  * @license
4186
4186
  * Copyright 2022 Google Inc. All Rights Reserved.
@@ -4230,7 +4230,7 @@ function(e,t,n){const a=e.shape.slice();a[n]=1;const i=Ma(t,a),s=mi(e,n,!0,!1),r
4230
4230
  * limitations under the License.
4231
4231
  * =============================================================================
4232
4232
  */
4233
- const bh=[ru,ou,lu,cu,uu,hu,pu,du,fu,mu,gu,vu,bu,ku,xu,Su,Nu,Tu,Iu,$u,Cu,Au,ju,Eu,Du,Fu,_u,Ru,Lu,Mu,{kernelName:me,inputsToSave:["a","b"],gradFunc:(e,t)=>{const[n,a]=t,i=ma(n.shape,a.shape);return{a:()=>{const t=Na(e,ra(a,"float32")),s=fa(n.shape,i);return s.length>0?Ma(Ri(t,s),n.shape):t},b:()=>{let t=Ta(e,ra(n,"float32"));const s=fa(a.shape,i);s.length>0&&(t=Ma(Ri(t,s),a.shape));const r=_i(a);return ua(Na(t,ra(r,"float32")))}}}},Ou,Pu,Bu,Uu,Wu,Vu,Gu,Ku,qu,Zu,Yu,Qu,Xu,eh,th,nh,ah,ih,rh,lh,lh,ch,hh,dh,{kernelName:Ae,inputsToSave:["x"],gradFunc:(e,t,n)=>{const[a]=t,{axis:i}=n,s=C(i,a.shape),r=N(Ii(a.shape,s)[1]);return{x:()=>{const t=a.shape.slice();s.forEach((e=>{t[e]=1}));const n=Ma(e,t);return Na(Ta(n,us(a.shape,"float32")),r)}}}},{kernelName:"Min",inputsToSave:["x"],outputsToSave:[!0],gradFunc:(e,t,n)=>{const a=n,{axis:i}=a,[s,r]=t,o=oh(e,r,s,C(i,s.shape));return{x:()=>o.x()}}},{kernelName:Ee,inputsToSave:["a","b"],gradFunc:(e,t)=>{const[n,a]=t;return{a:()=>Ta(e,ra(Ji(n,a),"float32")),b:()=>Ta(e,ra(Vi(n,a),"float32"))}}},{kernelName:"MirrorPad",inputsToSave:["x"],gradFunc:(e,t,n)=>{const a=t[0],{paddings:i}=n,s=i.map((e=>e[0]));return{x:()=>Ga(e,s,a.shape)}}},{kernelName:"Mod",inputsToSave:["a","b"],gradFunc:(e,t)=>{const[n,a]=t,i=ma(n.shape,a.shape);return{a:()=>{const t=fa(n.shape,i);return t.length>0?Ma(Ri(e,t),n.shape):e},b:()=>{const t=Ta(e,ua(Wi(Na(n,a)))),s=fa(a.shape,i);return s.length>0?Ma(Ri(t,s),a.shape):t}}}},{kernelName:je,inputsToSave:["a","b"],gradFunc:(e,t)=>{const[n,a]=t,i=ma(n.shape,a.shape);return{a:()=>{const t=Ta(e,ra(a,"float32")),s=fa(n.shape,i);return s.length>0?Ma(Ri(t,s),n.shape):t},b:()=>{const t=Ta(e,ra(n,"float32")),s=fa(a.shape,i);return s.length>0?Ma(Ri(t,s),a.shape):t}}}},{kernelName:"Neg",gradFunc:e=>({x:()=>ua(e)})},{kernelName:De,inputsToSave:["indices"],gradFunc:(e,t)=>{const n=t[0];return{indices:()=>cs(n.shape,"float32")}}},{kernelName:ze,gradFunc:e=>({x:()=>ki(e)})},{kernelName:Fe,saveAllInputs:!0,gradFunc:(e,t,n)=>{const{axis:a}=n;return gr(e,a).map((e=>()=>e))}},fh,fh,mh,{kernelName:Re,inputsToSave:["x","alpha"],gradFunc:(e,t)=>{const[n,a]=t,i=Vi(n,0);return{x:()=>wi(i,e,Ta(e,a)),alpha:()=>{let t=wi(i,ki(e),Ta(e,n));const s=fa(a.shape,e.shape);return s.length>0&&(t=Ri(t,s)),Ma(t,a.shape)}}}},{kernelName:"Prod",inputsToSave:["x"],gradFunc:(e,t,n)=>{const[a]=t,{axis:i}=n;let s=[];return s=null==i?a.shape.map(((e,t)=>t)):"number"==typeof i?[i]:i,{x:()=>gh(a,e,s)}}},{kernelName:"Reciprocal",inputsToSave:["x"],gradFunc:(e,t)=>{const[n]=t;return{x:()=>Na(e,ua(_i(n)))}}},{kernelName:Be,inputsToSave:["x"],gradFunc:(e,t)=>{const[n]=t,a=Ta(Ji(n,6),hr(n));return{x:()=>Ta(e,ra(a,"float32"))}}},{kernelName:Le,inputsToSave:["x"],gradFunc:(e,t)=>{const[n]=t;return{x:()=>Ta(e,ra(hr(n),"float32"))}}},{kernelName:Me,inputsToSave:["x"],gradFunc:(e,t)=>{const[n]=t;return{x:()=>Ma(e,n.shape)}}},{kernelName:Pe,inputsToSave:["images"],gradFunc:(e,t,n)=>{const[a]=t,i={dy:e,images:a};return{images:()=>an.runKernel("ResizeBilinearGrad",i,n)}}},{kernelName:Oe,inputsToSave:["images"],gradFunc:(e,t,n)=>{const[a]=t,i={dy:e,images:a};return{images:()=>an.runKernel("ResizeNearestNeighborGrad",i,n)}}},{kernelName:Ue,gradFunc:(e,t,n)=>{const{dims:a}=n,i=C(a,e.shape);return{x:()=>Zs(e,i)}}},{kernelName:We,gradFunc:e=>({x:()=>ki(e)})},{kernelName:Ge,inputsToSave:["x"],gradFunc:(e,t)=>{const[n]=t;return{x:()=>ua(Na(e,Ta(zi(n,1.5),2)))}}},{kernelName:Ve,inputsToSave:["condition"],gradFunc:(e,t)=>{const[n]=t;return{condition:()=>ra(ki(n),"float32"),t:()=>Ta(e,ra(n,e.dtype)),e:()=>Ta(e,ra(is(n),e.dtype))}}},{kernelName:Ke,inputsToSave:["x"],gradFunc:(e,t)=>{const[n]=t;return{x:()=>{const t=Vi(n,Di(0)),a=Di(1.7580993408473768),i=Di(1.0507009873554805),s=Ta(e,i),r=Ta(Ta(e,a),Oi(ra(n,"float32")));return wi(t,s,r)}}}},{kernelName:Je,outputsToSave:[!0],gradFunc:(e,t)=>{const[n]=t;return{x:()=>Ta(e,Ta(n,es(Di(1),n)))}}},{kernelName:"Sign",gradFunc:e=>({x:()=>ki(e)})},{kernelName:"Sin",inputsToSave:["x"],gradFunc:(e,t)=>{const[n]=t;return{x:()=>Ta(di(ra(n,"float32")),e)}}},{kernelName:He,inputsToSave:["x"],gradFunc:(e,t)=>{const[n]=t;return{x:()=>Ta(fi(ra(n,"float32")),e)}}},{kernelName:qe,inputsToSave:["x"],gradFunc:(e,t,n)=>{const[a]=t,{begin:i,size:s}=n,r=a.shape,[o,l]=ga(a,i,s),c=[];for(let t=0;t<e.rank;t++)c.push([o[t],r[t]-o[t]-l[t]]);return{x:()=>ms(e,c)}}},{kernelName:tt,outputsToSave:[!0],gradFunc:(e,t,n)=>{const[a]=t,{dim:i}=n,s=Ta(e,a);return{logits:()=>es(s,Ta(Ri(s,[i],true),a))}}},{kernelName:Ze,inputsToSave:["x"],gradFunc:(e,t)=>{const[n]=t;return{x:()=>Ta(e,Wa(n))}}},vh,vh,yh,yh,{kernelName:Ye,inputsToSave:["x"],gradFunc:(e,t)=>{const[n]=t;return{x:()=>Na(e,Ta(Fi(ra(n,"float32")),2))}}},{kernelName:"SquaredDifference",inputsToSave:["a","b"],gradFunc:(e,t)=>{const[n,a]=t,i=Di(2);return{a:()=>Ta(e,Ta(i,es(n,a))),b:()=>Ta(e,Ta(i,es(a,n)))}}},{kernelName:"Square",inputsToSave:["x"],gradFunc:(e,t)=>{const[n]=t;return{x:()=>Ta(e,Ta(ra(n,"float32"),2))}}},{kernelName:lt,gradFunc:e=>({x:()=>ki(e)})},{kernelName:"Sub",inputsToSave:["a","b"],gradFunc:(e,t)=>{const[n,a]=t,i=ma(n.shape,a.shape);return{a:()=>{let t=e;const a=fa(n.shape,i);return a.length>0&&(t=Ri(t,a)),Ma(t,n.shape)},b:()=>{let t=e;const n=fa(a.shape,i);return n.length>0&&(t=Ri(t,n)),Ma(ua(t),a.shape)}}}},{kernelName:Qe,inputsToSave:["x"],gradFunc:(e,t,n)=>{const[a]=t,i=a.shape.slice(),{axis:s}=n;C(s,a.shape).forEach((e=>{i[e]=1}));const r=Ma(e,i),o=Ta(r,us(a.shape,"float32"));return{x:()=>o}}},{kernelName:"Tan",inputsToSave:["x"],gradFunc:(e,t)=>{const[n]=t;return{x:()=>Na(e,_i(di(n)))}}},{kernelName:nt,outputsToSave:[!0],gradFunc:(e,t)=>{const[n]=t;return{x:()=>Ta(es(Di(1),_i(n)),e)}}},{kernelName:at,inputsToSave:["x"],gradFunc:(e,t,n)=>{const[a]=t,{reps:i}=n;return{x:()=>{let t=ki(a);if(1===a.rank)for(let n=0;n<i[0];++n)t=xa(t,Ga(e,[n*a.shape[0]],[a.shape[0]]));else if(2===a.rank)for(let n=0;n<i[0];++n)for(let s=0;s<i[1];++s)t=xa(t,Ga(e,[n*a.shape[0],s*a.shape[1]],[a.shape[0],a.shape[1]]));else if(3===a.rank)for(let n=0;n<i[0];++n)for(let s=0;s<i[1];++s)for(let r=0;r<i[2];++r)t=xa(t,Ga(e,[n*a.shape[0],s*a.shape[1],r*a.shape[2]],[a.shape[0],a.shape[1],a.shape[2]]));else{if(4!==a.rank)throw new Error(`Gradient for tile operation is not implemented for rank-${a.rank} tensors yet.`);for(let n=0;n<i[0];++n)for(let s=0;s<i[1];++s)for(let r=0;r<i[2];++r)for(let o=0;o<i[3];++o)t=xa(t,Ga(e,[n*a.shape[0],s*a.shape[1],r*a.shape[2],o*a.shape[3]],[a.shape[0],a.shape[1],a.shape[2],a.shape[3]]))}return t}}}},{kernelName:it,gradFunc:(e,t,n)=>{const a=n,{perm:i}=a,s=Ai(i);return{x:()=>pa(e,s)}}},{kernelName:st,gradFunc:(e,t,n)=>{const a=n,{axis:i}=a;return{value:()=>ur(e,i)}}},{kernelName:rt,inputsToSave:["segmentIds"],gradFunc:(e,t)=>{const[n]=t;return{x:()=>function(e,t){const n=os(t,ki(t)),a=Gi(e,n);let i=Ki(t,Di(0,"int32"));const s=a.rank-i.rank;for(let e=0;e<s;++e)i=Pi(i,e+1);i=as(i,us(a.shape,"bool"));const r=ki(a);return wi(i,a,r)}(e,n)}}},{kernelName:ot,gradFunc:e=>({x:()=>ki(e)})}];
4233
+ const bh=[ru,ou,lu,cu,uu,hu,pu,du,fu,mu,gu,vu,bu,ku,xu,Su,Nu,Tu,Iu,Cu,$u,Au,ju,Eu,Du,Fu,_u,Ru,Lu,Mu,{kernelName:me,inputsToSave:["a","b"],gradFunc:(e,t)=>{const[n,a]=t,i=ma(n.shape,a.shape);return{a:()=>{const t=Na(e,ra(a,"float32")),s=fa(n.shape,i);return s.length>0?Ma(Ri(t,s),n.shape):t},b:()=>{let t=Ta(e,ra(n,"float32"));const s=fa(a.shape,i);s.length>0&&(t=Ma(Ri(t,s),a.shape));const r=_i(a);return ua(Na(t,ra(r,"float32")))}}}},Ou,Pu,Bu,Uu,Wu,Vu,Gu,Ku,qu,Zu,Yu,Qu,Xu,eh,th,nh,ah,ih,rh,lh,lh,ch,hh,dh,{kernelName:Ae,inputsToSave:["x"],gradFunc:(e,t,n)=>{const[a]=t,{axis:i}=n,s=$(i,a.shape),r=N(Ii(a.shape,s)[1]);return{x:()=>{const t=a.shape.slice();s.forEach((e=>{t[e]=1}));const n=Ma(e,t);return Na(Ta(n,us(a.shape,"float32")),r)}}}},{kernelName:"Min",inputsToSave:["x"],outputsToSave:[!0],gradFunc:(e,t,n)=>{const a=n,{axis:i}=a,[s,r]=t,o=oh(e,r,s,$(i,s.shape));return{x:()=>o.x()}}},{kernelName:Ee,inputsToSave:["a","b"],gradFunc:(e,t)=>{const[n,a]=t;return{a:()=>Ta(e,ra(Ji(n,a),"float32")),b:()=>Ta(e,ra(Vi(n,a),"float32"))}}},{kernelName:"MirrorPad",inputsToSave:["x"],gradFunc:(e,t,n)=>{const a=t[0],{paddings:i}=n,s=i.map((e=>e[0]));return{x:()=>Ga(e,s,a.shape)}}},{kernelName:"Mod",inputsToSave:["a","b"],gradFunc:(e,t)=>{const[n,a]=t,i=ma(n.shape,a.shape);return{a:()=>{const t=fa(n.shape,i);return t.length>0?Ma(Ri(e,t),n.shape):e},b:()=>{const t=Ta(e,ua(Wi(Na(n,a)))),s=fa(a.shape,i);return s.length>0?Ma(Ri(t,s),a.shape):t}}}},{kernelName:je,inputsToSave:["a","b"],gradFunc:(e,t)=>{const[n,a]=t,i=ma(n.shape,a.shape);return{a:()=>{const t=Ta(e,ra(a,"float32")),s=fa(n.shape,i);return s.length>0?Ma(Ri(t,s),n.shape):t},b:()=>{const t=Ta(e,ra(n,"float32")),s=fa(a.shape,i);return s.length>0?Ma(Ri(t,s),a.shape):t}}}},{kernelName:"Neg",gradFunc:e=>({x:()=>ua(e)})},{kernelName:De,inputsToSave:["indices"],gradFunc:(e,t)=>{const n=t[0];return{indices:()=>cs(n.shape,"float32")}}},{kernelName:ze,gradFunc:e=>({x:()=>ki(e)})},{kernelName:Fe,saveAllInputs:!0,gradFunc:(e,t,n)=>{const{axis:a}=n;return gr(e,a).map((e=>()=>e))}},fh,fh,mh,{kernelName:Re,inputsToSave:["x","alpha"],gradFunc:(e,t)=>{const[n,a]=t,i=Vi(n,0);return{x:()=>wi(i,e,Ta(e,a)),alpha:()=>{let t=wi(i,ki(e),Ta(e,n));const s=fa(a.shape,e.shape);return s.length>0&&(t=Ri(t,s)),Ma(t,a.shape)}}}},{kernelName:"Prod",inputsToSave:["x"],gradFunc:(e,t,n)=>{const[a]=t,{axis:i}=n;let s=[];return s=null==i?a.shape.map(((e,t)=>t)):"number"==typeof i?[i]:i,{x:()=>gh(a,e,s)}}},{kernelName:"Reciprocal",inputsToSave:["x"],gradFunc:(e,t)=>{const[n]=t;return{x:()=>Na(e,ua(_i(n)))}}},{kernelName:Be,inputsToSave:["x"],gradFunc:(e,t)=>{const[n]=t,a=Ta(Ji(n,6),hr(n));return{x:()=>Ta(e,ra(a,"float32"))}}},{kernelName:Le,inputsToSave:["x"],gradFunc:(e,t)=>{const[n]=t;return{x:()=>Ta(e,ra(hr(n),"float32"))}}},{kernelName:Me,inputsToSave:["x"],gradFunc:(e,t)=>{const[n]=t;return{x:()=>Ma(e,n.shape)}}},{kernelName:Pe,inputsToSave:["images"],gradFunc:(e,t,n)=>{const[a]=t,i={dy:e,images:a};return{images:()=>an.runKernel("ResizeBilinearGrad",i,n)}}},{kernelName:Oe,inputsToSave:["images"],gradFunc:(e,t,n)=>{const[a]=t,i={dy:e,images:a};return{images:()=>an.runKernel("ResizeNearestNeighborGrad",i,n)}}},{kernelName:Ue,gradFunc:(e,t,n)=>{const{dims:a}=n,i=$(a,e.shape);return{x:()=>Zs(e,i)}}},{kernelName:We,gradFunc:e=>({x:()=>ki(e)})},{kernelName:Ge,inputsToSave:["x"],gradFunc:(e,t)=>{const[n]=t;return{x:()=>ua(Na(e,Ta(zi(n,1.5),2)))}}},{kernelName:Ve,inputsToSave:["condition"],gradFunc:(e,t)=>{const[n]=t;return{condition:()=>ra(ki(n),"float32"),t:()=>Ta(e,ra(n,e.dtype)),e:()=>Ta(e,ra(is(n),e.dtype))}}},{kernelName:Ke,inputsToSave:["x"],gradFunc:(e,t)=>{const[n]=t;return{x:()=>{const t=Vi(n,Di(0)),a=Di(1.7580993408473768),i=Di(1.0507009873554805),s=Ta(e,i),r=Ta(Ta(e,a),Oi(ra(n,"float32")));return wi(t,s,r)}}}},{kernelName:Je,outputsToSave:[!0],gradFunc:(e,t)=>{const[n]=t;return{x:()=>Ta(e,Ta(n,es(Di(1),n)))}}},{kernelName:"Sign",gradFunc:e=>({x:()=>ki(e)})},{kernelName:"Sin",inputsToSave:["x"],gradFunc:(e,t)=>{const[n]=t;return{x:()=>Ta(di(ra(n,"float32")),e)}}},{kernelName:He,inputsToSave:["x"],gradFunc:(e,t)=>{const[n]=t;return{x:()=>Ta(fi(ra(n,"float32")),e)}}},{kernelName:qe,inputsToSave:["x"],gradFunc:(e,t,n)=>{const[a]=t,{begin:i,size:s}=n,r=a.shape,[o,l]=ga(a,i,s),c=[];for(let t=0;t<e.rank;t++)c.push([o[t],r[t]-o[t]-l[t]]);return{x:()=>ms(e,c)}}},{kernelName:tt,outputsToSave:[!0],gradFunc:(e,t,n)=>{const[a]=t,{dim:i}=n,s=Ta(e,a);return{logits:()=>es(s,Ta(Ri(s,[i],true),a))}}},{kernelName:Ze,inputsToSave:["x"],gradFunc:(e,t)=>{const[n]=t;return{x:()=>Ta(e,Wa(n))}}},vh,vh,yh,yh,{kernelName:Ye,inputsToSave:["x"],gradFunc:(e,t)=>{const[n]=t;return{x:()=>Na(e,Ta(Fi(ra(n,"float32")),2))}}},{kernelName:"SquaredDifference",inputsToSave:["a","b"],gradFunc:(e,t)=>{const[n,a]=t,i=Di(2);return{a:()=>Ta(e,Ta(i,es(n,a))),b:()=>Ta(e,Ta(i,es(a,n)))}}},{kernelName:"Square",inputsToSave:["x"],gradFunc:(e,t)=>{const[n]=t;return{x:()=>Ta(e,Ta(ra(n,"float32"),2))}}},{kernelName:lt,gradFunc:e=>({x:()=>ki(e)})},{kernelName:"Sub",inputsToSave:["a","b"],gradFunc:(e,t)=>{const[n,a]=t,i=ma(n.shape,a.shape);return{a:()=>{let t=e;const a=fa(n.shape,i);return a.length>0&&(t=Ri(t,a)),Ma(t,n.shape)},b:()=>{let t=e;const n=fa(a.shape,i);return n.length>0&&(t=Ri(t,n)),Ma(ua(t),a.shape)}}}},{kernelName:Qe,inputsToSave:["x"],gradFunc:(e,t,n)=>{const[a]=t,i=a.shape.slice(),{axis:s}=n;$(s,a.shape).forEach((e=>{i[e]=1}));const r=Ma(e,i),o=Ta(r,us(a.shape,"float32"));return{x:()=>o}}},{kernelName:"Tan",inputsToSave:["x"],gradFunc:(e,t)=>{const[n]=t;return{x:()=>Na(e,_i(di(n)))}}},{kernelName:nt,outputsToSave:[!0],gradFunc:(e,t)=>{const[n]=t;return{x:()=>Ta(es(Di(1),_i(n)),e)}}},{kernelName:at,inputsToSave:["x"],gradFunc:(e,t,n)=>{const[a]=t,{reps:i}=n;return{x:()=>{let t=ki(a);if(1===a.rank)for(let n=0;n<i[0];++n)t=xa(t,Ga(e,[n*a.shape[0]],[a.shape[0]]));else if(2===a.rank)for(let n=0;n<i[0];++n)for(let s=0;s<i[1];++s)t=xa(t,Ga(e,[n*a.shape[0],s*a.shape[1]],[a.shape[0],a.shape[1]]));else if(3===a.rank)for(let n=0;n<i[0];++n)for(let s=0;s<i[1];++s)for(let r=0;r<i[2];++r)t=xa(t,Ga(e,[n*a.shape[0],s*a.shape[1],r*a.shape[2]],[a.shape[0],a.shape[1],a.shape[2]]));else{if(4!==a.rank)throw new Error(`Gradient for tile operation is not implemented for rank-${a.rank} tensors yet.`);for(let n=0;n<i[0];++n)for(let s=0;s<i[1];++s)for(let r=0;r<i[2];++r)for(let o=0;o<i[3];++o)t=xa(t,Ga(e,[n*a.shape[0],s*a.shape[1],r*a.shape[2],o*a.shape[3]],[a.shape[0],a.shape[1],a.shape[2],a.shape[3]]))}return t}}}},{kernelName:it,gradFunc:(e,t,n)=>{const a=n,{perm:i}=a,s=Ai(i);return{x:()=>pa(e,s)}}},{kernelName:st,gradFunc:(e,t,n)=>{const a=n,{axis:i}=a;return{value:()=>ur(e,i)}}},{kernelName:rt,inputsToSave:["segmentIds"],gradFunc:(e,t)=>{const[n]=t;return{x:()=>function(e,t){const n=os(t,ki(t)),a=Gi(e,n);let i=Ki(t,Di(0,"int32"));const s=a.rank-i.rank;for(let e=0;e<s;++e)i=Pi(i,e+1);i=as(i,us(a.shape,"bool"));const r=ki(a);return wi(i,a,r)}(e,n)}}},{kernelName:ot,gradFunc:e=>({x:()=>ki(e)})}];
4234
4234
  /**
4235
4235
  * @license
4236
4236
  * Copyright 2020 Google LLC. All Rights Reserved.
@@ -4255,7 +4255,7 @@ const bh=[ru,ou,lu,cu,uu,hu,pu,du,fu,mu,gu,vu,bu,ku,xu,Su,Nu,Tu,Iu,$u,Cu,Au,ju,E
4255
4255
  * license that can be found in the LICENSE file or at
4256
4256
  * https://opensource.org/licenses/MIT.
4257
4257
  * =============================================================================
4258
- */function wh(e,t){return wn((()=>Fi(Ri(Ta(e,e),t,!0))))}class kh extends ba{getConfig(){return{}}}class xh extends kh{constructor(e){super(),this.defaultMaxValue=2,this.defaultAxis=0,this.maxValue=null!=e.maxValue?e.maxValue:this.defaultMaxValue,this.axis=null!=e.axis?e.axis:this.defaultAxis}apply(e){return wn((()=>{const t=wh(e,this.axis),n=ti(t,0,this.maxValue);return Ta(e,Na(n,xa(Yl(),t)))}))}getConfig(){return{maxValue:this.maxValue,axis:this.axis}}}xh.className="MaxNorm",ka(xh);class Sh extends kh{constructor(e){super(),this.defaultAxis=0,this.axis=null!=e.axis?e.axis:this.defaultAxis}apply(e){return wn((()=>Na(e,xa(Yl(),wh(e,this.axis)))))}getConfig(){return{axis:this.axis}}}Sh.className="UnitNorm",ka(Sh);class Nh extends kh{apply(e){return Hs(e)}}Nh.className="NonNeg",ka(Nh);class Th extends kh{constructor(e){super(),this.defaultMinValue=0,this.defaultMaxValue=1,this.defaultRate=1,this.defaultAxis=0,this.minValue=null!=e.minValue?e.minValue:this.defaultMinValue,this.maxValue=null!=e.maxValue?e.maxValue:this.defaultMaxValue,this.rate=null!=e.rate?e.rate:this.defaultRate,this.axis=null!=e.axis?e.axis:this.defaultAxis}apply(e){return wn((()=>{const t=wh(e,this.axis),n=xa(Ta(this.rate,ti(t,this.minValue,this.maxValue)),Ta(1-this.rate,t));return Ta(e,Na(n,xa(Yl(),t)))}))}getConfig(){return{minValue:this.minValue,maxValue:this.maxValue,rate:this.rate,axis:this.axis}}}Th.className="MinMaxNorm",ka(Th);const Ih={maxNorm:"MaxNorm",minMaxNorm:"MinMaxNorm",nonNeg:"NonNeg",unitNorm:"UnitNorm"};function $h(e){return gl(e)}function Ch(e,t={}){return yl(e,wa.getMap().classNameMap,t,"constraint")}function Ah(e){if(null==e)return null;if("string"==typeof e){return Ch({className:e in Ih?Ih[e]:e,config:{}})}return e instanceof kh?e:Ch(e)}
4258
+ */function wh(e,t){return wn((()=>Fi(Ri(Ta(e,e),t,!0))))}class kh extends ba{getConfig(){return{}}}class xh extends kh{constructor(e){super(),this.defaultMaxValue=2,this.defaultAxis=0,this.maxValue=null!=e.maxValue?e.maxValue:this.defaultMaxValue,this.axis=null!=e.axis?e.axis:this.defaultAxis}apply(e){return wn((()=>{const t=wh(e,this.axis),n=ti(t,0,this.maxValue);return Ta(e,Na(n,xa(Yl(),t)))}))}getConfig(){return{maxValue:this.maxValue,axis:this.axis}}}xh.className="MaxNorm",ka(xh);class Sh extends kh{constructor(e){super(),this.defaultAxis=0,this.axis=null!=e.axis?e.axis:this.defaultAxis}apply(e){return wn((()=>Na(e,xa(Yl(),wh(e,this.axis)))))}getConfig(){return{axis:this.axis}}}Sh.className="UnitNorm",ka(Sh);class Nh extends kh{apply(e){return Hs(e)}}Nh.className="NonNeg",ka(Nh);class Th extends kh{constructor(e){super(),this.defaultMinValue=0,this.defaultMaxValue=1,this.defaultRate=1,this.defaultAxis=0,this.minValue=null!=e.minValue?e.minValue:this.defaultMinValue,this.maxValue=null!=e.maxValue?e.maxValue:this.defaultMaxValue,this.rate=null!=e.rate?e.rate:this.defaultRate,this.axis=null!=e.axis?e.axis:this.defaultAxis}apply(e){return wn((()=>{const t=wh(e,this.axis),n=xa(Ta(this.rate,ti(t,this.minValue,this.maxValue)),Ta(1-this.rate,t));return Ta(e,Na(n,xa(Yl(),t)))}))}getConfig(){return{minValue:this.minValue,maxValue:this.maxValue,rate:this.rate,axis:this.axis}}}Th.className="MinMaxNorm",ka(Th);const Ih={maxNorm:"MaxNorm",minMaxNorm:"MinMaxNorm",nonNeg:"NonNeg",unitNorm:"UnitNorm"};function Ch(e){return gl(e)}function $h(e,t={}){return yl(e,wa.getMap().classNameMap,t,"constraint")}function Ah(e){if(null==e)return null;if("string"==typeof e){return $h({className:e in Ih?Ih[e]:e,config:{}})}return e instanceof kh?e:$h(e)}
4259
4259
  /**
4260
4260
  * @license
4261
4261
  * Copyright 2018 Google LLC
@@ -4338,7 +4338,7 @@ const op=1048576;function lp(e,t,n=!1){if(null==e||"object"!=typeof e||Object.ge
4338
4338
  * https://opensource.org/licenses/MIT.
4339
4339
  * =============================================================================
4340
4340
  */function fp(e,t,n){return("inboundNodes"===e||"outputLayers"===e||"inputLayers"===e)&&0===t&&"string"==typeof n}function mp(e,t){if(null===e)return null;if("string"==typeof e)return fl(e);if("number"==typeof e||"boolean"==typeof e)return e;if(e instanceof Array){const n=[],a=e.length;for(let i=0;i<a;++i){const a=e[i];fp(t,i,a)?n.push(a):n.push(mp(a,t))}return n}{const t={};for(const n of Object.keys(e)){const a=e[n];if("name"===n&&"string"==typeof a)t[n]=a;else{const e=fl(n);t[e]=mp(a,e)}}return t}}function gp(e,t){if(null==e)return null;if("string"==typeof e)return dl(e);if("number"==typeof e||"boolean"==typeof e)return e;if(e instanceof Array){const n=[],a=e.length;for(let i=0;i<a;++i){const a=e[i];fp(t,i,a)?n.push(a):n.push(gp(a,t))}return n}{const t={};for(const n of Object.keys(e)){const a=e[n],i=dl(n);t[i]="name"!==n&&"className"!==n||"string"!=typeof a?gp(a,n):a}return t}}
4341
- /** @license See the LICENSE file. */const vp="4.20.0";
4341
+ /** @license See the LICENSE file. */const vp="4.22.0";
4342
4342
  /**
4343
4343
  * @license
4344
4344
  * Copyright 2018 Google LLC
@@ -4375,7 +4375,7 @@ const op=1048576;function lp(e,t,n=!1){if(null==e||"object"!=typeof e||Object.ge
4375
4375
  * https://opensource.org/licenses/MIT.
4376
4376
  * =============================================================================
4377
4377
  */
4378
- function Ip(e){x(e>0&&Number.isInteger(e),(()=>`batchSize is required to be a positive integer, but got ${e}`))}function $p(e,t,n){return null==e?[null]:Array.isArray(e)?e.map((e=>ec(e,t,n-t))):ec(e,t,n-t)}function Cp(e,t){return wn((()=>null==e?null:Array.isArray(e)?e.map((e=>Cp(e,t))):lc(e,"int32"===t.dtype?t:ra(t,"int32"))))}function Ap(e,t){const n=[];let a=0,i=null;for(;a<e;)i=a+t,i>=e&&(i=e),n.push([a,i]),a=i;return n}function Ep(e){const t=[];e instanceof Mt&&(e=[e]);for(let n=0;n<e.length;++n){const a=e[n];if(1===a.rank)t.push(Xl(a,1));else{if(0===a.rank)throw new Error("Expected tensor to be at least 1D, but received a 0D tensor (scalar).");t.push(a)}}return t}function jp(e,t){if(null==e)return;const n=[];if(t instanceof Mt)n.push(t.id);else if(Array.isArray(t))t.forEach((e=>n.push(e.id)));else if(null!=t)for(const e in t){const a=t[e];n.push(a.id)}const a=[];if(e instanceof Mt)-1===n.indexOf(e.id)&&a.push(e);else if(Array.isArray(e))e.forEach((e=>{-1===n.indexOf(e.id)&&a.push(e)}));else if(null!=e)for(const t in e){const i=e[t];-1===n.indexOf(i.id)&&a.push(i)}a.forEach((e=>{e.isDisposed||e.dispose()}))}
4378
+ function Ip(e){x(e>0&&Number.isInteger(e),(()=>`batchSize is required to be a positive integer, but got ${e}`))}function Cp(e,t,n){return null==e?[null]:Array.isArray(e)?e.map((e=>ec(e,t,n-t))):ec(e,t,n-t)}function $p(e,t){return wn((()=>null==e?null:Array.isArray(e)?e.map((e=>$p(e,t))):lc(e,"int32"===t.dtype?t:ra(t,"int32"))))}function Ap(e,t){const n=[];let a=0,i=null;for(;a<e;)i=a+t,i>=e&&(i=e),n.push([a,i]),a=i;return n}function Ep(e){const t=[];e instanceof Mt&&(e=[e]);for(let n=0;n<e.length;++n){const a=e[n];if(1===a.rank)t.push(Xl(a,1));else{if(0===a.rank)throw new Error("Expected tensor to be at least 1D, but received a 0D tensor (scalar).");t.push(a)}}return t}function jp(e,t){if(null==e)return;const n=[];if(t instanceof Mt)n.push(t.id);else if(Array.isArray(t))t.forEach((e=>n.push(e.id)));else if(null!=t)for(const e in t){const a=t[e];n.push(a.id)}const a=[];if(e instanceof Mt)-1===n.indexOf(e.id)&&a.push(e);else if(Array.isArray(e))e.forEach((e=>{-1===n.indexOf(e.id)&&a.push(e)}));else if(null!=e)for(const t in e){const i=e[t];-1===n.indexOf(i.id)&&a.push(i)}a.forEach((e=>{e.isDisposed||e.dispose()}))}
4379
4379
  /**
4380
4380
  * @license
4381
4381
  * Copyright 2018 Google LLC
@@ -4384,7 +4384,7 @@ function Ip(e){x(e>0&&Number.isInteger(e),(()=>`batchSize is required to be a po
4384
4384
  * license that can be found in the LICENSE file or at
4385
4385
  * https://opensource.org/licenses/MIT.
4386
4386
  * =============================================================================
4387
- */function zp(e){return Array.isArray(e)}function Dp(e){return!function(e){return e instanceof Mt}(e)&&!zp(e)}function Fp(e,t,n,a=!0,i=""){if(null==t||0===t.length){if(null!=e){let t=!1;if(zp(e)&&e.length>0)t=!0;else if(Dp(e)){for(const n in e)if(e.hasOwnProperty(n)){t=!0;break}}else t=!0;if(t)throw new il(`Error when checking model ${i} expected no data, but got ${e}`)}return[]}if(null==e)return t.map((e=>null));let s;if(Dp(e)){s=[];for(const n of t){if(null==e[n])throw new il(`No data provided for "${n}". Need data for each key in: ${t}`);s.push(e[n])}}else if(zp(e)){if(e.length!==t.length)throw new il(`Error when checking model ${i}: the Array of Tensors that you are passing to your model is not the size the model expected. Expected to see ${t.length} Tensor(s), but instead got the following list of Tensor(s): ${e}`);s=e}else{if(t.length>1)throw new il(`The model ${i} expects ${t.length} Tensor(s), but only received one Tensor. Found: Tensor with shape ${e.shape}`);s=[e]}if(s=Ep(s),null!=n)for(let e=0;e<t.length;++e){if(null==n[e])continue;const r=s[e];if(r.shape.length!==n[e].length)throw new il(`Error when checking ${i}: expected ${t[e]} to have ${n[e].length} dimension(s). but got array with shape ${r.shape}`);for(let t=0;t<n[e].length;++t){if(0===t&&!a)continue;const s=r.shape[t],o=n[e][t];if(null!=o&&o>=0&&s!==o)throw new il(`${i} expected a batch of elements where each example has shape [${n[e].slice(1,n[e].length)}] (i.e.,tensor shape [*,${n[e].slice(1,n[e].length)}]) but the ${i} received an input with ${r.shape[0]} examples, each with shape [${r.shape.slice(1,r.shape.length)}] (tensor shape [${r.shape}])`)}}return s}function _p(e,t,n,a=!0,i=""){let s;if(Array.isArray(e)){if(e.length!==t.length)throw new il(`Error when checking model ${i}: the Array of Tensors that you are passing to your model is not the size the the model expected. Expected to see ${t.length} Tensor(s), but instead got ${e.length} Tensors(s).`);s=e}else{if(t.length>1)throw new il(`The model expects ${t.length} ${i} Tensors, but only received one Tensor. Found: array with shape ${JSON.stringify(e.shape)}.`);s=[e]}if(null!=n)for(let e=0;e<t.length;++e){if(null==n[e])continue;const r=s[e];if(r.shape.length!==n[e].length)throw new il(`Error when checking ${i}: expected ${t[e]} to have ${n[e].length} dimension(s), but got array with shape ${JSON.stringify(r.shape)}`);for(let s=0;s<n[e].length;++s){if(0===s&&!a)continue;const o=r.shape[s],l=n[e][s];if(null!=l&&l!==o)throw new il(`Error when checking ${i}: expected ${t[e]} to have shape ${JSON.stringify(n[e])} but got array with shape ${JSON.stringify(r.shape)}.`)}}}class Rp extends yp{constructor(e){super(e),this.isTraining=!1}summary(e,t,n=console.log){if(!this.built)throw new il("This model has never been called, thus its weights have not been created yet. So no summary can be displayed. Build the model first (e.g., by calling it on some test data).");up(this,e,t,n)}compile(e){if(null==e.loss&&(e.loss=[]),this.loss=e.loss,"string"==typeof e.optimizer)this.optimizer_=function(e){const t={Adagrad:()=>ro.adagrad(.01),Adadelta:()=>ro.adadelta(1,.95,Yl()),Adam:()=>ro.adam(.001,.9,.999,Yl()),Adamax:()=>ro.adamax(.002,.9,.999,Yl(),0),RMSProp:()=>ro.rmsprop(.001,.9,0,Yl()),SGD:()=>ro.sgd(.01)};if(t.adagrad=t.Adagrad,t.adadelta=t.Adadelta,t.adam=t.Adam,t.adamax=t.Adamax,t.rmsprop=t.RMSProp,t.sgd=t.SGD,e in t)return t[e]();throw new il(`Unknown Optimizer ${e}`)}(e.optimizer),this.isOptimizerOwned=!0;else{if(!(e.optimizer instanceof Qr))throw new il("User-defined optimizer must be an instance of tf.Optimizer.");this.optimizer_=e.optimizer,this.isOptimizerOwned=!1}let t=[];if(Array.isArray(e.loss)||"string"==typeof e.loss||"function"==typeof e.loss)if(Array.isArray(e.loss)){if(e.loss.length!==this.outputs.length)throw new il(`When passing an Array as loss, it should have one entry per model output. The model has ${this.outputs.length} output(s), but you passed loss=${e.loss}.`);const n=e.loss;t=n.map((e=>Yh(e)))}else{const n=Yh(e.loss);this.outputs.forEach((e=>{t.push(n)}))}else{e.loss=e.loss;for(const t in e.loss)if(-1===this.outputNames.indexOf(t))throw new il(`Unknown entry in loss dictionary: "${t}". Only expected the following keys: ${this.outputNames}`);for(const n of this.outputNames)null==e.loss[n]&&console.warn(`Output "${n}" is missing from loss dictionary. We assume this was done on purpose, and we will not be expecting data to be passed to ${n} during training`),t.push(Yh(e.loss[n]))}this.lossFunctions=t,this.feedOutputNames=[],this.feedOutputShapes=[],this.feedLossFns=[];for(let e=0;e<this.outputs.length;++e){const t=this.internalOutputShapes[e],n=this.outputNames[e];this.feedOutputNames.push(n),this.feedOutputShapes.push(t),this.feedLossFns.push(this.lossFunctions[e])}const n=[];this.metrics=e.metrics,this.metricsNames=["loss"],this.metricsTensors=[],Bl("loss",(()=>{for(let e=0;e<this.outputs.length;++e){if(-1!==n.indexOf(e))continue;const t=this.lossFunctions[e];this.outputs.length>1&&(this.metricsTensors.push([t,e]),this.metricsNames.push(this.outputNames[e]+"_loss"))}}));const a=function(e,t){if(null==e||Array.isArray(e)&&0===e.length)return t.map((e=>[]));let n;if("string"==typeof e||"function"==typeof e)n=[e];else{if(!Array.isArray(e)&&"object"!=typeof e)throw new TypeError(`Type of metrics argument not understood. Expected an string,function, Array, or Object, found: ${e}`);n=e}if(Array.isArray(n))return t.map((e=>n));{const e=[];for(const a of t){let t=n.hasOwnProperty(a)?n[a]:[];Array.isArray(t)||(t=[t]),e.push(t)}return e}}(e.metrics,this.outputNames),i=(e,t,n)=>{this.outputNames.length>1&&(t=this.outputNames[e]+"_"+t),this.metricsNames.push(t),this.metricsTensors.push([n,e])};Bl("metric",(()=>{for(let e=0;e<this.outputs.length;++e){if(-1!==n.indexOf(e))continue;(t=>{let n,a,s;for(const r of t){if("string"==typeof r&&-1!==["accuracy","acc","crossentropy","ce"].indexOf(r)){const t=this.internalOutputShapes[e];let i;1===t[t.length-1]||this.lossFunctions[e]===Hh?-1!==["accuracy","acc"].indexOf(r)?a=Qh:-1!==["crossentropy","ce"].indexOf(r)&&(a=ep):this.lossFunctions[e]===qh?-1!==["accuracy","acc"].indexOf(r)?a=tp:-1!==["crossentropy","ce"].indexOf(r)&&(a=ap):-1!==["accuracy","acc"].indexOf(r)?a=Xh:-1!==["crossentropy","ce"].indexOf(r)&&(a=np),-1!==["accuracy","acc"].indexOf(r)?i="acc":-1!==["crossentropy","ce"].indexOf(r)&&(i="ce"),s=a,n=""+i}else{const e=sp(r);s=e,n=""+rp(r)}let t;Bl(n,(()=>{t=s})),i(e,n,t)}})(a[e])}})),this.collectedTrainableWeights=this.trainableWeights}checkTrainableWeightsConsistency(){null!=this.collectedTrainableWeights&&this.trainableWeights.length!==this.collectedTrainableWeights.length&&console.warn("Discrepancy between trainableweights and collected trainable weights. Did you set `model.trainable` without calling `model.compile()` afterwards?")}evaluate(e,t,n={}){const a=null==n.batchSize?32:n.batchSize;Ip(a);const i=this.standardizeUserDataXY(e,t,!0,a);try{const e=i[0].concat(i[1]);this.makeTestFunction();const t=this.testFunction;return hl(this.testLoop(t,e,a,n.verbose,n.steps))}finally{jp(i[0],e),jp(i[1],t)}}async evaluateDataset(e,t){return this.makeTestFunction(),async function(e,t,n){const a=null!=(n=n||{}).batches,i=e.testFunction;let s=[];if(n.verbose>0)throw new sl("Verbose mode is not implemented yet.");x(!a||n.batches>0&&Number.isInteger(n.batches),(()=>`Test loop expects \`batches\` to be a positive integer, but received ${JSON.stringify(n.batches)}`));const r="function"==typeof t.next?t:await t.iterator();let o=0,l=0;for(;!a||l<n.batches;){const t=await r.next();if(s=wn((()=>{if(t.value){const{xs:n,ys:a}=xp(e,t.value),r=n.concat(a),c=wn((()=>i(r)));if(kn(r),0===l)for(let e=0;e<c.length;++e)s.push(Di(0));const u=r[0].shape[0];for(let e=0;e<c.length;++e){const t=c[e],n=s[e];s[e]=wn((()=>xa(s[e],Ta(u,t)))),l>0&&kn(n)}kn(c),o+=u,++l}return s})),t.done){a&&console.warn(`Your dataset iterator ran out of data during evaluateDataset(). Interrupting evalution. Make sure that your dataset can generate at least \`batches\` batches (in this case, ${n.batches} batches). You may need to use the repeat() function when building your dataset.`);break}}for(let e=0;e<s.length;++e){const t=s[e];s[e]=Na(s[e],o),kn(t)}return hl(s)}(this,e,t)}checkNumSamples(e,t,n,a="steps"){let i;if(null!=n){if(i=null,null!=t)throw new il(`If ${a} is set, batchSize must be null or undefined.Got batchSize = ${t}`)}else{if(null==e)throw new il(`Either the input data should have a defined shape, or ${a} shoud be specified.`);i=Array.isArray(e)?e[0].shape[0]:e.shape[0]}return i}execute(e,t){if(Array.isArray(t)&&0===t.length)throw new il("`outputs` is an empty Array, which is not allowed.");const n=Array.isArray(t),a=n?t:[t],i=this.retrieveSymbolicTensors(a),s=new Xc;if(e instanceof Mt&&(e=[e]),Array.isArray(e)){if(e.length!==this.inputs.length)throw new il(`The number of inputs provided (${e.length}) does not match the number of inputs of this model (${this.inputs.length}).`);for(let t=0;t<this.inputs.length;++t)s.add(this.inputs[t],e[t])}else for(const t of this.inputs){const n=e[t.name];if(null==n)throw new il(`No value is provided for the model's input ${t.name}`);s.add(t,n)}const r=nu(i,s);return n?r:r[0]}retrieveSymbolicTensors(e){const t=ll(null,e.length);let n=e.length;for(const a of this.layers){const i=Array.isArray(a.output)?a.output:[a.output],s=i.map((e=>e.name));for(let a=0;a<e.length;++a){const r=s.indexOf(e[a]);if(-1!==r&&(t[a]=i[r],n--),0===n)break}if(0===n)break}if(n>0){const n=[];throw t.forEach(((t,a)=>{null==t&&n.push(e[a])})),new il(`Cannot find SymbolicTensors for output name(s): ${JSON.stringify(n)}`)}return t}predictLoop(e,t=32,n=!1){return wn((()=>{const a=this.checkNumSamples(e);if(n)throw new sl("Verbose predictLoop() is not implemented yet.");const i=Ap(a,t),s=this.outputs.map((e=>[]));for(let t=0;t<i.length;++t){wn((()=>{const n=i[t][0],a=i[t][1],s=$p(e,n,a),r=[];if(Array.isArray(s))for(let e=0;e<s.length;++e)r.push({key:this.inputs[e],value:s[e]});else r.push({key:this.inputs[0],value:s});const o=new Xc(r);return nu(this.outputs,o)})).forEach(((e,t)=>s[t].push(e)))}return hl(s.map((e=>Ua(e,0))))}))}predict(e,t={}){const n=Ep(e);_p(n,this.inputNames,this.feedInputShapes,!1);try{const e=null==t.batchSize?32:t.batchSize;return Ip(e),this.predictLoop(n,e)}finally{jp(n,e)}}predictOnBatch(e){_p(e,this.inputNames,this.feedInputShapes,!0);const t=(Array.isArray(e)?e[0]:e).shape[0];return this.predictLoop(e,t)}standardizeUserDataXY(e,t,n=!0,a){if(null==this.optimizer_)throw new al("You must compile a model before training/testing. Use LayersModel.compile(modelCompileArgs).");const i=[];for(let e=0;e<this.feedOutputShapes.length;++e){const t=this.feedOutputShapes[e];this.feedLossFns[e]===qh?i.push(t.slice(0,t.length-1).concat([1])):i.push(t)}if(function(e,t){const n=wl(e.map((e=>e.shape[0])));n.sort();const a=wl(t.map((e=>e.shape[0])));if(a.sort(),n.length>1)throw new il(`All input Tensors (x) should have the same number of samples. Got array shapes: ${JSON.stringify(e.map((e=>e.shape)))}`);if(a.length>1)throw new il(`All target Tensors (y) should have the same number of samples. Got array shapes: ${JSON.stringify(t.map((e=>e.shape)))}`);if(n.length>0&&a.length>0&&!T(n,a))throw new il(`Input Tensors should have the same number of samples as target Tensors. Found ${n[0]} input sample(s) and ${a[0]} target sample(s).`)}(e=Fp(e,this.feedInputNames,this.feedInputShapes,!1,"input"),t=Fp(t,this.feedOutputNames,i,!1,"target")),function(e,t,n){const a=[Wh,Hh,Kh];for(let i=0;i<e.length;++i){const s=e[i],r=t[i],o=n[i];if(null!=r){if(r===Kh&&1===s.shape[s.shape.length-1])throw new il(`You are passing a target array of shape ${s.shape} while using a loss 'categorical_crossentropy'. 'categorical_crossentropy'expects targets to be binary matrices (1s and 0s) of shape [samples, classes].`);if(-1!==a.indexOf(r)){const e=s.shape.slice(1),t=o.slice(1);for(let n=0;n<e.length;++n){const a=e[n],i=t[n];if(null!=i&&a!==i)throw new il(`A target Tensor with shape ${s.shape} was passed for an output of shape ${o}, while using a loss function that expects targets to have the same shape as the output.`)}}}}}(t,this.feedLossFns,this.feedOutputShapes),this.stateful&&null!=a&&a>0&&e[0].shape[0]%a!=0)throw new il(`In a stateful network, you should only pass inputs with a number of samples that is divisible by the batch size ${a}. Found: ${e[0].shape[0]} sample(s).`);return[e,t]}async standardizeUserData(e,t,n,a,i=!0,s){const[r,o]=this.standardizeUserDataXY(e,t,i,s);if(null!=n)throw new Error("sample weight is not supported yet.");let l=null;if(null!=a){const e=bp(a,this.outputNames);l=[];for(let t=0;t<e.length;++t)l.push(await wp(o[t],0,e[t]))}return[r,o,l]}testLoop(e,t,n,a=0,i){return wn((()=>{const s=this.checkNumSamples(t,n,i,"steps"),r=[];if(a>0)throw new sl("Verbose mode is not implemented yet.");if(null!=i)throw new sl("steps mode in testLoop() is not implemented yet");{const a=Ap(s,n),i=pr(Jl(0,s));for(let n=0;n<a.length;++n){const s=a[n][0],o=a[n][1],l=ec(i,s,o-s),c=Cp(t,l),u=e(c);if(0===n)for(let e=0;e<u.length;++e)r.push(Di(0));for(let e=0;e<u.length;++e){const t=u[e];r[e]=xa(r[e],Ta(o-s,t))}}for(let e=0;e<r.length;++e)r[e]=Na(r[e],s)}return r}))}getDedupedMetricsNames(){const e=this.metricsNames,t=[];for(let n=0;n<e.length;++n){const a=e[n];let i=a;if(ul(e,a)>1){i+=`_${ul(e.slice(0,n),a)}`}t.push(i)}return t}makeTrainFunction(){return e=>{const t=[],n=e.slice(0,this.inputs.length),a=e.slice(this.inputs.length,this.inputs.length+this.outputs.length),i=e.slice(this.inputs.length+this.outputs.length,this.inputs.length+2*this.outputs.length),s=[],r=this.collectedTrainableWeights.map((e=>e.read()));return[this.optimizer_.minimize((()=>{const e=[];for(let t=0;t<this.inputs.length;++t)e.push({key:this.inputs[t],value:n[t]});const r=new Xc(e),o=nu(this.outputs,r,{training:!0});let l;for(let e=0;e<this.lossFunctions.length;++e){let n=(0,this.lossFunctions[e])(a[e],o[e]);null!=i[e]&&(n=kp(n,i[e]));const s=ls(n);t.push(s),l=0===e?n:xa(l,n)}for(let e=0;e<this.metricsTensors.length;++e){let n;if(this.outputs.length>1&&e<this.outputs.length)n=t[e];else{const t=this.metricsTensors[e][0],i=this.metricsTensors[e][1];n=ls(t(a[i],o[i]))}xn(n),s.push(n)}return l=ls(l),this.calculateLosses().forEach((e=>{l=xa(l,e)})),l}),!0,r)].concat(s)}}makeTestFunction(){this.testFunction=e=>wn((()=>{const t=[];let n;const a=e.slice(0,this.inputs.length),i=e.slice(this.inputs.length,this.inputs.length+this.outputs.length),s=[];for(let e=0;e<this.inputs.length;++e)s.push({key:this.inputs[e],value:a[e]});const r=new Xc(s),o=nu(this.outputs,r);for(let e=0;e<this.lossFunctions.length;++e){const a=this.lossFunctions[e],s=ls(a(i[e],o[e]));n=0===e?s:xa(n,s),t.push(n)}for(let e=0;e<this.metricsTensors.length;++e){const n=this.metricsTensors[e][0],a=this.metricsTensors[e][1],s=ls(n(i[a],o[a]));t.push(s)}return t}))}async fit(e,t,n={}){if(this.isTraining)throw new Error("Cannot start training because another fit() call is ongoing.");let a,i,s,r,o,l,c,u,h;this.isTraining=!0;try{const p=null==n.batchSize?32:n.batchSize;Ip(p);const d=!1,f=await this.standardizeUserData(e,t,n.sampleWeight,n.classWeight,d,p);a=f[0],i=f[1],h=f[2];let m,g=!1;if(null!=n.validationData&&n.validationData.length>0){if(g=!0,2!==n.validationData.length)throw 3===n.validationData.length?new sl("validationData including sample weights is not supported yet."):new il(`When passing validation data, it must contain 2 (valX, valY) or 3 (valX, valY, valSampleWeight) items; ${n.validationData} is invalid.`);o=n.validationData[0],l=n.validationData[1];const e=!0,t=await this.standardizeUserData(o,l,null,null,e,p);c=t[0],u=t[1],m=c.concat(u)}else if(null!=n.validationSplit&&n.validationSplit>0&&n.validationSplit<1){g=!0;const e=Math.floor(a[0].shape[0]*(1-n.validationSplit)),t=a[0].shape[0];c=$p(a,e,t),s=a,a=$p(a,0,e),u=$p(i,e,t),r=i,i=$p(i,0,e),m=c.concat(u)}else null!=n.validationSteps&&(g=!0);const v=a.concat(i).concat(h);this.checkTrainableWeightsConsistency();const y=this.makeTrainFunction(),b=this.getDedupedMetricsNames();let w,k;g?(this.makeTestFunction(),w=this.testFunction,k=b.slice().concat(b.map((e=>"val_"+e)))):(w=null,m=[],k=b.slice());const x=Mh(n.callbacks,n.yieldEvery);return await this.fitLoop(y,v,b,p,n.epochs,n.verbose,x,w,m,n.shuffle,k,n.initialEpoch,null,null)}finally{this.isTraining=!1,jp(a,e),jp(i,t),jp(s,e),jp(r,t),jp(c,o),jp(u,l),null!=h&&kn(h)}}async fitLoop(e,t,n,a,i,s,r,o,l,c,u,h,p,d){null==a&&(a=32),null==i&&(i=1),null==c&&(c=!0),null==h&&(h=0);let f=!1;if(null!=o&&null!=l&&(f=!0),null!=d&&(f=!0,null==p))throw new il("Can only use `validationSteps` when doing step-wise training, i.e., `stepsPerEpoch` must be set.");const m=this.checkNumSamples(t,a,p,"steps_per_epoch");let g;null!=m&&(g=Jl(0,m)),null==s&&(s=1);const{callbackList:v,history:y}=Ph(r,s,i,h,m,p,a,f,u);v.setModel(this),this.history=y,await v.onTrainBegin(),this.stopTraining_=!1;for(let s=h;s<i;++s){await v.onEpochBegin(s);const i={};if(null!=p)throw new sl("stepsPerEpoch mode is not implemented yet.");{if("batch"===c)throw new sl("batch shuffling is not implemneted yet");c&&w(g);const s=pr(g),r=Ap(m,a);for(let c=0;c<r.length;++c){const u={};if(await v.onBatchBegin(c,u),wn((()=>{const h=r[c][0],p=r[c][1],d=ec(s,h,p-h);u.batch=c,u.size=p-h;const m=Cp(t,d),g=e(m);for(let e=0;e<n.length;++e){const t=n[e],a=g[e];u[t]=a,xn(a)}if(c===r.length-1&&f){const e=this.testLoop(o,l,a);for(let t=0;t<n.length;++t){const a=n[t],s=e[t];xn(s),i["val_"+a]=s}}})),await v.onBatchEnd(c,u),jh(u),this.stopTraining_)break}s.dispose()}if(await v.onEpochEnd(s,i),this.stopTraining_)break}return await v.onTrainEnd(),await this.history.syncData(),this.history}async fitDataset(e,t){return Np(this,e,t)}async trainOnBatch(e,t){const n=await this.standardizeUserData(e,t),a=n[0],i=n[1],s=this.makeTrainFunction()(a.concat(i)),r=[];for(const e of s){const t=await e.data();r.push(t[0])}return kn(s),jp(n[0],e),jp(n[1],t),hl(r)}getNamedWeights(e){const t=[],n=null!=e&&e.trainableOnly,a=n?this.trainableWeights:this.weights,i=this.getWeights(n);for(let e=0;e<a.length;++e)n&&!a[e].trainable||t.push({name:a[e].originalName,tensor:i[e]});return t}set stopTraining(e){this.stopTraining_=e}get stopTraining(){return this.stopTraining_}get optimizer(){return this.optimizer_}set optimizer(e){this.optimizer_!==e&&(this.optimizer_=e,this.isOptimizerOwned=!1)}dispose(){const e=super.dispose();if(0===e.refCountAfterDispose&&null!=this.optimizer&&this.isOptimizerOwned){const t=bn().numTensors;this.optimizer_.dispose(),e.numDisposedVariables+=t-bn().numTensors}return e}getLossIdentifiers(){let e;if("string"==typeof this.loss)e=dl(this.loss);else if(Array.isArray(this.loss)){for(const e of this.loss)if("string"!=typeof e)throw new Error("Serialization of non-string loss is not supported.");e=this.loss.map((e=>dl(e)))}else{const t=Object.keys(this.loss);e={};const n=this.loss;for(const a of t){if("string"!=typeof n[a])throw new Error("Serialization of non-string loss is not supported.");e[a]=dl(n[a])}}return e}getMetricIdentifiers(){if("string"==typeof this.metrics||"function"==typeof this.metrics)return[dl(rp(this.metrics))];if(Array.isArray(this.metrics))return this.metrics.map((e=>dl(rp(e))));{const e={};for(const t in this.metrics)e[t]=dl(rp(this.metrics[t]));return e}}getTrainingConfig(){return{loss:this.getLossIdentifiers(),metrics:this.getMetricIdentifiers(),optimizer_config:{class_name:this.optimizer.getClassName(),config:this.optimizer.getConfig()}}}loadTrainingConfig(e){if(null!=e.weighted_metrics)throw new Error("Loading weight_metrics is not supported yet.");if(null!=e.loss_weights)throw new Error("Loading loss_weights is not supported yet.");if(null!=e.sample_weight_mode)throw new Error("Loading sample_weight_mode is not supported yet.");const t=Bh(mp(e.optimizer_config));let n,a;if("string"==typeof e.loss)n=fl(e.loss);else if(Array.isArray(e.loss))n=e.loss.map((e=>fl(e)));else if(null!=e.loss){n={};for(const t in e.loss)n[t]=fl(e.loss[t])}if(Array.isArray(e.metrics))a=e.metrics.map((e=>fl(e)));else if(null!=e.metrics){a={};for(const t in e.metrics)a[t]=fl(e.metrics[t])}this.compile({loss:n,metrics:a,optimizer:t})}async save(e,t){if("string"==typeof e){const t=(n=e,zn.getSaveHandlers(n));if(0===t.length)throw new il(`Cannot find any save handlers for URL '${e}'`);if(t.length>1)throw new il(`Found more than one (${t.length}) save handlers for URL '${e}'`);e=t[0]}var n;if(null==e.save)throw new il("LayersModel.save() cannot proceed because the IOHandler provided does not have the `save` attribute defined.");const a=await Sn(this.getNamedWeights(t)),i={modelTopology:this.toJSON(null,!1),format:"layers-model",generatedBy:`TensorFlow.js tfjs-layers v${vp}`,convertedBy:null};if(null!=t&&t.includeOptimizer&&null!=this.optimizer){i.trainingConfig=this.getTrainingConfig();const e="optimizer",{data:t,specs:n}=await Sn(await this.optimizer.getWeights(),e);a.specs.push(...n),a.data=(s=[a.data,t],vn.join(s))}var s;if(null!=this.userDefinedMetadata){const e=!0;lp(this.userDefinedMetadata,this.name,e),i.userDefinedMetadata=this.userDefinedMetadata}return i.weightData=a.data,i.weightSpecs=a.specs,e.save(i)}setUserDefinedMetadata(e){lp(e,this.name),this.userDefinedMetadata=e}getUserDefinedMetadata(){return this.userDefinedMetadata}}Rp.className="Model",ka(Rp);class Lp extends Rp{}
4387
+ */function zp(e){return Array.isArray(e)}function Dp(e){return!function(e){return e instanceof Mt}(e)&&!zp(e)}function Fp(e,t,n,a=!0,i=""){if(null==t||0===t.length){if(null!=e){let t=!1;if(zp(e)&&e.length>0)t=!0;else if(Dp(e)){for(const n in e)if(e.hasOwnProperty(n)){t=!0;break}}else t=!0;if(t)throw new il(`Error when checking model ${i} expected no data, but got ${e}`)}return[]}if(null==e)return t.map((e=>null));let s;if(Dp(e)){s=[];for(const n of t){if(null==e[n])throw new il(`No data provided for "${n}". Need data for each key in: ${t}`);s.push(e[n])}}else if(zp(e)){if(e.length!==t.length)throw new il(`Error when checking model ${i}: the Array of Tensors that you are passing to your model is not the size the model expected. Expected to see ${t.length} Tensor(s), but instead got the following list of Tensor(s): ${e}`);s=e}else{if(t.length>1)throw new il(`The model ${i} expects ${t.length} Tensor(s), but only received one Tensor. Found: Tensor with shape ${e.shape}`);s=[e]}if(s=Ep(s),null!=n)for(let e=0;e<t.length;++e){if(null==n[e])continue;const r=s[e];if(r.shape.length!==n[e].length)throw new il(`Error when checking ${i}: expected ${t[e]} to have ${n[e].length} dimension(s). but got array with shape ${r.shape}`);for(let t=0;t<n[e].length;++t){if(0===t&&!a)continue;const s=r.shape[t],o=n[e][t];if(null!=o&&o>=0&&s!==o)throw new il(`${i} expected a batch of elements where each example has shape [${n[e].slice(1,n[e].length)}] (i.e.,tensor shape [*,${n[e].slice(1,n[e].length)}]) but the ${i} received an input with ${r.shape[0]} examples, each with shape [${r.shape.slice(1,r.shape.length)}] (tensor shape [${r.shape}])`)}}return s}function _p(e,t,n,a=!0,i=""){let s;if(Array.isArray(e)){if(e.length!==t.length)throw new il(`Error when checking model ${i}: the Array of Tensors that you are passing to your model is not the size the the model expected. Expected to see ${t.length} Tensor(s), but instead got ${e.length} Tensors(s).`);s=e}else{if(t.length>1)throw new il(`The model expects ${t.length} ${i} Tensors, but only received one Tensor. Found: array with shape ${JSON.stringify(e.shape)}.`);s=[e]}if(null!=n)for(let e=0;e<t.length;++e){if(null==n[e])continue;const r=s[e];if(r.shape.length!==n[e].length)throw new il(`Error when checking ${i}: expected ${t[e]} to have ${n[e].length} dimension(s), but got array with shape ${JSON.stringify(r.shape)}`);for(let s=0;s<n[e].length;++s){if(0===s&&!a)continue;const o=r.shape[s],l=n[e][s];if(null!=l&&l!==o)throw new il(`Error when checking ${i}: expected ${t[e]} to have shape ${JSON.stringify(n[e])} but got array with shape ${JSON.stringify(r.shape)}.`)}}}class Rp extends yp{constructor(e){super(e),this.isTraining=!1}summary(e,t,n=console.log){if(!this.built)throw new il("This model has never been called, thus its weights have not been created yet. So no summary can be displayed. Build the model first (e.g., by calling it on some test data).");up(this,e,t,n)}compile(e){if(null==e.loss&&(e.loss=[]),this.loss=e.loss,"string"==typeof e.optimizer)this.optimizer_=function(e){const t={Adagrad:()=>ro.adagrad(.01),Adadelta:()=>ro.adadelta(1,.95,Yl()),Adam:()=>ro.adam(.001,.9,.999,Yl()),Adamax:()=>ro.adamax(.002,.9,.999,Yl(),0),RMSProp:()=>ro.rmsprop(.001,.9,0,Yl()),SGD:()=>ro.sgd(.01)};if(t.adagrad=t.Adagrad,t.adadelta=t.Adadelta,t.adam=t.Adam,t.adamax=t.Adamax,t.rmsprop=t.RMSProp,t.sgd=t.SGD,e in t)return t[e]();throw new il(`Unknown Optimizer ${e}`)}(e.optimizer),this.isOptimizerOwned=!0;else{if(!(e.optimizer instanceof Qr))throw new il("User-defined optimizer must be an instance of tf.Optimizer.");this.optimizer_=e.optimizer,this.isOptimizerOwned=!1}let t=[];if(Array.isArray(e.loss)||"string"==typeof e.loss||"function"==typeof e.loss)if(Array.isArray(e.loss)){if(e.loss.length!==this.outputs.length)throw new il(`When passing an Array as loss, it should have one entry per model output. The model has ${this.outputs.length} output(s), but you passed loss=${e.loss}.`);const n=e.loss;t=n.map((e=>Yh(e)))}else{const n=Yh(e.loss);this.outputs.forEach((e=>{t.push(n)}))}else{e.loss=e.loss;for(const t in e.loss)if(-1===this.outputNames.indexOf(t))throw new il(`Unknown entry in loss dictionary: "${t}". Only expected the following keys: ${this.outputNames}`);for(const n of this.outputNames)null==e.loss[n]&&console.warn(`Output "${n}" is missing from loss dictionary. We assume this was done on purpose, and we will not be expecting data to be passed to ${n} during training`),t.push(Yh(e.loss[n]))}this.lossFunctions=t,this.feedOutputNames=[],this.feedOutputShapes=[],this.feedLossFns=[];for(let e=0;e<this.outputs.length;++e){const t=this.internalOutputShapes[e],n=this.outputNames[e];this.feedOutputNames.push(n),this.feedOutputShapes.push(t),this.feedLossFns.push(this.lossFunctions[e])}const n=[];this.metrics=e.metrics,this.metricsNames=["loss"],this.metricsTensors=[],Bl("loss",(()=>{for(let e=0;e<this.outputs.length;++e){if(-1!==n.indexOf(e))continue;const t=this.lossFunctions[e];this.outputs.length>1&&(this.metricsTensors.push([t,e]),this.metricsNames.push(this.outputNames[e]+"_loss"))}}));const a=function(e,t){if(null==e||Array.isArray(e)&&0===e.length)return t.map((e=>[]));let n;if("string"==typeof e||"function"==typeof e)n=[e];else{if(!Array.isArray(e)&&"object"!=typeof e)throw new TypeError(`Type of metrics argument not understood. Expected an string,function, Array, or Object, found: ${e}`);n=e}if(Array.isArray(n))return t.map((e=>n));{const e=[];for(const a of t){let t=n.hasOwnProperty(a)?n[a]:[];Array.isArray(t)||(t=[t]),e.push(t)}return e}}(e.metrics,this.outputNames),i=(e,t,n)=>{this.outputNames.length>1&&(t=this.outputNames[e]+"_"+t),this.metricsNames.push(t),this.metricsTensors.push([n,e])};Bl("metric",(()=>{for(let e=0;e<this.outputs.length;++e){if(-1!==n.indexOf(e))continue;(t=>{let n,a,s;for(const r of t){if("string"==typeof r&&-1!==["accuracy","acc","crossentropy","ce"].indexOf(r)){const t=this.internalOutputShapes[e];let i;1===t[t.length-1]||this.lossFunctions[e]===Hh?-1!==["accuracy","acc"].indexOf(r)?a=Qh:-1!==["crossentropy","ce"].indexOf(r)&&(a=ep):this.lossFunctions[e]===qh?-1!==["accuracy","acc"].indexOf(r)?a=tp:-1!==["crossentropy","ce"].indexOf(r)&&(a=ap):-1!==["accuracy","acc"].indexOf(r)?a=Xh:-1!==["crossentropy","ce"].indexOf(r)&&(a=np),-1!==["accuracy","acc"].indexOf(r)?i="acc":-1!==["crossentropy","ce"].indexOf(r)&&(i="ce"),s=a,n=""+i}else{const e=sp(r);s=e,n=""+rp(r)}let t;Bl(n,(()=>{t=s})),i(e,n,t)}})(a[e])}})),this.collectedTrainableWeights=this.trainableWeights}checkTrainableWeightsConsistency(){null!=this.collectedTrainableWeights&&this.trainableWeights.length!==this.collectedTrainableWeights.length&&console.warn("Discrepancy between trainableweights and collected trainable weights. Did you set `model.trainable` without calling `model.compile()` afterwards?")}evaluate(e,t,n={}){const a=null==n.batchSize?32:n.batchSize;Ip(a);const i=this.standardizeUserDataXY(e,t,!0,a);try{const e=i[0].concat(i[1]);this.makeTestFunction();const t=this.testFunction;return hl(this.testLoop(t,e,a,n.verbose,n.steps))}finally{jp(i[0],e),jp(i[1],t)}}async evaluateDataset(e,t){return this.makeTestFunction(),async function(e,t,n){const a=null!=(n=n||{}).batches,i=e.testFunction;let s=[];if(n.verbose>0)throw new sl("Verbose mode is not implemented yet.");x(!a||n.batches>0&&Number.isInteger(n.batches),(()=>`Test loop expects \`batches\` to be a positive integer, but received ${JSON.stringify(n.batches)}`));const r="function"==typeof t.next?t:await t.iterator();let o=0,l=0;for(;!a||l<n.batches;){const t=await r.next();if(s=wn((()=>{if(t.value){const{xs:n,ys:a}=xp(e,t.value),r=n.concat(a),c=wn((()=>i(r)));if(kn(r),0===l)for(let e=0;e<c.length;++e)s.push(Di(0));const u=r[0].shape[0];for(let e=0;e<c.length;++e){const t=c[e],n=s[e];s[e]=wn((()=>xa(s[e],Ta(u,t)))),l>0&&kn(n)}kn(c),o+=u,++l}return s})),t.done){a&&console.warn(`Your dataset iterator ran out of data during evaluateDataset(). Interrupting evalution. Make sure that your dataset can generate at least \`batches\` batches (in this case, ${n.batches} batches). You may need to use the repeat() function when building your dataset.`);break}}for(let e=0;e<s.length;++e){const t=s[e];s[e]=Na(s[e],o),kn(t)}return hl(s)}(this,e,t)}checkNumSamples(e,t,n,a="steps"){let i;if(null!=n){if(i=null,null!=t)throw new il(`If ${a} is set, batchSize must be null or undefined.Got batchSize = ${t}`)}else{if(null==e)throw new il(`Either the input data should have a defined shape, or ${a} shoud be specified.`);i=Array.isArray(e)?e[0].shape[0]:e.shape[0]}return i}execute(e,t){if(Array.isArray(t)&&0===t.length)throw new il("`outputs` is an empty Array, which is not allowed.");const n=Array.isArray(t),a=n?t:[t],i=this.retrieveSymbolicTensors(a),s=new Xc;if(e instanceof Mt&&(e=[e]),Array.isArray(e)){if(e.length!==this.inputs.length)throw new il(`The number of inputs provided (${e.length}) does not match the number of inputs of this model (${this.inputs.length}).`);for(let t=0;t<this.inputs.length;++t)s.add(this.inputs[t],e[t])}else for(const t of this.inputs){const n=e[t.name];if(null==n)throw new il(`No value is provided for the model's input ${t.name}`);s.add(t,n)}const r=nu(i,s);return n?r:r[0]}retrieveSymbolicTensors(e){const t=ll(null,e.length);let n=e.length;for(const a of this.layers){const i=Array.isArray(a.output)?a.output:[a.output],s=i.map((e=>e.name));for(let a=0;a<e.length;++a){const r=s.indexOf(e[a]);if(-1!==r&&(t[a]=i[r],n--),0===n)break}if(0===n)break}if(n>0){const n=[];throw t.forEach(((t,a)=>{null==t&&n.push(e[a])})),new il(`Cannot find SymbolicTensors for output name(s): ${JSON.stringify(n)}`)}return t}predictLoop(e,t=32,n=!1){return wn((()=>{const a=this.checkNumSamples(e);if(n)throw new sl("Verbose predictLoop() is not implemented yet.");const i=Ap(a,t),s=this.outputs.map((e=>[]));for(let t=0;t<i.length;++t){wn((()=>{const n=i[t][0],a=i[t][1],s=Cp(e,n,a),r=[];if(Array.isArray(s))for(let e=0;e<s.length;++e)r.push({key:this.inputs[e],value:s[e]});else r.push({key:this.inputs[0],value:s});const o=new Xc(r);return nu(this.outputs,o)})).forEach(((e,t)=>s[t].push(e)))}return hl(s.map((e=>Ua(e,0))))}))}predict(e,t={}){const n=Ep(e);_p(n,this.inputNames,this.feedInputShapes,!1);try{const e=null==t.batchSize?32:t.batchSize;return Ip(e),this.predictLoop(n,e)}finally{jp(n,e)}}predictOnBatch(e){_p(e,this.inputNames,this.feedInputShapes,!0);const t=(Array.isArray(e)?e[0]:e).shape[0];return this.predictLoop(e,t)}standardizeUserDataXY(e,t,n=!0,a){if(null==this.optimizer_)throw new al("You must compile a model before training/testing. Use LayersModel.compile(modelCompileArgs).");const i=[];for(let e=0;e<this.feedOutputShapes.length;++e){const t=this.feedOutputShapes[e];this.feedLossFns[e]===qh?i.push(t.slice(0,t.length-1).concat([1])):i.push(t)}if(function(e,t){const n=wl(e.map((e=>e.shape[0])));n.sort();const a=wl(t.map((e=>e.shape[0])));if(a.sort(),n.length>1)throw new il(`All input Tensors (x) should have the same number of samples. Got array shapes: ${JSON.stringify(e.map((e=>e.shape)))}`);if(a.length>1)throw new il(`All target Tensors (y) should have the same number of samples. Got array shapes: ${JSON.stringify(t.map((e=>e.shape)))}`);if(n.length>0&&a.length>0&&!T(n,a))throw new il(`Input Tensors should have the same number of samples as target Tensors. Found ${n[0]} input sample(s) and ${a[0]} target sample(s).`)}(e=Fp(e,this.feedInputNames,this.feedInputShapes,!1,"input"),t=Fp(t,this.feedOutputNames,i,!1,"target")),function(e,t,n){const a=[Wh,Hh,Kh];for(let i=0;i<e.length;++i){const s=e[i],r=t[i],o=n[i];if(null!=r){if(r===Kh&&1===s.shape[s.shape.length-1])throw new il(`You are passing a target array of shape ${s.shape} while using a loss 'categorical_crossentropy'. 'categorical_crossentropy'expects targets to be binary matrices (1s and 0s) of shape [samples, classes].`);if(-1!==a.indexOf(r)){const e=s.shape.slice(1),t=o.slice(1);for(let n=0;n<e.length;++n){const a=e[n],i=t[n];if(null!=i&&a!==i)throw new il(`A target Tensor with shape ${s.shape} was passed for an output of shape ${o}, while using a loss function that expects targets to have the same shape as the output.`)}}}}}(t,this.feedLossFns,this.feedOutputShapes),this.stateful&&null!=a&&a>0&&e[0].shape[0]%a!=0)throw new il(`In a stateful network, you should only pass inputs with a number of samples that is divisible by the batch size ${a}. Found: ${e[0].shape[0]} sample(s).`);return[e,t]}async standardizeUserData(e,t,n,a,i=!0,s){const[r,o]=this.standardizeUserDataXY(e,t,i,s);if(null!=n)throw new Error("sample weight is not supported yet.");let l=null;if(null!=a){const e=bp(a,this.outputNames);l=[];for(let t=0;t<e.length;++t)l.push(await wp(o[t],0,e[t]))}return[r,o,l]}testLoop(e,t,n,a=0,i){return wn((()=>{const s=this.checkNumSamples(t,n,i,"steps"),r=[];if(a>0)throw new sl("Verbose mode is not implemented yet.");if(null!=i)throw new sl("steps mode in testLoop() is not implemented yet");{const a=Ap(s,n),i=pr(Jl(0,s));for(let n=0;n<a.length;++n){const s=a[n][0],o=a[n][1],l=ec(i,s,o-s),c=$p(t,l),u=e(c);if(0===n)for(let e=0;e<u.length;++e)r.push(Di(0));for(let e=0;e<u.length;++e){const t=u[e];r[e]=xa(r[e],Ta(o-s,t))}}for(let e=0;e<r.length;++e)r[e]=Na(r[e],s)}return r}))}getDedupedMetricsNames(){const e=this.metricsNames,t=[];for(let n=0;n<e.length;++n){const a=e[n];let i=a;if(ul(e,a)>1){i+=`_${ul(e.slice(0,n),a)}`}t.push(i)}return t}makeTrainFunction(){return e=>{const t=[],n=e.slice(0,this.inputs.length),a=e.slice(this.inputs.length,this.inputs.length+this.outputs.length),i=e.slice(this.inputs.length+this.outputs.length,this.inputs.length+2*this.outputs.length),s=[],r=this.collectedTrainableWeights.map((e=>e.read()));return[this.optimizer_.minimize((()=>{const e=[];for(let t=0;t<this.inputs.length;++t)e.push({key:this.inputs[t],value:n[t]});const r=new Xc(e),o=nu(this.outputs,r,{training:!0});let l;for(let e=0;e<this.lossFunctions.length;++e){let n=(0,this.lossFunctions[e])(a[e],o[e]);null!=i[e]&&(n=kp(n,i[e]));const s=ls(n);t.push(s),l=0===e?n:xa(l,n)}for(let e=0;e<this.metricsTensors.length;++e){let n;if(this.outputs.length>1&&e<this.outputs.length)n=t[e];else{const t=this.metricsTensors[e][0],i=this.metricsTensors[e][1];n=ls(t(a[i],o[i]))}xn(n),s.push(n)}return l=ls(l),this.calculateLosses().forEach((e=>{l=xa(l,e)})),l}),!0,r)].concat(s)}}makeTestFunction(){this.testFunction=e=>wn((()=>{const t=[];let n;const a=e.slice(0,this.inputs.length),i=e.slice(this.inputs.length,this.inputs.length+this.outputs.length),s=[];for(let e=0;e<this.inputs.length;++e)s.push({key:this.inputs[e],value:a[e]});const r=new Xc(s),o=nu(this.outputs,r);for(let e=0;e<this.lossFunctions.length;++e){const a=this.lossFunctions[e],s=ls(a(i[e],o[e]));n=0===e?s:xa(n,s),t.push(n)}for(let e=0;e<this.metricsTensors.length;++e){const n=this.metricsTensors[e][0],a=this.metricsTensors[e][1],s=ls(n(i[a],o[a]));t.push(s)}return t}))}async fit(e,t,n={}){if(this.isTraining)throw new Error("Cannot start training because another fit() call is ongoing.");let a,i,s,r,o,l,c,u,h;this.isTraining=!0;try{const p=null==n.batchSize?32:n.batchSize;Ip(p);const d=!1,f=await this.standardizeUserData(e,t,n.sampleWeight,n.classWeight,d,p);a=f[0],i=f[1],h=f[2];let m,g=!1;if(null!=n.validationData&&n.validationData.length>0){if(g=!0,2!==n.validationData.length)throw 3===n.validationData.length?new sl("validationData including sample weights is not supported yet."):new il(`When passing validation data, it must contain 2 (valX, valY) or 3 (valX, valY, valSampleWeight) items; ${n.validationData} is invalid.`);o=n.validationData[0],l=n.validationData[1];const e=!0,t=await this.standardizeUserData(o,l,null,null,e,p);c=t[0],u=t[1],m=c.concat(u)}else if(null!=n.validationSplit&&n.validationSplit>0&&n.validationSplit<1){g=!0;const e=Math.floor(a[0].shape[0]*(1-n.validationSplit)),t=a[0].shape[0];c=Cp(a,e,t),s=a,a=Cp(a,0,e),u=Cp(i,e,t),r=i,i=Cp(i,0,e),m=c.concat(u)}else null!=n.validationSteps&&(g=!0);const v=a.concat(i).concat(h);this.checkTrainableWeightsConsistency();const y=this.makeTrainFunction(),b=this.getDedupedMetricsNames();let w,k;g?(this.makeTestFunction(),w=this.testFunction,k=b.slice().concat(b.map((e=>"val_"+e)))):(w=null,m=[],k=b.slice());const x=Mh(n.callbacks,n.yieldEvery);return await this.fitLoop(y,v,b,p,n.epochs,n.verbose,x,w,m,n.shuffle,k,n.initialEpoch,null,null)}finally{this.isTraining=!1,jp(a,e),jp(i,t),jp(s,e),jp(r,t),jp(c,o),jp(u,l),null!=h&&kn(h)}}async fitLoop(e,t,n,a,i,s,r,o,l,c,u,h,p,d){null==a&&(a=32),null==i&&(i=1),null==c&&(c=!0),null==h&&(h=0);let f=!1;if(null!=o&&null!=l&&(f=!0),null!=d&&(f=!0,null==p))throw new il("Can only use `validationSteps` when doing step-wise training, i.e., `stepsPerEpoch` must be set.");const m=this.checkNumSamples(t,a,p,"steps_per_epoch");let g;null!=m&&(g=Jl(0,m)),null==s&&(s=1);const{callbackList:v,history:y}=Ph(r,s,i,h,m,p,a,f,u);v.setModel(this),this.history=y,await v.onTrainBegin(),this.stopTraining_=!1;for(let s=h;s<i;++s){await v.onEpochBegin(s);const i={};if(null!=p)throw new sl("stepsPerEpoch mode is not implemented yet.");{if("batch"===c)throw new sl("batch shuffling is not implemneted yet");c&&w(g);const s=pr(g),r=Ap(m,a);for(let c=0;c<r.length;++c){const u={};if(await v.onBatchBegin(c,u),wn((()=>{const h=r[c][0],p=r[c][1],d=ec(s,h,p-h);u.batch=c,u.size=p-h;const m=$p(t,d),g=e(m);for(let e=0;e<n.length;++e){const t=n[e],a=g[e];u[t]=a,xn(a)}if(c===r.length-1&&f){const e=this.testLoop(o,l,a);for(let t=0;t<n.length;++t){const a=n[t],s=e[t];xn(s),i["val_"+a]=s}}})),await v.onBatchEnd(c,u),jh(u),this.stopTraining_)break}s.dispose()}if(await v.onEpochEnd(s,i),this.stopTraining_)break}return await v.onTrainEnd(),await this.history.syncData(),this.history}async fitDataset(e,t){return Np(this,e,t)}async trainOnBatch(e,t){const n=await this.standardizeUserData(e,t),a=n[0],i=n[1],s=this.makeTrainFunction()(a.concat(i)),r=[];for(const e of s){const t=await e.data();r.push(t[0])}return kn(s),jp(n[0],e),jp(n[1],t),hl(r)}getNamedWeights(e){const t=[],n=null!=e&&e.trainableOnly,a=n?this.trainableWeights:this.weights,i=this.getWeights(n);for(let e=0;e<a.length;++e)n&&!a[e].trainable||t.push({name:a[e].originalName,tensor:i[e]});return t}set stopTraining(e){this.stopTraining_=e}get stopTraining(){return this.stopTraining_}get optimizer(){return this.optimizer_}set optimizer(e){this.optimizer_!==e&&(this.optimizer_=e,this.isOptimizerOwned=!1)}dispose(){const e=super.dispose();if(0===e.refCountAfterDispose&&null!=this.optimizer&&this.isOptimizerOwned){const t=bn().numTensors;this.optimizer_.dispose(),e.numDisposedVariables+=t-bn().numTensors}return e}getLossIdentifiers(){let e;if("string"==typeof this.loss)e=dl(this.loss);else if(Array.isArray(this.loss)){for(const e of this.loss)if("string"!=typeof e)throw new Error("Serialization of non-string loss is not supported.");e=this.loss.map((e=>dl(e)))}else{const t=Object.keys(this.loss);e={};const n=this.loss;for(const a of t){if("string"!=typeof n[a])throw new Error("Serialization of non-string loss is not supported.");e[a]=dl(n[a])}}return e}getMetricIdentifiers(){if("string"==typeof this.metrics||"function"==typeof this.metrics)return[dl(rp(this.metrics))];if(Array.isArray(this.metrics))return this.metrics.map((e=>dl(rp(e))));{const e={};for(const t in this.metrics)e[t]=dl(rp(this.metrics[t]));return e}}getTrainingConfig(){return{loss:this.getLossIdentifiers(),metrics:this.getMetricIdentifiers(),optimizer_config:{class_name:this.optimizer.getClassName(),config:this.optimizer.getConfig()}}}loadTrainingConfig(e){if(null!=e.weighted_metrics)throw new Error("Loading weight_metrics is not supported yet.");if(null!=e.loss_weights)throw new Error("Loading loss_weights is not supported yet.");if(null!=e.sample_weight_mode)throw new Error("Loading sample_weight_mode is not supported yet.");const t=Bh(mp(e.optimizer_config));let n,a;if("string"==typeof e.loss)n=fl(e.loss);else if(Array.isArray(e.loss))n=e.loss.map((e=>fl(e)));else if(null!=e.loss){n={};for(const t in e.loss)n[t]=fl(e.loss[t])}if(Array.isArray(e.metrics))a=e.metrics.map((e=>fl(e)));else if(null!=e.metrics){a={};for(const t in e.metrics)a[t]=fl(e.metrics[t])}this.compile({loss:n,metrics:a,optimizer:t})}async save(e,t){if("string"==typeof e){const t=(n=e,zn.getSaveHandlers(n));if(0===t.length)throw new il(`Cannot find any save handlers for URL '${e}'`);if(t.length>1)throw new il(`Found more than one (${t.length}) save handlers for URL '${e}'`);e=t[0]}var n;if(null==e.save)throw new il("LayersModel.save() cannot proceed because the IOHandler provided does not have the `save` attribute defined.");const a=await Sn(this.getNamedWeights(t)),i={modelTopology:this.toJSON(null,!1),format:"layers-model",generatedBy:`TensorFlow.js tfjs-layers v${vp}`,convertedBy:null};if(null!=t&&t.includeOptimizer&&null!=this.optimizer){i.trainingConfig=this.getTrainingConfig();const e="optimizer",{data:t,specs:n}=await Sn(await this.optimizer.getWeights(),e);a.specs.push(...n),a.data=(s=[a.data,t],vn.join(s))}var s;if(null!=this.userDefinedMetadata){const e=!0;lp(this.userDefinedMetadata,this.name,e),i.userDefinedMetadata=this.userDefinedMetadata}return i.weightData=a.data,i.weightSpecs=a.specs,e.save(i)}setUserDefinedMetadata(e){lp(e,this.name),this.userDefinedMetadata=e}getUserDefinedMetadata(){return this.userDefinedMetadata}}Rp.className="Model",ka(Rp);class Lp extends Rp{}
4388
4388
  /**
4389
4389
  * @license
4390
4390
  * Copyright 2018 Google LLC
@@ -4454,7 +4454,7 @@ let Pp=class extends ba{getConfig(){return{}}};class Bp extends Pp{apply(e,t=1){
4454
4454
  * license that can be found in the LICENSE file or at
4455
4455
  * https://opensource.org/licenses/MIT.
4456
4456
  * =============================================================================
4457
- */class pd extends Zc{constructor(e){super(null==e?{}:e),this.supportsMasking=!0,null!=e&&(this.maxValue=e.maxValue)}call(e,t){e=Mc(e);let n=Hs(e);return null!=this.maxValue&&(n=ti(n,0,this.maxValue)),n}computeOutputShape(e){return e}getConfig(){const e={maxValue:this.maxValue},t=super.getConfig();return Object.assign(e,t),e}}pd.className="ReLU",ka(pd);class dd extends Zc{constructor(e){super(null==e?{}:e),this.DEFAULT_ALPHA=.3,null==e&&(e={}),this.alpha=null==e.alpha?this.DEFAULT_ALPHA:e.alpha}call(e,t){const n=Mc(e);return qi(n,this.alpha)}computeOutputShape(e){return e}getConfig(){const e={alpha:this.alpha},t=super.getConfig();return Object.assign(e,t),e}}dd.className="LeakyReLU",ka(dd);class fd extends Zc{constructor(e){if(super(null==e?{}:e),this.DEFAULT_ALPHA_INITIALIZER="zeros",null==e&&(e={}),this.supportsMasking=!0,this.alphaInitializer=_c(e.alphaInitializer||this.DEFAULT_ALPHA_INITIALIZER),this.alphaRegularizer=hd(e.alphaRegularizer),this.alphaConstraint=Ah(e.alphaConstraint),null==e.sharedAxes)this.sharedAxes=null;else if(Array.isArray(e.sharedAxes))this.sharedAxes=e.sharedAxes;else{if("number"!=typeof e.sharedAxes)throw new il(`Expected sharedAxes to be a number or an array of numbers, but got ${e.sharedAxes}`);this.sharedAxes=[e.sharedAxes]}}build(e){const t=(e=Oc(e)).slice(1);if(null!=this.sharedAxes)for(const e of this.sharedAxes)t[e-1]=1;this.alpha=this.addWeight("alpha",t,"float32",this.alphaInitializer,this.alphaRegularizer,!0,this.alphaConstraint);const n={};if(null!=this.sharedAxes)for(let t=1;t<e.length;++t)n[t]=e[t];this.inputSpec=[new Vc({ndim:e.length,axes:n})],this.built=!0}call(e,t){return e=Mc(e),vs(e,this.alpha.read())}getConfig(){const e={alphaInitializer:Fc(this.alphaInitializer),alphaRegularizer:cd(this.alphaRegularizer),alphaConstraint:$h(this.alphaConstraint),sharedAxes:this.sharedAxes},t=super.getConfig();return Object.assign(e,t),e}}fd.className="PReLU",ka(fd);class md extends Zc{constructor(e){if(super(null==e?{}:e),this.DEFAULT_ALPHA=1,null==e&&(e={}),null!=e.alpha&&e.alpha!==this.DEFAULT_ALPHA)throw new sl(`Non-default alpha value (${e.alpha}) is not supported by the ELU layer yet.`);this.alpha=null==e.alpha?this.DEFAULT_ALPHA:e.alpha}call(e,t){const n=Mc(e);return Si(n)}computeOutputShape(e){return e}getConfig(){const e={alpha:this.alpha},t=super.getConfig();return Object.assign(e,t),e}}md.className="ELU",ka(md);class gd extends Zc{constructor(e){super(null==e?{}:e),this.DEFAULT_THETA=1,null==e&&(e={}),this.theta=null==e.theta?this.DEFAULT_THETA:e.theta}call(e,t){const n=Mc(e);return Ta(n,ra(Vi(n,this.theta),"float32"))}computeOutputShape(e){return e}getConfig(){const e={theta:this.theta},t=super.getConfig();return Object.assign(e,t),e}}gd.className="ThresholdedReLU",ka(gd);class vd extends Zc{constructor(e){super(null==e?{}:e),this.DEFAULT_AXIS=1,null==e&&(e={}),this.softmax=(new Yp).apply,this.axis=null==e.axis?this.DEFAULT_AXIS:e.axis}call(e,t){return wn((()=>{let n=Mc(e);const a=t.mask;if(null!=a){const e=Ta(es(us(n.shape),ra(a,n.dtype)),Di(-1e9));n=xa(n,e)}return this.axis instanceof Array?this.axis.length>1?Oi(es(n,ns(n,this.axis,!0))):this.softmax(n,this.axis[0]):this.softmax(n,this.axis)}))}computeOutputShape(e){return e}getConfig(){const e={axis:this.axis},t=super.getConfig();return Object.assign(e,t),e}}
4457
+ */class pd extends Zc{constructor(e){super(null==e?{}:e),this.supportsMasking=!0,null!=e&&(this.maxValue=e.maxValue)}call(e,t){e=Mc(e);let n=Hs(e);return null!=this.maxValue&&(n=ti(n,0,this.maxValue)),n}computeOutputShape(e){return e}getConfig(){const e={maxValue:this.maxValue},t=super.getConfig();return Object.assign(e,t),e}}pd.className="ReLU",ka(pd);class dd extends Zc{constructor(e){super(null==e?{}:e),this.DEFAULT_ALPHA=.3,null==e&&(e={}),this.alpha=null==e.alpha?this.DEFAULT_ALPHA:e.alpha}call(e,t){const n=Mc(e);return qi(n,this.alpha)}computeOutputShape(e){return e}getConfig(){const e={alpha:this.alpha},t=super.getConfig();return Object.assign(e,t),e}}dd.className="LeakyReLU",ka(dd);class fd extends Zc{constructor(e){if(super(null==e?{}:e),this.DEFAULT_ALPHA_INITIALIZER="zeros",null==e&&(e={}),this.supportsMasking=!0,this.alphaInitializer=_c(e.alphaInitializer||this.DEFAULT_ALPHA_INITIALIZER),this.alphaRegularizer=hd(e.alphaRegularizer),this.alphaConstraint=Ah(e.alphaConstraint),null==e.sharedAxes)this.sharedAxes=null;else if(Array.isArray(e.sharedAxes))this.sharedAxes=e.sharedAxes;else{if("number"!=typeof e.sharedAxes)throw new il(`Expected sharedAxes to be a number or an array of numbers, but got ${e.sharedAxes}`);this.sharedAxes=[e.sharedAxes]}}build(e){const t=(e=Oc(e)).slice(1);if(null!=this.sharedAxes)for(const e of this.sharedAxes)t[e-1]=1;this.alpha=this.addWeight("alpha",t,"float32",this.alphaInitializer,this.alphaRegularizer,!0,this.alphaConstraint);const n={};if(null!=this.sharedAxes)for(let t=1;t<e.length;++t)n[t]=e[t];this.inputSpec=[new Vc({ndim:e.length,axes:n})],this.built=!0}call(e,t){return e=Mc(e),vs(e,this.alpha.read())}getConfig(){const e={alphaInitializer:Fc(this.alphaInitializer),alphaRegularizer:cd(this.alphaRegularizer),alphaConstraint:Ch(this.alphaConstraint),sharedAxes:this.sharedAxes},t=super.getConfig();return Object.assign(e,t),e}}fd.className="PReLU",ka(fd);class md extends Zc{constructor(e){if(super(null==e?{}:e),this.DEFAULT_ALPHA=1,null==e&&(e={}),null!=e.alpha&&e.alpha!==this.DEFAULT_ALPHA)throw new sl(`Non-default alpha value (${e.alpha}) is not supported by the ELU layer yet.`);this.alpha=null==e.alpha?this.DEFAULT_ALPHA:e.alpha}call(e,t){const n=Mc(e);return Si(n)}computeOutputShape(e){return e}getConfig(){const e={alpha:this.alpha},t=super.getConfig();return Object.assign(e,t),e}}md.className="ELU",ka(md);class gd extends Zc{constructor(e){super(null==e?{}:e),this.DEFAULT_THETA=1,null==e&&(e={}),this.theta=null==e.theta?this.DEFAULT_THETA:e.theta}call(e,t){const n=Mc(e);return Ta(n,ra(Vi(n,this.theta),"float32"))}computeOutputShape(e){return e}getConfig(){const e={theta:this.theta},t=super.getConfig();return Object.assign(e,t),e}}gd.className="ThresholdedReLU",ka(gd);class vd extends Zc{constructor(e){super(null==e?{}:e),this.DEFAULT_AXIS=1,null==e&&(e={}),this.softmax=(new Yp).apply,this.axis=null==e.axis?this.DEFAULT_AXIS:e.axis}call(e,t){return wn((()=>{let n=Mc(e);const a=t.mask;if(null!=a){const e=Ta(es(us(n.shape),ra(a,n.dtype)),Di(-1e9));n=xa(n,e)}return this.axis instanceof Array?this.axis.length>1?Oi(es(n,ns(n,this.axis,!0))):this.softmax(n,this.axis[0]):this.softmax(n,this.axis)}))}computeOutputShape(e){return e}getConfig(){const e={axis:this.axis},t=super.getConfig();return Object.assign(e,t),e}}
4458
4458
  /**
4459
4459
  * @license
4460
4460
  * Copyright 2018 Google LLC
@@ -4473,7 +4473,7 @@ function yd(e,t,n){if("number"==typeof e)return ll(e,t);if(e.length!==t)throw ne
4473
4473
  * license that can be found in the LICENSE file or at
4474
4474
  * https://opensource.org/licenses/MIT.
4475
4475
  * =============================================================================
4476
- */function kd(e,t){return wn((()=>(Ll(t),"channelsFirst"===t?pa(e,[0,2,3,1]):e)))}function xd(e,t){return wn((()=>(Ll(t),"channelsFirst"===t?pa(e,[0,2,3,4,1]):e)))}function Sd(e,t,n,a=[1,1],i="valid",s,r,o=null){return wn((()=>{if(null==s&&(s="channelsLast"),Ll(s),3!==e.rank&&4!==e.rank)throw new il(`conv2dWithBiasActivation expects input to be of rank 3 or 4, but received ${e.rank}.`);if(3!==t.rank&&4!==t.rank)throw new il(`conv2dWithBiasActivation expects kernel to be of rank 3 or 4, but received ${e.rank}.`);let l=kd(e,s);if("causal"===i)throw new sl("The support for CAUSAL padding mode in conv1dWithBias is not implemented yet.");return l=Sr({x:l,filter:t,strides:a,pad:"same"===i?"same":"valid",dilations:r,dataFormat:"NHWC",bias:n,activation:o}),"channelsFirst"===s&&(l=pa(l,[0,3,1,2])),l}))}vd.className="Softmax",ka(vd);class Nd extends Zc{constructor(e,t){if(super(t),this.bias=null,this.DEFAULT_KERNEL_INITIALIZER="glorotNormal",this.DEFAULT_BIAS_INITIALIZER="zeros",Nd.verifyArgs(t),this.rank=e,Nl(this.rank,"rank"),1!==this.rank&&2!==this.rank&&3!==this.rank)throw new sl(`Convolution layer for rank other than 1, 2, or 3 (${this.rank}) is not implemented yet.`);if(this.kernelSize=yd(t.kernelSize,e,"kernelSize"),this.strides=yd(null==t.strides?1:t.strides,e,"strides"),this.padding=null==t.padding?"valid":t.padding,Ml(this.padding),this.dataFormat=null==t.dataFormat?"channelsLast":t.dataFormat,Ll(this.dataFormat),this.activation=sd(t.activation),this.useBias=null==t.useBias||t.useBias,this.biasInitializer=_c(t.biasInitializer||this.DEFAULT_BIAS_INITIALIZER),this.biasConstraint=Ah(t.biasConstraint),this.biasRegularizer=hd(t.biasRegularizer),this.activityRegularizer=hd(t.activityRegularizer),this.dilationRate=yd(null==t.dilationRate?1:t.dilationRate,e,"dilationRate"),1===this.rank&&Array.isArray(this.dilationRate)&&1!==this.dilationRate.length)throw new il(`dilationRate must be a number or an array of a single number for 1D convolution, but received ${JSON.stringify(this.dilationRate)}`);if(2===this.rank){if("number"==typeof this.dilationRate)this.dilationRate=[this.dilationRate,this.dilationRate];else if(2!==this.dilationRate.length)throw new il(`dilationRate must be a number or array of two numbers for 2D convolution, but received ${JSON.stringify(this.dilationRate)}`)}else if(3===this.rank)if("number"==typeof this.dilationRate)this.dilationRate=[this.dilationRate,this.dilationRate,this.dilationRate];else if(3!==this.dilationRate.length)throw new il(`dilationRate must be a number or array of three numbers for 3D convolution, but received ${JSON.stringify(this.dilationRate)}`)}static verifyArgs(e){if(cl("kernelSize"in e,"required key 'kernelSize' not in config"),"number"!=typeof e.kernelSize&&!Sl(e.kernelSize,"number",1,3))throw new il(`BaseConv expects config.kernelSize to be number or number[] with length 1, 2, or 3, but received ${JSON.stringify(e.kernelSize)}.`)}getConfig(){const e={kernelSize:this.kernelSize,strides:this.strides,padding:this.padding,dataFormat:this.dataFormat,dilationRate:this.dilationRate,activation:ad(this.activation),useBias:this.useBias,biasInitializer:Fc(this.biasInitializer),biasRegularizer:cd(this.biasRegularizer),activityRegularizer:cd(this.activityRegularizer),biasConstraint:$h(this.biasConstraint)},t=super.getConfig();return Object.assign(e,t),e}}class Td extends Nd{constructor(e,t){super(e,t),this.kernel=null,Td.verifyArgs(t),this.filters=t.filters,Nl(this.filters,"filters"),this.kernelInitializer=_c(t.kernelInitializer||this.DEFAULT_KERNEL_INITIALIZER),this.kernelConstraint=Ah(t.kernelConstraint),this.kernelRegularizer=hd(t.kernelRegularizer)}build(e){e=Oc(e);const t="channelsFirst"===this.dataFormat?1:e.length-1;if(null==e[t])throw new il(`The channel dimension of the input should be defined. Found ${e[t]}`);const n=e[t],a=this.kernelSize.concat([n,this.filters]);this.kernel=this.addWeight("kernel",a,null,this.kernelInitializer,this.kernelRegularizer,!0,this.kernelConstraint),this.useBias&&(this.bias=this.addWeight("bias",[this.filters],null,this.biasInitializer,this.biasRegularizer,!0,this.biasConstraint)),this.inputSpec=[{ndim:this.rank+2,axes:{[t]:n}}],this.built=!0}call(e,t){return wn((()=>{let t;e=Mc(e);const n=null==this.bias?null:this.bias.read(),a=Il(this.activation.getClassName());if(null!=a&&2===this.rank)t=Sd(e,this.kernel.read(),n,this.strides,this.padding,this.dataFormat,this.dilationRate,a);else{if(1===this.rank)t=function(e,t,n,a=1,i="valid",s,r=1){return wn((()=>{if(null==s&&(s="channelsLast"),Ll(s),3!==e.shape.length)throw new il(`The input of a conv1dWithBias operation should be 3, but is ${e.shape.length} instead.`);if(3!==t.shape.length)throw new il(`The kernel for a conv1dWithBias operation should be 3, but is ${t.shape.length} instead`);if(null!=n&&1!==n.shape.length)throw new il(`The bias for a conv1dWithBias operation should be 1, but is ${n.shape.length} instead`);if("channelsFirst"===s&&(e=pa(e,[0,2,1])),"causal"===i)throw new sl("The support for CAUSAL padding mode in conv1dWithBias is not implemented yet.");let o=oi(e,t,a,"same"===i?"same":"valid","NWC",r);return null!=n&&(o=hc(o,n)),o}))}(e,this.kernel.read(),n,this.strides[0],this.padding,this.dataFormat,this.dilationRate[0]);else if(2===this.rank)t=Sd(e,this.kernel.read(),n,this.strides,this.padding,this.dataFormat,this.dilationRate);else{if(3!==this.rank)throw new sl("convolutions greater than 3D are not implemented yet.");t=function(e,t,n,a=[1,1,1],i="valid",s,r){return wn((()=>{if(null==s&&(s="channelsLast"),Ll(s),4!==e.rank&&5!==e.rank)throw new il(`conv3dWithBias expects input to be of rank 4 or 5, but received ${e.rank}.`);if(4!==t.rank&&5!==t.rank)throw new il(`conv3dWithBias expects kernel to be of rank 4 or 5, but received ${e.rank}.`);let o=xd(e,s);if("causal"===i)throw new sl("The support for CAUSAL padding mode in conv3dWithBias is not implemented yet.");return o=ui(o,t,a,"same"===i?"same":"valid","NDHWC",r),null!=n&&(o=hc(o,n)),"channelsFirst"===s&&(o=pa(o,[0,4,1,2,3])),o}))}(e,this.kernel.read(),n,this.strides,this.padding,this.dataFormat,this.dilationRate)}null!=this.activation&&(t=this.activation.apply(t))}return t}))}computeOutputShape(e){e=Oc(e);const t=[],n="channelsLast"===this.dataFormat?e.slice(1,e.length-1):e.slice(2);for(let e=0;e<n.length;++e){const a=bd(n[e],this.kernelSize[e],this.padding,this.strides[e],"number"==typeof this.dilationRate?this.dilationRate:this.dilationRate[e]);t.push(a)}let a=[e[0]];return"channelsLast"===this.dataFormat?(a=a.concat(t),a.push(this.filters)):(a.push(this.filters),a=a.concat(t)),a}getConfig(){const e={filters:this.filters,kernelInitializer:Fc(this.kernelInitializer),kernelRegularizer:cd(this.kernelRegularizer),kernelConstraint:$h(this.kernelConstraint)},t=super.getConfig();return Object.assign(e,t),e}static verifyArgs(e){if(!("filters"in e)||"number"!=typeof e.filters||e.filters<1)throw new il(`Convolution layer expected config.filters to be a 'number' > 0 but got ${JSON.stringify(e.filters)}`)}}class Id extends Td{constructor(e){super(2,e),Id.verifyArgs(e)}getConfig(){const e=super.getConfig();return delete e.rank,e}static verifyArgs(e){if("number"!=typeof e.kernelSize&&!Sl(e.kernelSize,"number",1,2))throw new il(`Conv2D expects config.kernelSize to be number or number[] with length 1 or 2, but received ${JSON.stringify(e.kernelSize)}.`)}}Id.className="Conv2D",ka(Id);class $d extends Td{constructor(e){super(3,e),$d.verifyArgs(e)}getConfig(){const e=super.getConfig();return delete e.rank,e}static verifyArgs(e){if("number"!=typeof e.kernelSize&&(!Array.isArray(e.kernelSize)||1!==e.kernelSize.length&&3!==e.kernelSize.length))throw new il(`Conv3D expects config.kernelSize to be number or [number, number, number], but received ${JSON.stringify(e.kernelSize)}.`)}}$d.className="Conv3D",ka($d);class Cd extends Id{constructor(e){if(super(e),this.inputSpec=[new Vc({ndim:4})],"same"!==this.padding&&"valid"!==this.padding)throw new il(`Conv2DTranspose currently supports only padding modes 'same' and 'valid', but received padding mode ${this.padding}`)}build(e){if(4!==(e=Oc(e)).length)throw new il("Input should have rank 4; Received input shape: "+JSON.stringify(e));const t="channelsFirst"===this.dataFormat?1:e.length-1;if(null==e[t])throw new il("The channel dimension of the inputs should be defined. Found `None`.");const n=e[t],a=this.kernelSize.concat([this.filters,n]);this.kernel=this.addWeight("kernel",a,"float32",this.kernelInitializer,this.kernelRegularizer,!0,this.kernelConstraint),this.useBias&&(this.bias=this.addWeight("bias",[this.filters],"float32",this.biasInitializer,this.biasRegularizer,!0,this.biasConstraint)),this.inputSpec=[new Vc({ndim:4,axes:{[t]:n}})],this.built=!0}call(e,t){return wn((()=>{let t=Mc(e);if(4!==t.shape.length)throw new il(`Conv2DTranspose.call() expects input tensor to be rank-4, but received a tensor of rank-${t.shape.length}`);const n=t.shape,a=n[0];let i,s;"channelsFirst"===this.dataFormat?(i=2,s=3):(i=1,s=2);const r=n[i],o=n[s],l=this.kernelSize[0],c=this.kernelSize[1],u=this.strides[0],h=this.strides[1],p=[a,wd(r,u,l,this.padding),wd(o,h,c,this.padding),this.filters];"channelsLast"!==this.dataFormat&&(t=pa(t,[0,2,3,1]));let d=ci(t,this.kernel.read(),p,this.strides,this.padding);return"channelsLast"!==this.dataFormat&&(d=pa(d,[0,3,1,2])),null!=this.bias&&(d=hc(d,this.bias.read(),this.dataFormat)),null!=this.activation&&(d=this.activation.apply(d)),d}))}computeOutputShape(e){const t=(e=Oc(e)).slice();let n,a,i;"channelsFirst"===this.dataFormat?(n=1,a=2,i=3):(n=3,a=1,i=2);const s=this.kernelSize[0],r=this.kernelSize[1],o=this.strides[0],l=this.strides[1];return t[n]=this.filters,t[a]=wd(t[a],o,s,this.padding),t[i]=wd(t[i],l,r,this.padding),t}getConfig(){const e=super.getConfig();return delete e.dilationRate,e}}Cd.className="Conv2DTranspose",ka(Cd);class Ad extends $d{constructor(e){if(super(e),this.inputSpec=[new Vc({ndim:5})],"same"!==this.padding&&"valid"!==this.padding)throw new il(`Conv3DTranspose currently supports only padding modes 'same' and 'valid', but received padding mode ${this.padding}`)}build(e){if(5!==(e=Oc(e)).length)throw new il("Input should have rank 5; Received input shape: "+JSON.stringify(e));const t="channelsFirst"===this.dataFormat?1:e.length-1;if(null==e[t])throw new il("The channel dimension of the inputs should be defined. Found `None`.");const n=e[t],a=this.kernelSize.concat([this.filters,n]);this.kernel=this.addWeight("kernel",a,"float32",this.kernelInitializer,this.kernelRegularizer,!0,this.kernelConstraint),this.useBias&&(this.bias=this.addWeight("bias",[this.filters],"float32",this.biasInitializer,this.biasRegularizer,!0,this.biasConstraint)),this.inputSpec=[new Vc({ndim:5,axes:{[t]:n}})],this.built=!0}call(e,t){return wn((()=>{let t=Mc(e);if(5!==t.shape.length)throw new il(`Conv3DTranspose.call() expects input tensor to be rank-4, but received a tensor of rank-${t.shape.length}`);const n=t.shape,a=n[0];let i,s,r;"channelsFirst"===this.dataFormat?(r=2,i=3,s=4):(r=1,i=2,s=3);const o=n[r],l=n[i],c=n[s],u=this.kernelSize[0],h=this.kernelSize[1],p=this.kernelSize[2],d=this.strides[0],f=this.strides[1],m=this.strides[2],g=[a,wd(o,d,u,this.padding),wd(l,f,h,this.padding),wd(c,m,p,this.padding),this.filters];"channelsLast"!==this.dataFormat&&(t=pa(t,[0,2,3,4,1]));let v=pi(t,this.kernel.read(),g,this.strides,this.padding);return"channelsLast"!==this.dataFormat&&(v=pa(v,[0,4,1,2,3])),null!==this.bias&&(v=hc(v,this.bias.read(),this.dataFormat)),null!==this.activation&&(v=this.activation.apply(v)),v}))}computeOutputShape(e){const t=(e=Oc(e)).slice();let n,a,i,s;"channelsFirst"===this.dataFormat?(n=1,a=2,i=3,s=4):(n=4,a=1,i=2,s=3);const r=this.kernelSize[0],o=this.kernelSize[1],l=this.kernelSize[2],c=this.strides[0],u=this.strides[1],h=this.strides[2];return t[n]=this.filters,t[a]=wd(t[a],c,r,this.padding),t[i]=wd(t[i],u,o,this.padding),t[s]=wd(t[s],h,l,this.padding),t}getConfig(){const e=super.getConfig();return delete e.dilationRate,e}}Ad.className="Conv3DTranspose",ka(Ad);class Ed extends Td{constructor(e,t){if(super(e,t),this.DEFAULT_DEPTHWISE_INITIALIZER="glorotUniform",this.DEFAULT_POINTWISE_INITIALIZER="glorotUniform",this.depthwiseKernel=null,this.pointwiseKernel=null,null==t.filters)throw new il("The `filters` configuration field is required by SeparableConv, but is unspecified.");if(null!=t.kernelInitializer||null!=t.kernelRegularizer||null!=t.kernelConstraint)throw new il("Fields kernelInitializer, kernelRegularizer and kernelConstraint are invalid for SeparableConv2D. Use depthwiseInitializer, depthwiseRegularizer, depthwiseConstraint, pointwiseInitializer, pointwiseRegularizer and pointwiseConstraint instead.");if(null!=t.padding&&"same"!==t.padding&&"valid"!==t.padding)throw new il(`SeparableConv${this.rank}D supports only padding modes: 'same' and 'valid', but received ${JSON.stringify(t.padding)}`);this.depthMultiplier=null==t.depthMultiplier?1:t.depthMultiplier,this.depthwiseInitializer=_c(t.depthwiseInitializer||this.DEFAULT_DEPTHWISE_INITIALIZER),this.depthwiseRegularizer=hd(t.depthwiseRegularizer),this.depthwiseConstraint=Ah(t.depthwiseConstraint),this.pointwiseInitializer=_c(t.depthwiseInitializer||this.DEFAULT_POINTWISE_INITIALIZER),this.pointwiseRegularizer=hd(t.pointwiseRegularizer),this.pointwiseConstraint=Ah(t.pointwiseConstraint)}build(e){if((e=Oc(e)).length<this.rank+2)throw new il(`Inputs to SeparableConv${this.rank}D should have rank ${this.rank+2}, but received input shape: ${JSON.stringify(e)}`);const t="channelsFirst"===this.dataFormat?1:e.length-1;if(null==e[t]||e[t]<0)throw new il(`The channel dimension of the inputs should be defined, but found ${JSON.stringify(e[t])}`);const n=e[t],a=this.kernelSize.concat([n,this.depthMultiplier]),i=[];for(let e=0;e<this.rank;++e)i.push(1);i.push(n*this.depthMultiplier,this.filters);const s=!0;this.depthwiseKernel=this.addWeight("depthwise_kernel",a,"float32",this.depthwiseInitializer,this.depthwiseRegularizer,s,this.depthwiseConstraint),this.pointwiseKernel=this.addWeight("pointwise_kernel",i,"float32",this.pointwiseInitializer,this.pointwiseRegularizer,s,this.pointwiseConstraint),this.useBias?this.bias=this.addWeight("bias",[this.filters],"float32",this.biasInitializer,this.biasRegularizer,s,this.biasConstraint):this.bias=null,this.inputSpec=[new Vc({ndim:this.rank+2,axes:{[t]:n}})],this.built=!0}call(e,t){return wn((()=>{let t;if(e=Mc(e),1===this.rank)throw new sl("1D separable convolution is not implemented yet.");return 2===this.rank&&("channelsFirst"===this.dataFormat&&(e=pa(e,[0,2,3,1])),t=er(e,this.depthwiseKernel.read(),this.pointwiseKernel.read(),this.strides,this.padding,this.dilationRate,"NHWC")),this.useBias&&(t=hc(t,this.bias.read(),this.dataFormat)),null!=this.activation&&(t=this.activation.apply(t)),"channelsFirst"===this.dataFormat&&(t=pa(t,[0,3,1,2])),t}))}getConfig(){const e=super.getConfig();return delete e.rank,delete e.kernelInitializer,delete e.kernelRegularizer,delete e.kernelConstraint,e.depthwiseInitializer=Fc(this.depthwiseInitializer),e.pointwiseInitializer=Fc(this.pointwiseInitializer),e.depthwiseRegularizer=cd(this.depthwiseRegularizer),e.pointwiseRegularizer=cd(this.pointwiseRegularizer),e.depthwiseConstraint=$h(this.depthwiseConstraint),e.pointwiseConstraint=$h(this.pointwiseConstraint),e}}Ed.className="SeparableConv";class jd extends Ed{constructor(e){super(2,e)}}jd.className="SeparableConv2D",ka(jd);class zd extends Td{constructor(e){super(1,e),zd.verifyArgs(e),this.inputSpec=[{ndim:3}]}getConfig(){const e=super.getConfig();return delete e.rank,delete e.dataFormat,e}static verifyArgs(e){if("number"!=typeof e.kernelSize&&!Sl(e.kernelSize,"number",1,1))throw new il(`Conv1D expects config.kernelSize to be number or number[] with length 1, but received ${JSON.stringify(e.kernelSize)}.`)}}zd.className="Conv1D",ka(zd);class Dd extends Zc{constructor(e){super(e),"number"==typeof e.cropping?this.cropping=[[e.cropping,e.cropping],[e.cropping,e.cropping]]:"number"==typeof e.cropping[0]?this.cropping=[[e.cropping[0],e.cropping[0]],[e.cropping[1],e.cropping[1]]]:this.cropping=e.cropping,this.dataFormat=void 0===e.dataFormat?"channelsLast":e.dataFormat,this.inputSpec=[{ndim:4}]}computeOutputShape(e){return"channelsFirst"===this.dataFormat?[e[0],e[1],e[2]-this.cropping[0][0]-this.cropping[0][1],e[3]-this.cropping[1][0]-this.cropping[1][1]]:[e[0],e[1]-this.cropping[0][0]-this.cropping[0][1],e[2]-this.cropping[1][0]-this.cropping[1][1],e[3]]}call(e,t){return wn((()=>{if(e=Mc(e),"channelsLast"===this.dataFormat){const t=nc(e,this.cropping[0][0],e.shape[1]-this.cropping[0][0]-this.cropping[0][1],2);return nc(t,this.cropping[1][0],e.shape[2]-this.cropping[1][1]-this.cropping[1][0],3)}{const t=nc(e,this.cropping[0][0],e.shape[2]-this.cropping[0][0]-this.cropping[0][1],3);return nc(t,this.cropping[1][0],e.shape[3]-this.cropping[1][1]-this.cropping[1][0],4)}}))}getConfig(){const e={cropping:this.cropping,dataFormat:this.dataFormat},t=super.getConfig();return Object.assign(e,t),e}}Dd.className="Cropping2D",ka(Dd);class Fd extends Zc{constructor(e){var t;super(e),this.DEFAULT_SIZE=[2,2],this.inputSpec=[{ndim:4}],this.size=null==e.size?this.DEFAULT_SIZE:e.size,this.dataFormat=null==e.dataFormat?"channelsLast":e.dataFormat,Ll(this.dataFormat),this.interpolation=null==e.interpolation?"nearest":e.interpolation,t=this.interpolation,xl(zl,"InterpolationFormat",t)}computeOutputShape(e){if("channelsFirst"===this.dataFormat){const t=null==e[2]?null:this.size[0]*e[2],n=null==e[3]?null:this.size[1]*e[3];return[e[0],e[1],t,n]}{const t=null==e[1]?null:this.size[0]*e[1],n=null==e[2]?null:this.size[1]*e[2];return[e[0],t,n,e[3]]}}call(e,t){return wn((()=>{let t=Mc(e);const n=t.shape;if("channelsFirst"===this.dataFormat){t=pa(t,[0,2,3,1]);const e=this.size[0]*n[2],a=this.size[1]*n[3],i="nearest"===this.interpolation?Zr.resizeNearestNeighbor(t,[e,a]):Zr.resizeBilinear(t,[e,a]);return pa(i,[0,3,1,2])}{const e=this.size[0]*n[1],a=this.size[1]*n[2];return"nearest"===this.interpolation?Zr.resizeNearestNeighbor(t,[e,a]):Zr.resizeBilinear(t,[e,a])}}))}getConfig(){const e={size:this.size,dataFormat:this.dataFormat,interpolation:this.interpolation},t=super.getConfig();return Object.assign(e,t),e}}Fd.className="UpSampling2D",ka(Fd);class _d extends Nd{constructor(e){super(2,e),this.depthwiseKernel=null,this.depthMultiplier=null==e.depthMultiplier?1:e.depthMultiplier,this.depthwiseInitializer=_c(e.depthwiseInitializer||this.DEFAULT_KERNEL_INITIALIZER),this.depthwiseConstraint=Ah(e.depthwiseConstraint),this.depthwiseRegularizer=hd(e.depthwiseRegularizer)}build(e){if((e=Oc(e)).length<4)throw new il(`Inputs to DepthwiseConv2D should have rank 4. Received input shape: ${JSON.stringify(e)}.`);const t="channelsFirst"===this.dataFormat?1:3;if(null==e[t]||e[t]<0)throw new il(`The channel dimension of the inputs to DepthwiseConv2D should be defined, but is not (${e[t]}).`);const n=e[t],a=[this.kernelSize[0],this.kernelSize[1],n,this.depthMultiplier];this.depthwiseKernel=this.addWeight("depthwise_kernel",a,null,this.depthwiseInitializer,this.depthwiseRegularizer,!0,this.depthwiseConstraint),this.useBias?this.bias=this.addWeight("bias",[n*this.depthMultiplier],null,this.biasInitializer,this.biasRegularizer,!0,this.biasConstraint):this.bias=null,this.built=!0}call(e,t){return wn((()=>{let t=
4476
+ */function kd(e,t){return wn((()=>(Ll(t),"channelsFirst"===t?pa(e,[0,2,3,1]):e)))}function xd(e,t){return wn((()=>(Ll(t),"channelsFirst"===t?pa(e,[0,2,3,4,1]):e)))}function Sd(e,t,n,a=[1,1],i="valid",s,r,o=null){return wn((()=>{if(null==s&&(s="channelsLast"),Ll(s),3!==e.rank&&4!==e.rank)throw new il(`conv2dWithBiasActivation expects input to be of rank 3 or 4, but received ${e.rank}.`);if(3!==t.rank&&4!==t.rank)throw new il(`conv2dWithBiasActivation expects kernel to be of rank 3 or 4, but received ${e.rank}.`);let l=kd(e,s);if("causal"===i)throw new sl("The support for CAUSAL padding mode in conv1dWithBias is not implemented yet.");return l=Sr({x:l,filter:t,strides:a,pad:"same"===i?"same":"valid",dilations:r,dataFormat:"NHWC",bias:n,activation:o}),"channelsFirst"===s&&(l=pa(l,[0,3,1,2])),l}))}vd.className="Softmax",ka(vd);class Nd extends Zc{constructor(e,t){if(super(t),this.bias=null,this.DEFAULT_KERNEL_INITIALIZER="glorotNormal",this.DEFAULT_BIAS_INITIALIZER="zeros",Nd.verifyArgs(t),this.rank=e,Nl(this.rank,"rank"),1!==this.rank&&2!==this.rank&&3!==this.rank)throw new sl(`Convolution layer for rank other than 1, 2, or 3 (${this.rank}) is not implemented yet.`);if(this.kernelSize=yd(t.kernelSize,e,"kernelSize"),this.strides=yd(null==t.strides?1:t.strides,e,"strides"),this.padding=null==t.padding?"valid":t.padding,Ml(this.padding),this.dataFormat=null==t.dataFormat?"channelsLast":t.dataFormat,Ll(this.dataFormat),this.activation=sd(t.activation),this.useBias=null==t.useBias||t.useBias,this.biasInitializer=_c(t.biasInitializer||this.DEFAULT_BIAS_INITIALIZER),this.biasConstraint=Ah(t.biasConstraint),this.biasRegularizer=hd(t.biasRegularizer),this.activityRegularizer=hd(t.activityRegularizer),this.dilationRate=yd(null==t.dilationRate?1:t.dilationRate,e,"dilationRate"),1===this.rank&&Array.isArray(this.dilationRate)&&1!==this.dilationRate.length)throw new il(`dilationRate must be a number or an array of a single number for 1D convolution, but received ${JSON.stringify(this.dilationRate)}`);if(2===this.rank){if("number"==typeof this.dilationRate)this.dilationRate=[this.dilationRate,this.dilationRate];else if(2!==this.dilationRate.length)throw new il(`dilationRate must be a number or array of two numbers for 2D convolution, but received ${JSON.stringify(this.dilationRate)}`)}else if(3===this.rank)if("number"==typeof this.dilationRate)this.dilationRate=[this.dilationRate,this.dilationRate,this.dilationRate];else if(3!==this.dilationRate.length)throw new il(`dilationRate must be a number or array of three numbers for 3D convolution, but received ${JSON.stringify(this.dilationRate)}`)}static verifyArgs(e){if(cl("kernelSize"in e,"required key 'kernelSize' not in config"),"number"!=typeof e.kernelSize&&!Sl(e.kernelSize,"number",1,3))throw new il(`BaseConv expects config.kernelSize to be number or number[] with length 1, 2, or 3, but received ${JSON.stringify(e.kernelSize)}.`)}getConfig(){const e={kernelSize:this.kernelSize,strides:this.strides,padding:this.padding,dataFormat:this.dataFormat,dilationRate:this.dilationRate,activation:ad(this.activation),useBias:this.useBias,biasInitializer:Fc(this.biasInitializer),biasRegularizer:cd(this.biasRegularizer),activityRegularizer:cd(this.activityRegularizer),biasConstraint:Ch(this.biasConstraint)},t=super.getConfig();return Object.assign(e,t),e}}class Td extends Nd{constructor(e,t){super(e,t),this.kernel=null,Td.verifyArgs(t),this.filters=t.filters,Nl(this.filters,"filters"),this.kernelInitializer=_c(t.kernelInitializer||this.DEFAULT_KERNEL_INITIALIZER),this.kernelConstraint=Ah(t.kernelConstraint),this.kernelRegularizer=hd(t.kernelRegularizer)}build(e){e=Oc(e);const t="channelsFirst"===this.dataFormat?1:e.length-1;if(null==e[t])throw new il(`The channel dimension of the input should be defined. Found ${e[t]}`);const n=e[t],a=this.kernelSize.concat([n,this.filters]);this.kernel=this.addWeight("kernel",a,null,this.kernelInitializer,this.kernelRegularizer,!0,this.kernelConstraint),this.useBias&&(this.bias=this.addWeight("bias",[this.filters],null,this.biasInitializer,this.biasRegularizer,!0,this.biasConstraint)),this.inputSpec=[{ndim:this.rank+2,axes:{[t]:n}}],this.built=!0}call(e,t){return wn((()=>{let t;e=Mc(e);const n=null==this.bias?null:this.bias.read(),a=Il(this.activation.getClassName());if(null!=a&&2===this.rank)t=Sd(e,this.kernel.read(),n,this.strides,this.padding,this.dataFormat,this.dilationRate,a);else{if(1===this.rank)t=function(e,t,n,a=1,i="valid",s,r=1){return wn((()=>{if(null==s&&(s="channelsLast"),Ll(s),3!==e.shape.length)throw new il(`The input of a conv1dWithBias operation should be 3, but is ${e.shape.length} instead.`);if(3!==t.shape.length)throw new il(`The kernel for a conv1dWithBias operation should be 3, but is ${t.shape.length} instead`);if(null!=n&&1!==n.shape.length)throw new il(`The bias for a conv1dWithBias operation should be 1, but is ${n.shape.length} instead`);if("channelsFirst"===s&&(e=pa(e,[0,2,1])),"causal"===i)throw new sl("The support for CAUSAL padding mode in conv1dWithBias is not implemented yet.");let o=oi(e,t,a,"same"===i?"same":"valid","NWC",r);return null!=n&&(o=hc(o,n)),o}))}(e,this.kernel.read(),n,this.strides[0],this.padding,this.dataFormat,this.dilationRate[0]);else if(2===this.rank)t=Sd(e,this.kernel.read(),n,this.strides,this.padding,this.dataFormat,this.dilationRate);else{if(3!==this.rank)throw new sl("convolutions greater than 3D are not implemented yet.");t=function(e,t,n,a=[1,1,1],i="valid",s,r){return wn((()=>{if(null==s&&(s="channelsLast"),Ll(s),4!==e.rank&&5!==e.rank)throw new il(`conv3dWithBias expects input to be of rank 4 or 5, but received ${e.rank}.`);if(4!==t.rank&&5!==t.rank)throw new il(`conv3dWithBias expects kernel to be of rank 4 or 5, but received ${e.rank}.`);let o=xd(e,s);if("causal"===i)throw new sl("The support for CAUSAL padding mode in conv3dWithBias is not implemented yet.");return o=ui(o,t,a,"same"===i?"same":"valid","NDHWC",r),null!=n&&(o=hc(o,n)),"channelsFirst"===s&&(o=pa(o,[0,4,1,2,3])),o}))}(e,this.kernel.read(),n,this.strides,this.padding,this.dataFormat,this.dilationRate)}null!=this.activation&&(t=this.activation.apply(t))}return t}))}computeOutputShape(e){e=Oc(e);const t=[],n="channelsLast"===this.dataFormat?e.slice(1,e.length-1):e.slice(2);for(let e=0;e<n.length;++e){const a=bd(n[e],this.kernelSize[e],this.padding,this.strides[e],"number"==typeof this.dilationRate?this.dilationRate:this.dilationRate[e]);t.push(a)}let a=[e[0]];return"channelsLast"===this.dataFormat?(a=a.concat(t),a.push(this.filters)):(a.push(this.filters),a=a.concat(t)),a}getConfig(){const e={filters:this.filters,kernelInitializer:Fc(this.kernelInitializer),kernelRegularizer:cd(this.kernelRegularizer),kernelConstraint:Ch(this.kernelConstraint)},t=super.getConfig();return Object.assign(e,t),e}static verifyArgs(e){if(!("filters"in e)||"number"!=typeof e.filters||e.filters<1)throw new il(`Convolution layer expected config.filters to be a 'number' > 0 but got ${JSON.stringify(e.filters)}`)}}class Id extends Td{constructor(e){super(2,e),Id.verifyArgs(e)}getConfig(){const e=super.getConfig();return delete e.rank,e}static verifyArgs(e){if("number"!=typeof e.kernelSize&&!Sl(e.kernelSize,"number",1,2))throw new il(`Conv2D expects config.kernelSize to be number or number[] with length 1 or 2, but received ${JSON.stringify(e.kernelSize)}.`)}}Id.className="Conv2D",ka(Id);class Cd extends Td{constructor(e){super(3,e),Cd.verifyArgs(e)}getConfig(){const e=super.getConfig();return delete e.rank,e}static verifyArgs(e){if("number"!=typeof e.kernelSize&&(!Array.isArray(e.kernelSize)||1!==e.kernelSize.length&&3!==e.kernelSize.length))throw new il(`Conv3D expects config.kernelSize to be number or [number, number, number], but received ${JSON.stringify(e.kernelSize)}.`)}}Cd.className="Conv3D",ka(Cd);class $d extends Id{constructor(e){if(super(e),this.inputSpec=[new Vc({ndim:4})],"same"!==this.padding&&"valid"!==this.padding)throw new il(`Conv2DTranspose currently supports only padding modes 'same' and 'valid', but received padding mode ${this.padding}`)}build(e){if(4!==(e=Oc(e)).length)throw new il("Input should have rank 4; Received input shape: "+JSON.stringify(e));const t="channelsFirst"===this.dataFormat?1:e.length-1;if(null==e[t])throw new il("The channel dimension of the inputs should be defined. Found `None`.");const n=e[t],a=this.kernelSize.concat([this.filters,n]);this.kernel=this.addWeight("kernel",a,"float32",this.kernelInitializer,this.kernelRegularizer,!0,this.kernelConstraint),this.useBias&&(this.bias=this.addWeight("bias",[this.filters],"float32",this.biasInitializer,this.biasRegularizer,!0,this.biasConstraint)),this.inputSpec=[new Vc({ndim:4,axes:{[t]:n}})],this.built=!0}call(e,t){return wn((()=>{let t=Mc(e);if(4!==t.shape.length)throw new il(`Conv2DTranspose.call() expects input tensor to be rank-4, but received a tensor of rank-${t.shape.length}`);const n=t.shape,a=n[0];let i,s;"channelsFirst"===this.dataFormat?(i=2,s=3):(i=1,s=2);const r=n[i],o=n[s],l=this.kernelSize[0],c=this.kernelSize[1],u=this.strides[0],h=this.strides[1],p=[a,wd(r,u,l,this.padding),wd(o,h,c,this.padding),this.filters];"channelsLast"!==this.dataFormat&&(t=pa(t,[0,2,3,1]));let d=ci(t,this.kernel.read(),p,this.strides,this.padding);return"channelsLast"!==this.dataFormat&&(d=pa(d,[0,3,1,2])),null!=this.bias&&(d=hc(d,this.bias.read(),this.dataFormat)),null!=this.activation&&(d=this.activation.apply(d)),d}))}computeOutputShape(e){const t=(e=Oc(e)).slice();let n,a,i;"channelsFirst"===this.dataFormat?(n=1,a=2,i=3):(n=3,a=1,i=2);const s=this.kernelSize[0],r=this.kernelSize[1],o=this.strides[0],l=this.strides[1];return t[n]=this.filters,t[a]=wd(t[a],o,s,this.padding),t[i]=wd(t[i],l,r,this.padding),t}getConfig(){const e=super.getConfig();return delete e.dilationRate,e}}$d.className="Conv2DTranspose",ka($d);class Ad extends Cd{constructor(e){if(super(e),this.inputSpec=[new Vc({ndim:5})],"same"!==this.padding&&"valid"!==this.padding)throw new il(`Conv3DTranspose currently supports only padding modes 'same' and 'valid', but received padding mode ${this.padding}`)}build(e){if(5!==(e=Oc(e)).length)throw new il("Input should have rank 5; Received input shape: "+JSON.stringify(e));const t="channelsFirst"===this.dataFormat?1:e.length-1;if(null==e[t])throw new il("The channel dimension of the inputs should be defined. Found `None`.");const n=e[t],a=this.kernelSize.concat([this.filters,n]);this.kernel=this.addWeight("kernel",a,"float32",this.kernelInitializer,this.kernelRegularizer,!0,this.kernelConstraint),this.useBias&&(this.bias=this.addWeight("bias",[this.filters],"float32",this.biasInitializer,this.biasRegularizer,!0,this.biasConstraint)),this.inputSpec=[new Vc({ndim:5,axes:{[t]:n}})],this.built=!0}call(e,t){return wn((()=>{let t=Mc(e);if(5!==t.shape.length)throw new il(`Conv3DTranspose.call() expects input tensor to be rank-4, but received a tensor of rank-${t.shape.length}`);const n=t.shape,a=n[0];let i,s,r;"channelsFirst"===this.dataFormat?(r=2,i=3,s=4):(r=1,i=2,s=3);const o=n[r],l=n[i],c=n[s],u=this.kernelSize[0],h=this.kernelSize[1],p=this.kernelSize[2],d=this.strides[0],f=this.strides[1],m=this.strides[2],g=[a,wd(o,d,u,this.padding),wd(l,f,h,this.padding),wd(c,m,p,this.padding),this.filters];"channelsLast"!==this.dataFormat&&(t=pa(t,[0,2,3,4,1]));let v=pi(t,this.kernel.read(),g,this.strides,this.padding);return"channelsLast"!==this.dataFormat&&(v=pa(v,[0,4,1,2,3])),null!==this.bias&&(v=hc(v,this.bias.read(),this.dataFormat)),null!==this.activation&&(v=this.activation.apply(v)),v}))}computeOutputShape(e){const t=(e=Oc(e)).slice();let n,a,i,s;"channelsFirst"===this.dataFormat?(n=1,a=2,i=3,s=4):(n=4,a=1,i=2,s=3);const r=this.kernelSize[0],o=this.kernelSize[1],l=this.kernelSize[2],c=this.strides[0],u=this.strides[1],h=this.strides[2];return t[n]=this.filters,t[a]=wd(t[a],c,r,this.padding),t[i]=wd(t[i],u,o,this.padding),t[s]=wd(t[s],h,l,this.padding),t}getConfig(){const e=super.getConfig();return delete e.dilationRate,e}}Ad.className="Conv3DTranspose",ka(Ad);class Ed extends Td{constructor(e,t){if(super(e,t),this.DEFAULT_DEPTHWISE_INITIALIZER="glorotUniform",this.DEFAULT_POINTWISE_INITIALIZER="glorotUniform",this.depthwiseKernel=null,this.pointwiseKernel=null,null==t.filters)throw new il("The `filters` configuration field is required by SeparableConv, but is unspecified.");if(null!=t.kernelInitializer||null!=t.kernelRegularizer||null!=t.kernelConstraint)throw new il("Fields kernelInitializer, kernelRegularizer and kernelConstraint are invalid for SeparableConv2D. Use depthwiseInitializer, depthwiseRegularizer, depthwiseConstraint, pointwiseInitializer, pointwiseRegularizer and pointwiseConstraint instead.");if(null!=t.padding&&"same"!==t.padding&&"valid"!==t.padding)throw new il(`SeparableConv${this.rank}D supports only padding modes: 'same' and 'valid', but received ${JSON.stringify(t.padding)}`);this.depthMultiplier=null==t.depthMultiplier?1:t.depthMultiplier,this.depthwiseInitializer=_c(t.depthwiseInitializer||this.DEFAULT_DEPTHWISE_INITIALIZER),this.depthwiseRegularizer=hd(t.depthwiseRegularizer),this.depthwiseConstraint=Ah(t.depthwiseConstraint),this.pointwiseInitializer=_c(t.depthwiseInitializer||this.DEFAULT_POINTWISE_INITIALIZER),this.pointwiseRegularizer=hd(t.pointwiseRegularizer),this.pointwiseConstraint=Ah(t.pointwiseConstraint)}build(e){if((e=Oc(e)).length<this.rank+2)throw new il(`Inputs to SeparableConv${this.rank}D should have rank ${this.rank+2}, but received input shape: ${JSON.stringify(e)}`);const t="channelsFirst"===this.dataFormat?1:e.length-1;if(null==e[t]||e[t]<0)throw new il(`The channel dimension of the inputs should be defined, but found ${JSON.stringify(e[t])}`);const n=e[t],a=this.kernelSize.concat([n,this.depthMultiplier]),i=[];for(let e=0;e<this.rank;++e)i.push(1);i.push(n*this.depthMultiplier,this.filters);const s=!0;this.depthwiseKernel=this.addWeight("depthwise_kernel",a,"float32",this.depthwiseInitializer,this.depthwiseRegularizer,s,this.depthwiseConstraint),this.pointwiseKernel=this.addWeight("pointwise_kernel",i,"float32",this.pointwiseInitializer,this.pointwiseRegularizer,s,this.pointwiseConstraint),this.useBias?this.bias=this.addWeight("bias",[this.filters],"float32",this.biasInitializer,this.biasRegularizer,s,this.biasConstraint):this.bias=null,this.inputSpec=[new Vc({ndim:this.rank+2,axes:{[t]:n}})],this.built=!0}call(e,t){return wn((()=>{let t;if(e=Mc(e),1===this.rank)throw new sl("1D separable convolution is not implemented yet.");return 2===this.rank&&("channelsFirst"===this.dataFormat&&(e=pa(e,[0,2,3,1])),t=er(e,this.depthwiseKernel.read(),this.pointwiseKernel.read(),this.strides,this.padding,this.dilationRate,"NHWC")),this.useBias&&(t=hc(t,this.bias.read(),this.dataFormat)),null!=this.activation&&(t=this.activation.apply(t)),"channelsFirst"===this.dataFormat&&(t=pa(t,[0,3,1,2])),t}))}getConfig(){const e=super.getConfig();return delete e.rank,delete e.kernelInitializer,delete e.kernelRegularizer,delete e.kernelConstraint,e.depthwiseInitializer=Fc(this.depthwiseInitializer),e.pointwiseInitializer=Fc(this.pointwiseInitializer),e.depthwiseRegularizer=cd(this.depthwiseRegularizer),e.pointwiseRegularizer=cd(this.pointwiseRegularizer),e.depthwiseConstraint=Ch(this.depthwiseConstraint),e.pointwiseConstraint=Ch(this.pointwiseConstraint),e}}Ed.className="SeparableConv";class jd extends Ed{constructor(e){super(2,e)}}jd.className="SeparableConv2D",ka(jd);class zd extends Td{constructor(e){super(1,e),zd.verifyArgs(e),this.inputSpec=[{ndim:3}]}getConfig(){const e=super.getConfig();return delete e.rank,delete e.dataFormat,e}static verifyArgs(e){if("number"!=typeof e.kernelSize&&!Sl(e.kernelSize,"number",1,1))throw new il(`Conv1D expects config.kernelSize to be number or number[] with length 1, but received ${JSON.stringify(e.kernelSize)}.`)}}zd.className="Conv1D",ka(zd);class Dd extends Zc{constructor(e){super(e),"number"==typeof e.cropping?this.cropping=[[e.cropping,e.cropping],[e.cropping,e.cropping]]:"number"==typeof e.cropping[0]?this.cropping=[[e.cropping[0],e.cropping[0]],[e.cropping[1],e.cropping[1]]]:this.cropping=e.cropping,this.dataFormat=void 0===e.dataFormat?"channelsLast":e.dataFormat,this.inputSpec=[{ndim:4}]}computeOutputShape(e){return"channelsFirst"===this.dataFormat?[e[0],e[1],e[2]-this.cropping[0][0]-this.cropping[0][1],e[3]-this.cropping[1][0]-this.cropping[1][1]]:[e[0],e[1]-this.cropping[0][0]-this.cropping[0][1],e[2]-this.cropping[1][0]-this.cropping[1][1],e[3]]}call(e,t){return wn((()=>{if(e=Mc(e),"channelsLast"===this.dataFormat){const t=nc(e,this.cropping[0][0],e.shape[1]-this.cropping[0][0]-this.cropping[0][1],2);return nc(t,this.cropping[1][0],e.shape[2]-this.cropping[1][1]-this.cropping[1][0],3)}{const t=nc(e,this.cropping[0][0],e.shape[2]-this.cropping[0][0]-this.cropping[0][1],3);return nc(t,this.cropping[1][0],e.shape[3]-this.cropping[1][1]-this.cropping[1][0],4)}}))}getConfig(){const e={cropping:this.cropping,dataFormat:this.dataFormat},t=super.getConfig();return Object.assign(e,t),e}}Dd.className="Cropping2D",ka(Dd);class Fd extends Zc{constructor(e){var t;super(e),this.DEFAULT_SIZE=[2,2],this.inputSpec=[{ndim:4}],this.size=null==e.size?this.DEFAULT_SIZE:e.size,this.dataFormat=null==e.dataFormat?"channelsLast":e.dataFormat,Ll(this.dataFormat),this.interpolation=null==e.interpolation?"nearest":e.interpolation,t=this.interpolation,xl(zl,"InterpolationFormat",t)}computeOutputShape(e){if("channelsFirst"===this.dataFormat){const t=null==e[2]?null:this.size[0]*e[2],n=null==e[3]?null:this.size[1]*e[3];return[e[0],e[1],t,n]}{const t=null==e[1]?null:this.size[0]*e[1],n=null==e[2]?null:this.size[1]*e[2];return[e[0],t,n,e[3]]}}call(e,t){return wn((()=>{let t=Mc(e);const n=t.shape;if("channelsFirst"===this.dataFormat){t=pa(t,[0,2,3,1]);const e=this.size[0]*n[2],a=this.size[1]*n[3],i="nearest"===this.interpolation?Zr.resizeNearestNeighbor(t,[e,a]):Zr.resizeBilinear(t,[e,a]);return pa(i,[0,3,1,2])}{const e=this.size[0]*n[1],a=this.size[1]*n[2];return"nearest"===this.interpolation?Zr.resizeNearestNeighbor(t,[e,a]):Zr.resizeBilinear(t,[e,a])}}))}getConfig(){const e={size:this.size,dataFormat:this.dataFormat,interpolation:this.interpolation},t=super.getConfig();return Object.assign(e,t),e}}Fd.className="UpSampling2D",ka(Fd);class _d extends Nd{constructor(e){super(2,e),this.depthwiseKernel=null,this.depthMultiplier=null==e.depthMultiplier?1:e.depthMultiplier,this.depthwiseInitializer=_c(e.depthwiseInitializer||this.DEFAULT_KERNEL_INITIALIZER),this.depthwiseConstraint=Ah(e.depthwiseConstraint),this.depthwiseRegularizer=hd(e.depthwiseRegularizer)}build(e){if((e=Oc(e)).length<4)throw new il(`Inputs to DepthwiseConv2D should have rank 4. Received input shape: ${JSON.stringify(e)}.`);const t="channelsFirst"===this.dataFormat?1:3;if(null==e[t]||e[t]<0)throw new il(`The channel dimension of the inputs to DepthwiseConv2D should be defined, but is not (${e[t]}).`);const n=e[t],a=[this.kernelSize[0],this.kernelSize[1],n,this.depthMultiplier];this.depthwiseKernel=this.addWeight("depthwise_kernel",a,null,this.depthwiseInitializer,this.depthwiseRegularizer,!0,this.depthwiseConstraint),this.useBias?this.bias=this.addWeight("bias",[n*this.depthMultiplier],null,this.biasInitializer,this.biasRegularizer,!0,this.biasConstraint):this.bias=null,this.built=!0}call(e,t){return wn((()=>{let t=
4477
4477
  /**
4478
4478
  * @license
4479
4479
  * Copyright 2018 Google LLC
@@ -4483,7 +4483,7 @@ function yd(e,t,n){if("number"==typeof e)return ll(e,t);if(e.length!==t)throw ne
4483
4483
  * https://opensource.org/licenses/MIT.
4484
4484
  * =============================================================================
4485
4485
  */
4486
- function(e,t,n=[1,1],a="valid",i,s){return wn((()=>{null==i&&(i="channelsLast"),Ll(i);let r=kd(e,i);if(4!==e.rank)throw new il(`Input for depthwiseConv2d is required to be 4-D, but is instead ${e.rank}-D`);if(4!==t.rank)throw new il(`depthwiseKernel is required to be 4-D, but is instead ${t.rank}-D`);return r=yi(r,t,n,"same"===a?"same":"valid","NHWC",s),"channelsFirst"===i&&(r=pa(r,[0,3,1,2])),r}))}(e=Mc(e),this.depthwiseKernel.read(),this.strides,this.padding,this.dataFormat,null);return this.useBias&&(t=hc(t,this.bias.read(),this.dataFormat)),null!=this.activation&&(t=this.activation.apply(t)),t}))}computeOutputShape(e){e=Oc(e);const t="channelsFirst"===this.dataFormat?e[2]:e[1],n="channelsFirst"===this.dataFormat?e[3]:e[2],a="channelsFirst"===this.dataFormat?e[1]*this.depthMultiplier:e[3]*this.depthMultiplier,i=bd(t,this.kernelSize[0],this.padding,this.strides[0]),s=bd(n,this.kernelSize[1],this.padding,this.strides[1]);return"channelsFirst"===this.dataFormat?[e[0],a,i,s]:[e[0],i,s,a]}getConfig(){const e=super.getConfig();return e.depthMultiplier=this.depthMultiplier,e.depthwiseInitializer=Fc(this.depthwiseInitializer),e.depthwiseRegularizer=cd(this.depthwiseRegularizer),e.depthwiseConstraint=$h(this.depthwiseRegularizer),e}}
4486
+ function(e,t,n=[1,1],a="valid",i,s){return wn((()=>{null==i&&(i="channelsLast"),Ll(i);let r=kd(e,i);if(4!==e.rank)throw new il(`Input for depthwiseConv2d is required to be 4-D, but is instead ${e.rank}-D`);if(4!==t.rank)throw new il(`depthwiseKernel is required to be 4-D, but is instead ${t.rank}-D`);return r=yi(r,t,n,"same"===a?"same":"valid","NHWC",s),"channelsFirst"===i&&(r=pa(r,[0,3,1,2])),r}))}(e=Mc(e),this.depthwiseKernel.read(),this.strides,this.padding,this.dataFormat,null);return this.useBias&&(t=hc(t,this.bias.read(),this.dataFormat)),null!=this.activation&&(t=this.activation.apply(t)),t}))}computeOutputShape(e){e=Oc(e);const t="channelsFirst"===this.dataFormat?e[2]:e[1],n="channelsFirst"===this.dataFormat?e[3]:e[2],a="channelsFirst"===this.dataFormat?e[1]*this.depthMultiplier:e[3]*this.depthMultiplier,i=bd(t,this.kernelSize[0],this.padding,this.strides[0]),s=bd(n,this.kernelSize[1],this.padding,this.strides[1]);return"channelsFirst"===this.dataFormat?[e[0],a,i,s]:[e[0],i,s,a]}getConfig(){const e=super.getConfig();return e.depthMultiplier=this.depthMultiplier,e.depthwiseInitializer=Fc(this.depthwiseInitializer),e.depthwiseRegularizer=cd(this.depthwiseRegularizer),e.depthwiseConstraint=Ch(this.depthwiseRegularizer),e}}
4487
4487
  /**
4488
4488
  * @license
4489
4489
  * Copyright 2018 Google LLC
@@ -4493,7 +4493,7 @@ function(e,t,n=[1,1],a="valid",i,s){return wn((()=>{null==i&&(i="channelsLast"),
4493
4493
  * https://opensource.org/licenses/MIT.
4494
4494
  * =============================================================================
4495
4495
  */
4496
- function Rd(e,t,n,a){if(Array.isArray(e)){if(null!=t||null!=n)throw new il("When inputs is an array, neither initialState or constants should be provided");null!=a&&(n=e.slice(e.length-a,e.length),e=e.slice(0,e.length-a)),e.length>1&&(t=e.slice(1,e.length)),e=e[0]}function i(e){return null==e||Array.isArray(e)?e:[e]}return{inputs:e,initialState:t=i(t),constants:n=i(n)}}function Ld(e,t,n,a=!1,i,s,r=!1,o=!1){return wn((()=>{const s=t.shape.length;if(s<3)throw new il(`Input should be at least 3D, but is ${s}D.`);const l=[1,0].concat(Jl(2,s));t=pa(t,l),r&&console.warn("Backend rnn(): the unroll = true option is not applicable to the imperative deeplearn.js backend."),null!=i&&((i=ra(ra(i,"bool"),"float32")).rank===s-1&&(i=Pi(i,-1)),i=pa(i,l)),a&&(t=Zs(t,0),null!=i&&(i=Zs(i,0)));const c=[];let u,h=n;const p=t.shape[0],d=gr(t);let f,m;null!=i&&(f=gr(i));for(let t=0;t<p;++t){const n=d[t],a=wn((()=>e(n,h)));if(null==i)u=a[0],h=a[1];else{const e=wn((()=>{const e=f[t],n=es(fs(e),e);return{output:xa(Ta(a[0],e),Ta(h[0],n)),newStates:h.map(((t,i)=>xa(Ta(a[1][i],e),Ta(t,n))))}}));u=e.output,h=e.newStates}o&&c.push(u)}if(o){m=ur(c,1)}return[u,m,h]}))}_d.className="DepthwiseConv2D",ka(_d);class Md extends Zc{constructor(e){let t;if(super(e),null==e.cell)throw new il("cell property is missing for the constructor of RNN.");if(t=Array.isArray(e.cell)?new Kd({cells:e.cell}):e.cell,null==t.stateSize)throw new il("The RNN cell should have an attribute `stateSize` (tuple of integers, one integer per RNN state).");this.cell=t,this.returnSequences=null!=e.returnSequences&&e.returnSequences,this.returnState=null!=e.returnState&&e.returnState,this.goBackwards=null!=e.goBackwards&&e.goBackwards,this._stateful=null!=e.stateful&&e.stateful,this.unroll=null!=e.unroll&&e.unroll,this.supportsMasking=!0,this.inputSpec=[new Vc({ndim:3})],this.stateSpec=null,this.states_=null,this.numConstants=null,this.keptStates=[]}getStates(){if(null==this.states_){return Jl(0,Array.isArray(this.cell.stateSize)?this.cell.stateSize.length:1).map((e=>null))}return this.states_}setStates(e){this.states_=e}computeOutputShape(e){Rc(e)&&(e=e[0]);let t=this.cell.stateSize;Array.isArray(t)||(t=[t]);const n=t[0];let a;if(a=this.returnSequences?[e[0],e[1],n]:[e[0],n],this.returnState){const n=[];for(const a of t)n.push([e[0],a]);return[a].concat(n)}return a}computeMask(e,t){return wn((()=>{Array.isArray(t)&&(t=t[0]);const e=this.returnSequences?t:null;if(this.returnState){const t=this.states.map((e=>null));return[e].concat(t)}return e}))}get states(){if(null==this.states_){const e=Array.isArray(this.cell.stateSize)?this.cell.stateSize.length:1,t=[];for(let n=0;n<e;++n)t.push(null);return t}return this.states_}set states(e){this.states_=e}build(e){if(null!=this.numConstants)throw new sl("Constants support is not implemented in RNN yet.");Rc(e)&&(e=e[0]);const t=this.stateful?e[0]:null,n=e.slice(2);this.inputSpec[0]=new Vc({shape:[t,null,...n]});const a=[e[0]].concat(e.slice(2));let i;if(this.cell.build(a),i=Array.isArray(this.cell.stateSize)?this.cell.stateSize:[this.cell.stateSize],null!=this.stateSpec){if(!T(this.stateSpec.map((e=>e.shape[e.shape.length-1])),i))throw new il(`An initialState was passed that is not compatible with cell.stateSize. Received stateSpec=${this.stateSpec}; However cell.stateSize is ${this.cell.stateSize}`)}else this.stateSpec=i.map((e=>new Vc({shape:[null,e]})));this.stateful&&this.resetStates()}resetStates(e,t=!1){wn((()=>{if(!this.stateful)throw new nl("Cannot call resetStates() on an RNN Layer that is not stateful.");const n=this.inputSpec[0].shape[0];if(null==n)throw new il("If an RNN is stateful, it needs to know its batch size. Specify the batch size of your input tensors: \n- If using a Sequential model, specify the batch size by passing a `batchInputShape` option to your first layer.\n- If using the functional API, specify the batch size by passing a `batchShape` option to your Input layer.");if(null==this.states_)Array.isArray(this.cell.stateSize)?this.states_=this.cell.stateSize.map((e=>cs([n,e]))):this.states_=[cs([n,this.cell.stateSize])];else if(null==e)kn(this.states_),null!=this.keptStates&&(kn(this.keptStates),this.keptStates=[]),Array.isArray(this.cell.stateSize)?this.states_=this.cell.stateSize.map((e=>cs([n,e]))):this.states_[0]=cs([n,this.cell.stateSize]);else{if(Array.isArray(e)||(e=[e]),e.length!==this.states_.length)throw new il(`Layer ${this.name} expects ${this.states_.length} state(s), but it received ${e.length} state value(s). Input received: ${e}`);!0===t?this.keptStates.push(this.states_.slice()):kn(this.states_);for(let t=0;t<this.states_.length;++t){const a=e[t],i=Array.isArray(this.cell.stateSize)?this.cell.stateSize[t]:this.cell.stateSize,s=[n,i];if(!T(a.shape,s))throw new il(`State ${t} is incompatible with layer ${this.name}: expected shape=${s}, received shape=${a.shape}`);this.states_[t]=a}}this.states_=this.states_.map((e=>xn(e.clone())))}))}apply(e,t){let n=null==t?null:t.initialState,a=null==t?null:t.constants;null==t&&(t={});const i=Rd(e,n,a,this.numConstants);e=i.inputs,n=i.initialState,a=i.constants;let s=[],r=[];if(null!=n){t.initialState=n,s=s.concat(n),this.stateSpec=[];for(const e of n)this.stateSpec.push(new Vc({shape:e.shape}));r=r.concat(this.stateSpec)}null!=a&&(t.constants=a,s=s.concat(a),this.numConstants=a.length);if(s[0]instanceof Kc){const n=[e].concat(s),a=this.inputSpec.concat(r),i=this.inputSpec;this.inputSpec=a;const o=super.apply(n,t);return this.inputSpec=i,o}return super.apply(e,t)}call(e,t){return wn((()=>{const n=null==t?null:t.mask,a=null==t?null:t.training;let i=null==t?null:t.initialState;e=Mc(e),null==i&&(i=this.stateful?this.states_:this.getInitialState(e));const s=Array.isArray(this.cell.stateSize)?this.cell.stateSize.length:1;if(i.length!==s)throw new il(`RNN Layer has ${s} state(s) but was passed ${i.length} initial state(s).`);this.unroll&&console.warn("Ignoring unroll = true for RNN layer, due to imperative backend.");const r={training:a},o=Ld(((e,t)=>{const n=this.cell.call([e].concat(t),r);return[n[0],n.slice(1)]}),e,i,this.goBackwards,n,0,this.unroll,this.returnSequences),l=o[0],c=o[1],u=o[2];this.stateful&&this.resetStates(u,a);const h=this.returnSequences?c:l;return this.returnState?[h].concat(u):h}))}getInitialState(e){return wn((()=>{let t=cs(e.shape);return t=Ri(t,[1,2]),t=Xl(t),Array.isArray(this.cell.stateSize)?this.cell.stateSize.map((e=>e>1?sc(t,[1,e]):t)):this.cell.stateSize>1?[sc(t,[1,this.cell.stateSize])]:[t]}))}get trainableWeights(){return this.trainable?this.cell.trainableWeights:[]}get nonTrainableWeights(){return this.trainable?this.cell.nonTrainableWeights:this.cell.weights}setFastWeightInitDuringBuild(e){super.setFastWeightInitDuringBuild(e),null!=this.cell&&this.cell.setFastWeightInitDuringBuild(e)}getConfig(){const e=super.getConfig(),t={returnSequences:this.returnSequences,returnState:this.returnState,goBackwards:this.goBackwards,stateful:this.stateful,unroll:this.unroll};null!=this.numConstants&&(t.numConstants=this.numConstants);const n=this.cell.getConfig();return this.getClassName()===Md.className&&(t.cell={className:this.cell.getClassName(),config:n}),Object.assign(Object.assign(Object.assign({},n),e),t)}static fromConfig(e,t,n={}){const a=Bh(t.cell,n);return new e(Object.assign(t,{cell:a}))}}Md.className="RNN",ka(Md);class Od extends Zc{}class Pd extends Od{constructor(e){super(e),this.DEFAULT_ACTIVATION="tanh",this.DEFAULT_KERNEL_INITIALIZER="glorotNormal",this.DEFAULT_RECURRENT_INITIALIZER="orthogonal",this.DEFAULT_BIAS_INITIALIZER="zeros",this.units=e.units,Nl(this.units,"units"),this.activation=sd(null==e.activation?this.DEFAULT_ACTIVATION:e.activation),this.useBias=null==e.useBias||e.useBias,this.kernelInitializer=_c(e.kernelInitializer||this.DEFAULT_KERNEL_INITIALIZER),this.recurrentInitializer=_c(e.recurrentInitializer||this.DEFAULT_RECURRENT_INITIALIZER),this.biasInitializer=_c(e.biasInitializer||this.DEFAULT_BIAS_INITIALIZER),this.kernelRegularizer=hd(e.kernelRegularizer),this.recurrentRegularizer=hd(e.recurrentRegularizer),this.biasRegularizer=hd(e.biasRegularizer),this.kernelConstraint=Ah(e.kernelConstraint),this.recurrentConstraint=Ah(e.recurrentConstraint),this.biasConstraint=Ah(e.biasConstraint),this.dropout=ql([1,Hl([0,null==e.dropout?0:e.dropout])]),this.recurrentDropout=ql([1,Hl([0,null==e.recurrentDropout?0:e.recurrentDropout])]),this.dropoutFunc=e.dropoutFunc,this.stateSize=this.units,this.dropoutMask=null,this.recurrentDropoutMask=null}build(e){e=Oc(e),this.kernel=this.addWeight("kernel",[e[e.length-1],this.units],null,this.kernelInitializer,this.kernelRegularizer,!0,this.kernelConstraint),this.recurrentKernel=this.addWeight("recurrent_kernel",[this.units,this.units],null,this.recurrentInitializer,this.recurrentRegularizer,!0,this.recurrentConstraint),this.useBias?this.bias=this.addWeight("bias",[this.units],null,this.biasInitializer,this.biasRegularizer,!0,this.biasConstraint):this.bias=null,this.built=!0}call(e,t){return wn((()=>{if(2!==e.length)throw new il(`SimpleRNNCell expects 2 input Tensors, got ${e.length}.`);let n=e[1];e=e[0];const a=null!=t.training&&t.training;let i;0<this.dropout&&this.dropout<1&&null==this.dropoutMask&&(this.dropoutMask=qd({ones:()=>fs(e),rate:this.dropout,training:a,dropoutFunc:this.dropoutFunc})),0<this.recurrentDropout&&this.recurrentDropout<1&&null==this.recurrentDropoutMask&&(this.recurrentDropoutMask=qd({ones:()=>fs(n),rate:this.recurrentDropout,training:a,dropoutFunc:this.dropoutFunc}));const s=this.dropoutMask,r=this.recurrentDropoutMask;i=oc(null!=s?Ta(e,s):e,this.kernel.read()),null!=this.bias&&(i=hc(i,this.bias.read())),null!=r&&(n=Ta(n,r));let o=xa(i,oc(n,this.recurrentKernel.read()));return null!=this.activation&&(o=this.activation.apply(o)),[o,o]}))}getConfig(){const e=super.getConfig(),t={units:this.units,activation:ad(this.activation),useBias:this.useBias,kernelInitializer:Fc(this.kernelInitializer),recurrentInitializer:Fc(this.recurrentInitializer),biasInitializer:Fc(this.biasInitializer),kernelRegularizer:cd(this.kernelRegularizer),recurrentRegularizer:cd(this.recurrentRegularizer),biasRegularizer:cd(this.biasRegularizer),activityRegularizer:cd(this.activityRegularizer),kernelConstraint:$h(this.kernelConstraint),recurrentConstraint:$h(this.recurrentConstraint),biasConstraint:$h(this.biasConstraint),dropout:this.dropout,recurrentDropout:this.recurrentDropout};return Object.assign(Object.assign({},e),t)}}Pd.className="SimpleRNNCell",ka(Pd);class Bd extends Md{constructor(e){e.cell=new Pd(e),super(e)}call(e,t){return wn((()=>{null!=this.cell.dropoutMask&&(kn(this.cell.dropoutMask),this.cell.dropoutMask=null),null!=this.cell.recurrentDropoutMask&&(kn(this.cell.recurrentDropoutMask),this.cell.recurrentDropoutMask=null);const n=null==t?null:t.mask,a=null==t?null:t.training,i=null==t?null:t.initialState;return super.call(e,{mask:n,training:a,initialState:i})}))}static fromConfig(e,t){return new e(t)}}Bd.className="SimpleRNN",ka(Bd);class Ud extends Od{constructor(e){if(super(e),this.DEFAULT_ACTIVATION="tanh",this.DEFAULT_RECURRENT_ACTIVATION="hardSigmoid",this.DEFAULT_KERNEL_INITIALIZER="glorotNormal",this.DEFAULT_RECURRENT_INITIALIZER="orthogonal",this.DEFAULT_BIAS_INITIALIZER="zeros",e.resetAfter)throw new il("GRUCell does not support reset_after parameter set to true.");this.units=e.units,Nl(this.units,"units"),this.activation=sd(void 0===e.activation?this.DEFAULT_ACTIVATION:e.activation),this.recurrentActivation=sd(void 0===e.recurrentActivation?this.DEFAULT_RECURRENT_ACTIVATION:e.recurrentActivation),this.useBias=null==e.useBias||e.useBias,this.kernelInitializer=_c(e.kernelInitializer||this.DEFAULT_KERNEL_INITIALIZER),this.recurrentInitializer=_c(e.recurrentInitializer||this.DEFAULT_RECURRENT_INITIALIZER),this.biasInitializer=_c(e.biasInitializer||this.DEFAULT_BIAS_INITIALIZER),this.kernelRegularizer=hd(e.kernelRegularizer),this.recurrentRegularizer=hd(e.recurrentRegularizer),this.biasRegularizer=hd(e.biasRegularizer),this.kernelConstraint=Ah(e.kernelConstraint),this.recurrentConstraint=Ah(e.recurrentConstraint),this.biasConstraint=Ah(e.biasConstraint),this.dropout=ql([1,Hl([0,null==e.dropout?0:e.dropout])]),this.recurrentDropout=ql([1,Hl([0,null==e.recurrentDropout?0:e.recurrentDropout])]),this.dropoutFunc=e.dropoutFunc,this.implementation=e.implementation,this.stateSize=this.units,this.dropoutMask=null,this.recurrentDropoutMask=null}build(e){const t=(e=Oc(e))[e.length-1];this.kernel=this.addWeight("kernel",[t,3*this.units],null,this.kernelInitializer,this.kernelRegularizer,!0,this.kernelConstraint),this.recurrentKernel=this.addWeight("recurrent_kernel",[this.units,3*this.units],null,this.recurrentInitializer,this.recurrentRegularizer,!0,this.recurrentConstraint),this.useBias?this.bias=this.addWeight("bias",[3*this.units],null,this.biasInitializer,this.biasRegularizer,!0,this.biasConstraint):this.bias=null,this.built=!0}call(e,t){return wn((()=>{if(2!==e.length)throw new il(`GRUCell expects 2 input Tensors (inputs, h, c), got ${e.length}.`);const n=null!=t.training&&t.training;let a=e[1];e=e[0],0<this.dropout&&this.dropout<1&&null==this.dropoutMask&&(this.dropoutMask=qd({ones:()=>fs(e),rate:this.dropout,training:n,count:3,dropoutFunc:this.dropoutFunc})),0<this.recurrentDropout&&this.recurrentDropout<1&&null==this.recurrentDropoutMask&&(this.recurrentDropoutMask=qd({ones:()=>fs(a),rate:this.recurrentDropout,training:n,count:3,dropoutFunc:this.dropoutFunc}));const i=this.dropoutMask,s=this.recurrentDropoutMask;let r,o,l;0<this.dropout&&this.dropout<1&&(e=Ta(e,i[0]));let c=oc(e,this.kernel.read());this.useBias&&(c=hc(c,this.bias.read())),0<this.recurrentDropout&&this.recurrentDropout<1&&(a=Ta(a,s[0]));const u=this.recurrentKernel.read(),[h,p]=lr(u,[2*this.units,this.units],u.rank-1),d=oc(a,h),[f,m,g]=lr(c,3,c.rank-1),[v,y]=lr(d,2,d.rank-1);r=this.recurrentActivation.apply(xa(f,v)),o=this.recurrentActivation.apply(xa(m,y));const b=oc(Ta(o,a),p);l=this.activation.apply(xa(g,b));const w=xa(Ta(r,a),Ta(xa(1,ua(r)),l));return[w,w]}))}getConfig(){const e=super.getConfig(),t={units:this.units,activation:ad(this.activation),recurrentActivation:ad(this.recurrentActivation),useBias:this.useBias,kernelInitializer:Fc(this.kernelInitializer),recurrentInitializer:Fc(this.recurrentInitializer),biasInitializer:Fc(this.biasInitializer),kernelRegularizer:cd(this.kernelRegularizer),recurrentRegularizer:cd(this.recurrentRegularizer),biasRegularizer:cd(this.biasRegularizer),activityRegularizer:cd(this.activityRegularizer),kernelConstraint:$h(this.kernelConstraint),recurrentConstraint:$h(this.recurrentConstraint),biasConstraint:$h(this.biasConstraint),dropout:this.dropout,recurrentDropout:this.recurrentDropout,implementation:this.implementation,resetAfter:!1};return Object.assign(Object.assign({},e),t)}}Ud.className="GRUCell",ka(Ud);class Wd extends Md{constructor(e){0===e.implementation&&console.warn("`implementation=0` has been deprecated, and now defaults to `implementation=1`. Please update your layer call."),e.cell=new Ud(e),super(e)}call(e,t){return wn((()=>{null!=this.cell.dropoutMask&&(kn(this.cell.dropoutMask),this.cell.dropoutMask=null),null!=this.cell.recurrentDropoutMask&&(kn(this.cell.recurrentDropoutMask),this.cell.recurrentDropoutMask=null);const n=null==t?null:t.mask,a=null==t?null:t.training,i=null==t?null:t.initialState;return super.call(e,{mask:n,training:a,initialState:i})}))}static fromConfig(e,t){return 0===t.implmentation&&(t.implementation=1),new e(t)}}Wd.className="GRU",ka(Wd);class Gd extends Od{constructor(e){super(e),this.DEFAULT_ACTIVATION="tanh",this.DEFAULT_RECURRENT_ACTIVATION="hardSigmoid",this.DEFAULT_KERNEL_INITIALIZER="glorotNormal",this.DEFAULT_RECURRENT_INITIALIZER="orthogonal",this.DEFAULT_BIAS_INITIALIZER="zeros",this.units=e.units,Nl(this.units,"units"),this.activation=sd(void 0===e.activation?this.DEFAULT_ACTIVATION:e.activation),this.recurrentActivation=sd(void 0===e.recurrentActivation?this.DEFAULT_RECURRENT_ACTIVATION:e.recurrentActivation),this.useBias=null==e.useBias||e.useBias,this.kernelInitializer=_c(e.kernelInitializer||this.DEFAULT_KERNEL_INITIALIZER),this.recurrentInitializer=_c(e.recurrentInitializer||this.DEFAULT_RECURRENT_INITIALIZER),this.biasInitializer=_c(e.biasInitializer||this.DEFAULT_BIAS_INITIALIZER),this.unitForgetBias=e.unitForgetBias,this.kernelRegularizer=hd(e.kernelRegularizer),this.recurrentRegularizer=hd(e.recurrentRegularizer),this.biasRegularizer=hd(e.biasRegularizer),this.kernelConstraint=Ah(e.kernelConstraint),this.recurrentConstraint=Ah(e.recurrentConstraint),this.biasConstraint=Ah(e.biasConstraint),this.dropout=ql([1,Hl([0,null==e.dropout?0:e.dropout])]),this.recurrentDropout=ql([1,Hl([0,null==e.recurrentDropout?0:e.recurrentDropout])]),this.dropoutFunc=e.dropoutFunc,this.implementation=e.implementation,this.stateSize=[this.units,this.units],this.dropoutMask=null,this.recurrentDropoutMask=null}build(e){var t;const n=(e=Oc(e))[e.length-1];let a;if(this.kernel=this.addWeight("kernel",[n,4*this.units],null,this.kernelInitializer,this.kernelRegularizer,!0,this.kernelConstraint),this.recurrentKernel=this.addWeight("recurrent_kernel",[this.units,4*this.units],null,this.recurrentInitializer,this.recurrentRegularizer,!0,this.recurrentConstraint),this.useBias){if(this.unitForgetBias){const e=this.biasInitializer,n=this.units;a=new((t=class extends gc{apply(t,a){const i=e.apply([n]),s=(new yc).apply([n]),r=e.apply([2*n]);return ic(ic(i,s),r)}}).className="CustomInit",t)}else a=this.biasInitializer;this.bias=this.addWeight("bias",[4*this.units],null,a,this.biasRegularizer,!0,this.biasConstraint)}else this.bias=null;this.built=!0}call(e,t){return wn((()=>{const n=null!=t.training&&t.training;if(3!==e.length)throw new il(`LSTMCell expects 3 input Tensors (inputs, h, c), got ${e.length}.`);let a=e[1];const i=e[2];e=e[0],0<this.dropout&&this.dropout<1&&null==this.dropoutMask&&(this.dropoutMask=qd({ones:()=>fs(e),rate:this.dropout,training:n,count:4,dropoutFunc:this.dropoutFunc})),0<this.recurrentDropout&&this.recurrentDropout<1&&null==this.recurrentDropoutMask&&(this.recurrentDropoutMask=qd({ones:()=>fs(a),rate:this.recurrentDropout,training:n,count:4,dropoutFunc:this.dropoutFunc}));const s=this.dropoutMask,r=this.recurrentDropoutMask;let o,l,c,u;0<this.dropout&&this.dropout<1&&(e=Ta(e,s[0]));let h=oc(e,this.kernel.read());0<this.recurrentDropout&&this.recurrentDropout<1&&(a=Ta(a,r[0])),h=xa(h,oc(a,this.recurrentKernel.read())),this.useBias&&(h=hc(h,this.bias.read()));const[p,d,f,m]=lr(h,4,h.rank-1);o=this.recurrentActivation.apply(p),l=this.recurrentActivation.apply(d),c=xa(Ta(l,i),Ta(o,this.activation.apply(f))),u=this.recurrentActivation.apply(m);const g=Ta(u,this.activation.apply(c));return[g,g,c]}))}getConfig(){const e=super.getConfig(),t={units:this.units,activation:ad(this.activation),recurrentActivation:ad(this.recurrentActivation),useBias:this.useBias,kernelInitializer:Fc(this.kernelInitializer),recurrentInitializer:Fc(this.recurrentInitializer),biasInitializer:Fc(this.biasInitializer),unitForgetBias:this.unitForgetBias,kernelRegularizer:cd(this.kernelRegularizer),recurrentRegularizer:cd(this.recurrentRegularizer),biasRegularizer:cd(this.biasRegularizer),activityRegularizer:cd(this.activityRegularizer),kernelConstraint:$h(this.kernelConstraint),recurrentConstraint:$h(this.recurrentConstraint),biasConstraint:$h(this.biasConstraint),dropout:this.dropout,recurrentDropout:this.recurrentDropout,implementation:this.implementation};return Object.assign(Object.assign({},e),t)}}Gd.className="LSTMCell",ka(Gd);class Vd extends Md{constructor(e){0===e.implementation&&console.warn("`implementation=0` has been deprecated, and now defaults to `implementation=1`. Please update your layer call."),e.cell=new Gd(e),super(e)}call(e,t){return wn((()=>{null!=this.cell.dropoutMask&&(kn(this.cell.dropoutMask),this.cell.dropoutMask=null),null!=this.cell.recurrentDropoutMask&&(kn(this.cell.recurrentDropoutMask),this.cell.recurrentDropoutMask=null);const n=null==t?null:t.mask,a=null==t?null:t.training,i=null==t?null:t.initialState;return super.call(e,{mask:n,training:a,initialState:i})}))}static fromConfig(e,t){return 0===t.implmentation&&(t.implementation=1),new e(t)}}Vd.className="LSTM",ka(Vd);class Kd extends Od{constructor(e){super(e),this.cells=e.cells}get stateSize(){const e=[];for(const t of this.cells.slice().reverse())Array.isArray(t.stateSize)?e.push(...t.stateSize):e.push(t.stateSize);return e}call(e,t){return wn((()=>{let n=e.slice(1);const a=[];for(const e of this.cells.slice().reverse())Array.isArray(e.stateSize)?a.push(n.splice(0,e.stateSize.length)):a.push(n.splice(0,1));a.reverse();const i=[];let s;for(let r=0;r<this.cells.length;++r){const o=this.cells[r];n=a[r],s=0===r?[e[0]].concat(n):[s[0]].concat(n),s=o.call(s,t),i.push(s.slice(1))}n=[];for(const e of i.slice().reverse())n.push(...e);return[s[0]].concat(n)}))}build(e){let t;Rc(e)&&(e=e[0]),this.cells.forEach(((n,a)=>{Bl(`RNNCell_${a}`,(()=>{n.build(e),t=Array.isArray(n.stateSize)?n.stateSize[0]:n.stateSize,e=[e[0],t]}))})),this.built=!0}getConfig(){const e=super.getConfig(),t={cells:this.cells.map((e=>({className:e.getClassName(),config:e.getConfig()})))};return Object.assign(Object.assign({},e),t)}static fromConfig(e,t,n={}){const a=[];for(const e of t.cells)a.push(Bh(e,n));return new e({cells:a})}get trainableWeights(){if(!this.trainable)return[];const e=[];for(const t of this.cells)e.push(...t.trainableWeights);return e}get nonTrainableWeights(){const e=[];for(const t of this.cells)e.push(...t.nonTrainableWeights);if(!this.trainable){const t=[];for(const e of this.cells)t.push(...e.trainableWeights);return t.concat(e)}return e}getWeights(){const e=[];for(const t of this.cells)e.push(...t.weights);return Wc(e)}setWeights(e){const t=[];for(const n of this.cells){const a=n.weights.length,i=e.splice(a);for(let e=0;e<n.weights.length;++e)t.push([n.weights[e],i[e]])}Gc(t)}}function qd(e){const{ones:t,rate:n,training:a=!1,count:i=1,dropoutFunc:s}=e,r=()=>null!=s?s(t(),n):pc(t(),n),o=()=>dc(r,t,a);if(!i||i<=1)return xn(o().clone());return Array(i).fill(void 0).map(o).map((e=>xn(e.clone())))}
4496
+ function Rd(e,t,n,a){if(Array.isArray(e)){if(null!=t||null!=n)throw new il("When inputs is an array, neither initialState or constants should be provided");null!=a&&(n=e.slice(e.length-a,e.length),e=e.slice(0,e.length-a)),e.length>1&&(t=e.slice(1,e.length)),e=e[0]}function i(e){return null==e||Array.isArray(e)?e:[e]}return{inputs:e,initialState:t=i(t),constants:n=i(n)}}function Ld(e,t,n,a=!1,i,s,r=!1,o=!1){return wn((()=>{const s=t.shape.length;if(s<3)throw new il(`Input should be at least 3D, but is ${s}D.`);const l=[1,0].concat(Jl(2,s));t=pa(t,l),r&&console.warn("Backend rnn(): the unroll = true option is not applicable to the imperative deeplearn.js backend."),null!=i&&((i=ra(ra(i,"bool"),"float32")).rank===s-1&&(i=Pi(i,-1)),i=pa(i,l)),a&&(t=Zs(t,0),null!=i&&(i=Zs(i,0)));const c=[];let u,h=n;const p=t.shape[0],d=gr(t);let f,m;null!=i&&(f=gr(i));for(let t=0;t<p;++t){const n=d[t],a=wn((()=>e(n,h)));if(null==i)u=a[0],h=a[1];else{const e=wn((()=>{const e=f[t],n=es(fs(e),e);return{output:xa(Ta(a[0],e),Ta(h[0],n)),newStates:h.map(((t,i)=>xa(Ta(a[1][i],e),Ta(t,n))))}}));u=e.output,h=e.newStates}o&&c.push(u)}if(o){m=ur(c,1)}return[u,m,h]}))}_d.className="DepthwiseConv2D",ka(_d);class Md extends Zc{constructor(e){let t;if(super(e),null==e.cell)throw new il("cell property is missing for the constructor of RNN.");if(t=Array.isArray(e.cell)?new Kd({cells:e.cell}):e.cell,null==t.stateSize)throw new il("The RNN cell should have an attribute `stateSize` (tuple of integers, one integer per RNN state).");this.cell=t,this.returnSequences=null!=e.returnSequences&&e.returnSequences,this.returnState=null!=e.returnState&&e.returnState,this.goBackwards=null!=e.goBackwards&&e.goBackwards,this._stateful=null!=e.stateful&&e.stateful,this.unroll=null!=e.unroll&&e.unroll,this.supportsMasking=!0,this.inputSpec=[new Vc({ndim:3})],this.stateSpec=null,this.states_=null,this.numConstants=null,this.keptStates=[]}getStates(){if(null==this.states_){return Jl(0,Array.isArray(this.cell.stateSize)?this.cell.stateSize.length:1).map((e=>null))}return this.states_}setStates(e){this.states_=e}computeOutputShape(e){Rc(e)&&(e=e[0]);let t=this.cell.stateSize;Array.isArray(t)||(t=[t]);const n=t[0];let a;if(a=this.returnSequences?[e[0],e[1],n]:[e[0],n],this.returnState){const n=[];for(const a of t)n.push([e[0],a]);return[a].concat(n)}return a}computeMask(e,t){return wn((()=>{Array.isArray(t)&&(t=t[0]);const e=this.returnSequences?t:null;if(this.returnState){const t=this.states.map((e=>null));return[e].concat(t)}return e}))}get states(){if(null==this.states_){const e=Array.isArray(this.cell.stateSize)?this.cell.stateSize.length:1,t=[];for(let n=0;n<e;++n)t.push(null);return t}return this.states_}set states(e){this.states_=e}build(e){if(null!=this.numConstants)throw new sl("Constants support is not implemented in RNN yet.");Rc(e)&&(e=e[0]);const t=this.stateful?e[0]:null,n=e.slice(2);this.inputSpec[0]=new Vc({shape:[t,null,...n]});const a=[e[0]].concat(e.slice(2));let i;if(this.cell.build(a),i=Array.isArray(this.cell.stateSize)?this.cell.stateSize:[this.cell.stateSize],null!=this.stateSpec){if(!T(this.stateSpec.map((e=>e.shape[e.shape.length-1])),i))throw new il(`An initialState was passed that is not compatible with cell.stateSize. Received stateSpec=${this.stateSpec}; However cell.stateSize is ${this.cell.stateSize}`)}else this.stateSpec=i.map((e=>new Vc({shape:[null,e]})));this.stateful&&this.resetStates()}resetStates(e,t=!1){wn((()=>{if(!this.stateful)throw new nl("Cannot call resetStates() on an RNN Layer that is not stateful.");const n=this.inputSpec[0].shape[0];if(null==n)throw new il("If an RNN is stateful, it needs to know its batch size. Specify the batch size of your input tensors: \n- If using a Sequential model, specify the batch size by passing a `batchInputShape` option to your first layer.\n- If using the functional API, specify the batch size by passing a `batchShape` option to your Input layer.");if(null==this.states_)Array.isArray(this.cell.stateSize)?this.states_=this.cell.stateSize.map((e=>cs([n,e]))):this.states_=[cs([n,this.cell.stateSize])];else if(null==e)kn(this.states_),null!=this.keptStates&&(kn(this.keptStates),this.keptStates=[]),Array.isArray(this.cell.stateSize)?this.states_=this.cell.stateSize.map((e=>cs([n,e]))):this.states_[0]=cs([n,this.cell.stateSize]);else{if(Array.isArray(e)||(e=[e]),e.length!==this.states_.length)throw new il(`Layer ${this.name} expects ${this.states_.length} state(s), but it received ${e.length} state value(s). Input received: ${e}`);!0===t?this.keptStates.push(this.states_.slice()):kn(this.states_);for(let t=0;t<this.states_.length;++t){const a=e[t],i=Array.isArray(this.cell.stateSize)?this.cell.stateSize[t]:this.cell.stateSize,s=[n,i];if(!T(a.shape,s))throw new il(`State ${t} is incompatible with layer ${this.name}: expected shape=${s}, received shape=${a.shape}`);this.states_[t]=a}}this.states_=this.states_.map((e=>xn(e.clone())))}))}apply(e,t){let n=null==t?null:t.initialState,a=null==t?null:t.constants;null==t&&(t={});const i=Rd(e,n,a,this.numConstants);e=i.inputs,n=i.initialState,a=i.constants;let s=[],r=[];if(null!=n){t.initialState=n,s=s.concat(n),this.stateSpec=[];for(const e of n)this.stateSpec.push(new Vc({shape:e.shape}));r=r.concat(this.stateSpec)}null!=a&&(t.constants=a,s=s.concat(a),this.numConstants=a.length);if(s[0]instanceof Kc){const n=[e].concat(s),a=this.inputSpec.concat(r),i=this.inputSpec;this.inputSpec=a;const o=super.apply(n,t);return this.inputSpec=i,o}return super.apply(e,t)}call(e,t){return wn((()=>{const n=null==t?null:t.mask,a=null==t?null:t.training;let i=null==t?null:t.initialState;e=Mc(e),null==i&&(i=this.stateful?this.states_:this.getInitialState(e));const s=Array.isArray(this.cell.stateSize)?this.cell.stateSize.length:1;if(i.length!==s)throw new il(`RNN Layer has ${s} state(s) but was passed ${i.length} initial state(s).`);this.unroll&&console.warn("Ignoring unroll = true for RNN layer, due to imperative backend.");const r={training:a},o=Ld(((e,t)=>{const n=this.cell.call([e].concat(t),r);return[n[0],n.slice(1)]}),e,i,this.goBackwards,n,0,this.unroll,this.returnSequences),l=o[0],c=o[1],u=o[2];this.stateful&&this.resetStates(u,a);const h=this.returnSequences?c:l;return this.returnState?[h].concat(u):h}))}getInitialState(e){return wn((()=>{let t=cs(e.shape);return t=Ri(t,[1,2]),t=Xl(t),Array.isArray(this.cell.stateSize)?this.cell.stateSize.map((e=>e>1?sc(t,[1,e]):t)):this.cell.stateSize>1?[sc(t,[1,this.cell.stateSize])]:[t]}))}get trainableWeights(){return this.trainable?this.cell.trainableWeights:[]}get nonTrainableWeights(){return this.trainable?this.cell.nonTrainableWeights:this.cell.weights}setFastWeightInitDuringBuild(e){super.setFastWeightInitDuringBuild(e),null!=this.cell&&this.cell.setFastWeightInitDuringBuild(e)}getConfig(){const e=super.getConfig(),t={returnSequences:this.returnSequences,returnState:this.returnState,goBackwards:this.goBackwards,stateful:this.stateful,unroll:this.unroll};null!=this.numConstants&&(t.numConstants=this.numConstants);const n=this.cell.getConfig();return this.getClassName()===Md.className&&(t.cell={className:this.cell.getClassName(),config:n}),Object.assign(Object.assign(Object.assign({},n),e),t)}static fromConfig(e,t,n={}){const a=Bh(t.cell,n);return new e(Object.assign(t,{cell:a}))}}Md.className="RNN",ka(Md);class Od extends Zc{}class Pd extends Od{constructor(e){super(e),this.DEFAULT_ACTIVATION="tanh",this.DEFAULT_KERNEL_INITIALIZER="glorotNormal",this.DEFAULT_RECURRENT_INITIALIZER="orthogonal",this.DEFAULT_BIAS_INITIALIZER="zeros",this.units=e.units,Nl(this.units,"units"),this.activation=sd(null==e.activation?this.DEFAULT_ACTIVATION:e.activation),this.useBias=null==e.useBias||e.useBias,this.kernelInitializer=_c(e.kernelInitializer||this.DEFAULT_KERNEL_INITIALIZER),this.recurrentInitializer=_c(e.recurrentInitializer||this.DEFAULT_RECURRENT_INITIALIZER),this.biasInitializer=_c(e.biasInitializer||this.DEFAULT_BIAS_INITIALIZER),this.kernelRegularizer=hd(e.kernelRegularizer),this.recurrentRegularizer=hd(e.recurrentRegularizer),this.biasRegularizer=hd(e.biasRegularizer),this.kernelConstraint=Ah(e.kernelConstraint),this.recurrentConstraint=Ah(e.recurrentConstraint),this.biasConstraint=Ah(e.biasConstraint),this.dropout=ql([1,Hl([0,null==e.dropout?0:e.dropout])]),this.recurrentDropout=ql([1,Hl([0,null==e.recurrentDropout?0:e.recurrentDropout])]),this.dropoutFunc=e.dropoutFunc,this.stateSize=this.units,this.dropoutMask=null,this.recurrentDropoutMask=null}build(e){e=Oc(e),this.kernel=this.addWeight("kernel",[e[e.length-1],this.units],null,this.kernelInitializer,this.kernelRegularizer,!0,this.kernelConstraint),this.recurrentKernel=this.addWeight("recurrent_kernel",[this.units,this.units],null,this.recurrentInitializer,this.recurrentRegularizer,!0,this.recurrentConstraint),this.useBias?this.bias=this.addWeight("bias",[this.units],null,this.biasInitializer,this.biasRegularizer,!0,this.biasConstraint):this.bias=null,this.built=!0}call(e,t){return wn((()=>{if(2!==e.length)throw new il(`SimpleRNNCell expects 2 input Tensors, got ${e.length}.`);let n=e[1];e=e[0];const a=null!=t.training&&t.training;let i;0<this.dropout&&this.dropout<1&&null==this.dropoutMask&&(this.dropoutMask=qd({ones:()=>fs(e),rate:this.dropout,training:a,dropoutFunc:this.dropoutFunc})),0<this.recurrentDropout&&this.recurrentDropout<1&&null==this.recurrentDropoutMask&&(this.recurrentDropoutMask=qd({ones:()=>fs(n),rate:this.recurrentDropout,training:a,dropoutFunc:this.dropoutFunc}));const s=this.dropoutMask,r=this.recurrentDropoutMask;i=oc(null!=s?Ta(e,s):e,this.kernel.read()),null!=this.bias&&(i=hc(i,this.bias.read())),null!=r&&(n=Ta(n,r));let o=xa(i,oc(n,this.recurrentKernel.read()));return null!=this.activation&&(o=this.activation.apply(o)),[o,o]}))}getConfig(){const e=super.getConfig(),t={units:this.units,activation:ad(this.activation),useBias:this.useBias,kernelInitializer:Fc(this.kernelInitializer),recurrentInitializer:Fc(this.recurrentInitializer),biasInitializer:Fc(this.biasInitializer),kernelRegularizer:cd(this.kernelRegularizer),recurrentRegularizer:cd(this.recurrentRegularizer),biasRegularizer:cd(this.biasRegularizer),activityRegularizer:cd(this.activityRegularizer),kernelConstraint:Ch(this.kernelConstraint),recurrentConstraint:Ch(this.recurrentConstraint),biasConstraint:Ch(this.biasConstraint),dropout:this.dropout,recurrentDropout:this.recurrentDropout};return Object.assign(Object.assign({},e),t)}}Pd.className="SimpleRNNCell",ka(Pd);class Bd extends Md{constructor(e){e.cell=new Pd(e),super(e)}call(e,t){return wn((()=>{null!=this.cell.dropoutMask&&(kn(this.cell.dropoutMask),this.cell.dropoutMask=null),null!=this.cell.recurrentDropoutMask&&(kn(this.cell.recurrentDropoutMask),this.cell.recurrentDropoutMask=null);const n=null==t?null:t.mask,a=null==t?null:t.training,i=null==t?null:t.initialState;return super.call(e,{mask:n,training:a,initialState:i})}))}static fromConfig(e,t){return new e(t)}}Bd.className="SimpleRNN",ka(Bd);class Ud extends Od{constructor(e){if(super(e),this.DEFAULT_ACTIVATION="tanh",this.DEFAULT_RECURRENT_ACTIVATION="hardSigmoid",this.DEFAULT_KERNEL_INITIALIZER="glorotNormal",this.DEFAULT_RECURRENT_INITIALIZER="orthogonal",this.DEFAULT_BIAS_INITIALIZER="zeros",e.resetAfter)throw new il("GRUCell does not support reset_after parameter set to true.");this.units=e.units,Nl(this.units,"units"),this.activation=sd(void 0===e.activation?this.DEFAULT_ACTIVATION:e.activation),this.recurrentActivation=sd(void 0===e.recurrentActivation?this.DEFAULT_RECURRENT_ACTIVATION:e.recurrentActivation),this.useBias=null==e.useBias||e.useBias,this.kernelInitializer=_c(e.kernelInitializer||this.DEFAULT_KERNEL_INITIALIZER),this.recurrentInitializer=_c(e.recurrentInitializer||this.DEFAULT_RECURRENT_INITIALIZER),this.biasInitializer=_c(e.biasInitializer||this.DEFAULT_BIAS_INITIALIZER),this.kernelRegularizer=hd(e.kernelRegularizer),this.recurrentRegularizer=hd(e.recurrentRegularizer),this.biasRegularizer=hd(e.biasRegularizer),this.kernelConstraint=Ah(e.kernelConstraint),this.recurrentConstraint=Ah(e.recurrentConstraint),this.biasConstraint=Ah(e.biasConstraint),this.dropout=ql([1,Hl([0,null==e.dropout?0:e.dropout])]),this.recurrentDropout=ql([1,Hl([0,null==e.recurrentDropout?0:e.recurrentDropout])]),this.dropoutFunc=e.dropoutFunc,this.implementation=e.implementation,this.stateSize=this.units,this.dropoutMask=null,this.recurrentDropoutMask=null}build(e){const t=(e=Oc(e))[e.length-1];this.kernel=this.addWeight("kernel",[t,3*this.units],null,this.kernelInitializer,this.kernelRegularizer,!0,this.kernelConstraint),this.recurrentKernel=this.addWeight("recurrent_kernel",[this.units,3*this.units],null,this.recurrentInitializer,this.recurrentRegularizer,!0,this.recurrentConstraint),this.useBias?this.bias=this.addWeight("bias",[3*this.units],null,this.biasInitializer,this.biasRegularizer,!0,this.biasConstraint):this.bias=null,this.built=!0}call(e,t){return wn((()=>{if(2!==e.length)throw new il(`GRUCell expects 2 input Tensors (inputs, h, c), got ${e.length}.`);const n=null!=t.training&&t.training;let a=e[1];e=e[0],0<this.dropout&&this.dropout<1&&null==this.dropoutMask&&(this.dropoutMask=qd({ones:()=>fs(e),rate:this.dropout,training:n,count:3,dropoutFunc:this.dropoutFunc})),0<this.recurrentDropout&&this.recurrentDropout<1&&null==this.recurrentDropoutMask&&(this.recurrentDropoutMask=qd({ones:()=>fs(a),rate:this.recurrentDropout,training:n,count:3,dropoutFunc:this.dropoutFunc}));const i=this.dropoutMask,s=this.recurrentDropoutMask;let r,o,l;0<this.dropout&&this.dropout<1&&(e=Ta(e,i[0]));let c=oc(e,this.kernel.read());this.useBias&&(c=hc(c,this.bias.read())),0<this.recurrentDropout&&this.recurrentDropout<1&&(a=Ta(a,s[0]));const u=this.recurrentKernel.read(),[h,p]=lr(u,[2*this.units,this.units],u.rank-1),d=oc(a,h),[f,m,g]=lr(c,3,c.rank-1),[v,y]=lr(d,2,d.rank-1);r=this.recurrentActivation.apply(xa(f,v)),o=this.recurrentActivation.apply(xa(m,y));const b=oc(Ta(o,a),p);l=this.activation.apply(xa(g,b));const w=xa(Ta(r,a),Ta(xa(1,ua(r)),l));return[w,w]}))}getConfig(){const e=super.getConfig(),t={units:this.units,activation:ad(this.activation),recurrentActivation:ad(this.recurrentActivation),useBias:this.useBias,kernelInitializer:Fc(this.kernelInitializer),recurrentInitializer:Fc(this.recurrentInitializer),biasInitializer:Fc(this.biasInitializer),kernelRegularizer:cd(this.kernelRegularizer),recurrentRegularizer:cd(this.recurrentRegularizer),biasRegularizer:cd(this.biasRegularizer),activityRegularizer:cd(this.activityRegularizer),kernelConstraint:Ch(this.kernelConstraint),recurrentConstraint:Ch(this.recurrentConstraint),biasConstraint:Ch(this.biasConstraint),dropout:this.dropout,recurrentDropout:this.recurrentDropout,implementation:this.implementation,resetAfter:!1};return Object.assign(Object.assign({},e),t)}}Ud.className="GRUCell",ka(Ud);class Wd extends Md{constructor(e){0===e.implementation&&console.warn("`implementation=0` has been deprecated, and now defaults to `implementation=1`. Please update your layer call."),e.cell=new Ud(e),super(e)}call(e,t){return wn((()=>{null!=this.cell.dropoutMask&&(kn(this.cell.dropoutMask),this.cell.dropoutMask=null),null!=this.cell.recurrentDropoutMask&&(kn(this.cell.recurrentDropoutMask),this.cell.recurrentDropoutMask=null);const n=null==t?null:t.mask,a=null==t?null:t.training,i=null==t?null:t.initialState;return super.call(e,{mask:n,training:a,initialState:i})}))}static fromConfig(e,t){return 0===t.implmentation&&(t.implementation=1),new e(t)}}Wd.className="GRU",ka(Wd);class Gd extends Od{constructor(e){super(e),this.DEFAULT_ACTIVATION="tanh",this.DEFAULT_RECURRENT_ACTIVATION="hardSigmoid",this.DEFAULT_KERNEL_INITIALIZER="glorotNormal",this.DEFAULT_RECURRENT_INITIALIZER="orthogonal",this.DEFAULT_BIAS_INITIALIZER="zeros",this.units=e.units,Nl(this.units,"units"),this.activation=sd(void 0===e.activation?this.DEFAULT_ACTIVATION:e.activation),this.recurrentActivation=sd(void 0===e.recurrentActivation?this.DEFAULT_RECURRENT_ACTIVATION:e.recurrentActivation),this.useBias=null==e.useBias||e.useBias,this.kernelInitializer=_c(e.kernelInitializer||this.DEFAULT_KERNEL_INITIALIZER),this.recurrentInitializer=_c(e.recurrentInitializer||this.DEFAULT_RECURRENT_INITIALIZER),this.biasInitializer=_c(e.biasInitializer||this.DEFAULT_BIAS_INITIALIZER),this.unitForgetBias=e.unitForgetBias,this.kernelRegularizer=hd(e.kernelRegularizer),this.recurrentRegularizer=hd(e.recurrentRegularizer),this.biasRegularizer=hd(e.biasRegularizer),this.kernelConstraint=Ah(e.kernelConstraint),this.recurrentConstraint=Ah(e.recurrentConstraint),this.biasConstraint=Ah(e.biasConstraint),this.dropout=ql([1,Hl([0,null==e.dropout?0:e.dropout])]),this.recurrentDropout=ql([1,Hl([0,null==e.recurrentDropout?0:e.recurrentDropout])]),this.dropoutFunc=e.dropoutFunc,this.implementation=e.implementation,this.stateSize=[this.units,this.units],this.dropoutMask=null,this.recurrentDropoutMask=null}build(e){var t;const n=(e=Oc(e))[e.length-1];let a;if(this.kernel=this.addWeight("kernel",[n,4*this.units],null,this.kernelInitializer,this.kernelRegularizer,!0,this.kernelConstraint),this.recurrentKernel=this.addWeight("recurrent_kernel",[this.units,4*this.units],null,this.recurrentInitializer,this.recurrentRegularizer,!0,this.recurrentConstraint),this.useBias){if(this.unitForgetBias){const e=this.biasInitializer,n=this.units;a=new((t=class extends gc{apply(t,a){const i=e.apply([n]),s=(new yc).apply([n]),r=e.apply([2*n]);return ic(ic(i,s),r)}}).className="CustomInit",t)}else a=this.biasInitializer;this.bias=this.addWeight("bias",[4*this.units],null,a,this.biasRegularizer,!0,this.biasConstraint)}else this.bias=null;this.built=!0}call(e,t){return wn((()=>{const n=null!=t.training&&t.training;if(3!==e.length)throw new il(`LSTMCell expects 3 input Tensors (inputs, h, c), got ${e.length}.`);let a=e[1];const i=e[2];e=e[0],0<this.dropout&&this.dropout<1&&null==this.dropoutMask&&(this.dropoutMask=qd({ones:()=>fs(e),rate:this.dropout,training:n,count:4,dropoutFunc:this.dropoutFunc})),0<this.recurrentDropout&&this.recurrentDropout<1&&null==this.recurrentDropoutMask&&(this.recurrentDropoutMask=qd({ones:()=>fs(a),rate:this.recurrentDropout,training:n,count:4,dropoutFunc:this.dropoutFunc}));const s=this.dropoutMask,r=this.recurrentDropoutMask;let o,l,c,u;0<this.dropout&&this.dropout<1&&(e=Ta(e,s[0]));let h=oc(e,this.kernel.read());0<this.recurrentDropout&&this.recurrentDropout<1&&(a=Ta(a,r[0])),h=xa(h,oc(a,this.recurrentKernel.read())),this.useBias&&(h=hc(h,this.bias.read()));const[p,d,f,m]=lr(h,4,h.rank-1);o=this.recurrentActivation.apply(p),l=this.recurrentActivation.apply(d),c=xa(Ta(l,i),Ta(o,this.activation.apply(f))),u=this.recurrentActivation.apply(m);const g=Ta(u,this.activation.apply(c));return[g,g,c]}))}getConfig(){const e=super.getConfig(),t={units:this.units,activation:ad(this.activation),recurrentActivation:ad(this.recurrentActivation),useBias:this.useBias,kernelInitializer:Fc(this.kernelInitializer),recurrentInitializer:Fc(this.recurrentInitializer),biasInitializer:Fc(this.biasInitializer),unitForgetBias:this.unitForgetBias,kernelRegularizer:cd(this.kernelRegularizer),recurrentRegularizer:cd(this.recurrentRegularizer),biasRegularizer:cd(this.biasRegularizer),activityRegularizer:cd(this.activityRegularizer),kernelConstraint:Ch(this.kernelConstraint),recurrentConstraint:Ch(this.recurrentConstraint),biasConstraint:Ch(this.biasConstraint),dropout:this.dropout,recurrentDropout:this.recurrentDropout,implementation:this.implementation};return Object.assign(Object.assign({},e),t)}}Gd.className="LSTMCell",ka(Gd);class Vd extends Md{constructor(e){0===e.implementation&&console.warn("`implementation=0` has been deprecated, and now defaults to `implementation=1`. Please update your layer call."),e.cell=new Gd(e),super(e)}call(e,t){return wn((()=>{null!=this.cell.dropoutMask&&(kn(this.cell.dropoutMask),this.cell.dropoutMask=null),null!=this.cell.recurrentDropoutMask&&(kn(this.cell.recurrentDropoutMask),this.cell.recurrentDropoutMask=null);const n=null==t?null:t.mask,a=null==t?null:t.training,i=null==t?null:t.initialState;return super.call(e,{mask:n,training:a,initialState:i})}))}static fromConfig(e,t){return 0===t.implmentation&&(t.implementation=1),new e(t)}}Vd.className="LSTM",ka(Vd);class Kd extends Od{constructor(e){super(e),this.cells=e.cells}get stateSize(){const e=[];for(const t of this.cells.slice().reverse())Array.isArray(t.stateSize)?e.push(...t.stateSize):e.push(t.stateSize);return e}call(e,t){return wn((()=>{let n=e.slice(1);const a=[];for(const e of this.cells.slice().reverse())Array.isArray(e.stateSize)?a.push(n.splice(0,e.stateSize.length)):a.push(n.splice(0,1));a.reverse();const i=[];let s;for(let r=0;r<this.cells.length;++r){const o=this.cells[r];n=a[r],s=0===r?[e[0]].concat(n):[s[0]].concat(n),s=o.call(s,t),i.push(s.slice(1))}n=[];for(const e of i.slice().reverse())n.push(...e);return[s[0]].concat(n)}))}build(e){let t;Rc(e)&&(e=e[0]),this.cells.forEach(((n,a)=>{Bl(`RNNCell_${a}`,(()=>{n.build(e),t=Array.isArray(n.stateSize)?n.stateSize[0]:n.stateSize,e=[e[0],t]}))})),this.built=!0}getConfig(){const e=super.getConfig(),t={cells:this.cells.map((e=>({className:e.getClassName(),config:e.getConfig()})))};return Object.assign(Object.assign({},e),t)}static fromConfig(e,t,n={}){const a=[];for(const e of t.cells)a.push(Bh(e,n));return new e({cells:a})}get trainableWeights(){if(!this.trainable)return[];const e=[];for(const t of this.cells)e.push(...t.trainableWeights);return e}get nonTrainableWeights(){const e=[];for(const t of this.cells)e.push(...t.nonTrainableWeights);if(!this.trainable){const t=[];for(const e of this.cells)t.push(...e.trainableWeights);return t.concat(e)}return e}getWeights(){const e=[];for(const t of this.cells)e.push(...t.weights);return Wc(e)}setWeights(e){const t=[];for(const n of this.cells){const a=n.weights.length,i=e.splice(a);for(let e=0;e<n.weights.length;++e)t.push([n.weights[e],i[e]])}Gc(t)}}function qd(e){const{ones:t,rate:n,training:a=!1,count:i=1,dropoutFunc:s}=e,r=()=>null!=s?s(t(),n):pc(t(),n),o=()=>dc(r,t,a);if(!i||i<=1)return xn(o().clone());return Array(i).fill(void 0).map(o).map((e=>xn(e.clone())))}
4497
4497
  /**
4498
4498
  * @license
4499
4499
  * Copyright 2020 Google LLC
@@ -4502,7 +4502,7 @@ function Rd(e,t,n,a){if(Array.isArray(e)){if(null!=t||null!=n)throw new il("When
4502
4502
  * license that can be found in the LICENSE file or at
4503
4503
  * https://opensource.org/licenses/MIT.
4504
4504
  * =============================================================================
4505
- */Kd.className="StackedRNNCells",ka(Kd);var Hd=function(e,t){var n={};for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&t.indexOf(a)<0&&(n[a]=e[a]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(a=Object.getOwnPropertySymbols(e);i<a.length;i++)t.indexOf(a[i])<0&&Object.prototype.propertyIsEnumerable.call(e,a[i])&&(n[a[i]]=e[a[i]])}return n};class Jd extends Md{constructor(e){if(e.unroll)throw new sl("Unrolling is not possible with convolutional RNNs.");if(Array.isArray(e.cell))throw new sl("It is not possible at the moment to stack convolutional cells.");super(e),this.inputSpec=[new Vc({ndim:5})]}call(e,t){return wn((()=>{if(null!=this.cell.dropoutMask&&(kn(this.cell.dropoutMask),this.cell.dropoutMask=null),null!=this.cell.recurrentDropoutMask&&(kn(this.cell.recurrentDropoutMask),this.cell.recurrentDropoutMask=null),t&&t.constants)throw new il("ConvRNN2D cell does not support constants");const n=null==t?null:t.mask,a=null==t?null:t.training,i=null==t?null:t.initialState;return super.call(e,{mask:n,training:a,initialState:i})}))}computeOutputShape(e){let t=this.computeSingleOutputShape(e);return this.returnSequences||(t=[t[0],...t.slice(2)]),this.returnState&&(t=[t,...Array(2).fill([e[0],...t.slice(-3)])]),t}getInitialState(e){return wn((()=>{const{stateSize:t}=this.cell,n=e.shape,a=this.computeSingleOutputShape(n),i=cs([a[0],...a.slice(2)]);return Array.isArray(t)?Array(t.length).fill(i):[i]}))}resetStates(e,t=!1){wn((()=>{if(!this.stateful)throw new nl("Cannot call resetStates() on an RNN Layer that is not stateful.");const n=this.inputSpec[0].shape,a=this.computeSingleOutputShape(n),i=[a[0],...a.slice(2)];if(null==n[0])throw new il("If an RNN is stateful, it needs to know its batch size. Specify the batch size of your input tensors: \n- If using a Sequential model, specify the batch size by passing a `batchInputShape` option to your first layer.\n- If using the functional API, specify the batch size by passing a `batchShape` option to your Input layer.");if(null==this.getStates())Array.isArray(this.cell.stateSize)?this.states_=this.cell.stateSize.map((()=>cs(i))):this.states_=[cs(i)];else if(null==e)kn(this.states_),null!=this.keptStates&&(kn(this.keptStates),this.keptStates=[]),Array.isArray(this.cell.stateSize)?this.states_=this.cell.stateSize.map((()=>cs(i))):this.states_[0]=cs(i);else{if(Array.isArray(e)||(e=[e]),e.length!==this.states_.length)throw new il(`Layer ${this.name} expects ${this.states_.length} state(s), but it received ${e.length} state value(s). Input received: ${e}`);t?this.keptStates.push(this.states_.slice()):kn(this.states_);for(let t=0;t<this.states_.length;++t){const n=e[t],a=i;if(!T(n.shape,a))throw new il(`State ${t} is incompatible with layer ${this.name}: expected shape=${a}, received shape=${n.shape}`);this.states_[t]=n}}this.states_=this.states_.map((e=>xn(e.clone())))}))}computeSingleOutputShape(e){const{dataFormat:t,filters:n,kernelSize:a,padding:i,strides:s,dilationRate:r}=this.cell,o="channelsFirst"===t,l=e[o?3:2],c=e[o?4:3],u=bd(l,a[0],i,s[0],r[0]),h=bd(c,a[1],i,s[1],r[1]);return[...e.slice(0,2),...o?[n,u,h]:[u,h,n]]}}Jd.className="ConvRNN2D";class Zd extends Gd{constructor(e){const{filters:t,kernelSize:n,strides:a,padding:i,dataFormat:s,dilationRate:r}=e;super(Object.assign(Object.assign({},e),{units:t})),this.filters=t,Nl(this.filters,"filters"),this.kernelSize=yd(n,2,"kernelSize"),this.kernelSize.forEach((e=>Nl(e,"kernelSize"))),this.strides=yd(a||1,2,"strides"),this.strides.forEach((e=>Nl(e,"strides"))),this.padding=i||"valid",Ml(this.padding),this.dataFormat=s||"channelsLast",Ll(this.dataFormat),this.dilationRate=yd(r||1,2,"dilationRate"),this.dilationRate.forEach((e=>Nl(e,"dilationRate")))}build(e){var t;e=Oc(e);const n="channelsFirst"===this.dataFormat?1:e.length-1;if(null==e[n])throw new il(`The channel dimension of the input should be defined. Found ${e[n]}`);const a=e[n],i=this.kernelSize.concat([a,4*this.filters]);this.kernel=this.addWeight("kernel",i,null,this.kernelInitializer,this.kernelRegularizer,!0,this.kernelConstraint);const s=this.kernelSize.concat([this.filters,4*this.filters]);if(this.recurrentKernel=this.addWeight("recurrent_kernel",s,null,this.recurrentInitializer,this.recurrentRegularizer,!0,this.recurrentConstraint),this.useBias){let e;if(this.unitForgetBias){const n=this.biasInitializer,a=this.filters;e=new((t=class extends gc{apply(e,t){return ac([n.apply([a]),us([a]),n.apply([2*a])])}}).className="CustomInit",t)}else e=this.biasInitializer;this.bias=this.addWeight("bias",[4*this.filters],null,e,this.biasRegularizer,!0,this.biasConstraint)}this.built=!0}call(e,t){return wn((()=>{if(3!==e.length)throw new il(`ConvLSTM2DCell expects 3 input Tensors (inputs, h, c), got ${e.length}.`);const n=t.training||!1,a=e[0],i=e[1],s=e[2];0<this.dropout&&this.dropout<1&&null==this.dropoutMask&&(this.dropoutMask=qd({ones:()=>fs(a),rate:this.dropout,training:n,count:4,dropoutFunc:this.dropoutFunc}));const r=this.dropoutMask,o=(e,t,n)=>t&&t[n]?Ta(t[n],e):e;let l=o(a,r,0),c=o(a,r,1),u=o(a,r,2),h=o(a,r,3);0<this.recurrentDropout&&this.recurrentDropout<1&&null==this.recurrentDropoutMask&&(this.recurrentDropoutMask=qd({ones:()=>fs(i),rate:this.recurrentDropout,training:n,count:4,dropoutFunc:this.dropoutFunc}));const p=this.recurrentDropoutMask;let d=o(i,p,0),f=o(i,p,1),m=o(i,p,2),g=o(i,p,3);const[v,y,b,w]=lr(this.kernel.read(),4,3),[k,x,S,N]=this.useBias?lr(this.bias.read(),4):[null,null,null,null];l=this.inputConv(l,v,k,this.padding),c=this.inputConv(c,y,x,this.padding),u=this.inputConv(u,b,S,this.padding),h=this.inputConv(h,w,N,this.padding);const[T,I,$,C]=lr(this.recurrentKernel.read(),4,3);d=this.recurrentConv(d,T),f=this.recurrentConv(f,I),m=this.recurrentConv(m,$),g=this.recurrentConv(g,C);const A=this.recurrentActivation.apply(xa(l,d)),E=this.recurrentActivation.apply(xa(c,f)),j=xa(Ta(E,s),Ta(A,this.activation.apply(xa(u,m)))),z=Ta(this.recurrentActivation.apply(xa(h,g)),this.activation.apply(j));return[z,z,j]}))}getConfig(){const e=super.getConfig(),t=Hd(e,["units"]),n={filters:this.filters,kernelSize:this.kernelSize,padding:this.padding,dataFormat:this.dataFormat,dilationRate:this.dilationRate,strides:this.strides};return Object.assign(Object.assign({},t),n)}inputConv(e,t,n,a){const i=ri(e,t,this.strides,a||"valid","channelsFirst"===this.dataFormat?"NCHW":"NHWC",this.dilationRate);return n?hc(i,n,this.dataFormat):i}recurrentConv(e,t){return ri(e,t,1,"same","channelsFirst"===this.dataFormat?"NCHW":"NHWC")}}Zd.className="ConvLSTM2DCell",ka(Zd);class Yd extends Jd{constructor(e){const t=new Zd(e);super(Object.assign(Object.assign({},e),{cell:t}))}static fromConfig(e,t){return new e(t)}}Yd.className="ConvLSTM2D",ka(Yd);
4505
+ */Kd.className="StackedRNNCells",ka(Kd);var Hd=function(e,t){var n={};for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&t.indexOf(a)<0&&(n[a]=e[a]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(a=Object.getOwnPropertySymbols(e);i<a.length;i++)t.indexOf(a[i])<0&&Object.prototype.propertyIsEnumerable.call(e,a[i])&&(n[a[i]]=e[a[i]])}return n};class Jd extends Md{constructor(e){if(e.unroll)throw new sl("Unrolling is not possible with convolutional RNNs.");if(Array.isArray(e.cell))throw new sl("It is not possible at the moment to stack convolutional cells.");super(e),this.inputSpec=[new Vc({ndim:5})]}call(e,t){return wn((()=>{if(null!=this.cell.dropoutMask&&(kn(this.cell.dropoutMask),this.cell.dropoutMask=null),null!=this.cell.recurrentDropoutMask&&(kn(this.cell.recurrentDropoutMask),this.cell.recurrentDropoutMask=null),t&&t.constants)throw new il("ConvRNN2D cell does not support constants");const n=null==t?null:t.mask,a=null==t?null:t.training,i=null==t?null:t.initialState;return super.call(e,{mask:n,training:a,initialState:i})}))}computeOutputShape(e){let t=this.computeSingleOutputShape(e);return this.returnSequences||(t=[t[0],...t.slice(2)]),this.returnState&&(t=[t,...Array(2).fill([e[0],...t.slice(-3)])]),t}getInitialState(e){return wn((()=>{const{stateSize:t}=this.cell,n=e.shape,a=this.computeSingleOutputShape(n),i=cs([a[0],...a.slice(2)]);return Array.isArray(t)?Array(t.length).fill(i):[i]}))}resetStates(e,t=!1){wn((()=>{if(!this.stateful)throw new nl("Cannot call resetStates() on an RNN Layer that is not stateful.");const n=this.inputSpec[0].shape,a=this.computeSingleOutputShape(n),i=[a[0],...a.slice(2)];if(null==n[0])throw new il("If an RNN is stateful, it needs to know its batch size. Specify the batch size of your input tensors: \n- If using a Sequential model, specify the batch size by passing a `batchInputShape` option to your first layer.\n- If using the functional API, specify the batch size by passing a `batchShape` option to your Input layer.");if(null==this.getStates())Array.isArray(this.cell.stateSize)?this.states_=this.cell.stateSize.map((()=>cs(i))):this.states_=[cs(i)];else if(null==e)kn(this.states_),null!=this.keptStates&&(kn(this.keptStates),this.keptStates=[]),Array.isArray(this.cell.stateSize)?this.states_=this.cell.stateSize.map((()=>cs(i))):this.states_[0]=cs(i);else{if(Array.isArray(e)||(e=[e]),e.length!==this.states_.length)throw new il(`Layer ${this.name} expects ${this.states_.length} state(s), but it received ${e.length} state value(s). Input received: ${e}`);t?this.keptStates.push(this.states_.slice()):kn(this.states_);for(let t=0;t<this.states_.length;++t){const n=e[t],a=i;if(!T(n.shape,a))throw new il(`State ${t} is incompatible with layer ${this.name}: expected shape=${a}, received shape=${n.shape}`);this.states_[t]=n}}this.states_=this.states_.map((e=>xn(e.clone())))}))}computeSingleOutputShape(e){const{dataFormat:t,filters:n,kernelSize:a,padding:i,strides:s,dilationRate:r}=this.cell,o="channelsFirst"===t,l=e[o?3:2],c=e[o?4:3],u=bd(l,a[0],i,s[0],r[0]),h=bd(c,a[1],i,s[1],r[1]);return[...e.slice(0,2),...o?[n,u,h]:[u,h,n]]}}Jd.className="ConvRNN2D";class Zd extends Gd{constructor(e){const{filters:t,kernelSize:n,strides:a,padding:i,dataFormat:s,dilationRate:r}=e;super(Object.assign(Object.assign({},e),{units:t})),this.filters=t,Nl(this.filters,"filters"),this.kernelSize=yd(n,2,"kernelSize"),this.kernelSize.forEach((e=>Nl(e,"kernelSize"))),this.strides=yd(a||1,2,"strides"),this.strides.forEach((e=>Nl(e,"strides"))),this.padding=i||"valid",Ml(this.padding),this.dataFormat=s||"channelsLast",Ll(this.dataFormat),this.dilationRate=yd(r||1,2,"dilationRate"),this.dilationRate.forEach((e=>Nl(e,"dilationRate")))}build(e){var t;e=Oc(e);const n="channelsFirst"===this.dataFormat?1:e.length-1;if(null==e[n])throw new il(`The channel dimension of the input should be defined. Found ${e[n]}`);const a=e[n],i=this.kernelSize.concat([a,4*this.filters]);this.kernel=this.addWeight("kernel",i,null,this.kernelInitializer,this.kernelRegularizer,!0,this.kernelConstraint);const s=this.kernelSize.concat([this.filters,4*this.filters]);if(this.recurrentKernel=this.addWeight("recurrent_kernel",s,null,this.recurrentInitializer,this.recurrentRegularizer,!0,this.recurrentConstraint),this.useBias){let e;if(this.unitForgetBias){const n=this.biasInitializer,a=this.filters;e=new((t=class extends gc{apply(e,t){return ac([n.apply([a]),us([a]),n.apply([2*a])])}}).className="CustomInit",t)}else e=this.biasInitializer;this.bias=this.addWeight("bias",[4*this.filters],null,e,this.biasRegularizer,!0,this.biasConstraint)}this.built=!0}call(e,t){return wn((()=>{if(3!==e.length)throw new il(`ConvLSTM2DCell expects 3 input Tensors (inputs, h, c), got ${e.length}.`);const n=t.training||!1,a=e[0],i=e[1],s=e[2];0<this.dropout&&this.dropout<1&&null==this.dropoutMask&&(this.dropoutMask=qd({ones:()=>fs(a),rate:this.dropout,training:n,count:4,dropoutFunc:this.dropoutFunc}));const r=this.dropoutMask,o=(e,t,n)=>t&&t[n]?Ta(t[n],e):e;let l=o(a,r,0),c=o(a,r,1),u=o(a,r,2),h=o(a,r,3);0<this.recurrentDropout&&this.recurrentDropout<1&&null==this.recurrentDropoutMask&&(this.recurrentDropoutMask=qd({ones:()=>fs(i),rate:this.recurrentDropout,training:n,count:4,dropoutFunc:this.dropoutFunc}));const p=this.recurrentDropoutMask;let d=o(i,p,0),f=o(i,p,1),m=o(i,p,2),g=o(i,p,3);const[v,y,b,w]=lr(this.kernel.read(),4,3),[k,x,S,N]=this.useBias?lr(this.bias.read(),4):[null,null,null,null];l=this.inputConv(l,v,k,this.padding),c=this.inputConv(c,y,x,this.padding),u=this.inputConv(u,b,S,this.padding),h=this.inputConv(h,w,N,this.padding);const[T,I,C,$]=lr(this.recurrentKernel.read(),4,3);d=this.recurrentConv(d,T),f=this.recurrentConv(f,I),m=this.recurrentConv(m,C),g=this.recurrentConv(g,$);const A=this.recurrentActivation.apply(xa(l,d)),E=this.recurrentActivation.apply(xa(c,f)),j=xa(Ta(E,s),Ta(A,this.activation.apply(xa(u,m)))),z=Ta(this.recurrentActivation.apply(xa(h,g)),this.activation.apply(j));return[z,z,j]}))}getConfig(){const e=super.getConfig(),t=Hd(e,["units"]),n={filters:this.filters,kernelSize:this.kernelSize,padding:this.padding,dataFormat:this.dataFormat,dilationRate:this.dilationRate,strides:this.strides};return Object.assign(Object.assign({},t),n)}inputConv(e,t,n,a){const i=ri(e,t,this.strides,a||"valid","channelsFirst"===this.dataFormat?"NCHW":"NHWC",this.dilationRate);return n?hc(i,n,this.dataFormat):i}recurrentConv(e,t){return ri(e,t,1,"same","channelsFirst"===this.dataFormat?"NCHW":"NHWC")}}Zd.className="ConvLSTM2DCell",ka(Zd);class Yd extends Jd{constructor(e){const t=new Zd(e);super(Object.assign(Object.assign({},e),{cell:t}))}static fromConfig(e,t){return new e(t)}}Yd.className="ConvLSTM2D",ka(Yd);
4506
4506
  /**
4507
4507
  * @license
4508
4508
  * Copyright 2018 Google LLC
@@ -4512,7 +4512,7 @@ function Rd(e,t,n,a){if(Array.isArray(e)){if(null!=t||null!=n)throw new il("When
4512
4512
  * https://opensource.org/licenses/MIT.
4513
4513
  * =============================================================================
4514
4514
  */
4515
- class Qd extends Zc{constructor(e){super(e),this.rate=Math.max(Math.min(e.rate,1),0),this.noiseShape=e.noiseShape,this.seed=e.seed,this.supportsMasking=!0}getNoiseShape(e){if(null==this.noiseShape)return this.noiseShape;const t=e.shape,n=[];for(let e=0;e<this.noiseShape.length;++e)n.push(null==this.noiseShape[e]?t[e]:this.noiseShape[e]);return n}call(e,t){return wn((()=>{this.invokeCallHook(e,t);const n=Mc(e);if(0<this.rate&&this.rate<1){const e=null!=t.training&&t.training,a=this.getNoiseShape(n);return dc((()=>pc(n,this.rate,a,this.seed)),(()=>n),e)}return e}))}getConfig(){const e={rate:this.rate,noiseShape:this.noiseShape,seed:this.seed},t=super.getConfig();return Object.assign(e,t),e}dispose(){return super.dispose()}}Qd.className="Dropout",ka(Qd);class Xd extends Qd{constructor(e){super(e),this.inputSpec=[{ndim:3}]}getNoiseShape(e){const t=e.shape;return[t[0],1,t[2]]}}Xd.className="SpatialDropout1D",ka(Xd);class ef extends Zc{constructor(e){if(super(e),this.activation=null,this.useBias=!0,this.kernel=null,this.bias=null,this.DEFAULT_KERNEL_INITIALIZER="glorotNormal",this.DEFAULT_BIAS_INITIALIZER="zeros",null==e.batchInputShape&&null==e.inputShape&&null!=e.inputDim){let t=null;null!=e.batchSize&&(t=e.batchSize),this.batchInputShape=[t,e.inputDim]}this.units=e.units,Nl(this.units,"units"),this.activation=sd(e.activation),null!=e.useBias&&(this.useBias=e.useBias),this.kernelInitializer=_c(e.kernelInitializer||this.DEFAULT_KERNEL_INITIALIZER),this.biasInitializer=_c(e.biasInitializer||this.DEFAULT_BIAS_INITIALIZER),this.kernelConstraint=Ah(e.kernelConstraint),this.biasConstraint=Ah(e.biasConstraint),this.kernelRegularizer=hd(e.kernelRegularizer),this.biasRegularizer=hd(e.biasRegularizer),this.activityRegularizer=hd(e.activityRegularizer),this.supportsMasking=!0,this.inputSpec=[{minNDim:2}]}build(e){const t=(e=Oc(e))[e.length-1];null==this.kernel&&(this.kernel=this.addWeight("kernel",[t,this.units],null,this.kernelInitializer,this.kernelRegularizer,!0,this.kernelConstraint),this.useBias&&(this.bias=this.addWeight("bias",[this.units],null,this.biasInitializer,this.biasRegularizer,!0,this.biasConstraint))),this.inputSpec=[{minNDim:2,axes:{[-1]:t}}],this.built=!0}computeOutputShape(e){const t=(e=Oc(e)).slice();return t[t.length-1]=this.units,t}call(e,t){return wn((()=>{this.invokeCallHook(e,t);const n=Mc(e),a=Il(this.activation.getClassName());let i;return null!=a?i=oc(n,this.kernel.read(),a,this.bias?this.bias.read():null):(i=oc(n,this.kernel.read()),null!=this.bias&&(i=hc(i,this.bias.read())),null!=this.activation&&(i=this.activation.apply(i))),i}))}getConfig(){const e={units:this.units,activation:ad(this.activation),useBias:this.useBias,kernelInitializer:Fc(this.kernelInitializer),biasInitializer:Fc(this.biasInitializer),kernelRegularizer:cd(this.kernelRegularizer),biasRegularizer:cd(this.biasRegularizer),activityRegularizer:cd(this.activityRegularizer),kernelConstraint:$h(this.kernelConstraint),biasConstraint:$h(this.biasConstraint)},t=super.getConfig();return Object.assign(e,t),e}}ef.className="Dense",ka(ef);class tf extends Zc{constructor(e){super(e=e||{}),this.inputSpec=[{minNDim:3}],this.dataFormat=e.dataFormat}computeOutputShape(e){e=Oc(e);for(const t of e.slice(1))if(null==t)throw new il(`The shape of the input to "Flatten" is not fully defined (got ${e.slice(1)}). Make sure to pass a complete "input_shape" or "batch_input_shape" argument to the first layer in your model.`);return[e[0],Kl(e,1)]}call(e,t){return wn((()=>{this.invokeCallHook(e,t);let n=Mc(e);if("channelsFirst"===this.dataFormat&&n.rank>1){const e=[0];for(let t=2;t<n.rank;++t)e.push(t);e.push(1),n=pa(n,e)}return function(e){if(e.rank<=1)throw new il(`batchFlatten requires a minimum rank of 2. Got rank: ${e.rank}.`);const t=[e.shape[0],Kl(e.shape,1)];return Ma(e,t)}(n)}))}getConfig(){const e={};null!=this.dataFormat&&(e.dataFormat=this.dataFormat);const t=super.getConfig();return Object.assign(e,t),e}}tf.className="Flatten",ka(tf);class nf extends Zc{constructor(e){super(e),this.supportsMasking=!0,this.activation=sd(e.activation)}call(e,t){return wn((()=>{this.invokeCallHook(e,t);const n=Mc(e);return this.activation.apply(n)}))}getConfig(){const e={activation:ad(this.activation)},t=super.getConfig();return Object.assign(e,t),e}}nf.className="Activation",ka(nf);class af extends Zc{constructor(e){super(e),this.n=e.n,this.inputSpec=[{ndim:2}]}computeOutputShape(e){return[e[0],this.n,e[1]]}call(e,t){return wn((()=>{return e=Mc(e),t=e,n=this.n,wn((()=>{if(2!==t.shape.length)throw new il(`repeat() expects a rank-2 tensor, but received a rank-${t.shape.length} tensor.`);return sc(Xl(t,1),[1,n,1])}));var t,n}))}getConfig(){const e={n:this.n},t=super.getConfig();return Object.assign(e,t),e}}af.className="RepeatVector",ka(af);class sf extends Zc{constructor(e){super(e),this.targetShape=e.targetShape;for(let e=0;e<this.targetShape.length;++e)this.isUnknown(this.targetShape[e])&&(this.targetShape[e]=null)}isUnknown(e){return e<0||null==e}fixUnknownDimension(e,t){const n="Total size of new array must be unchanged.",a=t.slice();let i=1,s=null;for(let e=0;e<a.length;++e){const t=a[e];if(this.isUnknown(t)){if(null!==s)throw new il("Can only specifiy one unknown dimension.");s=e}else i*=t}const r=Kl(e);if(null!==s){if(0===i||r%i!=0)throw new il(n);a[s]=r/i}else if(r!==i)throw new il(n);return a}computeOutputShape(e){let t=!1;for(let n=0;n<e.length;++n)if(this.isUnknown(e[n])){t=!0;break}return t?e.slice(0,1).concat(this.targetShape):e.slice(0,1).concat(this.fixUnknownDimension(e.slice(1),this.targetShape))}call(e,t){return wn((()=>{this.invokeCallHook(e,t);const n=Mc(e),a=n.shape,i=a.slice(0,1).concat(this.fixUnknownDimension(a.slice(1),this.targetShape));return Ma(n,i)}))}getConfig(){const e={targetShape:this.targetShape},t=super.getConfig();return Object.assign(e,t),e}}sf.className="Reshape",ka(sf);class rf extends Zc{constructor(e){if(super(e),null==e.dims)throw new Error("Required configuration field `dims` is missing during Permute constructor call.");if(!Array.isArray(e.dims))throw new Error(`Permute constructor requires \`dims\` to be an Array, but received ${e.dims} instead.`);const t=Jl(1,e.dims.length+1);if(!T(e.dims.slice().sort(),t))throw new Error("Invalid permutation `dims`: "+JSON.stringify(e.dims)+" `dims` must contain consecutive integers starting from 1.");this.dims=e.dims,this.dimsIncludingBatch=[0].concat(this.dims),this.inputSpec=[new Vc({ndim:this.dims.length+1})]}computeOutputShape(e){const t=(e=Oc(e)).slice();return this.dims.forEach(((n,a)=>{t[a+1]=e[n]})),t}call(e,t){return pa(Mc(e),this.dimsIncludingBatch)}getConfig(){const e={dims:this.dims},t=super.getConfig();return Object.assign(e,t),e}}rf.className="Permute",ka(rf);class of extends Zc{constructor(e){super(null==e?{}:e),this.supportsMasking=!0,this.maskValue=null!=e?null==e.maskValue?0:e.maskValue:0}computeOutputShape(e){return e}getConfig(){const e=super.getConfig(),t={maskValue:this.maskValue};return Object.assign(t,e),t}computeMask(e,t){const n=Mc(e);return Ca(ds(n,this.maskValue),-1)}call(e,t){return wn((()=>{this.invokeCallHook(e,t);const n=Mc(e),a=Ca(ds(n,this.maskValue),-1,!0);return Ta(n,ra(a,n.dtype))}))}}of.className="Masking",ka(of);
4515
+ class Qd extends Zc{constructor(e){super(e),this.rate=Math.max(Math.min(e.rate,1),0),this.noiseShape=e.noiseShape,this.seed=e.seed,this.supportsMasking=!0}getNoiseShape(e){if(null==this.noiseShape)return this.noiseShape;const t=e.shape,n=[];for(let e=0;e<this.noiseShape.length;++e)n.push(null==this.noiseShape[e]?t[e]:this.noiseShape[e]);return n}call(e,t){return wn((()=>{this.invokeCallHook(e,t);const n=Mc(e);if(0<this.rate&&this.rate<1){const e=null!=t.training&&t.training,a=this.getNoiseShape(n);return dc((()=>pc(n,this.rate,a,this.seed)),(()=>n),e)}return e}))}getConfig(){const e={rate:this.rate,noiseShape:this.noiseShape,seed:this.seed},t=super.getConfig();return Object.assign(e,t),e}dispose(){return super.dispose()}}Qd.className="Dropout",ka(Qd);class Xd extends Qd{constructor(e){super(e),this.inputSpec=[{ndim:3}]}getNoiseShape(e){const t=e.shape;return[t[0],1,t[2]]}}Xd.className="SpatialDropout1D",ka(Xd);class ef extends Zc{constructor(e){if(super(e),this.activation=null,this.useBias=!0,this.kernel=null,this.bias=null,this.DEFAULT_KERNEL_INITIALIZER="glorotNormal",this.DEFAULT_BIAS_INITIALIZER="zeros",null==e.batchInputShape&&null==e.inputShape&&null!=e.inputDim){let t=null;null!=e.batchSize&&(t=e.batchSize),this.batchInputShape=[t,e.inputDim]}this.units=e.units,Nl(this.units,"units"),this.activation=sd(e.activation),null!=e.useBias&&(this.useBias=e.useBias),this.kernelInitializer=_c(e.kernelInitializer||this.DEFAULT_KERNEL_INITIALIZER),this.biasInitializer=_c(e.biasInitializer||this.DEFAULT_BIAS_INITIALIZER),this.kernelConstraint=Ah(e.kernelConstraint),this.biasConstraint=Ah(e.biasConstraint),this.kernelRegularizer=hd(e.kernelRegularizer),this.biasRegularizer=hd(e.biasRegularizer),this.activityRegularizer=hd(e.activityRegularizer),this.supportsMasking=!0,this.inputSpec=[{minNDim:2}]}build(e){const t=(e=Oc(e))[e.length-1];null==this.kernel&&(this.kernel=this.addWeight("kernel",[t,this.units],null,this.kernelInitializer,this.kernelRegularizer,!0,this.kernelConstraint),this.useBias&&(this.bias=this.addWeight("bias",[this.units],null,this.biasInitializer,this.biasRegularizer,!0,this.biasConstraint))),this.inputSpec=[{minNDim:2,axes:{[-1]:t}}],this.built=!0}computeOutputShape(e){const t=(e=Oc(e)).slice();return t[t.length-1]=this.units,t}call(e,t){return wn((()=>{this.invokeCallHook(e,t);const n=Mc(e),a=Il(this.activation.getClassName());let i;return null!=a?i=oc(n,this.kernel.read(),a,this.bias?this.bias.read():null):(i=oc(n,this.kernel.read()),null!=this.bias&&(i=hc(i,this.bias.read())),null!=this.activation&&(i=this.activation.apply(i))),i}))}getConfig(){const e={units:this.units,activation:ad(this.activation),useBias:this.useBias,kernelInitializer:Fc(this.kernelInitializer),biasInitializer:Fc(this.biasInitializer),kernelRegularizer:cd(this.kernelRegularizer),biasRegularizer:cd(this.biasRegularizer),activityRegularizer:cd(this.activityRegularizer),kernelConstraint:Ch(this.kernelConstraint),biasConstraint:Ch(this.biasConstraint)},t=super.getConfig();return Object.assign(e,t),e}}ef.className="Dense",ka(ef);class tf extends Zc{constructor(e){super(e=e||{}),this.inputSpec=[{minNDim:3}],this.dataFormat=e.dataFormat}computeOutputShape(e){e=Oc(e);for(const t of e.slice(1))if(null==t)throw new il(`The shape of the input to "Flatten" is not fully defined (got ${e.slice(1)}). Make sure to pass a complete "input_shape" or "batch_input_shape" argument to the first layer in your model.`);return[e[0],Kl(e,1)]}call(e,t){return wn((()=>{this.invokeCallHook(e,t);let n=Mc(e);if("channelsFirst"===this.dataFormat&&n.rank>1){const e=[0];for(let t=2;t<n.rank;++t)e.push(t);e.push(1),n=pa(n,e)}return function(e){if(e.rank<=1)throw new il(`batchFlatten requires a minimum rank of 2. Got rank: ${e.rank}.`);const t=[e.shape[0],Kl(e.shape,1)];return Ma(e,t)}(n)}))}getConfig(){const e={};null!=this.dataFormat&&(e.dataFormat=this.dataFormat);const t=super.getConfig();return Object.assign(e,t),e}}tf.className="Flatten",ka(tf);class nf extends Zc{constructor(e){super(e),this.supportsMasking=!0,this.activation=sd(e.activation)}call(e,t){return wn((()=>{this.invokeCallHook(e,t);const n=Mc(e);return this.activation.apply(n)}))}getConfig(){const e={activation:ad(this.activation)},t=super.getConfig();return Object.assign(e,t),e}}nf.className="Activation",ka(nf);class af extends Zc{constructor(e){super(e),this.n=e.n,this.inputSpec=[{ndim:2}]}computeOutputShape(e){return[e[0],this.n,e[1]]}call(e,t){return wn((()=>{return e=Mc(e),t=e,n=this.n,wn((()=>{if(2!==t.shape.length)throw new il(`repeat() expects a rank-2 tensor, but received a rank-${t.shape.length} tensor.`);return sc(Xl(t,1),[1,n,1])}));var t,n}))}getConfig(){const e={n:this.n},t=super.getConfig();return Object.assign(e,t),e}}af.className="RepeatVector",ka(af);class sf extends Zc{constructor(e){super(e),this.targetShape=e.targetShape;for(let e=0;e<this.targetShape.length;++e)this.isUnknown(this.targetShape[e])&&(this.targetShape[e]=null)}isUnknown(e){return e<0||null==e}fixUnknownDimension(e,t){const n="Total size of new array must be unchanged.",a=t.slice();let i=1,s=null;for(let e=0;e<a.length;++e){const t=a[e];if(this.isUnknown(t)){if(null!==s)throw new il("Can only specifiy one unknown dimension.");s=e}else i*=t}const r=Kl(e);if(null!==s){if(0===i||r%i!=0)throw new il(n);a[s]=r/i}else if(r!==i)throw new il(n);return a}computeOutputShape(e){let t=!1;for(let n=0;n<e.length;++n)if(this.isUnknown(e[n])){t=!0;break}return t?e.slice(0,1).concat(this.targetShape):e.slice(0,1).concat(this.fixUnknownDimension(e.slice(1),this.targetShape))}call(e,t){return wn((()=>{this.invokeCallHook(e,t);const n=Mc(e),a=n.shape,i=a.slice(0,1).concat(this.fixUnknownDimension(a.slice(1),this.targetShape));return Ma(n,i)}))}getConfig(){const e={targetShape:this.targetShape},t=super.getConfig();return Object.assign(e,t),e}}sf.className="Reshape",ka(sf);class rf extends Zc{constructor(e){if(super(e),null==e.dims)throw new Error("Required configuration field `dims` is missing during Permute constructor call.");if(!Array.isArray(e.dims))throw new Error(`Permute constructor requires \`dims\` to be an Array, but received ${e.dims} instead.`);const t=Jl(1,e.dims.length+1);if(!T(e.dims.slice().sort(),t))throw new Error("Invalid permutation `dims`: "+JSON.stringify(e.dims)+" `dims` must contain consecutive integers starting from 1.");this.dims=e.dims,this.dimsIncludingBatch=[0].concat(this.dims),this.inputSpec=[new Vc({ndim:this.dims.length+1})]}computeOutputShape(e){const t=(e=Oc(e)).slice();return this.dims.forEach(((n,a)=>{t[a+1]=e[n]})),t}call(e,t){return pa(Mc(e),this.dimsIncludingBatch)}getConfig(){const e={dims:this.dims},t=super.getConfig();return Object.assign(e,t),e}}rf.className="Permute",ka(rf);class of extends Zc{constructor(e){super(null==e?{}:e),this.supportsMasking=!0,this.maskValue=null!=e?null==e.maskValue?0:e.maskValue:0}computeOutputShape(e){return e}getConfig(){const e=super.getConfig(),t={maskValue:this.maskValue};return Object.assign(t,e),t}computeMask(e,t){const n=Mc(e);return $a(ds(n,this.maskValue),-1)}call(e,t){return wn((()=>{this.invokeCallHook(e,t);const n=Mc(e),a=$a(ds(n,this.maskValue),-1,!0);return Ta(n,ra(a,n.dtype))}))}}of.className="Masking",ka(of);
4516
4516
  /**
4517
4517
  * @license
4518
4518
  * Copyright 2018 Google LLC
@@ -4522,7 +4522,7 @@ class Qd extends Zc{constructor(e){super(e),this.rate=Math.max(Math.min(e.rate,1
4522
4522
  * https://opensource.org/licenses/MIT.
4523
4523
  * =============================================================================
4524
4524
  */
4525
- class lf extends Zc{constructor(e){if(super(e),this.embeddings=null,this.DEFAULT_EMBEDDINGS_INITIALIZER="randomUniform",null==e.batchInputShape&&null==e.inputShape){let t=null;null!=e.batchSize&&(t=e.batchSize),null==e.inputLength?this.batchInputShape=[t,null]:this.batchInputShape=[t].concat(pl(e.inputLength))}this.inputDim=e.inputDim,Nl(this.inputDim,"inputDim"),this.outputDim=e.outputDim,Nl(this.outputDim,"outputDim"),this.embeddingsInitializer=_c(e.embeddingsInitializer||this.DEFAULT_EMBEDDINGS_INITIALIZER),this.embeddingsRegularizer=hd(e.embeddingsRegularizer),this.activityRegularizer=hd(e.activityRegularizer),this.embeddingsConstraint=Ah(e.embeddingsConstraint),this.maskZero=e.maskZero,this.supportsMasking=e.maskZero,this.inputLength=e.inputLength}build(e){this.embeddings=this.addWeight("embeddings",[this.inputDim,this.outputDim],this.dtype,this.embeddingsInitializer,this.embeddingsRegularizer,!0,this.embeddingsConstraint),this.built=!0}warnOnIncompatibleInputShape(e){}computeMask(e,t){return wn((()=>this.maskZero?(e=Mc(e),ds(e,ki(e))):null))}computeOutputShape(e){if(e=Oc(e),null==this.inputLength)return[...e,this.outputDim];const t=pl(this.inputLength);if(t.length!==e.length-1)throw new il(`"inputLength" is ${this.inputLength}, but received input shape has shape ${e}`);{let n=0;for(let a=0;a<t.length;++a){const i=t[a],s=e[a+1];if(null!=i&&null!=s&&i!==s)throw new il(`"inputLength" is ${this.inputLength}, but received input shape has shape ${e}`);null==i&&(t[n]=s),n++}}return[e[0],...t,this.outputDim]}call(e,t){return wn((()=>{this.invokeCallHook(e,t);let n=Mc(e);"int32"!==n.dtype&&(n=Ql(n,"int32"));const a=lc(this.embeddings.read(),Ma(n,[n.size]));return Ma(a,Oc(this.computeOutputShape(n.shape)))}))}getConfig(){const e={inputDim:this.inputDim,outputDim:this.outputDim,embeddingsInitializer:Fc(this.embeddingsInitializer),embeddingsRegularizer:cd(this.embeddingsRegularizer),activityRegularizer:cd(this.activityRegularizer),embeddingsConstraint:$h(this.embeddingsConstraint),maskZero:this.maskZero,inputLength:this.inputLength},t=super.getConfig();return Object.assign(e,t),e}}lf.className="Embedding",ka(lf);
4525
+ class lf extends Zc{constructor(e){if(super(e),this.embeddings=null,this.DEFAULT_EMBEDDINGS_INITIALIZER="randomUniform",null==e.batchInputShape&&null==e.inputShape){let t=null;null!=e.batchSize&&(t=e.batchSize),null==e.inputLength?this.batchInputShape=[t,null]:this.batchInputShape=[t].concat(pl(e.inputLength))}this.inputDim=e.inputDim,Nl(this.inputDim,"inputDim"),this.outputDim=e.outputDim,Nl(this.outputDim,"outputDim"),this.embeddingsInitializer=_c(e.embeddingsInitializer||this.DEFAULT_EMBEDDINGS_INITIALIZER),this.embeddingsRegularizer=hd(e.embeddingsRegularizer),this.activityRegularizer=hd(e.activityRegularizer),this.embeddingsConstraint=Ah(e.embeddingsConstraint),this.maskZero=e.maskZero,this.supportsMasking=e.maskZero,this.inputLength=e.inputLength}build(e){this.embeddings=this.addWeight("embeddings",[this.inputDim,this.outputDim],this.dtype,this.embeddingsInitializer,this.embeddingsRegularizer,!0,this.embeddingsConstraint),this.built=!0}warnOnIncompatibleInputShape(e){}computeMask(e,t){return wn((()=>this.maskZero?(e=Mc(e),ds(e,ki(e))):null))}computeOutputShape(e){if(e=Oc(e),null==this.inputLength)return[...e,this.outputDim];const t=pl(this.inputLength);if(t.length!==e.length-1)throw new il(`"inputLength" is ${this.inputLength}, but received input shape has shape ${e}`);{let n=0;for(let a=0;a<t.length;++a){const i=t[a],s=e[a+1];if(null!=i&&null!=s&&i!==s)throw new il(`"inputLength" is ${this.inputLength}, but received input shape has shape ${e}`);null==i&&(t[n]=s),n++}}return[e[0],...t,this.outputDim]}call(e,t){return wn((()=>{this.invokeCallHook(e,t);let n=Mc(e);"int32"!==n.dtype&&(n=Ql(n,"int32"));const a=lc(this.embeddings.read(),Ma(n,[n.size]));return Ma(a,Oc(this.computeOutputShape(n.shape)))}))}getConfig(){const e={inputDim:this.inputDim,outputDim:this.outputDim,embeddingsInitializer:Fc(this.embeddingsInitializer),embeddingsRegularizer:cd(this.embeddingsRegularizer),activityRegularizer:cd(this.activityRegularizer),embeddingsConstraint:Ch(this.embeddingsConstraint),maskZero:this.maskZero,inputLength:this.inputLength},t=super.getConfig();return Object.assign(e,t),e}}lf.className="Embedding",ka(lf);
4526
4526
  /**
4527
4527
  * @license
4528
4528
  * Copyright 2018 Google LLC
@@ -4532,7 +4532,7 @@ class lf extends Zc{constructor(e){if(super(e),this.embeddings=null,this.DEFAULT
4532
4532
  * https://opensource.org/licenses/MIT.
4533
4533
  * =============================================================================
4534
4534
  */
4535
- class cf extends Zc{constructor(e){super(e||{}),this.supportsMasking=!0}mergeFunction(e){throw new sl}computeElementwiseOpOutputShape(e,t){if(null==e||null==t)return null;if(e.length<t.length)return this.computeElementwiseOpOutputShape(t,e);if(0===t.length)return e;const n=e.slice(0,e.length-t.length);for(let a=0;a<t.length;++a){const i=e[e.length-t.length+a],s=t[a];if(null==i||null==s||i<0||s<0)n.push(null);else if(1===i)n.push(s);else if(1===s)n.push(i);else{if(i!==s)throw new il("Operands could not be broadcast together with shapes "+JSON.stringify(e)+" "+JSON.stringify(t));n.push(i)}}return n}build(e){if(Array.isArray(e)&&!Array.isArray(e[0])&&(e=[Oc(e)]),e.length<2)throw new il(`A merge layer should be called on an Array of at least 2 inputs. Got ${e.length} input(s).`);let t=[];for(const n of e)null!=n&&null!==n[0]&&t.push(n[0]);if(t=wl(t),t.length>1)throw new il(`Can not merge tensors with different batch sizes. Got tensors with shapes: ${JSON.stringify(e)}.`);let n=null==e[0]?null:e[0].slice(1);for(let t=1;t<e.length;++t){const a=null==e[t]?null:e[t].slice(1);n=this.computeElementwiseOpOutputShape(n,a)}const a=e.map((e=>e.length));-1===e.indexOf(null)&&1===wl(a).length?this.reshapeRequired=!1:this.reshapeRequired=!0}call(e,t){return wn((()=>{if(this.reshapeRequired){const t=[],n=e.map((e=>e.rank));if(-1===n.indexOf(null)){const a=Hl(n);for(let n of e){const e=n.rank;for(let t=0;t<a-e;++t)n=Xl(n,1);t.push(n)}return this.mergeFunction(t)}{let n=!1;for(const a of e){const e=a.rank;if(null==e){const e=a.shape,i=e[0],s=e.slice(1).concat([i]);let r=Ma(a,[i].concat(Kl(e.slice(1))));r=pa(r,[1,0]),r=Ma(r,s),t.push(r),n=!0}else if(e>1){const i=Jl(1,e).concat([0]);t.push(pa(a,i)),n=!0}else t.push(a)}let a=this.mergeFunction(t);const i=a.rank;if(n)if(null==i){const e=a.shape,t=e[e.length-1],n=[t].concat(e.slice(0,e.length-1));a=Ma(pa(Ma(a,[-1,t]),[1,0]),n)}else if(i>1){const e=[i-1].concat(Jl(0,i-1));a=pa(a,e)}return a}}return this.mergeFunction(e)}))}computeOutputShape(e){let t;t=null==e[0]?null:e[0].slice(1);for(let n=1;n<e.length;++n){const a=null==e[n]?null:e[n].slice(1);t=this.computeElementwiseOpOutputShape(t,a)}let n=[];for(const t of e)null!=t&&null!==t[0]&&n.push(t[0]);return n=wl(n),t=1===n.length?n.concat(t):[null].concat(t),t}computeMask(e,t){return wn((()=>{if(null==t)return null;if(!Array.isArray(t))throw new il("`mask` should be an Array");if(!Array.isArray(e))throw new il("`inputs` should be an Array");if(t.length!==e.length)throw new il(`The Array 'inputs' and 'mask' are expected to have the same length, but have different lengths (${e.length} vs ${t.length})`);if(t.every((e=>null==e)))return null;let n=(t=t.map((e=>null==e?e:Pi(e,0))))[0];for(let e=1;e<t.length-1;++e)n=as(n,t[e]);return n}))}}class uf extends cf{constructor(e){super(e)}mergeFunction(e){return wn((()=>{let t=e[0].clone();for(let n=1;n<e.length;++n)t=xa(t,e[n]);return t}))}}uf.className="Add",ka(uf);class hf extends cf{constructor(e){super(e)}mergeFunction(e){return wn((()=>{let t=e[0].clone();for(let n=1;n<e.length;++n)t=Ta(t,e[n]);return t}))}}hf.className="Multiply",ka(hf);class pf extends cf{constructor(e){super(e)}mergeFunction(e){return wn((()=>{let t=e[0].clone();for(let n=1;n<e.length;++n)t=xa(t,e[n]);return Ta(1/e.length,t)}))}}pf.className="Average",ka(pf);class df extends cf{constructor(e){super(e)}mergeFunction(e){return wn((()=>{let t=e[0];for(let n=1;n<e.length;++n)t=os(t,e[n]);return t}))}}df.className="Maximum",ka(df);class ff extends cf{constructor(e){super(e)}mergeFunction(e){return wn((()=>{let t=e[0];for(let n=1;n<e.length;++n)t=hs(t,e[n]);return t}))}}ff.className="Minimum",ka(ff);class mf extends cf{constructor(e){super(e),this.DEFAULT_AXIS=-1,null==e&&(e={}),this.axis=null==e.axis?this.DEFAULT_AXIS:e.axis,this.supportsMasking=!0,this.reshapeRequired=!1}build(e){if(!Array.isArray(e)||!Array.isArray(e[0])||1===e.length)throw new il("A `Concatenate` layer should be called on a list of at least 2 inputs");let t=!0;for(const n of e)if(null!=n){t=!1;break}if(t)return;const n=[];for(let t=0;t<e.length;++t){const a=e[t].slice();a.splice(this.axis,1);let i=!1;for(const e of n)if(T(e,a)){i=!0;break}i||n.push(a)}if(n.length>1)throw new il("A `Concatenate` layer requires inputs with matching shapes except for the concat axis. Got input shapes: "+JSON.stringify(e))}mergeFunction(e){return wn((()=>ac(e,this.axis)))}computeOutputShape(e){if(!Array.isArray(e)||!Array.isArray(e[0]))throw new il("A `Concatenate` layer should be called on a list of inputs.");const t=e,n=t[0].slice(),a=this.axis<0?n.length+this.axis:this.axis;for(const e of t.slice(1)){if(null==n[a]||null==e[a]){n[a]=null;break}n[a]+=e[a]}return n}computeMask(e,t){if(null==t)return null;if(!Array.isArray(t))throw new il("`mask` should be an array for Concatenate");if(!Array.isArray(e))throw new il("`inputs` should be an array for Concatenate");if(t.length!==e.length)throw new il(`Mismatch in the length of mask (${t.length}) and the legnth of inputs (${e.length})`);return wn((()=>{let n=!0;if(t.forEach((e=>{null==e||(n=!1)})),n)return null;const a=[];for(let n=0;n<e.length;++n)null==t[n]?a.push(ra(fs(e[n]),"bool")):t[n].rank<e[n].rank?a.push(Pi(t[n],-1)):a.push(t[n]);const i=Ua(a,this.axis);return $a(i,-1,!1)}))}getConfig(){const e={axis:this.axis},t=super.getConfig();return Object.assign(e,t),e}}function gf(e,t){for(;e<0;)e+=t;return e}mf.className="Concatenate",ka(mf);class vf extends cf{constructor(e){super(e),this.axes=e.axes,this.normalize=null!=e.normalize&&e.normalize,this.supportsMasking=!0,this.reshapeRequired=!1}build(e){x(Array.isArray(e)&&2===e.length&&Array.isArray(e[0])&&Array.isArray(e[1]),(()=>"A `Dot` layer should be called on a list of exactly 2 inputs."));const t=e[0],n=e[1];if(t.length>3||n.length>3)throw new sl("Dot layer does not support tensors of 4D or higher rank yet.");const a=this.interpretAxes(t,n);if(t[a[0]]!==n[a[1]])throw new il(`Dimension incompatibility: ${t[a[0]]} !== ${n[a[1]]}`)}mergeFunction(e){if(2!==e.length)throw new il(`A \`Dot\` layer must be called on exactly 2 inputs, but received ${e.length} input(s).`);let t,n=e[0],a=e[1];return t=Array.isArray(this.axes)?this.axes.map(((t,n)=>gf(t,e[n].shape.length))):[gf(this.axes,n.shape.length),gf(this.axes,a.shape.length)],this.normalize&&(n=Uh(n,t[0]),a=Uh(a,t[1])),function(e,t,n){if(e.shape.length>3||t.shape.length>3)throw new sl("batchDot is not implemented for tensors of 4D or higher rank yet");if(x(e.shape.length>=2,(()=>`batchDot requires the rank of x to be >= 2, but got ${e.shape.length}`)),x(e.shape.length>=2,(()=>`batchDot requires the rank of y to be >= 2, but got ${t.shape.length}`)),"number"==typeof n&&(n=[n,n]),"complex64"===e.dtype||"complex64"===t.dtype)throw new sl("batchDot is not implemented for complex64-type Tensors yet.");const a=e.shape.length,i=t.shape.length;null==n&&(n=[a-1,i-2]);const s=n;return wn((()=>{let n,r;if(a>i){n=a-i;const e=[];for(let t=0;t<n;++t)e.push(1);t=Ma(t,t.shape.concat(e))}else if(i>a){n=i-a;const t=[];for(let e=0;e<n;++e)t.push(1);e=Ma(e,e.shape.concat(t))}else n=0;if(2===e.shape.length&&2===t.shape.length)r=s[0]===s[1]?Ri(Ta(e,t),s[0]):Ri(Ta(pa(e,[1,0]),t),s[1]);else{const n=s[0]!==e.shape.length-1,a=s[1]===t.shape.length-1;r=oa(e,t,n,a)}if(n>0){let e;e=a>i?a+i-3:a-1;const t=[];for(let a=e;a<e+n;++a)t.push(a);r=cr(r,t)}return 1===r.shape.length&&(r=Pi(r,1)),r}))}(n,a,t)}interpretAxes(e,t){let n;return n=Array.isArray(this.axes)?this.axes:[gf(this.axes,e.length),gf(this.axes,t.length)],n}computeOutputShape(e){x(Array.isArray(e)&&2===e.length&&Array.isArray(e[0])&&Array.isArray(e[1]),(()=>"A `Dot` layer should be called on a list of exactly 2 inputs."));const t=e[0].slice(),n=e[1].slice();if(t.length>3||n.length>3)throw new sl("Dot layer does not support tensors of 4D or higher rank yet.");const a=this.interpretAxes(t,n);t.splice(a[0],1),n.splice(a[1],1),n.splice(0,1);const i=t.concat(n);return 1===i.length&&i.push(1),i}computeMask(e,t){return null}getConfig(){const e={axes:this.axes,normalize:this.normalize},t=super.getConfig();return Object.assign(e,t),e}}vf.className="Dot",ka(vf);
4535
+ class cf extends Zc{constructor(e){super(e||{}),this.supportsMasking=!0}mergeFunction(e){throw new sl}computeElementwiseOpOutputShape(e,t){if(null==e||null==t)return null;if(e.length<t.length)return this.computeElementwiseOpOutputShape(t,e);if(0===t.length)return e;const n=e.slice(0,e.length-t.length);for(let a=0;a<t.length;++a){const i=e[e.length-t.length+a],s=t[a];if(null==i||null==s||i<0||s<0)n.push(null);else if(1===i)n.push(s);else if(1===s)n.push(i);else{if(i!==s)throw new il("Operands could not be broadcast together with shapes "+JSON.stringify(e)+" "+JSON.stringify(t));n.push(i)}}return n}build(e){if(Array.isArray(e)&&!Array.isArray(e[0])&&(e=[Oc(e)]),e.length<2)throw new il(`A merge layer should be called on an Array of at least 2 inputs. Got ${e.length} input(s).`);let t=[];for(const n of e)null!=n&&null!==n[0]&&t.push(n[0]);if(t=wl(t),t.length>1)throw new il(`Can not merge tensors with different batch sizes. Got tensors with shapes: ${JSON.stringify(e)}.`);let n=null==e[0]?null:e[0].slice(1);for(let t=1;t<e.length;++t){const a=null==e[t]?null:e[t].slice(1);n=this.computeElementwiseOpOutputShape(n,a)}const a=e.map((e=>e.length));-1===e.indexOf(null)&&1===wl(a).length?this.reshapeRequired=!1:this.reshapeRequired=!0}call(e,t){return wn((()=>{if(this.reshapeRequired){const t=[],n=e.map((e=>e.rank));if(-1===n.indexOf(null)){const a=Hl(n);for(let n of e){const e=n.rank;for(let t=0;t<a-e;++t)n=Xl(n,1);t.push(n)}return this.mergeFunction(t)}{let n=!1;for(const a of e){const e=a.rank;if(null==e){const e=a.shape,i=e[0],s=e.slice(1).concat([i]);let r=Ma(a,[i].concat(Kl(e.slice(1))));r=pa(r,[1,0]),r=Ma(r,s),t.push(r),n=!0}else if(e>1){const i=Jl(1,e).concat([0]);t.push(pa(a,i)),n=!0}else t.push(a)}let a=this.mergeFunction(t);const i=a.rank;if(n)if(null==i){const e=a.shape,t=e[e.length-1],n=[t].concat(e.slice(0,e.length-1));a=Ma(pa(Ma(a,[-1,t]),[1,0]),n)}else if(i>1){const e=[i-1].concat(Jl(0,i-1));a=pa(a,e)}return a}}return this.mergeFunction(e)}))}computeOutputShape(e){let t;t=null==e[0]?null:e[0].slice(1);for(let n=1;n<e.length;++n){const a=null==e[n]?null:e[n].slice(1);t=this.computeElementwiseOpOutputShape(t,a)}let n=[];for(const t of e)null!=t&&null!==t[0]&&n.push(t[0]);return n=wl(n),t=1===n.length?n.concat(t):[null].concat(t),t}computeMask(e,t){return wn((()=>{if(null==t)return null;if(!Array.isArray(t))throw new il("`mask` should be an Array");if(!Array.isArray(e))throw new il("`inputs` should be an Array");if(t.length!==e.length)throw new il(`The Array 'inputs' and 'mask' are expected to have the same length, but have different lengths (${e.length} vs ${t.length})`);if(t.every((e=>null==e)))return null;let n=(t=t.map((e=>null==e?e:Pi(e,0))))[0];for(let e=1;e<t.length-1;++e)n=as(n,t[e]);return n}))}}class uf extends cf{constructor(e){super(e)}mergeFunction(e){return wn((()=>{let t=e[0].clone();for(let n=1;n<e.length;++n)t=xa(t,e[n]);return t}))}}uf.className="Add",ka(uf);class hf extends cf{constructor(e){super(e)}mergeFunction(e){return wn((()=>{let t=e[0].clone();for(let n=1;n<e.length;++n)t=Ta(t,e[n]);return t}))}}hf.className="Multiply",ka(hf);class pf extends cf{constructor(e){super(e)}mergeFunction(e){return wn((()=>{let t=e[0].clone();for(let n=1;n<e.length;++n)t=xa(t,e[n]);return Ta(1/e.length,t)}))}}pf.className="Average",ka(pf);class df extends cf{constructor(e){super(e)}mergeFunction(e){return wn((()=>{let t=e[0];for(let n=1;n<e.length;++n)t=os(t,e[n]);return t}))}}df.className="Maximum",ka(df);class ff extends cf{constructor(e){super(e)}mergeFunction(e){return wn((()=>{let t=e[0];for(let n=1;n<e.length;++n)t=hs(t,e[n]);return t}))}}ff.className="Minimum",ka(ff);class mf extends cf{constructor(e){super(e),this.DEFAULT_AXIS=-1,null==e&&(e={}),this.axis=null==e.axis?this.DEFAULT_AXIS:e.axis,this.supportsMasking=!0,this.reshapeRequired=!1}build(e){if(!Array.isArray(e)||!Array.isArray(e[0])||1===e.length)throw new il("A `Concatenate` layer should be called on a list of at least 2 inputs");let t=!0;for(const n of e)if(null!=n){t=!1;break}if(t)return;const n=[];for(let t=0;t<e.length;++t){const a=e[t].slice();a.splice(this.axis,1);let i=!1;for(const e of n)if(T(e,a)){i=!0;break}i||n.push(a)}if(n.length>1)throw new il("A `Concatenate` layer requires inputs with matching shapes except for the concat axis. Got input shapes: "+JSON.stringify(e))}mergeFunction(e){return wn((()=>ac(e,this.axis)))}computeOutputShape(e){if(!Array.isArray(e)||!Array.isArray(e[0]))throw new il("A `Concatenate` layer should be called on a list of inputs.");const t=e,n=t[0].slice(),a=this.axis<0?n.length+this.axis:this.axis;for(const e of t.slice(1)){if(null==n[a]||null==e[a]){n[a]=null;break}n[a]+=e[a]}return n}computeMask(e,t){if(null==t)return null;if(!Array.isArray(t))throw new il("`mask` should be an array for Concatenate");if(!Array.isArray(e))throw new il("`inputs` should be an array for Concatenate");if(t.length!==e.length)throw new il(`Mismatch in the length of mask (${t.length}) and the legnth of inputs (${e.length})`);return wn((()=>{let n=!0;if(t.forEach((e=>{null==e||(n=!1)})),n)return null;const a=[];for(let n=0;n<e.length;++n)null==t[n]?a.push(ra(fs(e[n]),"bool")):t[n].rank<e[n].rank?a.push(Pi(t[n],-1)):a.push(t[n]);const i=Ua(a,this.axis);return Ca(i,-1,!1)}))}getConfig(){const e={axis:this.axis},t=super.getConfig();return Object.assign(e,t),e}}function gf(e,t){for(;e<0;)e+=t;return e}mf.className="Concatenate",ka(mf);class vf extends cf{constructor(e){super(e),this.axes=e.axes,this.normalize=null!=e.normalize&&e.normalize,this.supportsMasking=!0,this.reshapeRequired=!1}build(e){x(Array.isArray(e)&&2===e.length&&Array.isArray(e[0])&&Array.isArray(e[1]),(()=>"A `Dot` layer should be called on a list of exactly 2 inputs."));const t=e[0],n=e[1];if(t.length>3||n.length>3)throw new sl("Dot layer does not support tensors of 4D or higher rank yet.");const a=this.interpretAxes(t,n);if(t[a[0]]!==n[a[1]])throw new il(`Dimension incompatibility: ${t[a[0]]} !== ${n[a[1]]}`)}mergeFunction(e){if(2!==e.length)throw new il(`A \`Dot\` layer must be called on exactly 2 inputs, but received ${e.length} input(s).`);let t,n=e[0],a=e[1];return t=Array.isArray(this.axes)?this.axes.map(((t,n)=>gf(t,e[n].shape.length))):[gf(this.axes,n.shape.length),gf(this.axes,a.shape.length)],this.normalize&&(n=Uh(n,t[0]),a=Uh(a,t[1])),function(e,t,n){if(e.shape.length>3||t.shape.length>3)throw new sl("batchDot is not implemented for tensors of 4D or higher rank yet");if(x(e.shape.length>=2,(()=>`batchDot requires the rank of x to be >= 2, but got ${e.shape.length}`)),x(e.shape.length>=2,(()=>`batchDot requires the rank of y to be >= 2, but got ${t.shape.length}`)),"number"==typeof n&&(n=[n,n]),"complex64"===e.dtype||"complex64"===t.dtype)throw new sl("batchDot is not implemented for complex64-type Tensors yet.");const a=e.shape.length,i=t.shape.length;null==n&&(n=[a-1,i-2]);const s=n;return wn((()=>{let n,r;if(a>i){n=a-i;const e=[];for(let t=0;t<n;++t)e.push(1);t=Ma(t,t.shape.concat(e))}else if(i>a){n=i-a;const t=[];for(let e=0;e<n;++e)t.push(1);e=Ma(e,e.shape.concat(t))}else n=0;if(2===e.shape.length&&2===t.shape.length)r=s[0]===s[1]?Ri(Ta(e,t),s[0]):Ri(Ta(pa(e,[1,0]),t),s[1]);else{const n=s[0]!==e.shape.length-1,a=s[1]===t.shape.length-1;r=oa(e,t,n,a)}if(n>0){let e;e=a>i?a+i-3:a-1;const t=[];for(let a=e;a<e+n;++a)t.push(a);r=cr(r,t)}return 1===r.shape.length&&(r=Pi(r,1)),r}))}(n,a,t)}interpretAxes(e,t){let n;return n=Array.isArray(this.axes)?this.axes:[gf(this.axes,e.length),gf(this.axes,t.length)],n}computeOutputShape(e){x(Array.isArray(e)&&2===e.length&&Array.isArray(e[0])&&Array.isArray(e[1]),(()=>"A `Dot` layer should be called on a list of exactly 2 inputs."));const t=e[0].slice(),n=e[1].slice();if(t.length>3||n.length>3)throw new sl("Dot layer does not support tensors of 4D or higher rank yet.");const a=this.interpretAxes(t,n);t.splice(a[0],1),n.splice(a[1],1),n.splice(0,1);const i=t.concat(n);return 1===i.length&&i.push(1),i}computeMask(e,t){return null}getConfig(){const e={axes:this.axes,normalize:this.normalize},t=super.getConfig();return Object.assign(e,t),e}}vf.className="Dot",ka(vf);
4536
4536
  /**
4537
4537
  * @license
4538
4538
  * Copyright 2018 Google LLC
@@ -4552,7 +4552,7 @@ class yf extends Zc{constructor(e){super(e),this.supportsMasking=!0,this.stddev=
4552
4552
  * https://opensource.org/licenses/MIT.
4553
4553
  * =============================================================================
4554
4554
  */
4555
- function kf(e,t,n,a,i,s=.001){let r;if(2===e.rank)r=Ha(e,t,n,a,i,s);else if(3===e.rank)r=Ja(e,t,n,a,i,s);else{if(4!==e.rank)throw new sl(`batchNormalization is not implemented for array of rank ${e.rank} yet`);r=Za(e,t,n,a,i,s)}return r}function xf(e,t,n,a,i=.001){return T(a.slice().sort(),Jl(0,e.rank-1))?function(e,t,n,a,i=.001){return wn((()=>{const s=ps(e,a),r=s.mean,o=s.variance;return[kf(e,r,o,n,t,i),r,o]}))}(e,t,n,a,i):function(e,t,n,a,i=.001){return wn((()=>{const s=ps(e,a),r=s.mean,o=s.variance,l=[];for(const t of Jl(0,e.rank))-1!==a.indexOf(t)?l.push(1):l.push(e.shape[t]);const c=Ma(r,l),u=Ma(o,l),h=null==t?null:Ma(t,l),p=null==n?null:Ma(n,l);return[kf(e,c,u,p,h,i),r,o]}))}(e,t,n,a,i)}wf.className="AlphaDropout",ka(wf);class Sf extends Zc{constructor(e){null==e&&(e={}),super(e),this.supportsMasking=!0,this.axis=null==e.axis?-1:e.axis,this.momentum=null==e.momentum?.99:e.momentum,this.epsilon=null==e.epsilon?.001:e.epsilon,this.center=null==e.center||e.center,this.scale=null==e.scale||e.scale,this.betaInitializer=_c(e.betaInitializer||"zeros"),this.gammaInitializer=_c(e.gammaInitializer||"ones"),this.movingMeanInitializer=_c(e.movingMeanInitializer||"zeros"),this.movingVarianceInitializer=_c(e.movingVarianceInitializer||"ones"),this.betaConstraint=Ah(e.betaConstraint),this.gammaConstraint=Ah(e.gammaConstraint),this.betaRegularizer=hd(e.betaRegularizer),this.gammaRegularizer=hd(e.gammaRegularizer)}build(e){e=Oc(e);const t=this.axis>=0?this.axis:this.axis+e.length,n=e[t];if(null==n)throw new il(`Axis ${t} of input tensor should have a defined dimension but the layer received an input with shape ${JSON.stringify(e)}.`);this.inputSpec=[new Vc({ndim:e.length,axes:{[t]:n}})];const a=[n];this.scale&&(this.gamma=this.addWeight("gamma",a,null,this.gammaInitializer,this.gammaRegularizer,!0,this.gammaConstraint)),this.center&&(this.beta=this.addWeight("beta",a,null,this.betaInitializer,this.betaRegularizer,!0,this.betaConstraint)),this.movingMean=this.addWeight("moving_mean",a,null,this.movingMeanInitializer,null,!1),this.movingVariance=this.addWeight("moving_variance",a,null,this.movingVarianceInitializer,null,!1),this.built=!0}call(e,t){return wn((()=>{const n=null!=t.training&&t.training,a=Mc(e),i=a.shape,s=i.length,r=Jl(0,s),o=this.axis>=0?this.axis:this.axis+s;r.splice(o,1);const l=ll(1,s);l[o]=i[o];const c=r.slice();c.sort();const u=!T(c,Jl(0,s).slice(0,s-1));if(!n)return(()=>{if(u){const e=Ma(this.movingMean.read(),l),t=Ma(this.movingVariance.read(),l),n=this.center?Ma(this.beta.read(),l):null,i=this.scale?Ma(this.gamma.read(),l):null;return kf(a,e,t,n,i,this.epsilon)}return kf(a,this.movingMean.read(),this.movingVariance.read(),null==this.beta?null:this.beta.read(),null==this.gamma?null:this.gamma.read(),this.epsilon)})();const[h,p,d]=xf(a,this.gamma.read(),this.beta.read(),r,this.epsilon),f=(e,t,n)=>{wn((()=>{const a=1-n,i=e.read(),s=Ta(es(i,t),a);e.write(es(i,s))}))};return(()=>{f(this.movingMean,p,this.momentum),f(this.movingVariance,d,this.momentum)})(),h}))}getConfig(){const e={axis:this.axis,momentum:this.momentum,epsilon:this.epsilon,center:this.center,scale:this.scale,betaInitializer:Fc(this.betaInitializer),gammaInitializer:Fc(this.gammaInitializer),movingMeanInitializer:Fc(this.movingMeanInitializer),movingVarianceInitializer:Fc(this.movingVarianceInitializer),betaRegularizer:cd(this.betaRegularizer),gammaRegularizer:cd(this.gammaRegularizer),betaConstraint:$h(this.betaConstraint),gammaConstraint:$h(this.gammaConstraint)},t=super.getConfig();return Object.assign(e,t),e}}Sf.className="BatchNormalization",ka(Sf);class Nf extends Zc{constructor(e){if(null==e&&(e={}),super(e),this.axis=null==e.axis?-1:e.axis,"number"==typeof this.axis){if(!Number.isInteger(this.axis))throw new Error(`Expected axis to be an integer, but received ${this.axis}`)}else{if(!Array.isArray(this.axis))throw new Error(`Expected axis to be an integer or an array of integers, but received ${JSON.stringify(this.axis)}`);for(const e of this.axis)if(!Number.isInteger(e))throw new Error(`Expected axis to be an array of integers, but received ${JSON.stringify(this.axis)}`)}this.epsilon=null==e.epsilon?.001:e.epsilon,this.center=null==e.center||e.center,this.scale=null==e.scale||e.scale,this.betaInitializer=_c(e.betaInitializer||"zeros"),this.gammaInitializer=_c(e.gammaInitializer||"ones"),this.betaRegularizer=hd(e.betaRegularizer),this.gammaRegularizer=hd(e.gammaRegularizer),this.supportsMasking=!0}build(e){const t=(e=Oc(e)).length;"number"==typeof this.axis&&(this.axis=[this.axis]);for(let e=0;e<this.axis.length;++e)this.axis[e]<0&&(this.axis[e]+=t);for(const e of this.axis)if(e<0||e>=t)throw new Error(`Invalid axis: ${e}`);if(this.axis.length!==wl(this.axis).length)throw new Error(`Found duplicate axes in: ${this.axis}`);const n=this.axis.map((t=>e[t])),a=!0;this.scale?this.gamma=this.addWeight("gamma",n,"float32",this.gammaInitializer,this.gammaRegularizer,a):this.gamma=null,this.center?this.beta=this.addWeight("beta",n,"float32",this.betaInitializer,this.betaRegularizer,a):this.beta=null,this.built=!0}call(e,t){const n=Mc(e),a=n.shape,i=a.length;return wn((()=>{let{mean:e,variance:t}=ps(n,this.axis,!0);const s=ll(1,i);for(const e of this.axis)s[e]=a[e];const r=e=>null!=e&&e.shape.length!==i?Ma(e,s):e;let o=this.scale?r(this.gamma.read()):null,l=this.center?r(this.beta.read()):null;const c=[],u=[];for(let e=0;e<i;++e)-1!==this.axis.indexOf(e)?(c.push(a[e]),u.push(1)):(c.push(1),u.push(a[e]));return e=Bi(e,c),t=Bi(t,c),null!=o&&(o=Bi(o,u)),null!=l&&(l=Bi(l,u)),kf(n,e,t,l,o,this.epsilon)}))}getConfig(){const e={axis:this.axis,epsilon:this.epsilon,center:this.center,scale:this.scale,betaInitializer:Fc(this.betaInitializer),gammaInitializer:Fc(this.gammaInitializer),betaRegularizer:cd(this.betaRegularizer),gammaRegularizer:cd(this.gammaRegularizer)},t=super.getConfig();return Object.assign(e,t),e}}Nf.className="LayerNormalization",ka(Nf);class Tf extends Zc{constructor(e){if(null==e&&(e={}),super(e),this.dataFormat=null==e.dataFormat?"channelsLast":e.dataFormat,null==e.padding)this.padding=[[1,1],[1,1]];else if("number"==typeof e.padding)this.padding=[[e.padding,e.padding],[e.padding,e.padding]];else{if(e.padding=e.padding,2!==e.padding.length)throw new il(`ZeroPadding2D expects padding to be a length-2 array, but received a length-${e.padding.length} array.`);let t,n;if("number"==typeof e.padding[0])t=[e.padding[0],e.padding[0]],n=[e.padding[1],e.padding[1]];else{if(e.padding=e.padding,2!==e.padding[0].length)throw new il(`ZeroPadding2D expects height padding to be a length-2 array, but received a length-${e.padding[0].length} array.`);if(t=e.padding[0],2!==e.padding[1].length)throw new il(`ZeroPadding2D expects width padding to be a length-2 array, but received a length-${e.padding[1].length} array.`);n=e.padding[1]}this.padding=[t,n]}this.inputSpec=[new Vc({ndim:4})]}computeOutputShape(e){let t,n;return e=Oc(e),"channelsFirst"===this.dataFormat?(t=null!=e[2]&&e[2]>=0?e[2]+this.padding[0][0]+this.padding[0][1]:null,n=null!=e[3]&&e[3]>=0?e[3]+this.padding[1][0]+this.padding[1][1]:null,[e[0],e[1],t,n]):(t=null!=e[1]&&e[1]>=0?e[1]+this.padding[0][0]+this.padding[0][1]:null,n=null!=e[2]&&e[2]>=0?e[2]+this.padding[1][0]+this.padding[1][1]:null,[e[0],t,n,e[3]])}call(e,t){return wn((()=>{return t=Mc(e),n=this.padding,a=this.dataFormat,wn((()=>{if(4!==t.rank)throw new il(`temporalPadding expects input tensor to be 4-D, but received a ${t.rank}-D tensor.`);if(null==n&&(n=[[1,1],[1,1]]),2!==n.length||2!==n[0].length||2!==n[1].length)throw new il("spatial2dPadding expects `padding` to be an Array of two Arrays, each of which is an Array of two integers.");if(null==a&&(a="channelsLast"),"channelsLast"!==a&&"channelsFirst"!==a)throw new il(`Unknown data format: ${a}. Supported data formats are 'channelsLast' and 'channelsFirst.`);let e;return e="channelsFirst"===a?[[0,0],[0,0],n[0],n[1]]:[[0,0],n[0],n[1],[0,0]],ms(t,e)}));
4555
+ function kf(e,t,n,a,i,s=.001){let r;if(2===e.rank)r=Ha(e,t,n,a,i,s);else if(3===e.rank)r=Ja(e,t,n,a,i,s);else{if(4!==e.rank)throw new sl(`batchNormalization is not implemented for array of rank ${e.rank} yet`);r=Za(e,t,n,a,i,s)}return r}function xf(e,t,n,a,i=.001){return T(a.slice().sort(),Jl(0,e.rank-1))?function(e,t,n,a,i=.001){return wn((()=>{const s=ps(e,a),r=s.mean,o=s.variance;return[kf(e,r,o,n,t,i),r,o]}))}(e,t,n,a,i):function(e,t,n,a,i=.001){return wn((()=>{const s=ps(e,a),r=s.mean,o=s.variance,l=[];for(const t of Jl(0,e.rank))-1!==a.indexOf(t)?l.push(1):l.push(e.shape[t]);const c=Ma(r,l),u=Ma(o,l),h=null==t?null:Ma(t,l),p=null==n?null:Ma(n,l);return[kf(e,c,u,p,h,i),r,o]}))}(e,t,n,a,i)}wf.className="AlphaDropout",ka(wf);class Sf extends Zc{constructor(e){null==e&&(e={}),super(e),this.supportsMasking=!0,this.axis=null==e.axis?-1:e.axis,this.momentum=null==e.momentum?.99:e.momentum,this.epsilon=null==e.epsilon?.001:e.epsilon,this.center=null==e.center||e.center,this.scale=null==e.scale||e.scale,this.betaInitializer=_c(e.betaInitializer||"zeros"),this.gammaInitializer=_c(e.gammaInitializer||"ones"),this.movingMeanInitializer=_c(e.movingMeanInitializer||"zeros"),this.movingVarianceInitializer=_c(e.movingVarianceInitializer||"ones"),this.betaConstraint=Ah(e.betaConstraint),this.gammaConstraint=Ah(e.gammaConstraint),this.betaRegularizer=hd(e.betaRegularizer),this.gammaRegularizer=hd(e.gammaRegularizer)}build(e){e=Oc(e);const t=this.axis>=0?this.axis:this.axis+e.length,n=e[t];if(null==n)throw new il(`Axis ${t} of input tensor should have a defined dimension but the layer received an input with shape ${JSON.stringify(e)}.`);this.inputSpec=[new Vc({ndim:e.length,axes:{[t]:n}})];const a=[n];this.scale&&(this.gamma=this.addWeight("gamma",a,null,this.gammaInitializer,this.gammaRegularizer,!0,this.gammaConstraint)),this.center&&(this.beta=this.addWeight("beta",a,null,this.betaInitializer,this.betaRegularizer,!0,this.betaConstraint)),this.movingMean=this.addWeight("moving_mean",a,null,this.movingMeanInitializer,null,!1),this.movingVariance=this.addWeight("moving_variance",a,null,this.movingVarianceInitializer,null,!1),this.built=!0}call(e,t){return wn((()=>{const n=null!=t.training&&t.training,a=Mc(e),i=a.shape,s=i.length,r=Jl(0,s),o=this.axis>=0?this.axis:this.axis+s;r.splice(o,1);const l=ll(1,s);l[o]=i[o];const c=r.slice();c.sort();const u=!T(c,Jl(0,s).slice(0,s-1));if(!n)return(()=>{if(u){const e=Ma(this.movingMean.read(),l),t=Ma(this.movingVariance.read(),l),n=this.center?Ma(this.beta.read(),l):null,i=this.scale?Ma(this.gamma.read(),l):null;return kf(a,e,t,n,i,this.epsilon)}return kf(a,this.movingMean.read(),this.movingVariance.read(),null==this.beta?null:this.beta.read(),null==this.gamma?null:this.gamma.read(),this.epsilon)})();const[h,p,d]=xf(a,this.gamma.read(),this.beta.read(),r,this.epsilon),f=(e,t,n)=>{wn((()=>{const a=1-n,i=e.read(),s=Ta(es(i,t),a);e.write(es(i,s))}))};return(()=>{f(this.movingMean,p,this.momentum),f(this.movingVariance,d,this.momentum)})(),h}))}getConfig(){const e={axis:this.axis,momentum:this.momentum,epsilon:this.epsilon,center:this.center,scale:this.scale,betaInitializer:Fc(this.betaInitializer),gammaInitializer:Fc(this.gammaInitializer),movingMeanInitializer:Fc(this.movingMeanInitializer),movingVarianceInitializer:Fc(this.movingVarianceInitializer),betaRegularizer:cd(this.betaRegularizer),gammaRegularizer:cd(this.gammaRegularizer),betaConstraint:Ch(this.betaConstraint),gammaConstraint:Ch(this.gammaConstraint)},t=super.getConfig();return Object.assign(e,t),e}}Sf.className="BatchNormalization",ka(Sf);class Nf extends Zc{constructor(e){if(null==e&&(e={}),super(e),this.axis=null==e.axis?-1:e.axis,"number"==typeof this.axis){if(!Number.isInteger(this.axis))throw new Error(`Expected axis to be an integer, but received ${this.axis}`)}else{if(!Array.isArray(this.axis))throw new Error(`Expected axis to be an integer or an array of integers, but received ${JSON.stringify(this.axis)}`);for(const e of this.axis)if(!Number.isInteger(e))throw new Error(`Expected axis to be an array of integers, but received ${JSON.stringify(this.axis)}`)}this.epsilon=null==e.epsilon?.001:e.epsilon,this.center=null==e.center||e.center,this.scale=null==e.scale||e.scale,this.betaInitializer=_c(e.betaInitializer||"zeros"),this.gammaInitializer=_c(e.gammaInitializer||"ones"),this.betaRegularizer=hd(e.betaRegularizer),this.gammaRegularizer=hd(e.gammaRegularizer),this.supportsMasking=!0}build(e){const t=(e=Oc(e)).length;"number"==typeof this.axis&&(this.axis=[this.axis]);for(let e=0;e<this.axis.length;++e)this.axis[e]<0&&(this.axis[e]+=t);for(const e of this.axis)if(e<0||e>=t)throw new Error(`Invalid axis: ${e}`);if(this.axis.length!==wl(this.axis).length)throw new Error(`Found duplicate axes in: ${this.axis}`);const n=this.axis.map((t=>e[t])),a=!0;this.scale?this.gamma=this.addWeight("gamma",n,"float32",this.gammaInitializer,this.gammaRegularizer,a):this.gamma=null,this.center?this.beta=this.addWeight("beta",n,"float32",this.betaInitializer,this.betaRegularizer,a):this.beta=null,this.built=!0}call(e,t){const n=Mc(e),a=n.shape,i=a.length;return wn((()=>{let{mean:e,variance:t}=ps(n,this.axis,!0);const s=ll(1,i);for(const e of this.axis)s[e]=a[e];const r=e=>null!=e&&e.shape.length!==i?Ma(e,s):e;let o=this.scale?r(this.gamma.read()):null,l=this.center?r(this.beta.read()):null;const c=[],u=[];for(let e=0;e<i;++e)-1!==this.axis.indexOf(e)?(c.push(a[e]),u.push(1)):(c.push(1),u.push(a[e]));return e=Bi(e,c),t=Bi(t,c),null!=o&&(o=Bi(o,u)),null!=l&&(l=Bi(l,u)),kf(n,e,t,l,o,this.epsilon)}))}getConfig(){const e={axis:this.axis,epsilon:this.epsilon,center:this.center,scale:this.scale,betaInitializer:Fc(this.betaInitializer),gammaInitializer:Fc(this.gammaInitializer),betaRegularizer:cd(this.betaRegularizer),gammaRegularizer:cd(this.gammaRegularizer)},t=super.getConfig();return Object.assign(e,t),e}}Nf.className="LayerNormalization",ka(Nf);class Tf extends Zc{constructor(e){if(null==e&&(e={}),super(e),this.dataFormat=null==e.dataFormat?"channelsLast":e.dataFormat,null==e.padding)this.padding=[[1,1],[1,1]];else if("number"==typeof e.padding)this.padding=[[e.padding,e.padding],[e.padding,e.padding]];else{if(e.padding=e.padding,2!==e.padding.length)throw new il(`ZeroPadding2D expects padding to be a length-2 array, but received a length-${e.padding.length} array.`);let t,n;if("number"==typeof e.padding[0])t=[e.padding[0],e.padding[0]],n=[e.padding[1],e.padding[1]];else{if(e.padding=e.padding,2!==e.padding[0].length)throw new il(`ZeroPadding2D expects height padding to be a length-2 array, but received a length-${e.padding[0].length} array.`);if(t=e.padding[0],2!==e.padding[1].length)throw new il(`ZeroPadding2D expects width padding to be a length-2 array, but received a length-${e.padding[1].length} array.`);n=e.padding[1]}this.padding=[t,n]}this.inputSpec=[new Vc({ndim:4})]}computeOutputShape(e){let t,n;return e=Oc(e),"channelsFirst"===this.dataFormat?(t=null!=e[2]&&e[2]>=0?e[2]+this.padding[0][0]+this.padding[0][1]:null,n=null!=e[3]&&e[3]>=0?e[3]+this.padding[1][0]+this.padding[1][1]:null,[e[0],e[1],t,n]):(t=null!=e[1]&&e[1]>=0?e[1]+this.padding[0][0]+this.padding[0][1]:null,n=null!=e[2]&&e[2]>=0?e[2]+this.padding[1][0]+this.padding[1][1]:null,[e[0],t,n,e[3]])}call(e,t){return wn((()=>{return t=Mc(e),n=this.padding,a=this.dataFormat,wn((()=>{if(4!==t.rank)throw new il(`temporalPadding expects input tensor to be 4-D, but received a ${t.rank}-D tensor.`);if(null==n&&(n=[[1,1],[1,1]]),2!==n.length||2!==n[0].length||2!==n[1].length)throw new il("spatial2dPadding expects `padding` to be an Array of two Arrays, each of which is an Array of two integers.");if(null==a&&(a="channelsLast"),"channelsLast"!==a&&"channelsFirst"!==a)throw new il(`Unknown data format: ${a}. Supported data formats are 'channelsLast' and 'channelsFirst.`);let e;return e="channelsFirst"===a?[[0,0],[0,0],n[0],n[1]]:[[0,0],n[0],n[1],[0,0]],ms(t,e)}));
4556
4556
  /**
4557
4557
  * @license
4558
4558
  * Copyright 2018 Google LLC
@@ -4572,7 +4572,7 @@ var t,n,a}))}getConfig(){const e={padding:this.padding,dataFormat:this.dataForma
4572
4572
  * https://opensource.org/licenses/MIT.
4573
4573
  * =============================================================================
4574
4574
  */
4575
- function If(e,t,n,a,i,s){return wn((()=>{let r;Ll(i),Ol(s),Ml(a),null==n&&(n=[1,1]),null==a&&(a="valid"),null==i&&(i="channelsLast"),null==s&&(s="max"),e=kd(e,i);const o="same"===a?"same":"valid";return r="max"===s?ss(e,t,n,o):Oa(e,t,n,o),"channelsFirst"===i&&(r=pa(r,[0,3,1,2])),r}))}function $f(e,t,n,a,i,s){return wn((()=>{let r;Ll(i),Ol(s),Ml(a),null==n&&(n=[1,1,1]),null==a&&(a="valid"),null==i&&(i="channelsLast"),null==s&&(s="max"),e=xd(e,i);const o="same"===a?"same":"valid";return r="max"===s?rs(e,t,n,o):Pa(e,t,n,o),"channelsFirst"===i&&(r=pa(r,[0,4,1,2,3])),r}))}Tf.className="ZeroPadding2D",ka(Tf);class Cf extends Zc{constructor(e){if(null==e.poolSize&&(e.poolSize=2),super(e),"number"==typeof e.poolSize)this.poolSize=[e.poolSize];else{if(!Array.isArray(e.poolSize)||1!==e.poolSize.length||"number"!=typeof e.poolSize[0])throw new il(`poolSize for 1D convolutional layer must be a number or an Array of a single number, but received ${JSON.stringify(e.poolSize)}`);this.poolSize=e.poolSize}if(Nl(this.poolSize,"poolSize"),null==e.strides)this.strides=this.poolSize;else if("number"==typeof e.strides)this.strides=[e.strides];else{if(!Array.isArray(e.strides)||1!==e.strides.length||"number"!=typeof e.strides[0])throw new il(`strides for 1D convolutional layer must be a number or an Array of a single number, but received ${JSON.stringify(e.strides)}`);this.strides=e.strides}Nl(this.strides,"strides"),this.padding=null==e.padding?"valid":e.padding,Ml(this.padding),this.inputSpec=[new Vc({ndim:3})]}computeOutputShape(e){const t=bd((e=Oc(e))[1],this.poolSize[0],this.padding,this.strides[0]);return[e[0],t,e[2]]}call(e,t){return wn((()=>{this.invokeCallHook(e,t),e=Xl(Mc(e),2);const n=this.poolingFunction(Mc(e),[this.poolSize[0],1],[this.strides[0],1],this.padding,"channelsLast");return cr(n,[2])}))}getConfig(){const e={poolSize:this.poolSize,padding:this.padding,strides:this.strides},t=super.getConfig();return Object.assign(e,t),e}}class Af extends Cf{constructor(e){super(e)}poolingFunction(e,t,n,a,i){return Ll(i),Ml(a),If(e,t,n,a,i,"max")}}Af.className="MaxPooling1D",ka(Af);class Ef extends Cf{constructor(e){super(e)}poolingFunction(e,t,n,a,i){return Ll(i),Ml(a),If(e,t,n,a,i,"avg")}}Ef.className="AveragePooling1D",ka(Ef);class jf extends Zc{constructor(e){if(null==e.poolSize&&(e.poolSize=[2,2]),super(e),this.poolSize=Array.isArray(e.poolSize)?e.poolSize:[e.poolSize,e.poolSize],null==e.strides)this.strides=this.poolSize;else if(Array.isArray(e.strides)){if(2!==e.strides.length)throw new il(`If the strides property of a 2D pooling layer is an Array, it is expected to have a length of 2, but received length ${e.strides.length}.`);this.strides=e.strides}else this.strides=[e.strides,e.strides];Nl(this.poolSize,"poolSize"),Nl(this.strides,"strides"),this.padding=null==e.padding?"valid":e.padding,this.dataFormat=null==e.dataFormat?"channelsLast":e.dataFormat,Ll(this.dataFormat),Ml(this.padding),this.inputSpec=[new Vc({ndim:4})]}computeOutputShape(e){e=Oc(e);let t="channelsFirst"===this.dataFormat?e[2]:e[1],n="channelsFirst"===this.dataFormat?e[3]:e[2];return t=bd(t,this.poolSize[0],this.padding,this.strides[0]),n=bd(n,this.poolSize[1],this.padding,this.strides[1]),"channelsFirst"===this.dataFormat?[e[0],e[1],t,n]:[e[0],t,n,e[3]]}call(e,t){return wn((()=>(this.invokeCallHook(e,t),this.poolingFunction(Mc(e),this.poolSize,this.strides,this.padding,this.dataFormat))))}getConfig(){const e={poolSize:this.poolSize,padding:this.padding,strides:this.strides,dataFormat:this.dataFormat},t=super.getConfig();return Object.assign(e,t),e}}class zf extends jf{constructor(e){super(e)}poolingFunction(e,t,n,a,i){return Ll(i),Ml(a),If(e,t,n,a,i,"max")}}zf.className="MaxPooling2D",ka(zf);class Df extends jf{constructor(e){super(e)}poolingFunction(e,t,n,a,i){return Ll(i),Ml(a),If(e,t,n,a,i,"avg")}}Df.className="AveragePooling2D",ka(Df);class Ff extends Zc{constructor(e){if(null==e.poolSize&&(e.poolSize=[2,2,2]),super(e),this.poolSize=Array.isArray(e.poolSize)?e.poolSize:[e.poolSize,e.poolSize,e.poolSize],null==e.strides)this.strides=this.poolSize;else if(Array.isArray(e.strides)){if(3!==e.strides.length)throw new il(`If the strides property of a 3D pooling layer is an Array, it is expected to have a length of 3, but received length ${e.strides.length}.`);this.strides=e.strides}else this.strides=[e.strides,e.strides,e.strides];Nl(this.poolSize,"poolSize"),Nl(this.strides,"strides"),this.padding=null==e.padding?"valid":e.padding,this.dataFormat=null==e.dataFormat?"channelsLast":e.dataFormat,Ll(this.dataFormat),Ml(this.padding),this.inputSpec=[new Vc({ndim:5})]}computeOutputShape(e){e=Oc(e);let t="channelsFirst"===this.dataFormat?e[2]:e[1],n="channelsFirst"===this.dataFormat?e[3]:e[2],a="channelsFirst"===this.dataFormat?e[4]:e[3];return t=bd(t,this.poolSize[0],this.padding,this.strides[0]),n=bd(n,this.poolSize[1],this.padding,this.strides[1]),a=bd(a,this.poolSize[2],this.padding,this.strides[2]),"channelsFirst"===this.dataFormat?[e[0],e[1],t,n,a]:[e[0],t,n,a,e[4]]}call(e,t){return wn((()=>(this.invokeCallHook(e,t),this.poolingFunction(Mc(e),this.poolSize,this.strides,this.padding,this.dataFormat))))}getConfig(){const e={poolSize:this.poolSize,padding:this.padding,strides:this.strides,dataFormat:this.dataFormat},t=super.getConfig();return Object.assign(e,t),e}}class _f extends Ff{constructor(e){super(e)}poolingFunction(e,t,n,a,i){return Ll(i),Ml(a),$f(e,t,n,a,i,"max")}}_f.className="MaxPooling3D",ka(_f);class Rf extends Ff{constructor(e){super(e)}poolingFunction(e,t,n,a,i){return Ll(i),Ml(a),$f(e,t,n,a,i,"avg")}}Rf.className="AveragePooling3D",ka(Rf);class Lf extends Zc{constructor(e){super(e),this.inputSpec=[new Vc({ndim:3})]}computeOutputShape(e){return[e[0],e[2]]}call(e,t){throw new sl}}class Mf extends Lf{constructor(e){super(e||{})}call(e,t){return wn((()=>{const t=Mc(e);return ls(t,1)}))}}Mf.className="GlobalAveragePooling1D",ka(Mf);class Of extends Lf{constructor(e){super(e||{})}call(e,t){return wn((()=>{const t=Mc(e);return Ei(t,1)}))}}Of.className="GlobalMaxPooling1D",ka(Of);class Pf extends Zc{constructor(e){super(e),this.dataFormat=null==e.dataFormat?"channelsLast":e.dataFormat,Ll(this.dataFormat),this.inputSpec=[new Vc({ndim:4})]}computeOutputShape(e){return"channelsLast"===this.dataFormat?[e[0],e[3]]:[e[0],e[1]]}call(e,t){throw new sl}getConfig(){const e={dataFormat:this.dataFormat},t=super.getConfig();return Object.assign(e,t),e}}class Bf extends Pf{call(e,t){return wn((()=>{const t=Mc(e);return"channelsLast"===this.dataFormat?ls(t,[1,2]):ls(t,[2,3])}))}}Bf.className="GlobalAveragePooling2D",ka(Bf);class Uf extends Pf{call(e,t){return wn((()=>{const t=Mc(e);return"channelsLast"===this.dataFormat?Ei(t,[1,2]):Ei(t,[2,3])}))}}Uf.className="GlobalMaxPooling2D",ka(Uf);
4575
+ function If(e,t,n,a,i,s){return wn((()=>{let r;Ll(i),Ol(s),Ml(a),null==n&&(n=[1,1]),null==a&&(a="valid"),null==i&&(i="channelsLast"),null==s&&(s="max"),e=kd(e,i);const o="same"===a?"same":"valid";return r="max"===s?ss(e,t,n,o):Oa(e,t,n,o),"channelsFirst"===i&&(r=pa(r,[0,3,1,2])),r}))}function Cf(e,t,n,a,i,s){return wn((()=>{let r;Ll(i),Ol(s),Ml(a),null==n&&(n=[1,1,1]),null==a&&(a="valid"),null==i&&(i="channelsLast"),null==s&&(s="max"),e=xd(e,i);const o="same"===a?"same":"valid";return r="max"===s?rs(e,t,n,o):Pa(e,t,n,o),"channelsFirst"===i&&(r=pa(r,[0,4,1,2,3])),r}))}Tf.className="ZeroPadding2D",ka(Tf);class $f extends Zc{constructor(e){if(null==e.poolSize&&(e.poolSize=2),super(e),"number"==typeof e.poolSize)this.poolSize=[e.poolSize];else{if(!Array.isArray(e.poolSize)||1!==e.poolSize.length||"number"!=typeof e.poolSize[0])throw new il(`poolSize for 1D convolutional layer must be a number or an Array of a single number, but received ${JSON.stringify(e.poolSize)}`);this.poolSize=e.poolSize}if(Nl(this.poolSize,"poolSize"),null==e.strides)this.strides=this.poolSize;else if("number"==typeof e.strides)this.strides=[e.strides];else{if(!Array.isArray(e.strides)||1!==e.strides.length||"number"!=typeof e.strides[0])throw new il(`strides for 1D convolutional layer must be a number or an Array of a single number, but received ${JSON.stringify(e.strides)}`);this.strides=e.strides}Nl(this.strides,"strides"),this.padding=null==e.padding?"valid":e.padding,Ml(this.padding),this.inputSpec=[new Vc({ndim:3})]}computeOutputShape(e){const t=bd((e=Oc(e))[1],this.poolSize[0],this.padding,this.strides[0]);return[e[0],t,e[2]]}call(e,t){return wn((()=>{this.invokeCallHook(e,t),e=Xl(Mc(e),2);const n=this.poolingFunction(Mc(e),[this.poolSize[0],1],[this.strides[0],1],this.padding,"channelsLast");return cr(n,[2])}))}getConfig(){const e={poolSize:this.poolSize,padding:this.padding,strides:this.strides},t=super.getConfig();return Object.assign(e,t),e}}class Af extends $f{constructor(e){super(e)}poolingFunction(e,t,n,a,i){return Ll(i),Ml(a),If(e,t,n,a,i,"max")}}Af.className="MaxPooling1D",ka(Af);class Ef extends $f{constructor(e){super(e)}poolingFunction(e,t,n,a,i){return Ll(i),Ml(a),If(e,t,n,a,i,"avg")}}Ef.className="AveragePooling1D",ka(Ef);class jf extends Zc{constructor(e){if(null==e.poolSize&&(e.poolSize=[2,2]),super(e),this.poolSize=Array.isArray(e.poolSize)?e.poolSize:[e.poolSize,e.poolSize],null==e.strides)this.strides=this.poolSize;else if(Array.isArray(e.strides)){if(2!==e.strides.length)throw new il(`If the strides property of a 2D pooling layer is an Array, it is expected to have a length of 2, but received length ${e.strides.length}.`);this.strides=e.strides}else this.strides=[e.strides,e.strides];Nl(this.poolSize,"poolSize"),Nl(this.strides,"strides"),this.padding=null==e.padding?"valid":e.padding,this.dataFormat=null==e.dataFormat?"channelsLast":e.dataFormat,Ll(this.dataFormat),Ml(this.padding),this.inputSpec=[new Vc({ndim:4})]}computeOutputShape(e){e=Oc(e);let t="channelsFirst"===this.dataFormat?e[2]:e[1],n="channelsFirst"===this.dataFormat?e[3]:e[2];return t=bd(t,this.poolSize[0],this.padding,this.strides[0]),n=bd(n,this.poolSize[1],this.padding,this.strides[1]),"channelsFirst"===this.dataFormat?[e[0],e[1],t,n]:[e[0],t,n,e[3]]}call(e,t){return wn((()=>(this.invokeCallHook(e,t),this.poolingFunction(Mc(e),this.poolSize,this.strides,this.padding,this.dataFormat))))}getConfig(){const e={poolSize:this.poolSize,padding:this.padding,strides:this.strides,dataFormat:this.dataFormat},t=super.getConfig();return Object.assign(e,t),e}}class zf extends jf{constructor(e){super(e)}poolingFunction(e,t,n,a,i){return Ll(i),Ml(a),If(e,t,n,a,i,"max")}}zf.className="MaxPooling2D",ka(zf);class Df extends jf{constructor(e){super(e)}poolingFunction(e,t,n,a,i){return Ll(i),Ml(a),If(e,t,n,a,i,"avg")}}Df.className="AveragePooling2D",ka(Df);class Ff extends Zc{constructor(e){if(null==e.poolSize&&(e.poolSize=[2,2,2]),super(e),this.poolSize=Array.isArray(e.poolSize)?e.poolSize:[e.poolSize,e.poolSize,e.poolSize],null==e.strides)this.strides=this.poolSize;else if(Array.isArray(e.strides)){if(3!==e.strides.length)throw new il(`If the strides property of a 3D pooling layer is an Array, it is expected to have a length of 3, but received length ${e.strides.length}.`);this.strides=e.strides}else this.strides=[e.strides,e.strides,e.strides];Nl(this.poolSize,"poolSize"),Nl(this.strides,"strides"),this.padding=null==e.padding?"valid":e.padding,this.dataFormat=null==e.dataFormat?"channelsLast":e.dataFormat,Ll(this.dataFormat),Ml(this.padding),this.inputSpec=[new Vc({ndim:5})]}computeOutputShape(e){e=Oc(e);let t="channelsFirst"===this.dataFormat?e[2]:e[1],n="channelsFirst"===this.dataFormat?e[3]:e[2],a="channelsFirst"===this.dataFormat?e[4]:e[3];return t=bd(t,this.poolSize[0],this.padding,this.strides[0]),n=bd(n,this.poolSize[1],this.padding,this.strides[1]),a=bd(a,this.poolSize[2],this.padding,this.strides[2]),"channelsFirst"===this.dataFormat?[e[0],e[1],t,n,a]:[e[0],t,n,a,e[4]]}call(e,t){return wn((()=>(this.invokeCallHook(e,t),this.poolingFunction(Mc(e),this.poolSize,this.strides,this.padding,this.dataFormat))))}getConfig(){const e={poolSize:this.poolSize,padding:this.padding,strides:this.strides,dataFormat:this.dataFormat},t=super.getConfig();return Object.assign(e,t),e}}class _f extends Ff{constructor(e){super(e)}poolingFunction(e,t,n,a,i){return Ll(i),Ml(a),Cf(e,t,n,a,i,"max")}}_f.className="MaxPooling3D",ka(_f);class Rf extends Ff{constructor(e){super(e)}poolingFunction(e,t,n,a,i){return Ll(i),Ml(a),Cf(e,t,n,a,i,"avg")}}Rf.className="AveragePooling3D",ka(Rf);class Lf extends Zc{constructor(e){super(e),this.inputSpec=[new Vc({ndim:3})]}computeOutputShape(e){return[e[0],e[2]]}call(e,t){throw new sl}}class Mf extends Lf{constructor(e){super(e||{})}call(e,t){return wn((()=>{const t=Mc(e);return ls(t,1)}))}}Mf.className="GlobalAveragePooling1D",ka(Mf);class Of extends Lf{constructor(e){super(e||{})}call(e,t){return wn((()=>{const t=Mc(e);return Ei(t,1)}))}}Of.className="GlobalMaxPooling1D",ka(Of);class Pf extends Zc{constructor(e){super(e),this.dataFormat=null==e.dataFormat?"channelsLast":e.dataFormat,Ll(this.dataFormat),this.inputSpec=[new Vc({ndim:4})]}computeOutputShape(e){return"channelsLast"===this.dataFormat?[e[0],e[3]]:[e[0],e[1]]}call(e,t){throw new sl}getConfig(){const e={dataFormat:this.dataFormat},t=super.getConfig();return Object.assign(e,t),e}}class Bf extends Pf{call(e,t){return wn((()=>{const t=Mc(e);return"channelsLast"===this.dataFormat?ls(t,[1,2]):ls(t,[2,3])}))}}Bf.className="GlobalAveragePooling2D",ka(Bf);class Uf extends Pf{call(e,t){return wn((()=>{const t=Mc(e);return"channelsLast"===this.dataFormat?Ei(t,[1,2]):Ei(t,[2,3])}))}}Uf.className="GlobalMaxPooling2D",ka(Uf);
4576
4576
  /**
4577
4577
  * @license
4578
4578
  * Copyright 2018 Google LLC
@@ -4679,7 +4679,7 @@ const tm=new Set(["bilinear","nearest"]);class nm extends em{constructor(e){supe
4679
4679
  * limitations under the License.
4680
4680
  * =============================================================================
4681
4681
  */
4682
- vt(Uo),vt($o),vt(Go),vt(Vo),vt(Ko),vt(qo),vt(Lo),vt(Ho),vt(tl),vt(Fo),vt(Qo),vt(Oo),vt(To);var am={"штих":"noun","пяних":"noun","белих":"adjective","борзих":"adjective","малих":"adjective","старих":"adjective","дарнопих":"noun","сухих":"adjective","черемних":"noun","сирих":"adjective","плохих":"adjective","целих":"adjective","жих":"noun","войцих":"noun","скорих":"adjective","бурих":"adjective","чалих":"adjective","серих":"adjective","удалих":"adjective","карих":"adjective","гених":"noun","литвих":"noun","марцих":"noun","сізих":"adjective","яних":"noun","мжачих":"adjective","сірих":"adjective","янбих":"noun","бодрих":"adjective","стрий":"noun","чорторий":"noun","юрий":"adjective","цибрий":"noun","цібрий":"noun","карий":"adjective","куприй":"noun","кирий":"noun","негрий":"noun","губрий":"noun","шкабрий":"noun","замрий":"noun","передрий":"noun","одерий":"noun","жегрий":"noun","жарий":"adjective","зюбрий":"noun","семерий":"noun","лий":"noun","бий":"noun","рий":"noun","вий":"noun","ший":"noun","валий":"noun","крайній":"adjective","осінній":"adjective","кутній":"adjective","середній":"adjective","горішній":"adjective","безродній":"adjective","осадчій":"adjective","кий":"noun","новохатній":"adjective","очеретній":"adjective","рбий":"noun","закутній":"adjective","недавній":"adjective","порожній":"adjective","бокий":"noun","вчерашній":"adjective","огородній":"adjective","трощий":"noun","вчорашній":"adjective","житній":"adjective","нижній":"adjective","синій":"adjective","хорий":"noun","краснобокій":"adjective","хижній":"adjective","забродній":"adjective","калюжній":"adjective","виноградній":"adjective","коломий":"noun","летучій":"adjective","поздній":"adjective","серий":"noun","нагорній":"adjective","фартушній":"adjective","холошвій":"noun","батий":"noun","волошиній":"adjective","жирий":"noun","заможній":"adjective","короткій":"adjective","останній":"adjective","передній":"adjective","піддубній":"adjective","пізній":"adjective","погородній":"adjective","бояжній":"adjective","смий":"noun","задвірній":"adjective","остатній":"adjective","підсадній":"adjective","достатній":"adjective","зимній":"adjective","рябой":"adjective","рудой":"adjective","козодой":"noun","яровой":"adjective","кривой":"adjective","садовой":"adjective","полевой":"adjective","сисой":"noun","плохой":"adjective","сухой":"adjective","гаєвой":"adjective","глухой":"adjective","горевой":"adjective","кутовой":"adjective","копаной":"adjective","злой":"adjective","сєдой":"adjective","благой":"adjective","водостой":"noun","косой":"adjective","ліждвой":"noun","большой":"adjective","половой":"adjective","чорной":"adjective","косогой":"adjective","золотой":"adjective","лановой":"adjective","яловой":"adjective","дорогой":"adjective","німой":"adjective","первой":"adjective","русой":"adjective","худой":"adjective","цаподой":"noun","авасілой":"noun","валовой":"adjective","гнідой":"adjective","молокопой":"noun","золотобой":"noun","ярковой":"noun","аміхалакіой":"noun","седой":"adjective","крутой":"adjective","кучной":"adjective","слепой":"adjective","дурной":"adjective","молодой":"adjective","бухой":"adjective","самотній":"adjective","біла":"adjective","бура":"adjective","велика":"adjective","домовина":"noun","рослина":"noun","врецьона":"noun","глибока":"adjective","висока":"adjective","гладка":"adjective","грицина":"noun","гужва":"noun","ковінька":"noun","дика":"adjective","діброва":"noun","кицька":"noun","ківа":"noun","лепка":"adjective","островерха":"adjective","петрина":"noun","прудка":"adjective","семенина":"noun","турчина":"noun","чуприна":"noun","швидка":"adjective","щербина":"noun","яковина":"noun","синьоока":"adjective","крива":"adjective","сліпа":"adjective","глуха":"adjective","жовта":"adjective","добра":"adjective","хоробра":"adjective","сухоребра":"adjective","гарна":"adjective","мала":"adjective","весна":"noun","зла":"adjective","жива":"adjective","ніяка":"adjective","ціла":"adjective","молода":"adjective","далека":"adjective","золота":"adjective","жвава":"adjective","дорога":"adjective","коса":"adjective","литва":"noun","чужа":"adjective","тепла":"adjective","груба":"adjective","слава":"noun","брова":"noun","стара":"adjective","катерина":"noun","василина":"noun","нижня":"adjective","худа":"adjective","проста":"adjective","дівоча":"adjective","крута":"adjective","метка":"adjective","чорна":"adjective","сторона":"noun","невкрита":"adjective","руда":"adjective","темна":"adjective","проява":"noun","тиха":"adjective","божа":"adjective","весела":"adjective","бабина":"adjective","суха":"adjective","люта":"adjective","стіна":"noun","вража":"adjective","хороша":"adjective","легка":"adjective","козача":"adjective","польща":"noun","недужа":"adjective","розлога":"adjective","гаряча":"adjective","середня":"adjective","торішня":"adjective","сита":"adjective","гостра":"adjective","осіння":"adjective","невесела":"adjective","москва":"noun","широка":"adjective","половина":"noun","синя":"adjective","сира":"adjective","довга":"adjective","коротка":"adjective","лукава":"adjective","абияка":"adjective","королева":"noun","чайна":"adjective","сіра":"adjective","сутула":"adjective","сава":"noun","дебела":"adjective","мокра":"adjective","убога":"adjective","безрука":"adjective","димна":"adjective","мила":"adjective","боса":"adjective","гола":"adjective","красноока":"adjective","остання":"adjective","десна":"noun","житня":"adjective","тризна":"noun","цупка":"adjective","порожня":"adjective","ліва":"adjective","сьома":"adjective","вовна":"noun","сова":"noun","бела":"adjective","ряба":"adjective","гніда":"adjective","гожа":"adjective","кисла":"adjective","кутня":"adjective","огниста":"adjective","мудра":"adjective","дужа":"adjective","підстава":"noun","бодра":"adjective","бадьора":"adjective","кривохижа":"adjective","прихожа":"adjective","побожа":"adjective","пригожа":"adjective","петрунька":"noun","ковинька":"noun","кишинька":"noun","кропивянька":"noun","зеленька":"noun","лабунька":"noun","м'якенька":"adjective","бухонька":"noun","сиза":"adjective","маза":"adjective","блаза":"adjective","улина":"adjective","ейвена":"adjective","еремина":"adjective","ена":"adjective","клята":"adjective","периста":"adjective","працевита":"adjective","свіжа":"adjective","рижа":"adjective","копистира":"noun","скорина":"noun","більченя":"noun","кривошеня":"noun","нестереня":"noun","захарченя":"noun","войценя":"noun","протасеня":"noun","олещеня":"noun","денисеня":"noun","стрельченя":"noun","молодоженя":"noun","заграва":"noun","неменша":"adjective","неменьша":"adjective","меньша":"adjective","паший":"noun","пєша":"adjective","дзвінка":"adjective","пухка":"adjective","безпала":"adjective","вобла":"adjective","горжа":"adjective","горіла":"adjective","китаста":"adjective","лиса":"adjective","осадча":"adjective","пелехата":"adjective","підпала":"adjective","ставнича":"adjective","чала":"adjective","чубата":"adjective","целомудра":"adjective","кара":"adjective","коцупатра":"adjective","немудра":"adjective","шара":"adjective","шингира":"adjective","передера":"adjective","далекора":"adjective","жара":"adjective","яра":"adjective","золотопера":"adjective","остра":"adjective","хитра":"adjective","прозора":"adjective","карчинска":"adjective","гнила":"adjective","хижа":"adjective","крижа":"adjective","погоріла":"adjective","куца":"adjective","солодка":"adjective","безверха":"adjective","усата":"adjective","довгопола":"adjective","щербата":"adjective","пишна":"adjective","хоружа":"adjective","мирна":"adjective","долга":"adjective","бєла":"adjective","надточа":"adjective","гаркава":"adjective","мягка":"adjective","топча":"adjective","товста":"adjective","блага":"adjective","захожа":"adjective","боліла":"adjective","басиста":"adjective","басіста":"adjective","люба":"adjective","горбата":"adjective","драна":"adjective","куряча":"adjective","куса":"adjective","зайва":"adjective","кругла":"adjective","брижата":"adjective","скора":"adjective","плоха":"adjective","горяча":"adjective","тверда":"adjective","невідома":"adjective","картава":"adjective","горна":"adjective","черна":"adjective","гуржа":"adjective","гикава":"adjective","шита":"adjective","сєра":"adjective","сіда":"adjective","гнуча":"adjective","слизька":"adjective","бистра":"adjective","полева":"adjective","парубоча":"adjective","вібла":"adjective","мазна":"adjective","волохата":"adjective","шалена":"adjective","щира":"adjective","слаба":"adjective","суковата":"adjective","нища":"adjective","одинока":"adjective","сядриста":"adjective","яшна":"adjective","ракоча":"adjective","губата":"adjective","летуча":"adjective","патлата":"adjective","вяла":"adjective","гірна":"adjective","кіптіла":"adjective","кривовяза":"adjective","лиха":"adjective","подуфала":"adjective","буйна":"adjective","зайшла":"adjective","купрата":"adjective","мерзла":"adjective","варгата":"adjective","горда":"adjective","драпата":"adjective","загризла":"adjective","кичата":"adjective","оковита":"adjective","тлуста":"adjective","тонка":"adjective","коптіла":"adjective","погожа":"adjective","товстокора":"adjective","гладенька":"adjective","глубока":"adjective","періста":"adjective","виконавча":"adjective","кохана":"adjective","кризька":"adjective","німа":"adjective","росла":"adjective","некипіла":"adjective","плакуща":"adjective","похила":"adjective","строга":"adjective","богата":"adjective","заливча":"adjective","крамна":"adjective","поставнича":"adjective","безуса":"adjective","плоска":"adjective","сергата":"adjective","сухотепла":"adjective","толста":"adjective","шарпата":"adjective","безребра":"adjective","душна":"adjective","змерзла":"adjective","золотоверха":"adjective","наточа":"adjective","положа":"adjective","рокоча":"adjective","горлата":"adjective","скупа":"adjective","бібла":"adjective","ільніцка":"adjective","рогоча":"adjective","сміла":"adjective","щедра":"adjective","безклуба":"adjective","білоока":"adjective","шерстка":"adjective","безкишка":"adjective","летюча":"adjective","ловча":"adjective","піша":"adjective","раба":"adjective","суховерха":"adjective","тягла":"adjective","шаблиста":"adjective","шубала":"adjective","бедрата":"adjective","верлата":"adjective","галича":"adjective","запухла":"adjective","зубата":"adjective","кунта":"adjective","некрита":"adjective","пахуча":"adjective","теляча":"adjective","шпарка":"adjective","глива":"adjective","косата":"adjective","любима":"adjective","низька":"adjective","окрепка":"adjective","робоча":"adjective","слизькоуха":"adjective","хропата":"adjective","цівата":"adjective","шията":"adjective","безборода":"adjective","голоборода":"adjective","голомоза":"adjective","горєла":"adjective","єжела":"adjective","калиста":"adjective","корчиста":"adjective","курна":"adjective","надута":"adjective","пікуща":"adjective","погорела":"adjective","савіцка":"adjective","тупа":"adjective","дзяна":"adjective","жовкла":"adjective","колюча":"adjective","мазана":"adjective","сапата":"adjective","світа":"adjective","сухолитка":"adjective","цаберяба":"adjective","цвіла":"adjective","чупла":"adjective","асадча":"adjective","гарагата":"adjective","дзюбата":"adjective","долгопола":"adjective","жилава":"adjective","козина":"adjective","крепка":"adjective","ласа":"adjective","личката":"adjective","лобата":"adjective","льогка":"adjective","мишаста":"adjective","невмита":"adjective","перката":"adjective","рідка":"adjective","саплива":"adjective","тонкошкура":"adjective","цепла":"adjective","беззуба":"adjective","бушна":"adjective","бяла":"adjective","кріпка":"adjective","лакома":"adjective","майна":"adjective","нагла":"adjective","огніста":"adjective","осядла":"adjective","рабоча":"adjective","рапава":"adjective","розмаїта":"adjective","тупча":"adjective","ушата":"adjective","чорноока":"adjective","галянта":"adjective","голомовза":"adjective","одажа":"adjective","орлата":"adjective","пашиста":"adjective","пробита":"adjective","сепіта":"adjective","слабка":"adjective","цікава":"adjective","шамка":"adjective","шибиста":"adjective","баліцка":"adjective","бита":"adjective","боляча":"adjective","глабчаста":"adjective","гусліста":"adjective","деньдобра":"adjective","замліла":"adjective","лабата":"adjective","мяка":"adjective","несміла":"adjective","нєма":"adjective","обща":"adjective","одайна":"adjective","оката":"adjective","остиста":"adjective","пахуща":"adjective","пстра":"adjective","сладка":"adjective","храпата":"adjective","чесніша":"adjective","чула":"adjective","бідноша":"adjective","довгорука":"adjective","довгоша":"adjective","іваніцка":"adjective","корната":"adjective","кулява":"adjective","літуча":"adjective","марна":"adjective","медзата":"adjective","обмокла":"adjective","піджара":"adjective","побоча":"adjective","сагата":"adjective","удала":"adjective","усяка":"adjective","байдужа":"adjective","бескорса":"adjective","гірка":"adjective","главата":"adjective","горча":"adjective","горька":"adjective","добровольска":"adjective","довгопта":"adjective","досужа":"adjective","драпята":"adjective","камяна":"adjective","каправа":"adjective","киричата":"adjective","колота":"adjective","комарніцка":"adjective","люзна":"adjective","молодша":"adjective","неумита":"adjective","пересідла":"adjective","підла":"adjective","пухла":"adjective","семяниста":"adjective","сіроока":"adjective","стряпча":"adjective","твереза":"adjective","цибульска":"adjective","чарна":"adjective","ярка":"adjective","безгуба":"adjective","білоборода":"adjective","болєла":"adjective","бровата":"adjective","гікава":"adjective","голобока":"adjective","драбата":"adjective","жарка":"adjective","каплата":"adjective","кісла":"adjective","ковалевска":"adjective","ковальска":"adjective","козловска":"adjective","крилата":"adjective","куцка":"adjective","малоока":"adjective","мгка":"adjective","немята":"adjective","непроста":"adjective","нехороша":"adjective","пелихата":"adjective","підласа":"adjective","подпала":"adjective","руцка":"adjective","семениста":"adjective","услиста":"adjective","шорстка":"adjective","хила":"adjective","буката":"adjective","васалата":"adjective","вибла":"adjective","видойна":"adjective","виловата":"adjective","гарча":"adjective","горела":"adjective","дута":"adjective","зибла":"adjective","індича":"adjective","кальноока":"adjective","карнауха":"adjective","кривобедра":"adjective","кричфалуша":"adjective","кубата":"adjective","кужда":"adjective","ломана":"adjective","мацевита":"adjective","івашина":"noun","солоха":"adjective","перерва":"noun","проскура":"adjective","бова":"noun","сметана":"noun","дуброва":"noun","проскурня":"noun","родіна":"noun","єна":"noun","солонина":"noun","ліщина":"noun","лугина":"adjective","сосна":"noun","гавва":"noun","ужва":"noun","кулина":"adjective","халява":"noun","холява":"noun","підкова":"noun","крайня":"adjective","хохотва":"noun","цибулька":"noun","нікульча":"noun","кравчина":"noun","лупина":"adjective","лихошва":"noun","думбрава":"noun","плахотня":"adjective","покутня":"adjective","пона":"noun","семена":"noun","грона":"noun","єва":"noun","парасківа":"noun","шова":"noun","бурдужа":"adjective","козюберда":"adjective","говтва":"noun","приколота":"adjective","варнава":"noun","гурина":"adjective","рябокобила":"noun","кучина":"adjective","савва":"noun","кремена":"noun","малая":"adjective","горішня":"adjective","бурдюжа":"adjective","слаква":"noun","городня":"adjective","лиштва":"noun","цяцька":"noun","походня":"noun","недавня":"adjective","долішня":"adjective","марюхна":"noun","борона":"noun","колошва":"noun","семенча":"noun","затона":"noun","заплава":"noun","краснопера":"adjective","рибитва":"noun","сидора":"adjective","краплина":"noun","крутиголова":"noun","бакалина":"adjective","немна":"noun","очеретня":"adjective","пробийголова":"noun","мальона":"noun","сажина":"adjective","вчерашня":"adjective","бузина":"noun","забийворота":"noun","магльона":"noun","нейчева":"noun","потороча":"noun","ревіна":"noun","матьора":"adjective","святина":"noun","хіна":"noun","кожина":"adjective","наріжня":"noun","леона":"noun","передня":"adjective","савина":"adjective","сікачина":"noun","кльова":"noun","недолуга":"adjective","шкоропата":"noun","карасава":"noun","морева":"adjective","мустафіна":"noun","цьова":"noun","бубна":"noun","катона":"noun","міна":"noun","похвала":"noun","слоква":"noun","статіва":"noun","строна":"noun","вова":"noun","карева":"adjective","місюна":"noun","швая":"noun","бальва":"noun","вершина":"noun","врона":"noun","білокобила":"noun","гордина":"noun","кольва":"noun","льова":"noun","перекліта":"noun","основа":"noun","харена":"noun","борозна":"noun","будаква":"noun","каранікола":"noun","палесіка":"noun","рожина":"noun","штана":"noun","вицина":"noun","дубна":"noun","жовна":"noun","зіва":"noun","катарина":"noun","похмура":"adjective","фесина":"noun","шемена":"noun","галутва":"noun","зарева":"noun","ковальва":"noun","мирона":"noun","новосела":"noun","пачина":"adjective","совва":"noun","гіна":"noun","корона":"noun","новоженя":"noun","підберезня":"adjective","ряднина":"noun","сакська":"noun","канна":"noun","лукачина":"noun","плачінта":"noun","редьква":"noun","софина":"adjective","шатня":"adjective","блозва":"noun","вчорашня":"adjective","гриценя":"noun","куропатва":"noun","людва":"noun","стехна":"noun","парахоня":"noun","плєва":"noun","яворина":"noun","бендина":"noun","жовтонога":"adjective","конева":"adjective","мандалина":"noun","мацина":"noun","перезва":"noun","похвата":"noun","токмина":"noun","тюрина":"adjective","гицина":"noun","дзіна":"noun","куява":"noun","малонога":"adjective","стоколоса":"adjective","тимина":"adjective","біднина":"noun","вдовина":"adjective","лисохмара":"noun","микитина":"adjective","полівара":"noun","рибонька":"noun","ружина":"noun","тишина":"noun","цюрмаста":"noun","чалая":"adjective","васина":"noun","воїна":"noun","гулая":"noun","кова":"noun","она":"noun","палісіка":"noun","підошва":"noun","свидина":"noun","тирсина":"noun","хаврона":"noun","зона":"noun","кнзєва":"noun","розна":"adjective","ронжина":"noun","рудомина":"noun","сальва":"noun","скільсара":"noun","служала":"noun","фомина":"adjective","чупина":"adjective","шалупня":"noun","джупина":"noun","зоська":"noun","кузява":"noun","неледва":"noun","равва":"noun","разьва":"noun","шкорина":"noun","білозора":"adjective","бранціра":"noun","випна":"noun","галина":"adjective","мандаліна":"noun","мицька":"noun","мячина":"adjective","недосєка":"noun","пристая":"noun","м'яка":"adjective","вовчина":"noun","гринява":"noun","дівонька":"noun","ігіна":"noun","обійдихата":"noun","хижня":"adjective","челядина":"noun","янева":"adjective","голева":"adjective","дзюнька":"noun","дубрава":"noun","лигомина":"noun","мална":"noun","мархева":"noun","несправа":"noun","озява":"noun","панна":"noun","пупена":"noun","силява":"noun","сухокобила":"noun","цюрмоста":"noun","чевельча":"noun","чівільча":"noun","башева":"noun","бражна":"noun","варавва":"noun","волна":"noun","гольча":"noun","густа":"adjective","достатня":"adjective","зуграва":"noun","карапулька":"noun","кірна":"adjective","крапіва":"noun","луковина":"noun","мамона":"noun","мелещеня":"noun","мряна":"noun","параскева":"noun","похідня":"noun","пріхна":"noun","свтина":"noun","сьоська":"noun","терепіща":"noun","ціцяла":"noun","бодаква":"noun","гальвіта":"noun","деревенча":"noun","дона":"noun","дубена":"noun","задависвічка":"noun","йовва":"noun","капаціла":"noun","котельва":"noun","лісота":"noun","малюська":"noun","підсадня":"adjective","рєва":"noun","сувора":"adjective","хаджава":"noun","хомина":"adjective","псина":"noun","бобина":"noun","болотня":"adjective","бруква":"noun","кіона":"noun","ковбінька":"noun","кривонога":"adjective","лєва":"noun","мухина":"adjective","нефортуна":"noun","органіста":"noun","пасулька":"noun","пристава":"noun","бачина":"noun","безкорса":"adjective","бєлокобила":"noun","борзина":"noun","бружина":"noun","воротня":"adjective","гальона":"noun","голтва":"noun","горемульта":"noun","дацина":"noun","забанджала":"noun","злая":"adjective","кікена":"noun","коропатва":"noun","кузина":"adjective","лапунька":"noun","літава":"noun","мінчуна":"noun","на":"noun","ничая":"noun","новіцка":"adjective","пенькна":"noun","пухна":"noun","пуцята":"noun","рісна":"noun","розмаіта":"noun","румина":"adjective","свтна":"noun","сердита":"adjective","січінава":"noun","сментина":"noun","трізна":"noun","шкуропата":"noun","безхутра":"adjective","гальва":"noun","гнєда":"adjective","гребенча":"noun","гусонька":"noun","калабанька":"noun","козупляка":"noun","лапина":"adjective","мурина":"adjective","некульча":"noun","орона":"noun","парна":"adjective","пліва":"noun","приходька":"noun","сенина":"noun","солотва":"noun","тетева":"adjective","хавана":"noun","царева":"adjective","ахалая":"noun","варенька":"noun","варшава":"noun","вересоча":"noun","галунька":"noun","гліва":"noun","голина":"adjective","грузька":"adjective","гудина":"noun","євона":"noun","кірева":"adjective","кожем'яка":"noun","колоберда":"adjective","курінька":"noun","маржина":"noun","мигалина":"noun","мікава":"adjective","падва":"noun","паланичка":"adjective","палена":"adjective","подкова":"noun","ратушня":"adjective","селегейна":"noun","сминтина":"noun","сумина":"adjective","теміркая":"noun","ухата":"adjective","хавроня":"noun","холоста":"adjective","ціва":"noun","чернята":"noun","чикольва":"noun","шалина":"adjective","юдина":"adjective","адвена":"noun","балева":"adjective","брона":"noun","вербовата":"adjective","веремєва":"noun","волчаста":"adjective","гафина":"adjective","голутва":"noun","закрева":"noun","каджая":"noun","кальченя":"noun","капаниста":"adjective","кикина":"adjective","костерева":"noun","кривокобила":"noun","кулєва":"noun","лавна":"noun","маліцка":"adjective","молдова":"noun","моркова":"noun","пажина":"adjective","перевернихата":"noun","пилева":"adjective","піддубня":"adjective","постіва":"noun","пуста":"adjective","суботня":"adjective","фадеева":"adjective","ходаніцка":"adjective","хохітва":"noun","цибата":"adjective","черноока":"adjective","чкадуа":"noun","чокена":"noun","шепетина":"noun","шербина":"noun","яка":"adjective","ятва":"noun","безена":"noun","безшкура":"adjective","безязика":"adjective","белая":"adjective","берулава":"noun","бузна":"noun","бурсала":"noun","бучаста":"adjective","вчина":"noun","гапона":"noun","гернажа":"noun","гордуна":"noun","горсва":"noun","горясва":"noun","грицька":"noun","двіжона":"noun","задурня":"adjective","заслона":"noun","зачешигрива":"noun","йона":"noun","качна":"adjective","козовіта":"noun","криворота":"adjective","кур'ята":"noun","лозна":"adjective","люлява":"noun","лютая":"adjective","матухна":"noun","накутня":"adjective","плохая":"adjective","бухая":"adjective","самотня":"adjective","панібудьласка":"noun","яцина":"noun"};class im{encode(t){const n=new Uint8Array(1);switch(t.wordClass){case e.WordClass.NOUN:n[0]=1;break;case e.WordClass.ADJECTIVE:n[0]=0;break;default:throw new TypeError(`Invalid word class: "${t.wordClass}".`)}return n}decode(t){if(t.length<1||t.length>1)throw new RangeError("Invalid vector length.");const n=t[0];if(n<0||n>1)throw new RangeError("Invalid vector value.");return{wordClass:n>=.5?e.WordClass.NOUN:e.WordClass.ADJECTIVE}}}class sm{constructor(e,t=0){this.vectorSize=e,this.unknownCharcode=t}encode(e){var t;const a=new Uint8Array(this.vectorSize),i=e.slice(-this.vectorSize).toLowerCase().padStart(this.vectorSize,"-");for(let e=0;e<i.length;e+=1){const s=i[e];a[e]=null!==(t=n[s])&&void 0!==t?t:this.unknownCharcode}return a}}H().set("IS_NODE",!1);var rm={class_name:"Sequential",config:{name:"sequential_1",layers:[{class_name:"Embedding",config:{input_dim:34,output_dim:16,embeddings_initializer:{class_name:"RandomUniform",config:{minval:-.05,maxval:.05,seed:null}},embeddings_regularizer:null,activity_regularizer:null,embeddings_constraint:null,mask_zero:null,input_length:null,name:"embedding_Embedding1",trainable:!0,batch_input_shape:[null,null]}},{class_name:"SimpleRNN",config:{name:"simple_rnn_SimpleRNN1",trainable:!0,units:16,activation:"relu",use_bias:!0,kernel_initializer:{class_name:"VarianceScaling",config:{scale:1,mode:"fan_avg",distribution:"normal",seed:null}},recurrent_initializer:{class_name:"Orthogonal",config:{gain:1,seed:null}},bias_initializer:{class_name:"Zeros",config:{}},kernel_regularizer:null,recurrent_regularizer:null,bias_regularizer:null,activity_regularizer:null,kernel_constraint:null,recurrent_constraint:null,bias_constraint:null,dropout:0,recurrent_dropout:0,return_sequences:!1,return_state:!1,go_backwards:!1,stateful:!1,unroll:!1}},{class_name:"Dense",config:{units:1,activation:"sigmoid",use_bias:!0,kernel_initializer:{class_name:"VarianceScaling",config:{scale:1,mode:"fan_avg",distribution:"normal",seed:null}},bias_initializer:{class_name:"Zeros",config:{}},kernel_regularizer:null,bias_regularizer:null,activity_regularizer:null,kernel_constraint:null,bias_constraint:null,name:"dense_Dense1",trainable:!0}}]},keras_version:"tfjs-layers 4.2.0",backend:"tensor_flow.js"},om=[{name:"embedding_Embedding1/embeddings",shape:[34,16],dtype:"float32"},{name:"simple_rnn_SimpleRNN1/kernel",shape:[16,16],dtype:"float32"},{name:"simple_rnn_SimpleRNN1/recurrent_kernel",shape:[16,16],dtype:"float32"},{name:"simple_rnn_SimpleRNN1/bias",shape:[16],dtype:"float32"},{name:"dense_Dense1/kernel",shape:[16,1],dtype:"float32"},{name:"dense_Dense1/bias",shape:[1],dtype:"float32"}],lm="D3HrvZUs7rxT6Vu+tVsfvPLyB70zbt695ECPvKyKWj7TnUO+JZ9pvs8MkL3/1DQ+kftzvPGZZL4aDpe8KiOnvSvRHz52vQK9mGiSPm50B72RCfM+7hW6PSOuTz7b9zG+M5MOPv/mYL7Q9Rk+aPgRvrfQuT6mQ2Q+eOawPp/PpLyM9yY+zB4APT27n75OVUk+V8y6vetFyD0zPlW+sqPfPER8Ub6J1pI+5QwEvcZktT12HLW+FSFGPU6s2ryQapW9/MNNvoK1t71R5sK8N6Y/vjqBzTtusl2+0Ks8PpZOQ74ua5U9TOIfvkpgHDxho/294hcTPkJaiL1iXTo9o28bPhnMBr69EoG8CAeCvtgxXT5kMKq+KnLfPbScM73jYjw+LTa8vSeQWj49+cU7/FH2PKtOwr5y8K29GMMdvrkIgb0wK4C8Zeq2vXlG+L15O4c+CaFGvpmCjD5guBg+0AAQPv0EjT3CdZ0+vLOBulXEAb7VVpi+WldAPpIP8T0ETFm+NcLIPZix17rKGEW+n8jxPfT8hr43TLC8esPRvX6k4D1lZ0C+WERdPo4Qab4SdWw+uWSevp7+zTjX5Xi8nw+ZvldSb7xUfke7HX01PVOV2zzFqV2+SqcNvvPUTz0nzZi9Zl+ePWj6Wr3PLjY+vbjrvSRr6b1es/w8oaLjPUC0G72spye9rsomPtW/t72QYEy9AtR6PuX44z1dLrk9k6HAPE1+Eb7w1mY+N8MSvuMLsj1qmsO6JrRAvsJowr7iA1E+udZGPDLR57xRSj8+GFSnvYNUujxIvpM8FHmHvkr8QD38Po29LslnvShYOD45FAE7vfaWPbnegruqB2W9MdUkPpskUb3YGTU+L3gwvQhAYD4ed66+qJQUvjydBr7bSam8fYz/PCTisD7GYoQ+HDxJvSaIR77s3u+8sVTkvaDBaL13FBs+Z8T4vT4aKj2d4DC7ft+GPvVXFLxGXGI9RJ9avl7RCD6ujIy+M+/zPQbAtr3B2+c9BpZcPYIBTj7QNsM95bqEPc221T3u7TO+M2PIPU/BQb78/nk+f4TmvV5Elj0VOAK+0Y+DPq0GkL364pI98CGUvjK4IL1CLoK+kohXvTS3I76BpcM9WE0Rva5vkz301Ui+CLe7vWkLnT1sjpM8EYyWPWblIryk+gI+gnQSvu9XKL7jtni9Rc/IvaonHj2sKBc+VzRovpdOpT64szY+OavnvfzjeLuBH62+OqC2OoeMBr0eJVi7ST7CPLK/3jxTOoC9BRUSPjNBaD6OIlm+7ApUPlbsWj5KIKi+J9F1Pfi88L1+JdA9a6F+PsiRub06rh2+HlXnPb5Wj774l+i6nifjvWMCtL2WnqW9pUNdvjQM4L0ZJDy9lZ+LPbJWhj2hUZO+iWF0vhq17zqKwOI9Qq6sPWo8gD3c0co9/5WaPLN6PL6HOLO8fXvUvEF2IL4QJ7S98UzCPZJTlb6VUCM+y7dqvkJXyTyxD+I9N6PXvUxuqr0jiuM9p1OgO/wUFL07zEy+n5rPvSLifbt4N5e+kbdRviF6Db0ZSjo+B+dXvqB+iT7nFI68Z9bUPU9FGT21fz4+fee2vaIHqLzRTtG8aGggPqQlpD1GORk9/FpnPjatAL60OPg8x+qAPdU74zxSk6+9lYwdPikogr6pxao99PmXvH+yEz4zu5U9IeURPXqY9LpuvYk8OGmYvFX7+TtuUaO9qg0GPph0Xr5vdYM+0deHvozgtryfgDC8DaCGPTVxHb6q0fI97pWqPOXMAj7Y9ae+fljRuoumt71vblO+UaetPcadt7yiUYi9R9x8PqXbmb4V9gK+v2jjvVsTU72VAJ29JC1vPcpy1D2uNZM9N5mlvru77rxAZSo9jZWkvv+0HD6CY6k9RvnyvLM8Wr4/Yjo+aEr4vcUQkj3Ef7+7DusLvhf0oLxUt1u+LdOWPndY+Ty5+Dq+QfqQvqgCbj7V0L68swkNviGjaz0SkyQ+h9uuvckW97rM35m+O7ERPQvQ4L2XN3a9XwqPPifY7TynN0i9enwJPWh2Tj27c02+k0bpPWtEGz4p+qs9DzsKPhlEoD7U1qM9v7SAvNgeIr7tPJM9om6CvhmNcz7pBIa9HEvlPRmEGj7SzgE9tdoAO8dkeT2N2Xm9ChofvhVPSj19rZG+A2PfPVrax72zacc9YWsTvjSKAj4inbu9GbJGvSEnt76qFeq8JsAnvZ0cO75Lk7e5G8+WPrc5Cb3RGVg+xwxfvgTMNr18pdU9U49jPaRh5rg8G2Q+iUtrObd+jT0FTYG+XgVgvKwXJr6TWuG9BWosPlr9pT6IF2G+boCIvU0FOb39ivu9aMA5viC1S714C3q+CES6Pt11j76mNqk+/btevCcEVL7z5cK+ALgyPJeTPb0+7O+7lftrPslPZz1EqIY9DWKYvdtgWL5/DwI9Q2NFvJhKcb0MMQo+NtltPWZcmT2FlVA9V5Nnvc9IJr0TXCA+nAIuPoF7xbon0SQ+Kwi8ve0ePb6O3++9k2/GvZoLlrxRDM48DwOkvEiWIz7jsgC+NYZzvTu7Jb7Jcgm8qAoyPg8zkT3o8UI+7Mt/vZsaYj7UZDm+Z4BTPBgkQr7CSTs+PKpvPbkSED3tAaW9LJ9APo74Fz62CFe8xMDCPi83F76ttk++K6FGvQkDDr42fbG+N9cbPvP1Br2CU1c+qukfvu3DJz6Vjfy8jlM9PZNaKL4Ceu29dDVCvoG7fD5qTLu75+YoPXt8GD7ey2U+KpynvemmCL1L1VC9LsfhvcoBND44he273UFiPrLzK72XXPS9ZjZGPtBwh7gwW2i+ccbxvXtoMj4Q/u49AzHBvoTjHD40AuW+OiwYP4x9JD6PGAY/KN7+Pc0xhb6OqxY9AptQvbc7Or39a9e6DJ/zPvd+iz6XX7g6kqsEP5LI1L7ICBk+1k5SP0lR0T43qYI+kbFLvcUh5L7+v90+5mnZveLTxj03yAS+phJLvW7x3b4m3J68GeeBvlrhgj05ac++0Yyfvcrz7L1/Y/i+ZjMKPhEy6j3ImRu+fRRuPkunGL5dMVG+Yd5Fv6ys1z6PXYI+JhzOvaGxDT4p38I+QcDHPtkxbb0XnjM/ogGYviZrLj291se+iNNqvpZuUb7nas8+lj4tvvyQ3D7w+FO9r4ybPs7MJD+WsIG9pGxHPqmQo75RdUG/gFs2vRXbrj7n87w9aGosPm8vDr/oUeO+2pWxPsk1RT7lvPS+YBmZvkDPU745ORi/BxbNPg83pD2KOSq9Nh0tPw6bSj+WVTk97hLcPnMDpT7GgXW8dL46vltPvb11QOu9CeYDPYDxwbx5UQ8+MnesPb+Ajj7Uv7m+qE+TvM+Qt77g88s+7940P8/1zj5p9+g+FugoPgNebT69zXg+IbhFvnHq6LsVozg+iIaBPau6Kr6tTOG+U1bhPS6zFD64rqY/FZebvhOPeL5DGXo+dwgLPjKu6z5+X78+iAsNPrs/Pb+RQoe+6MyqvWutu75ml7G+3Casvq63/b4exKi9+5lMv7V/yb4twI49cbIcv/+5/r5lWxE/78Q+PhjngT4SENI9xZKXPmmQEb9UJGK+eYE3vtOLiDxf4zo+9KX5Pl0APj9PhqA+i/wMv1iRsjzngaK+/ocBv8RUnr0hPdM+YAshv896DL1aukY+kiIJvsKhvD66FTi++84Fv5vWjL4lr6W+OLvyvba/krzwXgm9X8rUvv+XNb7jhSo/zfCAPLRlqD4Fn5S+DeQfP0847T7NIZ4+/gMAPxyfcT6VQOM+UOmWvWDtrD4TLFW9NGQSveJN9T7AuFm+MvUSv/TnFz8uw68+k05IPj26MTwDLsW+hsLFvifDqD7Z6d28z+AOv1DeZL8TnA++mrwBvT0BGL5ireW+PLbOOQjsJjzUmya/CcavOz8kwr70lmK+PHcmPsmi9r5VeAI+yly7PSGkIT6xV1Q/uHsKP4WFir4DBcc+SIJuPlP0Lb5Nufu+dKc3vk/X4L2Qvyo/jJSCPr3+Vr7NNA4/5AqcPoYisjuvO6g9JGKRPgxvQj/bUnG8yqAbP8wDO75rdkO+keIuPvrKxT4VCoQ9fx3XPih9K77kIOg99g2gPcrn4rxDzyy+TDdxPpzmHz//YWM+PIXFvTGs4z5SaaE9NAwkv4Qcub6gS3g+6Wa0vf3qJD8NDC2/q4z6PFVEob5p8yG+uSjhvjAMgD4GQ2Q/+EfRPlrsL79K2PO+FyOrPav1lT6vSzQ+nQOovRiVMD4Yfg4+weDxPv9V8b3ix407T0mFvEXdYT4DaKq+rE4YviLa2r4q/vI7hVWOvWgaV77A7QU/OU2iPp8QQT58RIA+Lbf+vo65Fz1RDRw+mv6WvdOImj4/IyY9a+vPO/pDuj6WiFe94SnbvW0cAb5HUcQ8croTvdeGIT6Q5p89/2EpPyPapj33gSS+q161vhFrSj00b5A9P6g4vssdob5sS5G+r72gvUDqCj+C5+a9lJHFPjtFxz10OYs+qXakvlUu5Trwp749nrcQPbAzwr5pCs8+UhoIvsHVdT7iw+i+UYxzPgTn5T50arg+R/4IP7kH2T2cguW+pQX+vFqQdr3z5yY+SdURProPID4CXhA9crIcP/7a4D6r/549Ly6lvXeFUb9n9xs/CC3oPrOgAj8iPwo/8nPXviKqAr8q6TQ+vrumPrdtHz8prJq+V1/oPUZWGr4Y4cU9nRopvtRCkz2jeTy+pJW0PgwDyz6XfIo+QmZevqCRSj1/pIa+KoufPllZvT5o244+nRIYP3TbM70N+8y+a7d2vcsSWj4Cdrw+AT8hPVoDwL0BxL2+G1pmPo/CZL66zSS+g2rFPvewar7nfGe+YEuevRgFIr7dyRS+KES0Pnu1p754F6s+/inJPXa3tL4Qd5A+OmbLPWvlnb75WsU9rRHMvsgqxD5MQ90+Y38LPnBkZj7fKIs9uJCHvdiuXr6D/Rw9hpVyPu9Vqr4Qzom85dP6vYymmr1yG5w+2gSMPlV5tT1D1ks+EKTZPm4gOb6ZC+w+k8EOPA8oXb6r9z2+h6Tgvm7Dvj7OzJQ+7tkIPvbDjz4TN6u9GneSPTIooD7GdRA/wYQ4vVr7b71F/QI+cRORPrRPWzxVX22+Yu2vPsHriL720za+oBlVPogMe72YNKM8r9aEO5uq1z7RegW+4aX1PqfYRD/wpfI9sVqvPCI99jpAtWC9eXJ2PBb++j6w+809iODsPfwV0b2kL7S9D+FLPQZECD4oYRA+V1Z+vjarEj5ZF/q8KJSAPkjENr7zNd28pKODPj8FPL8mgFY8kJVMvgBfQ75uooK++9TaPg/5Cr5Pzo6+1Yy3viONQL/Fvng+Bmn6vTpQkb0N7Oi94ZVHPYE2Hr7J/Rk+zQzKvL3Chj5d85o+Q/YRPrsjnj7YzJY+01w3PyVgGD6INkM+XtnevbmxiL7Z1NI+jpdgvggkdz0QnJq+35a8PZX0SL4+y78+grnOPYHzlD2VKRA/xRW4PqyCPL4Cowa/Ku+pvZabKz99894+sY/Vva/ezL1zsUw+er4IP8DL/D1qa2a+m6B3PK8Cq76mu2++gsjvvP0kBz8pWqe+SyotvKUdmz4pFXA7bkXCvbwSbj44g7c8mID4viXITL56E/G9zBVuPPD+u7wCmJc9v1nDuyyEX77G7Nq8GUwXvQJRVT3nTYY9/wK9Pct9sT1dCqU9aRsHvlmTFD2/B5M9PclmvNt2Jb8eqR2+bZhIvlmRVT4k0zU/OFSyvnCsHb/BfrK+ZZJGv10pNT8uXQk/AaVXvgbtG76M5kC+b6zpPfBICD8I1Lm8",cm={format:"layers-model",generatedBy:"TensorFlow.js tfjs-layers v4.2.0",convertedBy:null};const um="undefined"!=typeof Buffer&&("undefined"==typeof Blob||"undefined"==typeof atob||"undefined"==typeof btoa);class hm{inflect(e,n,a){return t(this,0,void 0,(function*(){const t=[],i=e.split("-");for(let e=0;e<i.length;e+=1){const s=yield this.inflectNamePart(i[e],n,a,e===i.length-1);t.push(s)}return t.join("-")}))}}const pm=/[ая]$/i,dm=/(ой|ий|ій|их)$/i;const fm=new class extends hm{constructor(e){super(),this.wordInflector=e}inflectNamePart(e,t,n){return this.wordInflector.inflect(e,{grammaticalCase:n,gender:t,applicationType:"givenName"})}}(g),mm=new class extends hm{constructor(e){super(),this.wordInflector=e}inflectNamePart(e,t,n){return this.wordInflector.inflect(e,{grammaticalCase:n,gender:t,applicationType:"patronymicName",customRuleFilter:e=>e.applicationType.includes("patronymicName")})}}(g),gm=new class{constructor(e){this.modelLoader=e,this.modelPromise=null,this.wordTransformer=new sm(20),this.familyNameClassTransformer=new im}classify(e){return t(this,0,void 0,(function*(){let t=this.getCached(e);if(null!=t)return t;const n=yield this.loadModel(),a=this.wordTransformer.encode(e),i=yield n.predict(dr([a])).data();return t=this.familyNameClassTransformer.decode(i),t}))}getCached(e){let t=null;const n=am[e.toLowerCase()];return n&&(t={wordClass:n}),t}loadModel(){return t(this,0,void 0,(function*(){return null==this.modelPromise&&(this.modelPromise=Mp(this.modelLoader)),this.modelPromise}))}}(new class{load(){return t(this,0,void 0,(function*(){const e={};if(e.modelTopology=rm,e.weightSpecs=om,e.weightData=function(e){if(um){const t=Buffer.from(e,"base64");return t.buffer.slice(t.byteOffset,t.byteOffset+t.byteLength)}const t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;++e)n.set([t.charCodeAt(e)],e);return n.buffer}(lm),null!=cm){const t=cm;e.format=t.format,e.generatedBy=t.generatedBy,e.convertedBy=t.convertedBy,null!=t.signature&&(e.signature=t.signature),null!=t.userDefinedMetadata&&(e.userDefinedMetadata=t.userDefinedMetadata),null!=t.modelInitializer&&(e.modelInitializer=t.modelInitializer),null!=t.initializerSignature&&(e.initializerSignature=t.initializerSignature),null!=t.trainingConfig&&(e.trainingConfig=t.trainingConfig)}return e}))}}),vm=new class extends hm{constructor(e,t){super(),this.wordInflector=e,this.familyNameClassifier=t}inflectNamePart(e,n,a,i){return t(this,0,void 0,(function*(){if(!i&&s(e))return e;let t=null;return this.isUncertainFamilyNameClass(e,n)&&(t=yield this.familyNameClassifier.classify(e)),this.wordInflector.inflect(e,{grammaticalCase:a,gender:n,wordClass:null==t?void 0:t.wordClass,applicationType:"familyName"})}))}isUncertainFamilyNameClass(t,n){return n===e.GrammaticalGender.FEMININE&&pm.test(t)||n===e.GrammaticalGender.MASCULINE&&dm.test(t)}}(g,gm),ym=new class{constructor(e,t,n){this.givenNameInflector=e,this.patronymicNameInflector=t,this.familyNameInflector=n}inflect(e,n,a){return t(this,0,void 0,(function*(){const t={};return null!=e.givenName&&(t.givenName=yield this.givenNameInflector.inflect(e.givenName,n,a)),null!=e.patronymicName&&(t.patronymicName=yield this.patronymicNameInflector.inflect(e.patronymicName,n,a)),null!=e.familyName&&(t.familyName=yield this.familyNameInflector.inflect(e.familyName,n,a)),t}))}}
4682
+ vt(Uo),vt(Co),vt(Go),vt(Vo),vt(Ko),vt(qo),vt(Lo),vt(Ho),vt(tl),vt(Fo),vt(Qo),vt(Oo),vt(To);var am={"штих":"noun","пяних":"noun","белих":"adjective","борзих":"adjective","малих":"adjective","старих":"adjective","дарнопих":"noun","сухих":"adjective","черемних":"noun","сирих":"adjective","плохих":"adjective","целих":"adjective","жих":"noun","войцих":"noun","скорих":"adjective","бурих":"adjective","чалих":"adjective","серих":"adjective","удалих":"adjective","карих":"adjective","гених":"noun","литвих":"noun","марцих":"noun","сізих":"adjective","яних":"noun","мжачих":"adjective","сірих":"adjective","янбих":"noun","бодрих":"adjective","стрий":"noun","чорторий":"noun","юрий":"adjective","цибрий":"noun","цібрий":"noun","карий":"adjective","куприй":"noun","кирий":"noun","негрий":"noun","губрий":"noun","шкабрий":"noun","замрий":"noun","передрий":"noun","одерий":"noun","жегрий":"noun","жарий":"adjective","зюбрий":"noun","семерий":"noun","лий":"noun","бий":"noun","рий":"noun","вий":"noun","ший":"noun","валий":"noun","крайній":"adjective","осінній":"adjective","кутній":"adjective","середній":"adjective","горішній":"adjective","безродній":"adjective","осадчій":"adjective","кий":"noun","новохатній":"adjective","очеретній":"adjective","рбий":"noun","закутній":"adjective","недавній":"adjective","порожній":"adjective","бокий":"noun","вчерашній":"adjective","огородній":"adjective","трощий":"noun","вчорашній":"adjective","житній":"adjective","нижній":"adjective","синій":"adjective","хорий":"noun","краснобокій":"adjective","хижній":"adjective","забродній":"adjective","калюжній":"adjective","виноградній":"adjective","коломий":"noun","летучій":"adjective","поздній":"adjective","серий":"noun","нагорній":"adjective","фартушній":"adjective","холошвій":"noun","батий":"noun","волошиній":"adjective","жирий":"noun","заможній":"adjective","короткій":"adjective","останній":"adjective","передній":"adjective","піддубній":"adjective","пізній":"adjective","погородній":"adjective","бояжній":"adjective","смий":"noun","задвірній":"adjective","остатній":"adjective","підсадній":"adjective","достатній":"adjective","зимній":"adjective","рябой":"adjective","рудой":"adjective","козодой":"noun","яровой":"adjective","кривой":"adjective","садовой":"adjective","полевой":"adjective","сисой":"noun","плохой":"adjective","сухой":"adjective","гаєвой":"adjective","глухой":"adjective","горевой":"adjective","кутовой":"adjective","копаной":"adjective","злой":"adjective","сєдой":"adjective","благой":"adjective","водостой":"noun","косой":"adjective","ліждвой":"noun","большой":"adjective","половой":"adjective","чорной":"adjective","косогой":"adjective","золотой":"adjective","лановой":"adjective","яловой":"adjective","дорогой":"adjective","німой":"adjective","первой":"adjective","русой":"adjective","худой":"adjective","цаподой":"noun","авасілой":"noun","валовой":"adjective","гнідой":"adjective","молокопой":"noun","золотобой":"noun","ярковой":"noun","аміхалакіой":"noun","седой":"adjective","крутой":"adjective","кучной":"adjective","слепой":"adjective","дурной":"adjective","молодой":"adjective","бухой":"adjective","самотній":"adjective","біла":"adjective","бура":"adjective","велика":"adjective","домовина":"noun","рослина":"noun","врецьона":"noun","глибока":"adjective","висока":"adjective","гладка":"adjective","грицина":"noun","гужва":"noun","ковінька":"noun","дика":"adjective","діброва":"noun","кицька":"noun","ківа":"noun","лепка":"adjective","островерха":"adjective","петрина":"noun","прудка":"adjective","семенина":"noun","турчина":"noun","чуприна":"noun","швидка":"adjective","щербина":"noun","яковина":"noun","синьоока":"adjective","крива":"adjective","сліпа":"adjective","глуха":"adjective","жовта":"adjective","добра":"adjective","хоробра":"adjective","сухоребра":"adjective","гарна":"adjective","мала":"adjective","весна":"noun","зла":"adjective","жива":"adjective","ніяка":"adjective","ціла":"adjective","молода":"adjective","далека":"adjective","золота":"adjective","жвава":"adjective","дорога":"adjective","коса":"adjective","литва":"noun","чужа":"adjective","тепла":"adjective","груба":"adjective","слава":"noun","брова":"noun","стара":"adjective","катерина":"noun","василина":"noun","нижня":"adjective","худа":"adjective","проста":"adjective","дівоча":"adjective","крута":"adjective","метка":"adjective","чорна":"adjective","сторона":"noun","невкрита":"adjective","руда":"adjective","темна":"adjective","проява":"noun","тиха":"adjective","божа":"adjective","весела":"adjective","бабина":"adjective","суха":"adjective","люта":"adjective","стіна":"noun","вража":"adjective","хороша":"adjective","легка":"adjective","козача":"adjective","польща":"noun","недужа":"adjective","розлога":"adjective","гаряча":"adjective","середня":"adjective","торішня":"adjective","сита":"adjective","гостра":"adjective","осіння":"adjective","невесела":"adjective","москва":"noun","широка":"adjective","половина":"noun","синя":"adjective","сира":"adjective","довга":"adjective","коротка":"adjective","лукава":"adjective","абияка":"adjective","королева":"noun","чайна":"adjective","сіра":"adjective","сутула":"adjective","сава":"noun","дебела":"adjective","мокра":"adjective","убога":"adjective","безрука":"adjective","димна":"adjective","мила":"adjective","боса":"adjective","гола":"adjective","красноока":"adjective","остання":"adjective","десна":"noun","житня":"adjective","тризна":"noun","цупка":"adjective","порожня":"adjective","ліва":"adjective","сьома":"adjective","вовна":"noun","сова":"noun","бела":"adjective","ряба":"adjective","гніда":"adjective","гожа":"adjective","кисла":"adjective","кутня":"adjective","огниста":"adjective","мудра":"adjective","дужа":"adjective","підстава":"noun","бодра":"adjective","бадьора":"adjective","кривохижа":"adjective","прихожа":"adjective","побожа":"adjective","пригожа":"adjective","петрунька":"noun","ковинька":"noun","кишинька":"noun","кропивянька":"noun","зеленька":"noun","лабунька":"noun","м'якенька":"adjective","бухонька":"noun","сиза":"adjective","маза":"adjective","блаза":"adjective","улина":"adjective","ейвена":"adjective","еремина":"adjective","ена":"adjective","клята":"adjective","периста":"adjective","працевита":"adjective","свіжа":"adjective","рижа":"adjective","копистира":"noun","скорина":"noun","більченя":"noun","кривошеня":"noun","нестереня":"noun","захарченя":"noun","войценя":"noun","протасеня":"noun","олещеня":"noun","денисеня":"noun","стрельченя":"noun","молодоженя":"noun","заграва":"noun","неменша":"adjective","неменьша":"adjective","меньша":"adjective","паший":"noun","пєша":"adjective","дзвінка":"adjective","пухка":"adjective","безпала":"adjective","вобла":"adjective","горжа":"adjective","горіла":"adjective","китаста":"adjective","лиса":"adjective","осадча":"adjective","пелехата":"adjective","підпала":"adjective","ставнича":"adjective","чала":"adjective","чубата":"adjective","целомудра":"adjective","кара":"adjective","коцупатра":"adjective","немудра":"adjective","шара":"adjective","шингира":"adjective","передера":"adjective","далекора":"adjective","жара":"adjective","яра":"adjective","золотопера":"adjective","остра":"adjective","хитра":"adjective","прозора":"adjective","карчинска":"adjective","гнила":"adjective","хижа":"adjective","крижа":"adjective","погоріла":"adjective","куца":"adjective","солодка":"adjective","безверха":"adjective","усата":"adjective","довгопола":"adjective","щербата":"adjective","пишна":"adjective","хоружа":"adjective","мирна":"adjective","долга":"adjective","бєла":"adjective","надточа":"adjective","гаркава":"adjective","мягка":"adjective","топча":"adjective","товста":"adjective","блага":"adjective","захожа":"adjective","боліла":"adjective","басиста":"adjective","басіста":"adjective","люба":"adjective","горбата":"adjective","драна":"adjective","куряча":"adjective","куса":"adjective","зайва":"adjective","кругла":"adjective","брижата":"adjective","скора":"adjective","плоха":"adjective","горяча":"adjective","тверда":"adjective","невідома":"adjective","картава":"adjective","горна":"adjective","черна":"adjective","гуржа":"adjective","гикава":"adjective","шита":"adjective","сєра":"adjective","сіда":"adjective","гнуча":"adjective","слизька":"adjective","бистра":"adjective","полева":"adjective","парубоча":"adjective","вібла":"adjective","мазна":"adjective","волохата":"adjective","шалена":"adjective","щира":"adjective","слаба":"adjective","суковата":"adjective","нища":"adjective","одинока":"adjective","сядриста":"adjective","яшна":"adjective","ракоча":"adjective","губата":"adjective","летуча":"adjective","патлата":"adjective","вяла":"adjective","гірна":"adjective","кіптіла":"adjective","кривовяза":"adjective","лиха":"adjective","подуфала":"adjective","буйна":"adjective","зайшла":"adjective","купрата":"adjective","мерзла":"adjective","варгата":"adjective","горда":"adjective","драпата":"adjective","загризла":"adjective","кичата":"adjective","оковита":"adjective","тлуста":"adjective","тонка":"adjective","коптіла":"adjective","погожа":"adjective","товстокора":"adjective","гладенька":"adjective","глубока":"adjective","періста":"adjective","виконавча":"adjective","кохана":"adjective","кризька":"adjective","німа":"adjective","росла":"adjective","некипіла":"adjective","плакуща":"adjective","похила":"adjective","строга":"adjective","богата":"adjective","заливча":"adjective","крамна":"adjective","поставнича":"adjective","безуса":"adjective","плоска":"adjective","сергата":"adjective","сухотепла":"adjective","толста":"adjective","шарпата":"adjective","безребра":"adjective","душна":"adjective","змерзла":"adjective","золотоверха":"adjective","наточа":"adjective","положа":"adjective","рокоча":"adjective","горлата":"adjective","скупа":"adjective","бібла":"adjective","ільніцка":"adjective","рогоча":"adjective","сміла":"adjective","щедра":"adjective","безклуба":"adjective","білоока":"adjective","шерстка":"adjective","безкишка":"adjective","летюча":"adjective","ловча":"adjective","піша":"adjective","раба":"adjective","суховерха":"adjective","тягла":"adjective","шаблиста":"adjective","шубала":"adjective","бедрата":"adjective","верлата":"adjective","галича":"adjective","запухла":"adjective","зубата":"adjective","кунта":"adjective","некрита":"adjective","пахуча":"adjective","теляча":"adjective","шпарка":"adjective","глива":"adjective","косата":"adjective","любима":"adjective","низька":"adjective","окрепка":"adjective","робоча":"adjective","слизькоуха":"adjective","хропата":"adjective","цівата":"adjective","шията":"adjective","безборода":"adjective","голоборода":"adjective","голомоза":"adjective","горєла":"adjective","єжела":"adjective","калиста":"adjective","корчиста":"adjective","курна":"adjective","надута":"adjective","пікуща":"adjective","погорела":"adjective","савіцка":"adjective","тупа":"adjective","дзяна":"adjective","жовкла":"adjective","колюча":"adjective","мазана":"adjective","сапата":"adjective","світа":"adjective","сухолитка":"adjective","цаберяба":"adjective","цвіла":"adjective","чупла":"adjective","асадча":"adjective","гарагата":"adjective","дзюбата":"adjective","долгопола":"adjective","жилава":"adjective","козина":"adjective","крепка":"adjective","ласа":"adjective","личката":"adjective","лобата":"adjective","льогка":"adjective","мишаста":"adjective","невмита":"adjective","перката":"adjective","рідка":"adjective","саплива":"adjective","тонкошкура":"adjective","цепла":"adjective","беззуба":"adjective","бушна":"adjective","бяла":"adjective","кріпка":"adjective","лакома":"adjective","майна":"adjective","нагла":"adjective","огніста":"adjective","осядла":"adjective","рабоча":"adjective","рапава":"adjective","розмаїта":"adjective","тупча":"adjective","ушата":"adjective","чорноока":"adjective","галянта":"adjective","голомовза":"adjective","одажа":"adjective","орлата":"adjective","пашиста":"adjective","пробита":"adjective","сепіта":"adjective","слабка":"adjective","цікава":"adjective","шамка":"adjective","шибиста":"adjective","баліцка":"adjective","бита":"adjective","боляча":"adjective","глабчаста":"adjective","гусліста":"adjective","деньдобра":"adjective","замліла":"adjective","лабата":"adjective","мяка":"adjective","несміла":"adjective","нєма":"adjective","обща":"adjective","одайна":"adjective","оката":"adjective","остиста":"adjective","пахуща":"adjective","пстра":"adjective","сладка":"adjective","храпата":"adjective","чесніша":"adjective","чула":"adjective","бідноша":"adjective","довгорука":"adjective","довгоша":"adjective","іваніцка":"adjective","корната":"adjective","кулява":"adjective","літуча":"adjective","марна":"adjective","медзата":"adjective","обмокла":"adjective","піджара":"adjective","побоча":"adjective","сагата":"adjective","удала":"adjective","усяка":"adjective","байдужа":"adjective","бескорса":"adjective","гірка":"adjective","главата":"adjective","горча":"adjective","горька":"adjective","добровольска":"adjective","довгопта":"adjective","досужа":"adjective","драпята":"adjective","камяна":"adjective","каправа":"adjective","киричата":"adjective","колота":"adjective","комарніцка":"adjective","люзна":"adjective","молодша":"adjective","неумита":"adjective","пересідла":"adjective","підла":"adjective","пухла":"adjective","семяниста":"adjective","сіроока":"adjective","стряпча":"adjective","твереза":"adjective","цибульска":"adjective","чарна":"adjective","ярка":"adjective","безгуба":"adjective","білоборода":"adjective","болєла":"adjective","бровата":"adjective","гікава":"adjective","голобока":"adjective","драбата":"adjective","жарка":"adjective","каплата":"adjective","кісла":"adjective","ковалевска":"adjective","ковальска":"adjective","козловска":"adjective","крилата":"adjective","куцка":"adjective","малоока":"adjective","мгка":"adjective","немята":"adjective","непроста":"adjective","нехороша":"adjective","пелихата":"adjective","підласа":"adjective","подпала":"adjective","руцка":"adjective","семениста":"adjective","услиста":"adjective","шорстка":"adjective","хила":"adjective","буката":"adjective","васалата":"adjective","вибла":"adjective","видойна":"adjective","виловата":"adjective","гарча":"adjective","горела":"adjective","дута":"adjective","зибла":"adjective","індича":"adjective","кальноока":"adjective","карнауха":"adjective","кривобедра":"adjective","кричфалуша":"adjective","кубата":"adjective","кужда":"adjective","ломана":"adjective","мацевита":"adjective","івашина":"noun","солоха":"adjective","перерва":"noun","проскура":"adjective","бова":"noun","сметана":"noun","дуброва":"noun","проскурня":"noun","родіна":"noun","єна":"noun","солонина":"noun","ліщина":"noun","лугина":"adjective","сосна":"noun","гавва":"noun","ужва":"noun","кулина":"adjective","халява":"noun","холява":"noun","підкова":"noun","крайня":"adjective","хохотва":"noun","цибулька":"noun","нікульча":"noun","кравчина":"noun","лупина":"adjective","лихошва":"noun","думбрава":"noun","плахотня":"adjective","покутня":"adjective","пона":"noun","семена":"noun","грона":"noun","єва":"noun","парасківа":"noun","шова":"noun","бурдужа":"adjective","козюберда":"adjective","говтва":"noun","приколота":"adjective","варнава":"noun","гурина":"adjective","рябокобила":"noun","кучина":"adjective","савва":"noun","кремена":"noun","малая":"adjective","горішня":"adjective","бурдюжа":"adjective","слаква":"noun","городня":"adjective","лиштва":"noun","цяцька":"noun","походня":"noun","недавня":"adjective","долішня":"adjective","марюхна":"noun","борона":"noun","колошва":"noun","семенча":"noun","затона":"noun","заплава":"noun","краснопера":"adjective","рибитва":"noun","сидора":"adjective","краплина":"noun","крутиголова":"noun","бакалина":"adjective","немна":"noun","очеретня":"adjective","пробийголова":"noun","мальона":"noun","сажина":"adjective","вчерашня":"adjective","бузина":"noun","забийворота":"noun","магльона":"noun","нейчева":"noun","потороча":"noun","ревіна":"noun","матьора":"adjective","святина":"noun","хіна":"noun","кожина":"adjective","наріжня":"noun","леона":"noun","передня":"adjective","савина":"adjective","сікачина":"noun","кльова":"noun","недолуга":"adjective","шкоропата":"noun","карасава":"noun","морева":"adjective","мустафіна":"noun","цьова":"noun","бубна":"noun","катона":"noun","міна":"noun","похвала":"noun","слоква":"noun","статіва":"noun","строна":"noun","вова":"noun","карева":"adjective","місюна":"noun","швая":"noun","бальва":"noun","вершина":"noun","врона":"noun","білокобила":"noun","гордина":"noun","кольва":"noun","льова":"noun","перекліта":"noun","основа":"noun","харена":"noun","борозна":"noun","будаква":"noun","каранікола":"noun","палесіка":"noun","рожина":"noun","штана":"noun","вицина":"noun","дубна":"noun","жовна":"noun","зіва":"noun","катарина":"noun","похмура":"adjective","фесина":"noun","шемена":"noun","галутва":"noun","зарева":"noun","ковальва":"noun","мирона":"noun","новосела":"noun","пачина":"adjective","совва":"noun","гіна":"noun","корона":"noun","новоженя":"noun","підберезня":"adjective","ряднина":"noun","сакська":"noun","канна":"noun","лукачина":"noun","плачінта":"noun","редьква":"noun","софина":"adjective","шатня":"adjective","блозва":"noun","вчорашня":"adjective","гриценя":"noun","куропатва":"noun","людва":"noun","стехна":"noun","парахоня":"noun","плєва":"noun","яворина":"noun","бендина":"noun","жовтонога":"adjective","конева":"adjective","мандалина":"noun","мацина":"noun","перезва":"noun","похвата":"noun","токмина":"noun","тюрина":"adjective","гицина":"noun","дзіна":"noun","куява":"noun","малонога":"adjective","стоколоса":"adjective","тимина":"adjective","біднина":"noun","вдовина":"adjective","лисохмара":"noun","микитина":"adjective","полівара":"noun","рибонька":"noun","ружина":"noun","тишина":"noun","цюрмаста":"noun","чалая":"adjective","васина":"noun","воїна":"noun","гулая":"noun","кова":"noun","она":"noun","палісіка":"noun","підошва":"noun","свидина":"noun","тирсина":"noun","хаврона":"noun","зона":"noun","кнзєва":"noun","розна":"adjective","ронжина":"noun","рудомина":"noun","сальва":"noun","скільсара":"noun","служала":"noun","фомина":"adjective","чупина":"adjective","шалупня":"noun","джупина":"noun","зоська":"noun","кузява":"noun","неледва":"noun","равва":"noun","разьва":"noun","шкорина":"noun","білозора":"adjective","бранціра":"noun","випна":"noun","галина":"adjective","мандаліна":"noun","мицька":"noun","мячина":"adjective","недосєка":"noun","пристая":"noun","м'яка":"adjective","вовчина":"noun","гринява":"noun","дівонька":"noun","ігіна":"noun","обійдихата":"noun","хижня":"adjective","челядина":"noun","янева":"adjective","голева":"adjective","дзюнька":"noun","дубрава":"noun","лигомина":"noun","мална":"noun","мархева":"noun","несправа":"noun","озява":"noun","панна":"noun","пупена":"noun","силява":"noun","сухокобила":"noun","цюрмоста":"noun","чевельча":"noun","чівільча":"noun","башева":"noun","бражна":"noun","варавва":"noun","волна":"noun","гольча":"noun","густа":"adjective","достатня":"adjective","зуграва":"noun","карапулька":"noun","кірна":"adjective","крапіва":"noun","луковина":"noun","мамона":"noun","мелещеня":"noun","мряна":"noun","параскева":"noun","похідня":"noun","пріхна":"noun","свтина":"noun","сьоська":"noun","терепіща":"noun","ціцяла":"noun","бодаква":"noun","гальвіта":"noun","деревенча":"noun","дона":"noun","дубена":"noun","задависвічка":"noun","йовва":"noun","капаціла":"noun","котельва":"noun","лісота":"noun","малюська":"noun","підсадня":"adjective","рєва":"noun","сувора":"adjective","хаджава":"noun","хомина":"adjective","псина":"noun","бобина":"noun","болотня":"adjective","бруква":"noun","кіона":"noun","ковбінька":"noun","кривонога":"adjective","лєва":"noun","мухина":"adjective","нефортуна":"noun","органіста":"noun","пасулька":"noun","пристава":"noun","бачина":"noun","безкорса":"adjective","бєлокобила":"noun","борзина":"noun","бружина":"noun","воротня":"adjective","гальона":"noun","голтва":"noun","горемульта":"noun","дацина":"noun","забанджала":"noun","злая":"adjective","кікена":"noun","коропатва":"noun","кузина":"adjective","лапунька":"noun","літава":"noun","мінчуна":"noun","на":"noun","ничая":"noun","новіцка":"adjective","пенькна":"noun","пухна":"noun","пуцята":"noun","рісна":"noun","розмаіта":"noun","румина":"adjective","свтна":"noun","сердита":"adjective","січінава":"noun","сментина":"noun","трізна":"noun","шкуропата":"noun","безхутра":"adjective","гальва":"noun","гнєда":"adjective","гребенча":"noun","гусонька":"noun","калабанька":"noun","козупляка":"noun","лапина":"adjective","мурина":"adjective","некульча":"noun","орона":"noun","парна":"adjective","пліва":"noun","приходька":"noun","сенина":"noun","солотва":"noun","тетева":"adjective","хавана":"noun","царева":"adjective","ахалая":"noun","варенька":"noun","варшава":"noun","вересоча":"noun","галунька":"noun","гліва":"noun","голина":"adjective","грузька":"adjective","гудина":"noun","євона":"noun","кірева":"adjective","кожем'яка":"noun","колоберда":"adjective","курінька":"noun","маржина":"noun","мигалина":"noun","мікава":"adjective","падва":"noun","паланичка":"adjective","палена":"adjective","подкова":"noun","ратушня":"adjective","селегейна":"noun","сминтина":"noun","сумина":"adjective","теміркая":"noun","ухата":"adjective","хавроня":"noun","холоста":"adjective","ціва":"noun","чернята":"noun","чикольва":"noun","шалина":"adjective","юдина":"adjective","адвена":"noun","балева":"adjective","брона":"noun","вербовата":"adjective","веремєва":"noun","волчаста":"adjective","гафина":"adjective","голутва":"noun","закрева":"noun","каджая":"noun","кальченя":"noun","капаниста":"adjective","кикина":"adjective","костерева":"noun","кривокобила":"noun","кулєва":"noun","лавна":"noun","маліцка":"adjective","молдова":"noun","моркова":"noun","пажина":"adjective","перевернихата":"noun","пилева":"adjective","піддубня":"adjective","постіва":"noun","пуста":"adjective","суботня":"adjective","фадеева":"adjective","ходаніцка":"adjective","хохітва":"noun","цибата":"adjective","черноока":"adjective","чкадуа":"noun","чокена":"noun","шепетина":"noun","шербина":"noun","яка":"adjective","ятва":"noun","безена":"noun","безшкура":"adjective","безязика":"adjective","белая":"adjective","берулава":"noun","бузна":"noun","бурсала":"noun","бучаста":"adjective","вчина":"noun","гапона":"noun","гернажа":"noun","гордуна":"noun","горсва":"noun","горясва":"noun","грицька":"noun","двіжона":"noun","задурня":"adjective","заслона":"noun","зачешигрива":"noun","йона":"noun","качна":"adjective","козовіта":"noun","криворота":"adjective","кур'ята":"noun","лозна":"adjective","люлява":"noun","лютая":"adjective","матухна":"noun","накутня":"adjective","плохая":"adjective","бухая":"adjective","самотня":"adjective","панібудьласка":"noun","яцина":"noun"};class im{encode(t){const n=new Uint8Array(1);switch(t.wordClass){case e.WordClass.NOUN:n[0]=1;break;case e.WordClass.ADJECTIVE:n[0]=0;break;default:throw new TypeError(`Invalid word class: "${t.wordClass}".`)}return n}decode(t){if(t.length<1||t.length>1)throw new RangeError("Invalid vector length.");const n=t[0];if(n<0||n>1)throw new RangeError("Invalid vector value.");return{wordClass:n>=.5?e.WordClass.NOUN:e.WordClass.ADJECTIVE}}}class sm{constructor(e,t=0){this.vectorSize=e,this.unknownCharcode=t}encode(e){var t;const a=new Uint8Array(this.vectorSize),i=e.slice(-this.vectorSize).toLowerCase().padStart(this.vectorSize,"-");for(let e=0;e<i.length;e+=1){const s=i[e];a[e]=null!==(t=n[s])&&void 0!==t?t:this.unknownCharcode}return a}}H().set("IS_NODE",!1);var rm={class_name:"Sequential",config:{name:"sequential_1",layers:[{class_name:"Embedding",config:{input_dim:34,output_dim:16,embeddings_initializer:{class_name:"RandomUniform",config:{minval:-.05,maxval:.05,seed:null}},embeddings_regularizer:null,activity_regularizer:null,embeddings_constraint:null,mask_zero:null,input_length:null,name:"embedding_Embedding1",trainable:!0,batch_input_shape:[null,null]}},{class_name:"SimpleRNN",config:{name:"simple_rnn_SimpleRNN1",trainable:!0,units:16,activation:"relu",use_bias:!0,kernel_initializer:{class_name:"VarianceScaling",config:{scale:1,mode:"fan_avg",distribution:"normal",seed:null}},recurrent_initializer:{class_name:"Orthogonal",config:{gain:1,seed:null}},bias_initializer:{class_name:"Zeros",config:{}},kernel_regularizer:null,recurrent_regularizer:null,bias_regularizer:null,activity_regularizer:null,kernel_constraint:null,recurrent_constraint:null,bias_constraint:null,dropout:0,recurrent_dropout:0,return_sequences:!1,return_state:!1,go_backwards:!1,stateful:!1,unroll:!1}},{class_name:"Dense",config:{units:1,activation:"sigmoid",use_bias:!0,kernel_initializer:{class_name:"VarianceScaling",config:{scale:1,mode:"fan_avg",distribution:"normal",seed:null}},bias_initializer:{class_name:"Zeros",config:{}},kernel_regularizer:null,bias_regularizer:null,activity_regularizer:null,kernel_constraint:null,bias_constraint:null,name:"dense_Dense1",trainable:!0}}]},keras_version:"tfjs-layers 4.2.0",backend:"tensor_flow.js"},om=[{name:"embedding_Embedding1/embeddings",shape:[34,16],dtype:"float32"},{name:"simple_rnn_SimpleRNN1/kernel",shape:[16,16],dtype:"float32"},{name:"simple_rnn_SimpleRNN1/recurrent_kernel",shape:[16,16],dtype:"float32"},{name:"simple_rnn_SimpleRNN1/bias",shape:[16],dtype:"float32"},{name:"dense_Dense1/kernel",shape:[16,1],dtype:"float32"},{name:"dense_Dense1/bias",shape:[1],dtype:"float32"}],lm="D3HrvZUs7rxT6Vu+tVsfvPLyB70zbt695ECPvKyKWj7TnUO+JZ9pvs8MkL3/1DQ+kftzvPGZZL4aDpe8KiOnvSvRHz52vQK9mGiSPm50B72RCfM+7hW6PSOuTz7b9zG+M5MOPv/mYL7Q9Rk+aPgRvrfQuT6mQ2Q+eOawPp/PpLyM9yY+zB4APT27n75OVUk+V8y6vetFyD0zPlW+sqPfPER8Ub6J1pI+5QwEvcZktT12HLW+FSFGPU6s2ryQapW9/MNNvoK1t71R5sK8N6Y/vjqBzTtusl2+0Ks8PpZOQ74ua5U9TOIfvkpgHDxho/294hcTPkJaiL1iXTo9o28bPhnMBr69EoG8CAeCvtgxXT5kMKq+KnLfPbScM73jYjw+LTa8vSeQWj49+cU7/FH2PKtOwr5y8K29GMMdvrkIgb0wK4C8Zeq2vXlG+L15O4c+CaFGvpmCjD5guBg+0AAQPv0EjT3CdZ0+vLOBulXEAb7VVpi+WldAPpIP8T0ETFm+NcLIPZix17rKGEW+n8jxPfT8hr43TLC8esPRvX6k4D1lZ0C+WERdPo4Qab4SdWw+uWSevp7+zTjX5Xi8nw+ZvldSb7xUfke7HX01PVOV2zzFqV2+SqcNvvPUTz0nzZi9Zl+ePWj6Wr3PLjY+vbjrvSRr6b1es/w8oaLjPUC0G72spye9rsomPtW/t72QYEy9AtR6PuX44z1dLrk9k6HAPE1+Eb7w1mY+N8MSvuMLsj1qmsO6JrRAvsJowr7iA1E+udZGPDLR57xRSj8+GFSnvYNUujxIvpM8FHmHvkr8QD38Po29LslnvShYOD45FAE7vfaWPbnegruqB2W9MdUkPpskUb3YGTU+L3gwvQhAYD4ed66+qJQUvjydBr7bSam8fYz/PCTisD7GYoQ+HDxJvSaIR77s3u+8sVTkvaDBaL13FBs+Z8T4vT4aKj2d4DC7ft+GPvVXFLxGXGI9RJ9avl7RCD6ujIy+M+/zPQbAtr3B2+c9BpZcPYIBTj7QNsM95bqEPc221T3u7TO+M2PIPU/BQb78/nk+f4TmvV5Elj0VOAK+0Y+DPq0GkL364pI98CGUvjK4IL1CLoK+kohXvTS3I76BpcM9WE0Rva5vkz301Ui+CLe7vWkLnT1sjpM8EYyWPWblIryk+gI+gnQSvu9XKL7jtni9Rc/IvaonHj2sKBc+VzRovpdOpT64szY+OavnvfzjeLuBH62+OqC2OoeMBr0eJVi7ST7CPLK/3jxTOoC9BRUSPjNBaD6OIlm+7ApUPlbsWj5KIKi+J9F1Pfi88L1+JdA9a6F+PsiRub06rh2+HlXnPb5Wj774l+i6nifjvWMCtL2WnqW9pUNdvjQM4L0ZJDy9lZ+LPbJWhj2hUZO+iWF0vhq17zqKwOI9Qq6sPWo8gD3c0co9/5WaPLN6PL6HOLO8fXvUvEF2IL4QJ7S98UzCPZJTlb6VUCM+y7dqvkJXyTyxD+I9N6PXvUxuqr0jiuM9p1OgO/wUFL07zEy+n5rPvSLifbt4N5e+kbdRviF6Db0ZSjo+B+dXvqB+iT7nFI68Z9bUPU9FGT21fz4+fee2vaIHqLzRTtG8aGggPqQlpD1GORk9/FpnPjatAL60OPg8x+qAPdU74zxSk6+9lYwdPikogr6pxao99PmXvH+yEz4zu5U9IeURPXqY9LpuvYk8OGmYvFX7+TtuUaO9qg0GPph0Xr5vdYM+0deHvozgtryfgDC8DaCGPTVxHb6q0fI97pWqPOXMAj7Y9ae+fljRuoumt71vblO+UaetPcadt7yiUYi9R9x8PqXbmb4V9gK+v2jjvVsTU72VAJ29JC1vPcpy1D2uNZM9N5mlvru77rxAZSo9jZWkvv+0HD6CY6k9RvnyvLM8Wr4/Yjo+aEr4vcUQkj3Ef7+7DusLvhf0oLxUt1u+LdOWPndY+Ty5+Dq+QfqQvqgCbj7V0L68swkNviGjaz0SkyQ+h9uuvckW97rM35m+O7ERPQvQ4L2XN3a9XwqPPifY7TynN0i9enwJPWh2Tj27c02+k0bpPWtEGz4p+qs9DzsKPhlEoD7U1qM9v7SAvNgeIr7tPJM9om6CvhmNcz7pBIa9HEvlPRmEGj7SzgE9tdoAO8dkeT2N2Xm9ChofvhVPSj19rZG+A2PfPVrax72zacc9YWsTvjSKAj4inbu9GbJGvSEnt76qFeq8JsAnvZ0cO75Lk7e5G8+WPrc5Cb3RGVg+xwxfvgTMNr18pdU9U49jPaRh5rg8G2Q+iUtrObd+jT0FTYG+XgVgvKwXJr6TWuG9BWosPlr9pT6IF2G+boCIvU0FOb39ivu9aMA5viC1S714C3q+CES6Pt11j76mNqk+/btevCcEVL7z5cK+ALgyPJeTPb0+7O+7lftrPslPZz1EqIY9DWKYvdtgWL5/DwI9Q2NFvJhKcb0MMQo+NtltPWZcmT2FlVA9V5Nnvc9IJr0TXCA+nAIuPoF7xbon0SQ+Kwi8ve0ePb6O3++9k2/GvZoLlrxRDM48DwOkvEiWIz7jsgC+NYZzvTu7Jb7Jcgm8qAoyPg8zkT3o8UI+7Mt/vZsaYj7UZDm+Z4BTPBgkQr7CSTs+PKpvPbkSED3tAaW9LJ9APo74Fz62CFe8xMDCPi83F76ttk++K6FGvQkDDr42fbG+N9cbPvP1Br2CU1c+qukfvu3DJz6Vjfy8jlM9PZNaKL4Ceu29dDVCvoG7fD5qTLu75+YoPXt8GD7ey2U+KpynvemmCL1L1VC9LsfhvcoBND44he273UFiPrLzK72XXPS9ZjZGPtBwh7gwW2i+ccbxvXtoMj4Q/u49AzHBvoTjHD40AuW+OiwYP4x9JD6PGAY/KN7+Pc0xhb6OqxY9AptQvbc7Or39a9e6DJ/zPvd+iz6XX7g6kqsEP5LI1L7ICBk+1k5SP0lR0T43qYI+kbFLvcUh5L7+v90+5mnZveLTxj03yAS+phJLvW7x3b4m3J68GeeBvlrhgj05ac++0Yyfvcrz7L1/Y/i+ZjMKPhEy6j3ImRu+fRRuPkunGL5dMVG+Yd5Fv6ys1z6PXYI+JhzOvaGxDT4p38I+QcDHPtkxbb0XnjM/ogGYviZrLj291se+iNNqvpZuUb7nas8+lj4tvvyQ3D7w+FO9r4ybPs7MJD+WsIG9pGxHPqmQo75RdUG/gFs2vRXbrj7n87w9aGosPm8vDr/oUeO+2pWxPsk1RT7lvPS+YBmZvkDPU745ORi/BxbNPg83pD2KOSq9Nh0tPw6bSj+WVTk97hLcPnMDpT7GgXW8dL46vltPvb11QOu9CeYDPYDxwbx5UQ8+MnesPb+Ajj7Uv7m+qE+TvM+Qt77g88s+7940P8/1zj5p9+g+FugoPgNebT69zXg+IbhFvnHq6LsVozg+iIaBPau6Kr6tTOG+U1bhPS6zFD64rqY/FZebvhOPeL5DGXo+dwgLPjKu6z5+X78+iAsNPrs/Pb+RQoe+6MyqvWutu75ml7G+3Casvq63/b4exKi9+5lMv7V/yb4twI49cbIcv/+5/r5lWxE/78Q+PhjngT4SENI9xZKXPmmQEb9UJGK+eYE3vtOLiDxf4zo+9KX5Pl0APj9PhqA+i/wMv1iRsjzngaK+/ocBv8RUnr0hPdM+YAshv896DL1aukY+kiIJvsKhvD66FTi++84Fv5vWjL4lr6W+OLvyvba/krzwXgm9X8rUvv+XNb7jhSo/zfCAPLRlqD4Fn5S+DeQfP0847T7NIZ4+/gMAPxyfcT6VQOM+UOmWvWDtrD4TLFW9NGQSveJN9T7AuFm+MvUSv/TnFz8uw68+k05IPj26MTwDLsW+hsLFvifDqD7Z6d28z+AOv1DeZL8TnA++mrwBvT0BGL5ireW+PLbOOQjsJjzUmya/CcavOz8kwr70lmK+PHcmPsmi9r5VeAI+yly7PSGkIT6xV1Q/uHsKP4WFir4DBcc+SIJuPlP0Lb5Nufu+dKc3vk/X4L2Qvyo/jJSCPr3+Vr7NNA4/5AqcPoYisjuvO6g9JGKRPgxvQj/bUnG8yqAbP8wDO75rdkO+keIuPvrKxT4VCoQ9fx3XPih9K77kIOg99g2gPcrn4rxDzyy+TDdxPpzmHz//YWM+PIXFvTGs4z5SaaE9NAwkv4Qcub6gS3g+6Wa0vf3qJD8NDC2/q4z6PFVEob5p8yG+uSjhvjAMgD4GQ2Q/+EfRPlrsL79K2PO+FyOrPav1lT6vSzQ+nQOovRiVMD4Yfg4+weDxPv9V8b3ix407T0mFvEXdYT4DaKq+rE4YviLa2r4q/vI7hVWOvWgaV77A7QU/OU2iPp8QQT58RIA+Lbf+vo65Fz1RDRw+mv6WvdOImj4/IyY9a+vPO/pDuj6WiFe94SnbvW0cAb5HUcQ8croTvdeGIT6Q5p89/2EpPyPapj33gSS+q161vhFrSj00b5A9P6g4vssdob5sS5G+r72gvUDqCj+C5+a9lJHFPjtFxz10OYs+qXakvlUu5Trwp749nrcQPbAzwr5pCs8+UhoIvsHVdT7iw+i+UYxzPgTn5T50arg+R/4IP7kH2T2cguW+pQX+vFqQdr3z5yY+SdURProPID4CXhA9crIcP/7a4D6r/549Ly6lvXeFUb9n9xs/CC3oPrOgAj8iPwo/8nPXviKqAr8q6TQ+vrumPrdtHz8prJq+V1/oPUZWGr4Y4cU9nRopvtRCkz2jeTy+pJW0PgwDyz6XfIo+QmZevqCRSj1/pIa+KoufPllZvT5o244+nRIYP3TbM70N+8y+a7d2vcsSWj4Cdrw+AT8hPVoDwL0BxL2+G1pmPo/CZL66zSS+g2rFPvewar7nfGe+YEuevRgFIr7dyRS+KES0Pnu1p754F6s+/inJPXa3tL4Qd5A+OmbLPWvlnb75WsU9rRHMvsgqxD5MQ90+Y38LPnBkZj7fKIs9uJCHvdiuXr6D/Rw9hpVyPu9Vqr4Qzom85dP6vYymmr1yG5w+2gSMPlV5tT1D1ks+EKTZPm4gOb6ZC+w+k8EOPA8oXb6r9z2+h6Tgvm7Dvj7OzJQ+7tkIPvbDjz4TN6u9GneSPTIooD7GdRA/wYQ4vVr7b71F/QI+cRORPrRPWzxVX22+Yu2vPsHriL720za+oBlVPogMe72YNKM8r9aEO5uq1z7RegW+4aX1PqfYRD/wpfI9sVqvPCI99jpAtWC9eXJ2PBb++j6w+809iODsPfwV0b2kL7S9D+FLPQZECD4oYRA+V1Z+vjarEj5ZF/q8KJSAPkjENr7zNd28pKODPj8FPL8mgFY8kJVMvgBfQ75uooK++9TaPg/5Cr5Pzo6+1Yy3viONQL/Fvng+Bmn6vTpQkb0N7Oi94ZVHPYE2Hr7J/Rk+zQzKvL3Chj5d85o+Q/YRPrsjnj7YzJY+01w3PyVgGD6INkM+XtnevbmxiL7Z1NI+jpdgvggkdz0QnJq+35a8PZX0SL4+y78+grnOPYHzlD2VKRA/xRW4PqyCPL4Cowa/Ku+pvZabKz99894+sY/Vva/ezL1zsUw+er4IP8DL/D1qa2a+m6B3PK8Cq76mu2++gsjvvP0kBz8pWqe+SyotvKUdmz4pFXA7bkXCvbwSbj44g7c8mID4viXITL56E/G9zBVuPPD+u7wCmJc9v1nDuyyEX77G7Nq8GUwXvQJRVT3nTYY9/wK9Pct9sT1dCqU9aRsHvlmTFD2/B5M9PclmvNt2Jb8eqR2+bZhIvlmRVT4k0zU/OFSyvnCsHb/BfrK+ZZJGv10pNT8uXQk/AaVXvgbtG76M5kC+b6zpPfBICD8I1Lm8",cm={format:"layers-model",generatedBy:"TensorFlow.js tfjs-layers v4.2.0",convertedBy:null};const um="undefined"!=typeof Buffer&&("undefined"==typeof Blob||"undefined"==typeof atob||"undefined"==typeof btoa);class hm{inflect(e,n,a){return t(this,0,void 0,(function*(){const t=[],i=e.split("-");for(let e=0;e<i.length;e+=1){const s=yield this.inflectNamePart(i[e],n,a,e===i.length-1);t.push(s)}return t.join("-")}))}}const pm=/[ая]$/i,dm=/(ой|ий|ій|их)$/i;const fm=new class extends hm{constructor(e){super(),this.wordInflector=e}inflectNamePart(e,t,n){return this.wordInflector.inflect(e,{grammaticalCase:n,gender:t,applicationType:"givenName"})}}(g),mm=new class extends hm{constructor(e){super(),this.wordInflector=e}inflectNamePart(e,t,n){return this.wordInflector.inflect(e,{grammaticalCase:n,gender:t,applicationType:"patronymicName",customRuleFilter:e=>e.applicationType.includes("patronymicName")})}}(g),gm=new class{constructor(e){this.modelLoader=e,this.modelPromise=null,this.wordTransformer=new sm(20),this.familyNameClassTransformer=new im}classify(e){return t(this,0,void 0,(function*(){let t=this.getCached(e);if(null!=t)return t;const n=yield this.loadModel(),a=this.wordTransformer.encode(e),i=yield n.predict(dr([a])).data();return t=this.familyNameClassTransformer.decode(i),t}))}getCached(e){let t=null;const n=am[e.toLowerCase()];return n&&(t={wordClass:n}),t}loadModel(){return t(this,0,void 0,(function*(){return null==this.modelPromise&&(this.modelPromise=Mp(this.modelLoader)),this.modelPromise}))}}(new class{load(){return t(this,0,void 0,(function*(){const e={};if(e.modelTopology=rm,e.weightSpecs=om,e.weightData=function(e){if(um){const t=Buffer.from(e,"base64");return t.buffer.slice(t.byteOffset,t.byteOffset+t.byteLength)}const t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;++e)n.set([t.charCodeAt(e)],e);return n.buffer}(lm),null!=cm){const t=cm;e.format=t.format,e.generatedBy=t.generatedBy,e.convertedBy=t.convertedBy,null!=t.signature&&(e.signature=t.signature),null!=t.userDefinedMetadata&&(e.userDefinedMetadata=t.userDefinedMetadata),null!=t.modelInitializer&&(e.modelInitializer=t.modelInitializer),null!=t.initializerSignature&&(e.initializerSignature=t.initializerSignature),null!=t.trainingConfig&&(e.trainingConfig=t.trainingConfig)}return e}))}}),vm=new class extends hm{constructor(e,t){super(),this.wordInflector=e,this.familyNameClassifier=t}inflectNamePart(e,n,a,i){return t(this,0,void 0,(function*(){if(!i&&s(e))return e;let t=null;return this.isUncertainFamilyNameClass(e,n)&&(t=yield this.familyNameClassifier.classify(e)),this.wordInflector.inflect(e,{grammaticalCase:a,gender:n,wordClass:null==t?void 0:t.wordClass,applicationType:"familyName"})}))}isUncertainFamilyNameClass(t,n){return n===e.GrammaticalGender.FEMININE&&pm.test(t)||n===e.GrammaticalGender.MASCULINE&&dm.test(t)}}(g,gm),ym=new class{constructor(e,t,n){this.givenNameInflector=e,this.patronymicNameInflector=t,this.familyNameInflector=n}inflect(e,n,a){return t(this,0,void 0,(function*(){const t={};return null!=e.givenName&&(t.givenName=yield this.givenNameInflector.inflect(e.givenName,n,a)),null!=e.patronymicName&&(t.patronymicName=yield this.patronymicNameInflector.inflect(e.patronymicName,n,a)),null!=e.familyName&&(t.familyName=yield this.familyNameInflector.inflect(e.familyName,n,a)),t}))}}
4683
4683
  /**
4684
4684
  * @license
4685
4685
  * Copyright 2020 Google LLC. All Rights Reserved.
@@ -4695,4 +4695,4 @@ vt(Uo),vt($o),vt(Go),vt(Vo),vt(Ko),vt(qo),vt(Lo),vt(Ho),vt(tl),vt(Fo),vt(Qo),vt(
4695
4695
  * See the License for the specific language governing permissions and
4696
4696
  * limitations under the License.
4697
4697
  * =============================================================================
4698
- */(fm,mm,vm),bm=[];function wm(){const e=[];for(const t of bm)e.push(...t.fieldNames);return e}var km="(ин|ій|ом|ам|ян|ан|ар|рт|ас|он|ін|ен|ем|ур|ип|ьд|ей|ко|ид|ст|ир|ав|сл|ис|ой|ил|им|др|ет|уб|ор|ад|ай|юб|од|юд|ол|ло|іб|ат|ун|ум|яд|іт|ик|ог|ач|ро|уг|ік|ід|то|ус|нн|ий|до|ев|ич|ух|ць|ег|сь|ів|ап|ім|зд|ац|єр|їл|рг|яр|лк|ок|іл|ох|іш|іг|ив|ук|ек|ош|иль|вір|ула|ята|зір|ива|иня|ега|лля|ьма|ука|пір|рит|мов|ага|дір|ала|ема|вит|воля|шата|ітер|біда|кита|кола|екса|лель|рава|сила|вута|урма|дота|чара|слава)$",xm="(ія|та|ая|на|да|за|са|ла|ка|ся|ра|ва|дя|ея|['’ʼ]я|ха|ма|ря|оя|га|па|дь|ня|ля|йя|ша|фа|ба|тя|ль|ут|уф|иф|iя|ста|ора|ика|їда|еса|ада|іта|іса|лла|еда|ела|іка|ида|иса|рта|ава|нда|ара|сса|кла|ера|тта|іра|ира|уда|рка|нка|мма|їла|ьда|фір|єва|вга|ета|шка|има|ата|яда|нга|зка|дра|тка|тра|уня|еля|ола|аня|бов|ила|вка|гда|ьва|чка|ога|йда|аля|лка|дка|ель|ьга|сла|ова|вла|зга|ева|зда|ька|їса|ека|кка|ода|ява|нта|рра|яра|ока|оня|кля|іва|ита|дит|хва|іга|гата|бара|лава|вара|іола|тава|уель|стер|бава|лата|ірма|фата|лара|дара|пава|мила|лола|ьоля|рита|рута|нель|ната|ніда|сава|шель|сара|зара|мара|лита|ікса|тата|цата|фота|ичара|услава|еслава|ислава|іслава|ослава|аслава|дслава|гуслава|леслава|рислава|ніслава|рослава|дислава|сеслава|чеслава|нислава|реслава|тослава|бислава|бослава|числава|лослава|тислава|діслава|наслава|гослава|едслава|дослава|біслава|цеслава)$",Sm="[иі]ч$",Nm="на$";class Tm{constructor(e){this.masculinePattern=e.masculinePattern,this.femininePattern=e.femininePattern}detect(t){const n=t.match(this.masculinePattern),a=t.match(this.femininePattern);if(null!=n&&null==a)return e.GrammaticalGender.MASCULINE;if(null==n&&null!=a)return e.GrammaticalGender.FEMININE;if(null!=n&&null!=a){const[t]=n,[i]=a;return t.length>i.length?e.GrammaticalGender.MASCULINE:e.GrammaticalGender.FEMININE}return null}}const Im=new Tm({masculinePattern:new RegExp(km,"i"),femininePattern:new RegExp(xm,"i")}),$m=new Tm({masculinePattern:new RegExp(Sm,"i"),femininePattern:new RegExp(Nm,"i")});class Cm extends TypeError{}const Am=["givenName","patronymicName","familyName"];function Em(e){return"object"==typeof e&&null!=e}function jm(n,a){return t(this,0,void 0,(function*(){!function(t){if(!Em(t))throw new Cm("The input type must be an object.");if(!Object.values(e.GrammaticalGender).includes(t.gender))throw new Cm(`The "gender" parameter must be one of the following: "${Object.values(e.GrammaticalGender).join('", "')}".`);const n=[...Am,...wm()];if(!n.some((e=>e in t&&void 0!==t[e])))throw new Cm(`At least one of the following parameters must present: "${n.join('", "')}".`);for(const e of n)if(void 0!==t[e]&&"string"!=typeof t[e])throw new Cm(`The "${e}" parameter must be a string.`)}(a);const i=yield ym.inflect(a,a.gender,n),s=yield function(e,n){var a;return t(this,0,void 0,(function*(){const t={};for(const i of bm){const s=yield null===(a=i.afterInflect)||void 0===a?void 0:a.call(i,e,n);null!=s&&Object.assign(t,s)}return t}))}(n,a);return Object.assign(Object.assign({},i),s)}))}e.InputValidationError=Cm,e.WordInflector=m,e.detectGender=function(e){return t(this,0,void 0,(function*(){return function(e){if(!Em(e))throw new Cm("The input type must be an object.");if(!Am.some((t=>t in e&&void 0!==e[t])))throw new Cm(`At least one of the following parameters must present: "${Am.join('", "')}".`);for(const t of Am)if(void 0!==e[t]&&"string"!=typeof e[t])throw new Cm(`The "${t}" parameter must be a string.`)}(e),(t=e).patronymicName?$m.detect(t.patronymicName.toLocaleLowerCase()):t.givenName?Im.detect(t.givenName.toLocaleLowerCase()):null;var t}))},e.inAblative=function(n){return t(this,0,void 0,(function*(){return jm(e.GrammaticalCase.ABLATIVE,n)}))},e.inAccusative=function(n){return t(this,0,void 0,(function*(){return jm(e.GrammaticalCase.ACCUSATIVE,n)}))},e.inDative=function(n){return t(this,0,void 0,(function*(){return jm(e.GrammaticalCase.DATIVE,n)}))},e.inGenitive=function(n){return t(this,0,void 0,(function*(){return jm(e.GrammaticalCase.GENITIVE,n)}))},e.inLocative=function(n){return t(this,0,void 0,(function*(){return jm(e.GrammaticalCase.LOCATIVE,n)}))},e.inNominative=function(n){return t(this,0,void 0,(function*(){return jm(e.GrammaticalCase.NOMINATIVE,n)}))},e.inVocative=function(n){return t(this,0,void 0,(function*(){return jm(e.GrammaticalCase.VOCATIVE,n)}))},e.registerExtension=function(e){const t=e({wordInflector:g});bm.push(t)}}));
4698
+ */(fm,mm,vm),bm=[];function wm(){const e=[];for(const t of bm)e.push(...t.fieldNames);return e}var km="(ин|ій|ом|ам|ян|ан|ар|рт|ас|он|ін|ен|ем|ур|ип|ьд|ей|ко|ид|ст|ир|ав|сл|ис|ой|ил|им|др|ет|уб|ор|ад|ай|юб|од|юд|ол|ло|іб|ат|ун|ум|яд|іт|ик|ог|ач|ро|уг|ік|ід|то|ус|нн|ий|до|ев|ич|ух|ць|ег|сь|ів|ап|ім|зд|ац|єр|їл|рг|яр|лк|ок|іл|ох|іш|іг|ив|ук|ек|ош|иль|вір|ула|ята|зір|ива|иня|ега|лля|ьма|ука|пір|рит|мов|ага|дір|ала|ема|вит|воля|шата|ітер|біда|кита|кола|екса|лель|рава|сила|вута|урма|дота|чара|слава)$",xm="(ія|та|ая|на|да|за|са|ла|ка|ся|ра|ва|дя|ея|['’ʼ]я|ха|ма|ря|оя|га|па|дь|ня|ля|йя|ша|фа|ба|тя|ль|ут|уф|иф|iя|ста|ора|ика|їда|еса|ада|іта|іса|лла|еда|ела|іка|ида|иса|рта|ава|нда|ара|сса|кла|ера|тта|іра|ира|уда|рка|нка|мма|їла|ьда|фір|єва|вга|ета|шка|има|ата|яда|нга|зка|дра|тка|тра|уня|еля|ола|аня|бов|ила|вка|гда|ьва|чка|ога|йда|аля|лка|дка|ель|ьга|сла|ова|вла|зга|ева|зда|ька|їса|ека|кка|ода|ява|нта|рра|яра|ока|оня|кля|іва|ита|дит|хва|іга|гата|бара|лава|вара|іола|тава|уель|стер|бава|лата|ірма|фата|лара|дара|пава|мила|лола|ьоля|рита|рута|нель|ната|ніда|сава|шель|сара|зара|мара|лита|ікса|тата|цата|фота|ичара|услава|еслава|ислава|іслава|ослава|аслава|дслава|гуслава|леслава|рислава|ніслава|рослава|дислава|сеслава|чеслава|нислава|реслава|тослава|бислава|бослава|числава|лослава|тислава|діслава|наслава|гослава|едслава|дослава|біслава|цеслава)$",Sm="[иі]ч$",Nm="на$";class Tm{constructor(e){this.masculinePattern=e.masculinePattern,this.femininePattern=e.femininePattern}detect(t){const n=t.match(this.masculinePattern),a=t.match(this.femininePattern);if(null!=n&&null==a)return e.GrammaticalGender.MASCULINE;if(null==n&&null!=a)return e.GrammaticalGender.FEMININE;if(null!=n&&null!=a){const[t]=n,[i]=a;return t.length>i.length?e.GrammaticalGender.MASCULINE:e.GrammaticalGender.FEMININE}return null}}const Im=new Tm({masculinePattern:new RegExp(km,"i"),femininePattern:new RegExp(xm,"i")}),Cm=new Tm({masculinePattern:new RegExp(Sm,"i"),femininePattern:new RegExp(Nm,"i")});class $m extends TypeError{}const Am=["givenName","patronymicName","familyName"];function Em(e){return"object"==typeof e&&null!=e}function jm(n,a){return t(this,0,void 0,(function*(){!function(t){if(!Em(t))throw new $m("The input type must be an object.");if(!Object.values(e.GrammaticalGender).includes(t.gender))throw new $m(`The "gender" parameter must be one of the following: "${Object.values(e.GrammaticalGender).join('", "')}".`);const n=[...Am,...wm()];if(!n.some((e=>e in t&&void 0!==t[e])))throw new $m(`At least one of the following parameters must present: "${n.join('", "')}".`);for(const e of n)if(void 0!==t[e]&&"string"!=typeof t[e])throw new $m(`The "${e}" parameter must be a string.`)}(a);const i=yield ym.inflect(a,a.gender,n),s=yield function(e,n){var a;return t(this,0,void 0,(function*(){const t={};for(const i of bm){const s=yield null===(a=i.afterInflect)||void 0===a?void 0:a.call(i,e,n);null!=s&&Object.assign(t,s)}return t}))}(n,a);return Object.assign(Object.assign({},i),s)}))}e.InputValidationError=$m,e.WordInflector=m,e.detectGender=function(e){return t(this,0,void 0,(function*(){return function(e){if(!Em(e))throw new $m("The input type must be an object.");if(!Am.some((t=>t in e&&void 0!==e[t])))throw new $m(`At least one of the following parameters must present: "${Am.join('", "')}".`);for(const t of Am)if(void 0!==e[t]&&"string"!=typeof e[t])throw new $m(`The "${t}" parameter must be a string.`)}(e),(t=e).patronymicName?Cm.detect(t.patronymicName.toLocaleLowerCase()):t.givenName?Im.detect(t.givenName.toLocaleLowerCase()):null;var t}))},e.inAblative=function(n){return t(this,0,void 0,(function*(){return jm(e.GrammaticalCase.ABLATIVE,n)}))},e.inAccusative=function(n){return t(this,0,void 0,(function*(){return jm(e.GrammaticalCase.ACCUSATIVE,n)}))},e.inDative=function(n){return t(this,0,void 0,(function*(){return jm(e.GrammaticalCase.DATIVE,n)}))},e.inGenitive=function(n){return t(this,0,void 0,(function*(){return jm(e.GrammaticalCase.GENITIVE,n)}))},e.inLocative=function(n){return t(this,0,void 0,(function*(){return jm(e.GrammaticalCase.LOCATIVE,n)}))},e.inNominative=function(n){return t(this,0,void 0,(function*(){return jm(e.GrammaticalCase.NOMINATIVE,n)}))},e.inVocative=function(n){return t(this,0,void 0,(function*(){return jm(e.GrammaticalCase.VOCATIVE,n)}))},e.registerExtension=function(e){const t=e({wordInflector:g});bm.push(t)}}));