@ JvmName ( "<STR_LIT>" ) <EOL> public fun < D : Dimension > MultiArray < ComplexDouble , D > . log ( ) : NDArray < ComplexDouble , D >

= mk . math . mathEx . logCD ( this )

/**
 * Returns an ndarray of [ComplexDouble] from the given ndarray to each element of which a log function has been applied.
 *
 * same as [Math.log]
 */


@ JvmName ( "<STR_LIT>" ) <EOL> public fun < T : Number , D : Dimension > MultiArray < T , D > . sin ( ) : NDArray < Double , D >

= mk . math . mathEx . sin ( this )

/**
 * Returns an ndarray of Double from the given ndarray to each element of which a sin function has been applied.
 *
 * same as [Math.sin]
 */


@ JvmName ( "<STR_LIT>" ) <EOL> public fun < D : Dimension > MultiArray < Float , D > . sin ( ) : NDArray < Float , D >

= mk . math . mathEx . sinF ( this )

/**
 * Returns an ndarray of Float from the given ndarray to each element of which a sin function has been applied.
 *
 * same as [Math.sin]
 */


@ JvmName ( "<STR_LIT>" ) <EOL> public fun < D : Dimension > MultiArray < ComplexFloat , D > . sin ( ) : NDArray < ComplexFloat , D >

= mk . math . mathEx . sinCF ( this )

/**
 * Returns an ndarray of [ComplexFloat] from the given ndarray to each element of which a sin function has been applied.
 *
 * same as [Math.sin]
 */


@ JvmName ( "<STR_LIT>" ) <EOL> public fun < D : Dimension > MultiArray < ComplexDouble , D > . sin ( ) : NDArray < ComplexDouble , D >

= mk . math . mathEx . sinCD ( this )

/**
 * Returns an ndarray of [ComplexDouble] from the given ndarray to each element of which a sin function has been applied.
 *
 * same as [Math.sin]
 */


@ JvmName ( "<STR_LIT>" ) <EOL> public fun < T : Number , D : Dimension > MultiArray < T , D > . cos ( ) : NDArray < Double , D >

= mk . math . mathEx . cos ( this )

/**
 * Returns an ndarray of Double from the given ndarray to each element of which a cos function has been applied.
 *
 * same as [Math.cos]
 */


@ JvmName ( "<STR_LIT>" ) <EOL> public fun < D : Dimension > MultiArray < Float , D > . cos ( ) : NDArray < Float , D >

= mk . math . mathEx . cosF ( this )

/**
 * Returns an ndarray of Float from the given ndarray to each element of which a cos function has been applied.
 *
 * same as [Math.cos]
 */


@ JvmName ( "<STR_LIT>" ) <EOL> public fun < D : Dimension > MultiArray < ComplexFloat , D > . cos ( ) : NDArray < ComplexFloat , D >

= mk . math . mathEx . cosCF ( this )

/**
 * Returns an ndarray of [ComplexFloat] from the given ndarray to each element of which a cos function has been applied.
 *
 * same as [Math.cos]
 */


@ JvmName ( "<STR_LIT>" ) <EOL> public fun < D : Dimension > MultiArray < ComplexDouble , D > . cos ( ) : NDArray < ComplexDouble , D >

= mk . math . mathEx . cosCD ( this )


public fun < T : Number , D : Dimension > MultiArray < T , D > . cumSum ( ) : D1Array < T >

= mk . math . cumSum ( this )

/**
 * Returns cumulative sum of all elements in the given ndarray.
 */


{ <EOL> fun localFoo ( ) { } <EOL> class LocalClass <EOL> }


@ Deprecated ( SHORTCUTS_DEPRECATION_MESSAGE ) <EOL> fun ios ( )

= ios ( "<STR_LIT>" ) { }

/**
 * Deprecated:
 * Declare targets explicitly like
 * ```kotlin
 * kotlin {
 * applyDefaultHierarchyTemplate() /* <- optional; is applied by default, when compatible */
 *
 * iosX64()
 * iosArm64()
 * iosSimulatorArm64() // <- Note: This target was previously not registered by the ios() shortcut!
 *
 * /* ... more targets! */
 * }
 * ```
 */


@ Deprecated ( SHORTCUTS_DEPRECATION_MESSAGE ) <EOL> fun tvos ( )

= tvos ( "<STR_LIT>" ) { }

/**
 * Deprecated:
 * Declare targets explicitly like
 * ```kotlin
 * kotlin {
 * applyDefaultHierarchyTemplate() /* <- optional; is applied by default, when compatible */
 *
 * tvosArm64()
 * tvosX64()
 * tvosSimulatorArm64() // <- Note: This target was previously not registered by the tvos() shortcut!
 *
 * /* ... more targets! */
 * }
 * ```
 */


@ Deprecated ( SHORTCUTS_DEPRECATION_MESSAGE ) <EOL> fun watchos ( )

= watchos ( "<STR_LIT>" ) { }

/**
 * Deprecated:
 * Declare targets explicitly like
 * ```kotlin
 * kotlin {
 * applyDefaultHierarchyTemplate() /* <- optional; is applied by default, when compatible */
 *
 * watchosArm64()
 * watchosX64()
 * watchosSimulatorArm64() // <- Note: This target was previously not registered by the watchos() shortcut!
 * watchosArm32() //<- Note: This target was previously applied, but is likely not needed anymore
 *
 *
 * /* ... more targets! */
 * }
 * ```
 */


{ <EOL> val modelBuilderFunction = :: resnet50Light <EOL> runResNetTraining ( modelBuilderFunction ) <EOL> }

/**
 * This example shows how to do image classification from scratch using pre-made [resnet50Light] model, without leveraging pre-trained weights.
 * We demonstrate the workflow on the Kaggle Cats vs Dogs binary classification dataset.
 *
 * We use the preprocessing DSL to describe the dataset generation pipeline.
 *
 * It includes:
 * - dataset loading from S3
 * - preprocessing DSL declaration
 * - [OnFlyImageDataset] dataset creation
 * - dataset splitting
 * - usage of pre-made model from [org.jetbrains.kotlinx.dl.api.core.model] package
 * - model compilation
 * - model training
 * - model evaluation
 */


= resnet50onDogsVsCatsDataset ( )


infix fun < T1 > EmptyTuple . concat ( other : Tuple1 < T1 > ) : Tuple1 < T1 >

= other . copy ( )

/**
 * This file provides functions to easily merge two separate tuples into one.
 *
 * For example (using tupleOf() to create a new tuple):
 * ```tupleOf(a, b) concat tupleOf(c, d) == tupleOf(a, b, c, d)```
 * or using the shorthand:
 * ```tupleOf(a, b) + tupleOf(c, d) == tupleOf(a, b, c, d)```
 *
 * If you mean to create ```tupleOf(a, b, tupleOf(c, d))``` or ```tupleOf(tupleOf(a, b), c, d)```,
 * use [appendedBy] and [prependedBy] explicitly:
 * ```t(a, b).appendedBy(t(c, d)) == t(a, b, t(c, d))```
 * or wrap it in another [Tuple1]:
 * ```t(a, b) + t(t(c, d)) == t(a, b, t(c, d))```
 *
 */


fun substituteArgumentProjection ( argument : TypeProjection ) : TypeProjection ?

{ <EOL> return null <EOL> }

/**
 * Returns not null when substitutor manages specific type projection substitution by itself.
 * Intended for corner cases involving interactions with legacy type substitutor,
 * please consider using substituteNotNullTypeWithConstructor instead of making manual projection substitutions.
 */


@ PublishedApi <EOL> @ SinceKotlin ( "<STR_LIT:1.2>" ) <EOL> internal fun apiVersionIsAtLeast ( major : Int , minor : Int , patch : Int ) : Boolean

= <EOL> KotlinVersion . CURRENT . isAtLeast ( major , minor , patch )

/**
 * Constant check of api version used during compilation
 *
 * This function is evaluated at compile time to a constant value,
 * so there should be no references to it in other modules.
 *
 * The function usages are validated to have literal argument values.
 */


fun strictEqualTypes ( a : UnwrappedType , b : UnwrappedType ) : Boolean

{ <EOL> return AbstractStrictEqualityTypeChecker . strictEqualTypes ( SimpleClassicTypeSystemContext , a , b ) <EOL> }

/**
 * String! != String & A<String!> != A<String>, also A<in Nothing> != A<out Any?>
 * also A<*> != A<out Any?>
 * different error types non-equals even errorTypeEqualToAnything
 */


{ <EOL> dependsOn ( DokkaSourceSetID ( sourceSet . name ) ) <EOL> }

/**
 * Convenient override to **append** source sets to [dependentSourceSets]
 */


fun dependsOn ( sourceSet : GradleDokkaSourceSetBuilder )

{ <EOL> dependsOn ( sourceSet . sourceSetID ) <EOL> }


fun dependsOn ( sourceSet : DokkaConfiguration . DokkaSourceSet )


fun dependsOn ( sourceSetName : String )

{ <EOL> dependsOn ( DokkaSourceSetID ( sourceSetName ) ) <EOL> }


fun dependsOn ( sourceSetID : DokkaSourceSetID )

{ <EOL> dependentSourceSets . add ( sourceSetID ) <EOL> }


{ <EOL> sourceRoots . from ( file ) <EOL> }

/**
 * Convenient override to **append** source roots to [sourceRoots]
 */


{ <EOL> sourceRoot ( project . file ( path ) ) <EOL> }


@ Suppress ( "<STR_LIT:DEPRECATION>" ) <EOL> fun sourceLink ( c : Closure < in GradleSourceLinkBuilder > )

{ <EOL> val configured = org . gradle . util . ConfigureUtil . configure ( c , GradleSourceLinkBuilder ( project ) ) <EOL> sourceLinks . add ( configured ) <EOL> }

/**
 * Closure for configuring source links, appending to [sourceLinks].
 *
 * @see [GradleSourceLinkBuilder] for details.
 */


fun sourceLink ( action : Action < in GradleSourceLinkBuilder > )

{ <EOL> val sourceLink = GradleSourceLinkBuilder ( project ) <EOL> action . execute ( sourceLink ) <EOL> sourceLinks . add ( sourceLink ) <EOL> }

/**
 * Action for configuring source links, appending to [sourceLinks].
 *
 * @see [GradleSourceLinkBuilder] for details.
 */


@ Suppress ( "<STR_LIT:DEPRECATION>" ) <EOL> fun perPackageOption ( c : Closure < in GradlePackageOptionsBuilder > )

{ <EOL> val configured = org . gradle . util . ConfigureUtil . configure ( c , GradlePackageOptionsBuilder ( project ) ) <EOL> perPackageOptions . add ( configured ) <EOL> }

/**
 * Closure for configuring package options, appending to [perPackageOptions].
 *
 * @see [GradlePackageOptionsBuilder] for details.
 */


fun perPackageOption ( action : Action < in GradlePackageOptionsBuilder > )

{ <EOL> val option = GradlePackageOptionsBuilder ( project ) <EOL> action . execute ( option ) <EOL> perPackageOptions . add ( option ) <EOL> }

/**
 * Action for configuring package options, appending to [perPackageOptions].
 *
 * @see [GradlePackageOptionsBuilder] for details.
 */


@ Suppress ( "<STR_LIT:DEPRECATION>" ) <EOL> fun externalDocumentationLink ( c : Closure < in GradleExternalDocumentationLinkBuilder > )

{ <EOL> val link = org . gradle . util . ConfigureUtil . configure ( c , GradleExternalDocumentationLinkBuilder ( project ) ) <EOL> externalDocumentationLinks . add ( link ) <EOL> }

/**
 * Closure for configuring external documentation links, appending to [externalDocumentationLinks].
 *
 * @see [GradleExternalDocumentationLinkBuilder] for details.
 */


fun externalDocumentationLink ( action : Action < in GradleExternalDocumentationLinkBuilder > )

{ <EOL> val link = GradleExternalDocumentationLinkBuilder ( project ) <EOL> action . execute ( link ) <EOL> externalDocumentationLinks . add ( link ) <EOL> }

/**
 * Action for configuring external documentation links, appending to [externalDocumentationLinks].
 *
 * See [GradleExternalDocumentationLinkBuilder] for details.
 */


fun externalDocumentationLink ( url : String , packageListUrl : String ? = null )

{ <EOL> externalDocumentationLink ( URI ( url ) . toURL ( ) , packageListUrl = packageListUrl ? . let ( :: URI ) ? . toURL ( ) ) <EOL> }

/**
 * Convenient override to **append** external documentation links to [externalDocumentationLinks].
 */


fun externalDocumentationLink ( url : URL , packageListUrl : URL ? = null )

{ <EOL> externalDocumentationLinks . add ( GradleExternalDocumentationLinkBuilder ( project ) . apply { <EOL> this . url . convention ( url ) <EOL> if ( packageListUrl != null ) { <EOL> this . packageListUrl . convention ( packageListUrl ) <EOL> } <EOL> } ) <EOL> }


private fun recordMappingsForNestedClassesActualizedViaTypealias ( typealiasClassId : ClassId , actualClassSymbol : IrClassSymbol )

{ <EOL> fun recordRecursively ( expectClass : IrClass , actualClass : IrClass ) { <EOL> val actualNestedClassesByName = actualClass . nestedClasses . associateBy { it . name } <EOL> for ( expectNestedClass in expectClass . nestedClasses ) { <EOL> val actualNestedClass = actualNestedClassesByName [ expectNestedClass . name ] ? : continue <EOL> actualClasses [ expectNestedClass . classIdOrFail ] = actualNestedClass . symbol <EOL> recordRecursively ( expectNestedClass , actualNestedClass ) <EOL> } <EOL> } <EOL> val expectClassSymbol = expectTopLevelClasses [ typealiasClassId ] ? : return <EOL> recordRecursively ( expectClassSymbol . owner , actualClassSymbol . owner ) <EOL> }

/**
 * For given actual typealias goes through all nested classes in expect class to record their mappings in [actualClasses].
 *
 * This is needed because in case of `expect` nested classes actualized via typealias we can't simply find actual symbol by
 * `expect` `ClassId` (like we do for top-level classes), because `ClassId` is different.
 * For example, `expect` class `com/example/ExpectClass.Nested` may have actual with id `real/package/ActualTypeliasTarget.Nested`.
 */


private fun String . withSystemLineSeparator ( ) : String

= this . replace ( "<STR_LIT:\n>" , System . lineSeparator ( ) )

/**
 * If the expected output was generated on Linux, but the tests are run under Windows,
 * the test might fail when comparing the strings due to different separators.
 */


private fun IrType . checkObjectLeak ( ) : Boolean

{ <EOL> return if ( this is IrSimpleType ) { <EOL> val signature = classifier . signature <EOL> val possibleLeakedClassifier = ( signature == null || signature . isLocal ) && classifier !is IrTypeParameterSymbol <EOL> possibleLeakedClassifier || arguments . any { it . typeOrNull ? . checkObjectLeak ( ) == true } <EOL> } else false <EOL> }

/**
 * In `declarations-only` mode in case of private property/function with inferred anonymous private type like this
 * class C {
 * private val p = object {
 * fun foo() = 42
 * }
 *
 * private fun f() = object {
 * fun bar() = "42"
 * }
 *
 * private val pp = p.foo()
 * private fun ff() = f().bar()
 * }
 * object's classifier is leaked outside p/f scopes and accessible on C's level so
 * if their initializer/body weren't read we have unbound `foo/bar` symbol and unbound `object` symbols.
 * To fix this make sure that such declaration forced to be deserialized completely.
 *
 * For more information see `anonymousClassLeak.kt` test and issue KT-40216
 */


internal inline fun < reified S : IrSymbol > IrSymbol . checkSymbolType ( fallbackSymbolKind : SymbolKind ? ) : S

{ <EOL> if ( this is S ) return this <EOL> if ( ! partialLinkageEnabled ) <EOL> throw IrSymbolTypeMismatchException ( S :: class . java , this ) <EOL> return referenceDeserializedSymbol ( symbolTable = symbolDeserializer . symbolTable , fileSymbol = null , symbolKind = fallbackSymbolKind ? : error ( "<STR_LIT>" ) , idSig = signature ? . takeIf { it . isPubliclyVisible } ? : error ( "<STR_LIT>" ) ) as S <EOL> }

/**
 * This function allows to check deserialized symbols. If the deserialized symbol mismatches the symbol kind
 * at the call site in the deserializer then generate and reference another symbol with
 * the same signature. In case PL is off, just throw [IrSymbolTypeMismatchException].
 *
 * Note: [fallbackSymbolKind] must not completely match [S], but it should represent a subclass of [S].
 *
 * Example: [S] is [IrClassifierSymbol] and [fallbackSymbolKind] is [CLASS_SYMBOL],
 * which is only one possible option along with [TYPE_PARAMETER_SYMBOL].
 *
 * Note, that for local IR declarations such as [IrValueDeclaration] [fallbackSymbolKind] can be left null.
 */


public fun getBinaryRoots ( ) : Collection < Path >

/**
 * A list of binary files which forms a binary module. It can be a list of JARs, KLIBs, folders with .class files.
 *
 * It should be consistent with [contentScope], so (pseudo-Kotlin):
 * ```
 * library.contentScope.contains(file) <=> library.getBinaryRoots().listRecursively().contains(file)
 * ```
 */


fun createDescriptor ( name : Name , storageManager : StorageManager , builtIns : KotlinBuiltIns , origin : KlibModuleOrigin , customCapabilities : Map < ModuleCapability < * > , Any ? > = emptyMap ( ) ) : ModuleDescriptorImpl

/**
 * Base method for creation of any Kotlin/Native [ModuleDescriptor].
 */


fun createDescriptorAndNewBuiltIns ( name : Name , storageManager : StorageManager , origin : KlibModuleOrigin , customCapabilities : Map < ModuleCapability < * > , Any ? > = emptyMap ( ) ) : ModuleDescriptorImpl

/**
 * Please use this method with care: As far as it creates an instance of [KotlinBuiltIns] it should be
 * normally used for creation of the very first (e.g. "stdlib") module in the set of created modules.
 */


public fun r ( re : Float ) : ComplexFloat

= ComplexFloat ( re , <NUM_LIT> )

/**
 * Returns a [ComplexFloat] with the given real part.
 *
 * @param re the real part of the complex number
 * @return a [ComplexFloat] number with the given real part and 0f imaginary part
 */


public fun r ( re : Double ) : ComplexDouble

= ComplexDouble ( re , <NUM_LIT:0.0> )

/**
 * Returns a [ComplexDouble] with the given real part.
 *
 * @param re the real part of the complex number
 * @return a [ComplexDouble] number with the given real part and 0.0 imaginary part
 */


public fun i ( im : Float ) : ComplexFloat

= ComplexFloat ( <NUM_LIT> , im )

/**
 * Returns the [ComplexFloat] number representation of the given imaginary part.
 *
 * @param im the imaginary part of the complex number
 * @return a [ComplexFloat] number with the 0f real part and given imaginary part
 */


public fun i ( im : Double ) : ComplexDouble

= ComplexDouble ( <NUM_LIT:0.0> , im )

/**
 * Returns the [ComplexDouble] number representation of the given imaginary part.
 *
 * @param im the imaginary part of the complex number.
 * @return a [ComplexDouble] number with the 0.0 real part and given imaginary part
 */


internal fun convertComplexFloatToLong ( re : Float , im : Float ) : Long

= <EOL> ( re . toRawBits ( ) . toLong ( ) shl <NUM_LIT> ) or ( im . toRawBits ( ) . toLong ( ) and <NUM_LIT> )

/**
 * Converts a complex float to a long value.
 *
 * This method takes in a real and imaginary float value and returns a long equivalent. The real
 * value is converted to raw bits and left shifted by 32 bits. The imaginary value is also
 * converted to raw bits and ANDed with the hexadecimal value 0xFFFFFFFFL to get the last 32 bits
 * of the long. The two 32-bit values are then ORed to get the final long value.
 *
 * @param re the real value of the complex number as a float
 * @param im the imaginary value of the complex number as a float
 *
 * @return the long equivalent of the complex number given by the real and imaginary values
 */


fun getAvailableScopes ( processTypeScope : FirTypeScope . ( ConeKotlinType ) -> FirTypeScope = { this } , ) : List < FirScope >

= when { <EOL> scope != null -> listOf ( scope ) <EOL> implicitReceiver != null -> listOf ( implicitReceiver . getImplicitScope ( processTypeScope ) ) <EOL> contextReceiverGroup != null -> contextReceiverGroup . map { it . getImplicitScope ( processTypeScope ) } <EOL> else -> error ( "<STR_LIT>" ) <EOL> }

/**
 * Returns [scope] if it is not null. Otherwise, returns scopes of implicit receivers (including context receivers).
 *
 * Note that a scope for a companion object is an implicit scope.
 */


protected fun libraryInCurrentDir ( name : String ) : KotlinLibrary

= <EOL> resolverByName ( emptyList ( ) , logger = KlibToolLogger ( output ) ) . resolve ( name )

/** TODO: unify with [libraryInDefaultRepoOrCurrentDir] */


protected fun libraryInDefaultRepoOrCurrentDir ( name : String ) : KotlinLibrary

= <EOL> resolverByName ( listOf ( DependencyDirectories . localKonanDir . resolve ( "<STR_LIT>" ) . absolutePath ) , logger = KlibToolLogger ( output ) ) . resolve ( name )

/** TODO: unify with [libraryInCurrentDir] */


@ Test <EOL> fun `test - KT58280 - jvmWithJava Target does not add main classes to test compile classpath` ( )

{ <EOL> val project = buildProject ( ) <EOL> project . plugins . apply ( "<STR_LIT>" ) <EOL> project . applyKotlinJvmPlugin ( ) <EOL> project . repositories . mavenLocal ( ) <EOL> project . repositories . mavenCentralCacheRedirector ( ) <EOL> val kotlin = project . kotlinJvmExtension <EOL> kotlin . target . compilations . test . internal . configurations . compileDependencyConfiguration . resolvedConfiguration . files . forEach { file -> <EOL> if ( file in kotlin . target . compilations . main . output . allOutputs ) { <EOL> fail ( "<STR_LIT>" ) <EOL> } <EOL> } <EOL> }

/**
 * Context:
 * https://youtrack.jetbrains.com/issue/KT-58280/org.jetbrains.kotlin.jvm-Gradle-plugin-contributes-build-directories-to-the-test-compile-classpath
 *
 * This is not necessarily a 'regression' as IntelliJ and CLI compilations work fine.
 * Tools like eclipse did not expect this output.
 *
 * The commit the initially (and accidentally) changed the behavior was:
 * [Gradle] Implement KotlinWithJavaCompilation with underlying KotlinCompilationImpl Sebastian Sellmair* 04.10.22, 17:16
 * af198825899df9943814e2cb54d39868fff399fb
 *
 * This test 'fixates' the old behaviour.
 */


public actual fun todo ( block : ( ) -> Unit )

{ <EOL> println ( "<STR_LIT>" + block ) <EOL> }

/**
 * Takes the given [block] of test code and _doesn't_ execute it.
 *
 * This keeps the code under test referenced, but doesn't actually test it until it is implemented.
 */


@ Suppress ( "<STR_LIT:NOTHING_TO_INLINE>" ) <EOL> internal actual inline fun AssertionErrorWithCause ( message : String ? , cause : Throwable ? ) : AssertionError

= <EOL> AssertionError ( message , cause )

/** Platform-specific construction of AssertionError with cause */


internal actual fun lookupAsserter ( ) : Asserter

= DefaultJsAsserter

/**
 * Provides the JS implementation of asserter
 */


private fun createTabs ( pageContext : ContentPage ) : List < ContentTab >

{ <EOL> return when ( pageContext ) { <EOL> is ClasslikePage -> createTabsForClasslikes ( pageContext ) <EOL> is PackagePage -> createTabsForPackage ( pageContext ) <EOL> else -> throw IllegalArgumentException ( "<STR_LIT>" ) <EOL> } <EOL> }

/**
 * Tabs themselves are created in HTML plugin since, currently, only HTML format supports them.
 * [TabbedContentType] is used to mark content that should be inside tab content.
 * A tab can display multiple [TabbedContentType].
 * The content style [ContentStyle.TabbedContent] is used to determine where tabs will be generated.
 *
 * @see TabbedContentType
 * @see ContentStyle.TabbedContent
 */


private fun FlowContent . buildRowForPlatformTaggedBrief ( contextNode : ContentGroup , toRender : List < ContentNode > , pageContext : ContentPage , sourceSetRestriction : Set < DisplaySourceSet > ? <EOL> )

{ <EOL> buildAnchor ( contextNode ) <EOL> div ( classes = "<STR_LIT>" ) { <EOL> addSourceSetFilteringAttributes ( contextNode ) <EOL> div { <EOL> div ( "<STR_LIT>" + contextNode . style . joinToString ( separator = "<STR_LIT:U+0020>" ) ) { <EOL> buildRowHeaderLink ( toRender , pageContext , sourceSetRestriction , contextNode . anchor ) <EOL> div ( "<STR_LIT>" ) { <EOL> if ( ContentKind . shouldBePlatformTagged ( contextNode . dci . kind ) ) { <EOL> createPlatformTags ( contextNode , cssClasses = "<STR_LIT>" ) <EOL> } <EOL> } <EOL> } <EOL> div { <EOL> buildRowBriefSectionForDocs ( toRender , pageContext , sourceSetRestriction ) <EOL> } <EOL> } <EOL> } <EOL> }

/**
 * Builds a row with support for filtering and showing platform bubble and brief content.
 *
 * Used for rendering packages in [ModulePage] and types in [AllTypesPageNode]
 */


public open fun FlowContent . clickableLogo ( page : PageNode , pathToRoot : String )

{ <EOL> if ( context . configuration . delayTemplateSubstitution && page is ContentPage ) { <EOL> templateCommand ( PathToRootSubstitutionCommand ( pattern = "<STR_LIT>" , default = pathToRoot ) ) { <EOL> a { <EOL> href = "<STR_LIT>" <EOL> templateCommand ( ProjectNameSubstitutionCommand ( pattern = "<STR_LIT>" , default = context . configuration . moduleName ) ) { <EOL> span { <EOL> text ( "<STR_LIT>" ) <EOL> } <EOL> } <EOL> } <EOL> } <EOL> } else { <EOL> a { <EOL> href = pathToRoot + "<STR_LIT>" <EOL> text ( context . configuration . moduleName ) <EOL> } <EOL> } <EOL> }

/**
 * This is deliberately left open for plugins that have some other pages above ours and would like to link to them
 * instead of ours when clicking the logo
 */


fun TestProject . preparePodfile ( iosAppLocation : String , mode : ImportMode )

{ <EOL> val iosAppDir = projectPath . resolve ( iosAppLocation ) <EOL> iosAppDir . resolve ( "<STR_LIT>" ) <EOL> . takeIf { it . exists ( ) } <EOL> ? . replaceText ( podfileImportDirectivePlaceholder , mode . directive ) <EOL> }

/**
 * Prepares the Podfile for an iOS app in the [TestProject]
 *
 * @param iosAppLocation The relative location of the iOS app directory within the [TestProject]
 * @param mode The [ImportMode] to be set for the Podfile.
 *
 */


fun Path . addSpecRepo ( specRepo : String )

= addCocoapodsBlock ( "<STR_LIT>" . wrapIntoBlock ( "<STR_LIT>" ) )

/**
 * Wraps the given string into a specRepos block and adds this block to the end of the [this] path.
 *
 * @param specRepo The code to be wrapped with the Cocoapods block.
 */


fun Path . addCocoapodsBlock ( str : String )

= addKotlinBlock ( str . wrapIntoBlock ( "<STR_LIT>" ) )

/**
 * Wraps the given string into a Cocoapods block and adds this block to the end of the [this] path.
 *
 * @param str The code to be wrapped with the Cocoapods block.
 */


fun Path . addKotlinBlock ( str : String )

= appendLine ( str . wrapIntoBlock ( "<STR_LIT:kotlin>" ) )

/**
 * Wraps the given string into a Kotlin block and adds this block to the end of the [this] path.
 *
 * @param str The code to be wrapped with the Cocoapods block.
 */


fun Path . addFrameworkBlock ( str : String )

= addCocoapodsBlock ( str . wrapIntoBlock ( "<STR_LIT>" ) )

/**
 * Wraps the given string into a Framework block and adds this block to the end of the [this] path.
 *
 * @param str The code to be wrapped with the Cocoapods block.
 */


fun Path . addPod ( podName : String , configuration : String ? = null )

{ <EOL> val pod = "<STR_LIT>" <EOL> val podBlock = configuration ? . wrapIntoBlock ( pod ) ? : pod <EOL> addCocoapodsBlock ( podBlock ) <EOL> }

/**
 * Adds a Cocoapods dependency to [this] build script.
 *
 * @param podName The name of the Cocoapods dependency to be added.
 * @param configuration The optional configuration string for the Cocoapods dependency.
 */


fun Path . removePod ( podName : String )

{ <EOL> val text = readText ( ) <EOL> val begin = text . indexOf ( """<STR_LIT>""" ) <EOL> require ( begin != - <NUM_LIT:1> ) { <EOL> """<STR_LIT>""" . trimIndent ( ) <EOL> } <EOL> var index = begin + """<STR_LIT>""" . length - <NUM_LIT:1> <EOL> if ( text . indexOf ( """<STR_LIT>""" , startIndex = begin ) != - <NUM_LIT:1> ) { <EOL> index += <NUM_LIT:2> <EOL> var bracket = <NUM_LIT:1> <EOL> while ( bracket != <NUM_LIT:0> ) { <EOL> if ( text [ ++ index ] == '<CHAR_LIT>' ) { <EOL> bracket ++ <EOL> } else if ( text [ index ] == '<CHAR_LIT>' ) { <EOL> bracket -- <EOL> } <EOL> } <EOL> } <EOL> writeText ( text . removeRange ( begin .. index ) ) <EOL> }

/**
 * Removes a Cocoapods dependency from [this] build script.
 *
 * @param podName The name of the Cocoapods dependency to be removes.
 */


fun cocoaPodsEnvironmentVariables ( ) : Map < String , String >

{ <EOL> if ( ! shouldInstallLocalCocoapods ) { <EOL> return emptyMap ( ) <EOL> } <EOL> val path = cocoapodsBinPath . absolutePathString ( ) + File . pathSeparator + System . getenv ( "<STR_LIT>" ) <EOL> val gemPath = System . getenv ( "<STR_LIT>" ) ? . let { <EOL> cocoapodsInstallationRoot . absolutePathString ( ) + File . pathSeparator + it <EOL> } ? : cocoapodsInstallationRoot . absolutePathString ( ) <EOL> return mapOf ( "<STR_LIT>" to path , "<STR_LIT>" to gemPath , ) <EOL> }

/**
 * Method returns required environment variables for cocoapods tests with execution of [POD_INSTALL_TASK_NAME]
 */


@ Synchronized <EOL> fun ensureCocoapodsInstalled ( )

{ <EOL> if ( shouldInstallLocalCocoapods ) { <EOL> val installDir = cocoapodsInstallationRoot . absolutePathString ( ) <EOL> println ( "<STR_LIT>" ) <EOL> try { <EOL> gem ( "<STR_LIT>" , "<STR_LIT>" , installDir , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ) <EOL> } catch ( e : AssertionError ) { <EOL> System . err . println ( "<STR_LIT>" ) <EOL> System . err . println ( e . toString ( ) ) <EOL> } <EOL> gem ( "<STR_LIT>" , "<STR_LIT>" , installDir , "<STR_LIT>" , "<STR_LIT>" , TestVersions . COCOAPODS . VERSION ) <EOL> } else if ( ! isCocoapodsInstalled ( ) ) { <EOL> fail ( """<STR_LIT>""" . trimIndent ( ) ) <EOL> } <EOL> }

/**
 * This method checks if Cocoapods should be installed and verifies its installation status.
 * If [shouldInstallLocalCocoapods] is true, it tries to install Cocoapods into the specified [cocoapodsInstallationRoot]
 * if it is not already installed.
 *
 * @throws AssertionError if [shouldInstallLocalCocoapods] is false and cocoapods has not been installed
 */


public fun loadModelConfiguration ( jsonFile : File ) : T

/**
 * Loads model configuration from the provided [jsonFile].
 */


fun canSynthesizeEnumEntries ( ) : Boolean ?

/**
 * Determines whether `Enum.entries` property can be synthesized for enums in this module,
 * when this property is not present in compiled code.
 * Returns `null` if it's not known.
 */


override fun compareTo ( other : SinceKotlinVersion ) : Int

{ <EOL> val i1 = parts . listIterator ( ) <EOL> val i2 = other . parts . listIterator ( ) <EOL> while ( i1 . hasNext ( ) || i2 . hasNext ( ) ) { <EOL> val diff = ( if ( i1 . hasNext ( ) ) i1 . next ( ) else <NUM_LIT:0> ) - ( if ( i2 . hasNext ( ) ) i2 . next ( ) else <NUM_LIT:0> ) <EOL> if ( diff != <NUM_LIT:0> ) return diff <EOL> } <EOL> return <NUM_LIT:0> <EOL> }


fun createCustomTagFromSinceKotlinVersion ( version : SinceKotlinVersion ? , platform : Platform ) : CustomTagWrapper

{ <EOL> val sinceKotlinVersion = version ? : minVersionOfPlatform ( platform ) <EOL> return CustomTagWrapper ( CustomDocTag ( children = listOf ( Text ( sinceKotlinVersion . toString ( ) ) ) , name = MARKDOWN_ELEMENT_FILE_NAME ) , SINCE_KOTLIN_TAG_NAME ) <EOL> }

/**
 * Should be in sync with [extractSinceKotlinVersionFromCustomTag]
 */


fun extractSinceKotlinVersionFromCustomTag ( tagWrapper : CustomTagWrapper , platform : Platform ) : SinceKotlinVersion

{ <EOL> val customTag = tagWrapper . root as? CustomDocTag <EOL> val sinceKotlinVersionText = customTag ? . children ? . firstOrNull ( ) as? Text <EOL> val sinceKotlinVersion = sinceKotlinVersionText ? . body ? . let ( :: SinceKotlinVersion ) <EOL> return sinceKotlinVersion ? : minVersionOfPlatform ( platform ) <EOL> }

/**
 * Should be in sync with [createCustomTagFromSinceKotlinVersion]
 */


fun isKotlinJvmCompiledFile ( file : VirtualFile , fileContent : ByteArray ? = null ) : Boolean

{ <EOL> if ( file . extension != JavaClassFileType . INSTANCE ! ! . defaultExtension ) { <EOL> return false <EOL> } <EOL> val binaryFromCache = getKotlinBinaryFromCache ( file ) <EOL> binaryFromCache ? . let { <EOL> return it . isKotlinBinary <EOL> } <EOL> return kotlinJvmBinaryClass ( file , fileContent , JvmMetadataVersion . INSTANCE , binaryFromCache ? . isKotlinBinary ) != null <EOL> }

/**
 * Checks if this file is a compiled Kotlin class file (not necessarily ABI-compatible with the current plugin)
 */


@ Test <EOL> fun testThreadLocalBeingThreadLocal ( )

= runTest { <EOL> val threadLocal = commonThreadLocal < Int > ( Symbol ( "<STR_LIT>" ) ) <EOL> newSingleThreadContext ( "<STR_LIT>" ) . use { <EOL> threadLocal . set ( <NUM_LIT:10> ) <EOL> assertEquals ( <NUM_LIT:10> , threadLocal . get ( ) ) <EOL> val job1 = launch ( it ) { <EOL> threadLocal . set ( <NUM_LIT:20> ) <EOL> assertEquals ( <NUM_LIT:20> , threadLocal . get ( ) ) <EOL> } <EOL> assertEquals ( <NUM_LIT:10> , threadLocal . get ( ) ) <EOL> job1 . join ( ) <EOL> val job2 = launch ( it ) { <EOL> assertEquals ( <NUM_LIT:20> , threadLocal . get ( ) ) <EOL> } <EOL> job2 . join ( ) <EOL> } <EOL> }

/**
 * Tests the basic functionality of [commonThreadLocal]: storing a separate value for each thread.
 */


@ Test <EOL> fun testThreadLocalWithNullableType ( )

= runTest { <EOL> val threadLocal = commonThreadLocal < Int ? > ( Symbol ( "<STR_LIT>" ) ) <EOL> newSingleThreadContext ( "<STR_LIT>" ) . use { <EOL> assertNull ( threadLocal . get ( ) ) <EOL> threadLocal . set ( <NUM_LIT:10> ) <EOL> assertEquals ( <NUM_LIT:10> , threadLocal . get ( ) ) <EOL> val job1 = launch ( it ) { <EOL> assertNull ( threadLocal . get ( ) ) <EOL> threadLocal . set ( <NUM_LIT:20> ) <EOL> assertEquals ( <NUM_LIT:20> , threadLocal . get ( ) ) <EOL> } <EOL> assertEquals ( <NUM_LIT:10> , threadLocal . get ( ) ) <EOL> job1 . join ( ) <EOL> threadLocal . set ( null ) <EOL> assertNull ( threadLocal . get ( ) ) <EOL> val job2 = launch ( it ) { <EOL> assertEquals ( <NUM_LIT:20> , threadLocal . get ( ) ) <EOL> threadLocal . set ( null ) <EOL> assertNull ( threadLocal . get ( ) ) <EOL> } <EOL> job2 . join ( ) <EOL> } <EOL> }

/**
 * Tests using [commonThreadLocal] with a nullable type.
 */


@ Test <EOL> fun testThreadLocalsWithDifferentNamesNotInterfering ( )

{ <EOL> val value1 = commonThreadLocal < Int > ( Symbol ( "<STR_LIT>" ) ) <EOL> val value2 = commonThreadLocal < Int > ( Symbol ( "<STR_LIT>" ) ) <EOL> value1 . set ( <NUM_LIT:5> ) <EOL> value2 . set ( <NUM_LIT:6> ) <EOL> assertEquals ( <NUM_LIT:5> , value1 . get ( ) ) <EOL> assertEquals ( <NUM_LIT:6> , value2 . get ( ) ) <EOL> }

/**
 * Tests that several instances of [commonThreadLocal] with different names don't affect each other.
 */


public fun resolveSample ( sourceSet : DokkaConfiguration . DokkaSourceSet , fullyQualifiedLink : String ) : SampleSnippet ?

/**
 * Resolves a Kotlin sample function by its fully qualified name, and returns its import statements and body.
 *
 * @param sourceSet must be either the source set in which this sample function resides, or the source set
 * for which [DokkaConfiguration#samples] or [DokkaConfiguration#sourceRoots]
 * have been configured with the sample's sources.
 * @param fullyQualifiedLink fully qualified path to the sample function, including all middle packages
 * and the name of the function. Only links to Kotlin functions are valid,
 * which can reside within a class. The package must be the same as the package
 * declared in the sample file. The function must be resolvable by Dokka,
 * meaning it must reside either in the main sources of the project or its
 * sources must be included in [DokkaConfiguration#samples] or
 * [DokkaConfiguration#sourceRoots]. Example: `com.example.pckg.topLevelKotlinFunction`
 *
 * @return a sample code snippet which includes import statements and the function body,
 * or null if the link could not be resolved (examine the logs to find out the reason).
 */


public fun < T , C > DataFrame < T > . update ( columns : ColumnsSelector < T , C > ) : Update < T , C >

= <EOL> Update ( this , null , columns )

/**
 * @include [CommonUpdateFunctionDoc]
 * @include [SelectingColumns.Dsl.WithExample] {@include [SetSelectingColumnsOperationArg]}
 * @include [Update.DslParam]
 */


public fun < T > DataFrame < T > . update ( vararg columns : String ) : Update < T , Any ? >

= update { columns . toColumnSet ( ) }

/**
 * @include [CommonUpdateFunctionDoc]
 * @include [SelectingColumns.ColumnNames.WithExample] {@include [SetSelectingColumnsOperationArg]}
 * @include [UpdateWithNote]
 * @include [Update.ColumnNamesParam]
 */


public fun < T , C > DataFrame < T > . update ( vararg columns : KProperty < C > ) : Update < T , C >

= update { columns . toColumnSet ( ) }

/**
 * @include [CommonUpdateFunctionDoc]
 * @include [SelectingColumns.KProperties.WithExample] {@include [SetSelectingColumnsOperationArg]}
 * @include [UpdateWithNote]
 * @include [Update.KPropertiesParam]
 */


public fun < T , C > DataFrame < T > . update ( vararg columns : ColumnReference < C > ) : Update < T , C >

= <EOL> update { columns . toColumnSet ( ) }

/**
 * @include [CommonUpdateFunctionDoc]
 * @include [SelectingColumns.ColumnAccessors.WithExample] {@include [SetSelectingColumnsOperationArg]}
 * @include [UpdateWithNote]
 * @include [Update.ColumnAccessorsParam]
 */


public fun < T , C > Update < T , C > . where ( predicate : RowValueFilter < T , C > ) : Update < T , C >

= <EOL> copy ( filter = filter and predicate )

/** ## Where
 * @include [SelectingRows.RowValueCondition.WithExample]
 * {@set [SelectingRows.FirstOperationArg] [update][update]}
 * {@set [SelectingRows.SecondOperationArg] [where][where]}
 *
 * @param [predicate] The [row value filter][RowValueFilter] to select the rows to update.
 */


public fun < T , C > Update < T , C > . at ( rowIndices : Collection < Int > ) : Update < T , C >

= where { index in rowIndices }

/**
 * @include [CommonUpdateAtFunctionDoc]
 *
 * Provide a [Collection]<[Int]> of row indices to update.
 *
 * @param [rowIndices] {@include [CommonUpdateAtFunctionDoc.RowIndicesParam]}
 */


public fun < T , C > Update < T , C > . at ( vararg rowIndices : Int ) : Update < T , C >

= at ( rowIndices . toSet ( ) )

/**
 * @include [CommonUpdateAtFunctionDoc]
 *
 * Provide a `vararg` of [Ints][Int] of row indices to update.
 *
 * @param [rowIndices] {@include [CommonUpdateAtFunctionDoc.RowIndicesParam]}
 */


public fun < T , C > Update < T , C > . at ( rowRange : IntRange ) : Update < T , C >

= where { index in rowRange }

/**
 * @include [CommonUpdateAtFunctionDoc]
 *
 * Provide an [IntRange] of row indices to update.
 *
 * @param [rowRange] {@include [CommonUpdateAtFunctionDoc.RowIndicesParam]}
 */


public fun < T , C > Update < T , C > . perRowCol ( expression : RowColumnExpression < T , C , C > ) : DataFrame < T >

= <EOL> updateImpl { row , column , _ -> expression ( row , column ) }

/** ## Per Row Col
 * @include [ExpressionsGivenRowAndColumn.RowColumnExpression.WithExample]
 * {@set [ExpressionsGivenRowAndColumn.OperationArg] [update][update]` { age \}.`[perRowCol][perRowCol]}
 *
 * ## See Also
 * - {@include [SeeAlsoWith]}
 * - {@include [SeeAlsoPerCol]}
 * @param [expression] The {@include [ExpressionsGivenRowAndColumn.RowColumnExpressionLink]} to provide a new value for every selected cell giving its row and column.
 */


public fun < T , C > Update < T , C > . with ( expression : UpdateExpression < T , C , C ? > ) : DataFrame < T >

= <EOL> updateImpl { row , _ , value -> <EOL> expression ( row , value ) <EOL> }

/** ## With
 * {@include [ExpressionsGivenRow.RowValueExpression.WithExample]}
 * {@set [ExpressionsGivenRow.OperationArg] [update][update]` { city \}.`[with][with]}
 *
 * ## Note
 * @include [ExpressionsGivenRow.AddDataRowNote]
 * ## See Also
 * - {@include [SeeAlsoPerCol]}
 * - {@include [SeeAlsoPerRowCol]}
 * @param [expression] The {@include [ExpressionsGivenRow.RowValueExpressionLink]} to update the rows with.
 */


public fun < T , C , R > Update < T , DataRow < C > > . asFrame ( expression : DataFrameExpression < C , DataFrame < R > > ) : DataFrame < T >

= <EOL> asFrameImpl ( expression )

/** ## As Frame
 *
 * Updates selected [column group][ColumnGroup] as a [DataFrame] with the given [expression].
 *
 * {@include [ExpressionsGivenDataFrame.DataFrameExpression.WithExample]}
 * {@set [ExpressionsGivenDataFrame.OperationArg] `df.`[update][update]` { name \}.`[asFrame][asFrame]}
 * @param [expression] The {@include [ExpressionsGivenDataFrame.DataFrameExpressionLink]} to replace the selected column group with.
 */


public fun < T , C > Update < T , C > . perCol ( values : Map < String , C > ) : DataFrame < T >

= updateWithValuePerColumnImpl { <EOL> values [ it . name ( ) ] ? : throw IllegalArgumentException ( "<STR_LIT>" ) <EOL> }

/**
 * @include [CommonUpdatePerColMapDoc]
 * {@set [CommonUpdatePerColMapDoc] `[mapOf][mapOf]`("name" to "Empty", "age" to 0)}
 *
 * @param [values] The [Map]<[String], Value> to provide a new value for every selected cell.
 * For each selected column, there must be a value in the map with the same name.
 */


public fun < T , C > Update < T , C > . perCol ( values : AnyRow ) : DataFrame < T >

= perCol ( values . toMap ( ) as Map < String , C > )

/**
 * {@include [CommonUpdatePerColMapDoc]}
 * {@set [CommonUpdatePerColMapDoc] df.`[getRows][DataFrame.getRows]`(`[listOf][listOf]`(0))`
 *
 * {@include [Indent]}`.`[update][update]` { name \}.`[with][Update.with]` { "Empty" \}`
 *
 * {@include [Indent]}`.`[update][update]` { age \}.`[with][Update.with]` { 0 \}`
 *
 * {@include [Indent]}`.first()}
 *
 * @param [values] The [DataRow] to provide a new value for every selected cell.
 */


public fun < T , C > Update < T , C > . perCol ( valueSelector : ColumnExpression < C , C > ) : DataFrame < T >

= <EOL> updateWithValuePerColumnImpl ( valueSelector )

/**
 * @include [CommonUpdatePerColDoc]
 * @include [ExpressionsGivenColumn.ColumnExpression.WithExample]
 * {@set [ExpressionsGivenColumn.OperationArg] [update][update]` { age \}.`[perCol][perCol]}
 *
 * @param [valueSelector] The {@include [ExpressionsGivenColumn.ColumnExpressionLink]} to provide a new value for every selected cell giving its column.
 */


internal infix fun < T , C > RowValueFilter < T , C > ? . and ( other : RowValueFilter < T , C > ) : RowValueFilter < T , C >

{ <EOL> if ( this == null ) return other <EOL> val thisExp = this <EOL> return { thisExp ( this , it ) && other ( this , it ) } <EOL> }

/** Chains up two row value filters together. */


public fun < T , C > Update < T , C ? > . notNull ( ) : Update < T , C >

= <EOL> where { it != null } as Update < T , C >


public fun < T , C > Update < T , C ? > . notNull ( expression : UpdateExpression < T , C , C > ) : DataFrame < T >

= <EOL> notNull ( ) . with ( expression )

/**
 * ## Not Null
 *
 * Selects only the rows where the values in the selected columns are not null.
 *
 * Shorthand for: [update][update]` { ... }.`[where][Update.where]` { it != null }`
 *
 * For example:
 *
 * `df.`[update][update]` { `[colsOf][colsOf]`<`[Number][Number]`?>() }.`[notNull][notNull]`().`[perCol][Update.perCol]` { `[mean][mean]`() }`
 *
 * ### Optional
 * Provide an [expression] to update the rows with.
 * This combines [with][Update.with] with [notNull].
 *
 * For example:
 *
 * `df.`[update][update]` { city }.`[notNull][Update.notNull]` { it.`[toUpperCase][String.toUpperCase]`() }`
 * {@comment No brackets around `expression` because this doc is copied to [Update.notNull]}
 * @param expression Optional {@include [ExpressionsGivenRow.RowExpressionLink]} to update the rows with.
 */


public fun < T , C > DataFrame < T > . update ( firstCol : ColumnReference < C > , vararg cols : ColumnReference < C > , expression : UpdateExpression < T , C , C > , ) : DataFrame < T >

= <EOL> update ( * headPlusArray ( firstCol , cols ) ) . with ( expression )

/**
 * @include [CommonUpdateFunctionDoc]
 * This overload is a combination of [update] and [with][Update.with].
 *
 * @include [SelectingColumns.ColumnAccessors]
 *
 * {@include [ExpressionsGivenRow.RowValueExpression.WithExample]}
 * {@set [ExpressionsGivenRow.OperationArg] [update][update]<code>`("city")`</code>}
 *
 * @include [Update.ColumnAccessorsParam]
 * @param [expression] The {@include [ExpressionsGivenRow.RowValueExpressionLink]} to update the rows with.
 */


public fun < T , C > DataFrame < T > . update ( firstCol : KProperty < C > , vararg cols : KProperty < C > , expression : UpdateExpression < T , C , C > , ) : DataFrame < T >

/**
 * @include [CommonUpdateFunctionDoc]
 * This overload is a combination of [update] and [with][Update.with].
 *
 * @include [SelectingColumns.KProperties]
 *
 * {@include [ExpressionsGivenRow.RowValueExpression.WithExample]}
 * {@set [ExpressionsGivenRow.OperationArg] [update][update]<code>`("city")`</code>}
 *
 * @include [Update.KPropertiesParam]
 * @param [expression] The {@include [ExpressionsGivenRow.RowValueExpressionLink]} to update the rows with.
 */


public fun < T > DataFrame < T > . update ( firstCol : String , vararg cols : String , expression : UpdateExpression < T , Any ? , Any ? > , ) : DataFrame < T >

/**
 * @include [CommonUpdateFunctionDoc]
 * This overload is a combination of [update] and [with][Update.with].
 *
 * @include [SelectingColumns.ColumnNames]
 *
 * {@include [ExpressionsGivenRow.RowValueExpression.WithExample]}
 * {@set [ExpressionsGivenRow.OperationArg] [update][update]<code>`("city")`</code>}
 *
 * @include [Update.ColumnNamesParam]
 * @param [expression] The {@include [ExpressionsGivenRow.RowValueExpressionLink]} to update the rows with.
 */


public fun < T , C > Update < T , C > . withNull ( ) : DataFrame < T >

= with { null }

/**
 * ## With Null
 * @include [CommonSpecificWithDoc]
 * {@set [CommonSpecificWithDoc.FirstArg] `null`}
 * {@set [CommonSpecificWithDoc.SecondArg] [withNull][withNull]`()}
 */


public fun < T , C > Update < T , C > . withZero ( ) : DataFrame < T >

= updateWithValuePerColumnImpl { <NUM_LIT:0> as C }

/**
 * ## With Zero
 * @include [CommonSpecificWithDoc]
 * {@set [CommonSpecificWithDoc.FirstArg] `0`}
 * {@set [CommonSpecificWithDoc.SecondArg] [withZero][withZero]`()}
 */


@ Test <EOL> fun testMaybeAwaitCancellation ( )

= runTest { <EOL> expect ( <NUM_LIT:1> ) <EOL> val maybe = MaybeSource < Int > { s -> <EOL> s . onSubscribe ( object : Disposable { <EOL> override fun dispose ( ) { expect ( <NUM_LIT:4> ) } <EOL> override fun isDisposed ( ) : Boolean { expectUnreached ( ) ; return false } <EOL> } ) <EOL> } <EOL> val job = launch ( start = CoroutineStart . UNDISPATCHED ) { <EOL> try { <EOL> expect ( <NUM_LIT:2> ) <EOL> maybe . awaitSingleOrNull ( ) <EOL> } catch ( e : CancellationException ) { <EOL> expect ( <NUM_LIT:5> ) <EOL> throw e <EOL> } <EOL> } <EOL> expect ( <NUM_LIT:3> ) <EOL> job . cancelAndJoin ( ) <EOL> finish ( <NUM_LIT:6> ) <EOL> }

/** Tests that calls to [awaitSingleOrNull] throw [CancellationException] and dispose of the subscription when their
 * [Job] is cancelled. */


@ Test <EOL> fun testMaybeCollectEmpty ( )

= runTest { <EOL> expect ( <NUM_LIT:1> ) <EOL> Maybe . empty < Int > ( ) . collect { <EOL> expectUnreached ( ) <EOL> } <EOL> finish ( <NUM_LIT:2> ) <EOL> }

/** Tests the simple scenario where the Maybe doesn't output a value. */


@ Test <EOL> fun testMaybeCollectSingle ( )

= runTest { <EOL> expect ( <NUM_LIT:1> ) <EOL> Maybe . just ( "<STR_LIT:OK>" ) . collect { <EOL> assertEquals ( "<STR_LIT:OK>" , it ) <EOL> expect ( <NUM_LIT:2> ) <EOL> } <EOL> finish ( <NUM_LIT:3> ) <EOL> }


@ Test <EOL> fun testMaybeCollectThrowingMaybe ( )

= runTest { <EOL> expect ( <NUM_LIT:1> ) <EOL> try { <EOL> Maybe . error < Int > ( TestException ( ) ) . collect { <EOL> expectUnreached ( ) <EOL> } <EOL> } catch ( e : TestException ) { <EOL> expect ( <NUM_LIT:2> ) <EOL> } <EOL> finish ( <NUM_LIT:3> ) <EOL> }

/** Tests the behavior of [collect] when the Maybe raises an error. */


@ Test <EOL> fun testMaybeCollectThrowingAction ( )

= runTest { <EOL> expect ( <NUM_LIT:1> ) <EOL> try { <EOL> Maybe . just ( "<STR_LIT:OK>" ) . collect { <EOL> expect ( <NUM_LIT:2> ) <EOL> throw TestException ( ) <EOL> } <EOL> } catch ( e : TestException ) { <EOL> expect ( <NUM_LIT:3> ) <EOL> } <EOL> finish ( <NUM_LIT:4> ) <EOL> }

/** Tests the behavior of [collect] when the action throws. */


public actual fun ComplexDouble ( re : Double , im : Double ) : ComplexDouble

{ <EOL> val reBits = re . toBits ( ) <EOL> val reHigherBits = ( reBits shr <NUM_LIT> ) . toInt ( ) <EOL> val reLowerBits = ( reBits and <NUM_LIT> ) . toInt ( ) <EOL> val imBits = im . toBits ( ) <EOL> val imHigherBits = ( imBits shr <NUM_LIT> ) . toInt ( ) <EOL> val imLowerBits = ( imBits and <NUM_LIT> ) . toInt ( ) <EOL> return NativeComplexDouble ( vectorOf ( reLowerBits , reHigherBits , imLowerBits , imHigherBits ) ) <EOL> }

/**
 * Creates a [ComplexDouble] with the given real and imaginary values in floating-point format.
 *
 * @param re the real value of the complex number in double format.
 * @param im the imaginary value of the complex number in double format.
 */


public actual fun ComplexDouble ( re : Number , im : Number ) : ComplexDouble

= ComplexDouble ( re . toDouble ( ) , im . toDouble ( ) )

/**
 * Creates a [ComplexDouble] with the given real and imaginary values in number format.
 *
 * @param re the real value of the complex number in number format.
 * @param im the imaginary value of the complex number in number format.
 */


{ <EOL> }


@ ExperimentalUnsignedTypes <EOL> internal fun sortArray ( array : UByteArray , fromIndex : Int , toIndex : Int )

= quickSort ( array , fromIndex , toIndex - <NUM_LIT:1> )

/**
 * Sorts the given array using qsort algorithm.
 */


{ <EOL> val model = SavedModel . load ( PATH_TO_MODEL ) <EOL> println ( model . graphToString ( ) ) <EOL> }

/**
 * Prints the TensorFlow graph as a sequence of TensorFlow operands.
 */


= printOutGraphOps ( )


public fun < DomainType : Comparable < DomainType > > continuousColorGradientN ( gradientColors : List < Color > , domain : ClosedRange < DomainType > , nullValue : Color ? = null , transform : Transformation ? = null ) : ScaleContinuousColorGradientN < DomainType >

= ScaleContinuousColorGradientN ( domain . let { <EOL> it . start to it . endInclusive <EOL> } , gradientColors , nullValue , transform )

/**
 * Creates smooth color gradient between multiple colors.
 *
 * @param DomainType type of domain
 * @param gradientColors gradient color [List].
 * @param domain [ClosedRange] defining the scale domain.
 * @param nullValue value which null is mapped to.
 * @param transform scale transformation.
 *
 * @return new continuous color scale.
 */


public fun < DomainType > continuousColorGradientN ( gradientColors : List < Color > , domainMin : DomainType ? = null , domainMax : DomainType ? = null , nullValue : Color ? = null , transform : Transformation ? = null ) : ScaleContinuousColorGradientN < DomainType >

= ScaleContinuousColorGradientN ( domainMin to domainMax , gradientColors , nullValue , transform )

/**
 * Creates smooth color gradient between multiple colors.
 *
 * @param DomainType type of domain
 * @param gradientColors gradient color [List].
 * @param domainMin scale domain minimum.
 * @param domainMax scale domain maximum.
 * @param nullValue value which null is mapped to.
 * @param transform scale transformation.
 *
 * @return new continuous color scale.
 */


public fun < DomainType : Comparable < DomainType > > continuousColorGradient2 ( low : Color , mid : Color , high : Color , midpoint : Double , domain : ClosedRange < DomainType > , nullValue : Color ? = null , transform : Transformation ? = null ) : ScaleContinuousColorGradient2 < DomainType >

= ScaleContinuousColorGradient2 ( domain . let { <EOL> it . start to it . endInclusive <EOL> } , low , mid , high , midpoint , nullValue , transform )

/**
 * Creates diverging color gradient (low-mid-high) for color aesthetic.
 *
 * @param DomainType type of domain
 * @param low color, scale range minimum.
 * @param mid color, corresponding to the midpoint.
 * @param high color, scale range maximum.
 * @param midpoint point on scale domain which is mapped to [mid] color.
 * @param domain segment defining the domain
 * @param transform the transformation of scale
 * @return new continuous color scale.
 */


public fun < DomainType > continuousColorGradient2 ( low : Color , mid : Color , high : Color , midpoint : Double , domainMin : DomainType ? = null , domainMax : DomainType ? = null , nullValue : Color ? = null , transform : Transformation ? = null ) : ScaleContinuousColorGradient2 < DomainType >

= ScaleContinuousColorGradient2 ( domainMin to domainMax , low , mid , high , midpoint , nullValue , transform )

/**
 * Creates diverging color gradient (low-mid-high) for color aesthetic.
 *
 * @param DomainType type of domain
 * @param low color, scale range minimum.
 * @param mid color, corresponding to the midpoint.
 * @param high color, scale range maximum.
 * @param midpoint point on scale domain which is mapped to [mid] color.
 * @param domainMin scale domain minimum.
 * @param domainMax scale domain maximum.
 * @param transform the transformation of scale
 * @return new continuous color scale.
 */


public fun toByteString ( ) : ByteString

{ <EOL> if ( size == <NUM_LIT:0> ) { <EOL> return ByteString ( ) <EOL> } <EOL> if ( buffer . size == size ) { <EOL> return ByteString . wrap ( buffer ) <EOL> } <EOL> return ByteString ( buffer , <NUM_LIT:0> , size ) <EOL> }

/**
 * Returns a new [ByteString] wrapping all bytes written to this builder.
 *
 * There will be no additional allocations or copying of data when `size == capacity`.
 */


{ <EOL> ensureCapacity ( size + <NUM_LIT:1> ) <EOL> buffer [ offset ++ ] = byte <EOL> }

/**
 * Append a single byte to this builder.
 *
 * @param byte the byte to append.
 */


public fun append ( array : ByteArray , startIndex : Int = <NUM_LIT:0> , endIndex : Int = array . size )

{ <EOL> require ( startIndex <= endIndex ) { "<STR_LIT>" } <EOL> if ( startIndex < <NUM_LIT:0> || endIndex > array . size ) { <EOL> throw IndexOutOfBoundsException ( "<STR_LIT>" + "<STR_LIT>" ) <EOL> } <EOL> ensureCapacity ( offset + endIndex - startIndex ) <EOL> array . copyInto ( buffer , offset , startIndex , endIndex ) <EOL> offset += endIndex - startIndex <EOL> }

/**
 * Appends a subarray of [array] starting at [startIndex] and ending at [endIndex] to this builder.
 *
 * @param array the array whose subarray should be appended.
 * @param startIndex the first index (inclusive) to copy data from the [array].
 * @param endIndex the last index (exclusive) to copy data from the [array]
 *
 * @throws IndexOutOfBoundsException when [startIndex] or [endIndex] is out of range of [array] array indices.
 * @throws IllegalArgumentException when `startIndex > endIndex`.
 */


public fun ByteStringBuilder . append ( byte : UByte ) : Unit

= append ( byte . toByte ( ) )

/**
 * Appends unsigned byte to this builder.
 */


public fun ByteStringBuilder . append ( byteString : ByteString )

{ <EOL> append ( byteString . getBackingArrayReference ( ) ) <EOL> }

/**
 * Appends a byte string to this builder.
 */


public fun ByteStringBuilder . append ( vararg bytes : Byte ) : Unit

= append ( bytes )

/**
 * Appends bytes to this builder.
 */


public inline fun buildByteString ( capacity : Int = <NUM_LIT:0> , builderAction : ByteStringBuilder . ( ) -> Unit ) : ByteString

{ <EOL> return ByteStringBuilder ( capacity ) . apply ( builderAction ) . toByteString ( ) <EOL> }

/**
 * Builds new byte string by populating newly created [ByteStringBuilder] initialized with the given [capacity]
 * using provided [builderAction] and then converting it to [ByteString].
 */


fun KtTestModule . publishModificationEventByDirective ( isOptional : Boolean = false )

{ <EOL> val modificationEventKinds = testModule . directives [ ModificationEventDirectives . MODIFICATION_EVENT ] <EOL> val modificationEventKind = when ( modificationEventKinds . size ) { <EOL> <NUM_LIT:0> -> { <EOL> if ( isOptional ) return <EOL> error ( "<STR_LIT>" ) <EOL> } <EOL> <NUM_LIT:1> -> modificationEventKinds . single ( ) <EOL> else -> error ( "<STR_LIT>" ) <EOL> } <EOL> publishModificationEvent ( modificationEventKind , ktModule ) <EOL> }

/**
 * Publishes a modification event as defined in [KotlinTopics][org.jetbrains.kotlin.analysis.providers.topics.KotlinTopics] based on the
 * [ModificationEventDirectives.MODIFICATION_EVENT] directive present in the test module in a write action.
 *
 * Module-level modification events will be published for the [KtTestModule]'s [KtModule].
 *
 * The function expects exactly one `MODIFICATION_EVENT` directive to be present, unless [isOptional] is `true`.
 */


fun KtTestModule . publishWildcardModificationEventByDirectiveIfPresent ( modificationEventKind : ModificationEventKind )

{ <EOL> if ( ModificationEventDirectives . WILDCARD_MODIFICATION_EVENT !in testModule . directives ) { <EOL> return <EOL> } <EOL> publishModificationEvent ( modificationEventKind , ktModule ) <EOL> }

/**
 * If the given test module contains a [ModificationEventDirectives.WILDCARD_MODIFICATION_EVENT] directive, publishes a modification event
 * as defined in [KotlinTopics][org.jetbrains.kotlin.analysis.providers.topics.KotlinTopics] based on the given [modificationEventKind] in
 * a write action.
 *
 * Module-level modification events will be published for the [KtTestModule]'s [KtModule].
 */


fun KtTestModuleStructure . publishWildcardModificationEventsByDirective ( modificationEventKind : ModificationEventKind )

{ <EOL> if ( modificationEventKind . isModuleLevel ) { <EOL> mainModules . forEach { ktTestModule -> <EOL> ktTestModule . publishWildcardModificationEventByDirectiveIfPresent ( modificationEventKind ) <EOL> } <EOL> } else { <EOL> if ( ! testModuleStructure . allDirectives . contains ( ModificationEventDirectives . WILDCARD_MODIFICATION_EVENT ) ) { <EOL> return <EOL> } <EOL> publishGlobalModificationEvent ( modificationEventKind , project ) <EOL> } <EOL> }

/**
 * For each test module that contains a [ModificationEventDirectives.WILDCARD_MODIFICATION_EVENT] directive, publishes a modification event
 * as defined in [KotlinTopics][org.jetbrains.kotlin.analysis.providers.topics.KotlinTopics] based on the given [modificationEventKind] in
 * a write action.
 *
 * Global-level modification events will only be published *once*, regardless of how many `WILDCARD_MODIFICATION_EVENT` directives the test
 * modules contain, as long as at least one test module contains it (to support test cases which don't want to publish any modification
 * events).
 */


public fun NotebookHttpClient . request ( builder : HttpRequestBuilder = HttpRequestBuilder ( ) ) : NotebookHttpResponse

= NotebookHttpResponse ( runBlocking { ktorClient . request ( builder ) } )

/**
 * Executes an [HttpClient]'s request with the parameters specified using [builder].
 *
 * Learn more from [Making requests](https://ktor.io/docs/request.html).
 */


public inline fun NotebookHttpClient . request ( crossinline block : HttpRequestBuilder . ( ) -> Unit ) : NotebookHttpResponse

= <EOL> NotebookHttpResponse ( runBlocking { ktorClient . request ( block ) } )

/**
 * Executes an [HttpClient]'s request with the parameters specified in [block].
 *
 * Learn more from [Making requests](https://ktor.io/docs/request.html).
 */


public suspend inline fun NotebookHttpClient . request ( urlString : String , crossinline block : HttpRequestBuilder . ( ) -> Unit = { } ) : NotebookHttpResponse

= NotebookHttpResponse ( runBlocking { ktorClient . request ( urlString , block ) } )

/**
 * Executes an [HttpClient]'s request with the [urlString] and the parameters configured in [block].
 *
 * Learn more from [Making requests](https://ktor.io/docs/request.html).
 */


public suspend inline fun NotebookHttpClient . request ( url : Url , crossinline block : HttpRequestBuilder . ( ) -> Unit = { } ) : NotebookHttpResponse

= NotebookHttpResponse ( runBlocking { ktorClient . request ( url , block ) } )

/**
 * Executes an [HttpClient]'s request with the [url] and the parameters configured in [block].
 *
 * Learn more from [Making requests](https://ktor.io/docs/request.html).
 */


public fun NotebookHttpClient . get ( builder : HttpRequestBuilder ) : NotebookHttpResponse

= <EOL> NotebookHttpResponse ( runBlocking { ktorClient . get ( builder ) } )

/**
 * Executes an [HttpClient]'s GET request with the parameters configured in [builder].
 *
 * Learn more from [Making requests](https://ktor.io/docs/request.html).
 */


public fun NotebookHttpClient . post ( builder : HttpRequestBuilder ) : NotebookHttpResponse

= <EOL> NotebookHttpResponse ( runBlocking { ktorClient . post ( builder ) } )

/**
 * Executes an [HttpClient]'s POST request with the parameters configured in [builder].
 *
 * Learn more from [Making requests](https://ktor.io/docs/request.html).
 */


public fun NotebookHttpClient . put ( builder : HttpRequestBuilder ) : HttpResponse

= <EOL> runBlocking { ktorClient . put ( builder ) }

/**
 * Executes a [HttpClient] PUT request with the parameters configured in [builder].
 *
 * Learn more from [Making requests](https://ktor.io/docs/request.html).
 */


public fun NotebookHttpClient . delete ( builder : HttpRequestBuilder ) : NotebookHttpResponse

= <EOL> NotebookHttpResponse ( runBlocking { ktorClient . delete ( builder ) } )

/**
 * Executes a [HttpClient] DELETE request with the parameters configured in [builder].
 *
 * Learn more from [Making requests](https://ktor.io/docs/request.html).
 */


public fun NotebookHttpClient . options ( builder : HttpRequestBuilder ) : NotebookHttpResponse

= <EOL> NotebookHttpResponse ( runBlocking { ktorClient . options ( builder ) } )

/**
 * Executes a [HttpClient] OPTIONS request with the parameters configured in [builder].
 *
 * Learn more from [Making requests](https://ktor.io/docs/request.html).
 */


public fun NotebookHttpClient . patch ( builder : HttpRequestBuilder ) : NotebookHttpResponse

= <EOL> NotebookHttpResponse ( runBlocking { ktorClient . patch ( builder ) } )

/**
 * Executes a [HttpClient] PATCH request with the parameters configured in [builder].
 *
 * Learn more from [Making requests](https://ktor.io/docs/request.html).
 */


public fun NotebookHttpClient . head ( builder : HttpRequestBuilder ) : HttpResponse

= <EOL> runBlocking { ktorClient . head ( builder ) }

/**
 * Executes a [HttpClient] HEAD request with the parameters configured in [builder].
 *
 * Learn more from [Making requests](https://ktor.io/docs/request.html).
 */


public inline fun NotebookHttpClient . get ( crossinline block : HttpRequestBuilder . ( ) -> Unit ) : NotebookHttpResponse

= <EOL> NotebookHttpResponse ( runBlocking { ktorClient . get ( block ) } )

/**
 * Executes an [HttpClient]'s GET request with the parameters configured in [block].
 *
 * Learn more from [Making requests](https://ktor.io/docs/request.html).
 */


public inline fun NotebookHttpClient . post ( crossinline block : HttpRequestBuilder . ( ) -> Unit ) : NotebookHttpResponse

= <EOL> NotebookHttpResponse ( runBlocking { ktorClient . post ( block ) } )

/**
 * Executes an [HttpClient]'s POST request with the parameters configured in [block].
 *
 * Learn more from [Making requests](https://ktor.io/docs/request.html).
 */


public inline fun NotebookHttpClient . put ( crossinline block : HttpRequestBuilder . ( ) -> Unit ) : NotebookHttpResponse

= <EOL> NotebookHttpResponse ( runBlocking { ktorClient . put ( block ) } )

/**
 * Executes an [HttpClient]'s PUT request with the parameters configured in [block].
 *
 * Learn more from [Making requests](https://ktor.io/docs/request.html).
 */


public inline fun NotebookHttpClient . delete ( crossinline block : HttpRequestBuilder . ( ) -> Unit ) : NotebookHttpResponse

= <EOL> NotebookHttpResponse ( runBlocking { ktorClient . delete ( block ) } )

/**
 * Executes an [HttpClient]'s DELETE request with the parameters configured in [block].
 *
 * Learn more from [Making requests](https://ktor.io/docs/request.html).
 */


public inline fun NotebookHttpClient . options ( crossinline block : HttpRequestBuilder . ( ) -> Unit ) : NotebookHttpResponse

= <EOL> NotebookHttpResponse ( runBlocking { ktorClient . options ( block ) } )

/**
 * Executes an [HttpClient]'s OPTIONS request with the parameters configured in [block].
 *
 * Learn more from [Making requests](https://ktor.io/docs/request.html).
 */


public inline fun NotebookHttpClient . patch ( crossinline block : HttpRequestBuilder . ( ) -> Unit ) : NotebookHttpResponse

= <EOL> NotebookHttpResponse ( runBlocking { ktorClient . patch ( block ) } )

/**
 * Executes an [HttpClient]'s PATCH request with the parameters configured in [block].
 *
 * Learn more from [Making requests](https://ktor.io/docs/request.html).
 */


public inline fun NotebookHttpClient . head ( crossinline block : HttpRequestBuilder . ( ) -> Unit ) : NotebookHttpResponse

= <EOL> NotebookHttpResponse ( runBlocking { ktorClient . head ( block ) } )

/**
 * Executes an [HttpClient]'s HEAD request with the parameters configured in [block].
 *
 * Learn more from [Making requests](https://ktor.io/docs/request.html).
 */


public inline fun NotebookHttpClient . get ( urlString : String , crossinline block : HttpRequestBuilder . ( ) -> Unit = { } ) : NotebookHttpResponse

= NotebookHttpResponse ( runBlocking { ktorClient . get ( urlString , block ) } )

/**
 * Executes an [HttpClient]'s GET request with the specified [url] and
 * an optional [block] receiving an [HttpRequestBuilder] for configuring the request.
 *
 * Learn more from [Making requests](https://ktor.io/docs/request.html).
 */


public inline fun NotebookHttpClient . post ( urlString : String , crossinline block : HttpRequestBuilder . ( ) -> Unit = { } ) : NotebookHttpResponse

= NotebookHttpResponse ( runBlocking { ktorClient . post ( urlString , block ) } )

/**
 * Executes an [HttpClient]'s POST request with the specified [url] and
 * an optional [block] receiving an [HttpRequestBuilder] for configuring the request.
 *
 * Learn more from [Making requests](https://ktor.io/docs/request.html).
 */


public inline fun NotebookHttpClient . put ( urlString : String , crossinline block : HttpRequestBuilder . ( ) -> Unit = { } ) : NotebookHttpResponse

= NotebookHttpResponse ( runBlocking { ktorClient . put ( urlString , block ) } )

/**
 * Executes an [HttpClient]'s PUT request with the specified [url] and
 * an optional [block] receiving an [HttpRequestBuilder] for configuring the request.
 *
 * Learn more from [Making requests](https://ktor.io/docs/request.html).
 */


public inline fun NotebookHttpClient . delete ( urlString : String , crossinline block : HttpRequestBuilder . ( ) -> Unit = { } ) : NotebookHttpResponse

= NotebookHttpResponse ( runBlocking { ktorClient . delete ( urlString , block ) } )

/**
 * Executes an [HttpClient]'s DELETE request with the specified [url] and
 * an optional [block] receiving an [HttpRequestBuilder] for configuring the request.
 *
 * Learn more from [Making requests](https://ktor.io/docs/request.html).
 */


public inline fun NotebookHttpClient . options ( urlString : String , crossinline block : HttpRequestBuilder . ( ) -> Unit = { } ) : NotebookHttpResponse

= NotebookHttpResponse ( runBlocking { ktorClient . options ( urlString , block ) } )

/**
 * Executes an [HttpClient]'s OPTIONS request with the specified [url] and
 * an optional [block] receiving an [HttpRequestBuilder] for configuring the request.
 *
 * Learn more from [Making requests](https://ktor.io/docs/request.html).
 */


public suspend inline fun NotebookHttpClient . patch ( urlString : String , crossinline block : HttpRequestBuilder . ( ) -> Unit = { } ) : NotebookHttpResponse

= NotebookHttpResponse ( runBlocking { ktorClient . patch ( urlString , block ) } )

/**
 * Executes an [HttpClient]'s PATCH request with the specified [url] and
 * an optional [block] receiving an [HttpRequestBuilder] for configuring the request.
 *
 * Learn more from [Making requests](https://ktor.io/docs/request.html).
 */


public suspend inline fun NotebookHttpClient . head ( urlString : String , crossinline block : HttpRequestBuilder . ( ) -> Unit = { } ) : NotebookHttpResponse

= NotebookHttpResponse ( runBlocking { ktorClient . head ( urlString , block ) } )

/**
 * Executes an [HttpClient]'s HEAD request with the specified [url] and
 * an optional [block] receiving an [HttpRequestBuilder] for configuring the request.
 *
 * Learn more from [Making requests](https://ktor.io/docs/request.html).
 */


fun shouldBeSkipped ( declaration : IrDeclaration ) : Boolean

/**
 * Fast check to determine if the given [declaration] should be skipped from the partial linkage point of view.
 *
 * This check is typically used to avoid processing and patching declarations that came from stdlib or were generated
 * on the fly by the compiler itself and this way are automatically supposed to be correct.
 *
 * Note: There is no need to call [shouldBeSkipped] prior to [exploreClassifiersInInlineLazyIrFunction] and
 * [generateStubsAndPatchUsages] functions. These function do the same check internally in more optimal way.
 */


fun exploreClassifiers ( fakeOverrideBuilder : IrLinkerFakeOverrideProvider )

/**
 * For general use in IR linker.
 *
 * Note: Those classifiers that were detected as partially linked are excluded from the fake overrides generation
 * to avoid failing with `Symbol for <signature> is unbound` error or generating fake overrides with incorrect signatures.
 */


fun exploreClassifiersInInlineLazyIrFunction ( function : IrFunction )

/**
 * For local use only in inline lazy-IR functions.
 *
 * Such functions are fully deserialized when e.g. a cache is generated for a Kotlin/Native library given that the function itself
 * is from another library. The rest of IR from another library remains lazy meantime.
 */


fun generateStubsAndPatchUsages ( symbolTable : SymbolTable , roots : ( ) -> Sequence < IrModuleFragment > )

/**
 * Generate stubs for the remaining unbound symbols. Traverse the IR tree and patch every usage of any unbound symbol
 * to throw an appropriate IrLinkageError on access.
 */


fun collectAllStubbedSymbols ( ) : Set < IrSymbol >

/**
 * Collect all symbols which were stubbed
 */


fun createImmutableBlob ( value : IrConst < String > ) : LLVMValueRef

{ <EOL> val args = value . value . map { llvm . int8 ( it . code . toByte ( ) ) } <EOL> return createConstKotlinArray ( context . ir . symbols . immutableBlob . owner , args ) <EOL> }

/**
 * Creates static instance of `konan.ImmutableByteArray` with given values of elements.
 *
 * @param args data for constant creation.
 */


public inline fun < T > Flow < T > . filter ( crossinline predicate : suspend ( T ) -> Boolean ) : Flow < T >

= transform { value -> <EOL> if ( predicate ( value ) ) return@transform emit ( value ) <EOL> }

/**
 * Returns a flow containing only values of the original flow that match the given [predicate].
 */


public inline fun < T > Flow < T > . filterNot ( crossinline predicate : suspend ( T ) -> Boolean ) : Flow < T >

= transform { value -> <EOL> if ( ! predicate ( value ) ) return@transform emit ( value ) <EOL> }

/**
 * Returns a flow containing only values of the original flow that do not match the given [predicate].
 */


@ Suppress ( "<STR_LIT:UNCHECKED_CAST>" ) <EOL> public inline fun < reified R > Flow < * > . filterIsInstance ( ) : Flow < R >

= filter { it is R } as Flow < R >

/**
 * Returns a flow containing only values that are instances of specified type [R].
 */


public fun < R : Any > Flow < * > . filterIsInstance ( klass : KClass < R > ) : Flow < R >

= filter { klass . isInstance ( it ) } as Flow < R >

/**
 * Returns a flow containing only values that are instances of the given [klass].
 */


public fun < T : Any > Flow < T ? > . filterNotNull ( ) : Flow < T >

= transform < T ? , T > { value -> <EOL> if ( value != null ) return@transform emit ( value ) <EOL> }

/**
 * Returns a flow containing only values of the original flow that are not null.
 */


public inline fun < T , R > Flow < T > . map ( crossinline transform : suspend ( value : T ) -> R ) : Flow < R >

= transform { value -> <EOL> return@transform emit ( transform ( value ) ) <EOL> }

/**
 * Returns a flow containing the results of applying the given [transform] function to each value of the original flow.
 */


public inline fun < T , R : Any > Flow < T > . mapNotNull ( crossinline transform : suspend ( value : T ) -> R ? ) : Flow < R >

= transform { value -> <EOL> val transformed = transform ( value ) ? : return@transform <EOL> return@transform emit ( transformed ) <EOL> }

/**
 * Returns a flow that contains only non-null results of applying the given [transform] function to each value of the original flow.
 */


public fun < T > Flow < T > . withIndex ( ) : Flow < IndexedValue < T > >

= flow { <EOL> var index = <NUM_LIT:0> <EOL> collect { value -> <EOL> emit ( IndexedValue ( checkIndexOverflow ( index ++ ) , value ) ) <EOL> } <EOL> }

/**
 * Returns a flow that wraps each element into [IndexedValue], containing value and its index (starting from zero).
 */


public fun < T > Flow < T > . onEach ( action : suspend ( T ) -> Unit ) : Flow < T >

= transform { value -> <EOL> action ( value ) <EOL> return@transform emit ( value ) <EOL> }

/**
 * Returns a flow that invokes the given [action] **before** each value of the upstream flow is emitted downstream.
 */


public fun < T , R > Flow < T > . scan ( initial : R , @ BuilderInference operation : suspend ( accumulator : R , value : T ) -> R ) : Flow < R >

= runningFold ( initial , operation )

/**
 * Folds the given flow with [operation], emitting every intermediate result, including [initial] value.
 * Note that initial value should be immutable (or should not be mutated) as it is shared between different collectors.
 * For example:
 * ```
 * flowOf(1, 2, 3).scan(emptyList<Int>()) { acc, value -> acc + value }.toList()
 * ```
 * will produce `[[], [1], [1, 2], [1, 2, 3]]`.
 *
 * This function is an alias to [runningFold] operator.
 */


public fun < T , R > Flow < T > . runningFold ( initial : R , @ BuilderInference operation : suspend ( accumulator : R , value : T ) -> R ) : Flow < R >

= flow { <EOL> var accumulator : R = initial <EOL> emit ( accumulator ) <EOL> collect { value -> <EOL> accumulator = operation ( accumulator , value ) <EOL> emit ( accumulator ) <EOL> } <EOL> }

/**
 * Folds the given flow with [operation], emitting every intermediate result, including [initial] value.
 * Note that initial value should be immutable (or should not be mutated) as it is shared between different collectors.
 * For example:
 * ```
 * flowOf(1, 2, 3).runningFold(emptyList<Int>()) { acc, value -> acc + value }.toList()
 * ```
 * will produce `[[], [1], [1, 2], [1, 2, 3]]`.
 */


public fun < T > Flow < T > . runningReduce ( operation : suspend ( accumulator : T , value : T ) -> T ) : Flow < T >

= flow { <EOL> var accumulator : Any ? = NULL <EOL> collect { value -> <EOL> accumulator = if ( accumulator === NULL ) { <EOL> value <EOL> } else { <EOL> operation ( accumulator as T , value ) <EOL> } <EOL> emit ( accumulator as T ) <EOL> } <EOL> }

/**
 * Reduces the given flow with [operation], emitting every intermediate result, including initial value.
 * The first element is taken as initial value for operation accumulator.
 * This operator has a sibling with initial value -- [scan].
 *
 * For example:
 * ```
 * flowOf(1, 2, 3, 4).runningReduce { acc, value -> acc + value }.toList()
 * ```
 * will produce `[1, 3, 6, 10]`
 */


fun isClassInlineLike ( klass : IrClass ) : Boolean

= klass . isSingleFieldValueClass

/**
 * Should this class be treated as inline class?
 */


fun getInlineClassUnderlyingType ( irClass : IrClass ) : IrType

= <EOL> irClass . declarations . firstIsInstanceOrNull < IrConstructor > ( ) ? . takeIf { it . isPrimary } ? . valueParameters ? . get ( <NUM_LIT:0> ) ? . type <EOL> ? : error ( "<STR_LIT>" )

/**
 * Unlike [org.jetbrains.kotlin.ir.util.getInlineClassUnderlyingType], doesn't use [IrClass.inlineClassRepresentation] because
 * for some reason it can be called for classes which are not inline, e.g. `kotlin.Double`.
 */


open fun transformForeignAnnotationCall ( symbol : FirBasedSymbol < * > , annotationCall : FirAnnotationCall ) : FirAnnotationCall

{ <EOL> return annotationCall <EOL> }

/**
 * @param symbol an owner of [annotationCall]
 * @param annotationCall an annotation call which does not belong to any declarations on the stack
 *
 * @see FirAnnotationCall.containingDeclarationSymbol
 */


fun FirClassSymbol < * > . isSupertypeOf ( other : FirClassSymbol < * > , session : FirSession ) : Boolean

{ <EOL> fun FirClassSymbol < * > . isSupertypeOf ( other : FirClassSymbol < * > , exclude : MutableSet < FirClassSymbol < * > > ) : Boolean { <EOL> for ( it in other . resolvedSuperTypeRefs ) { <EOL> val candidate = it . toClassLikeSymbol ( session ) ? . fullyExpandedClass ( session ) ? : continue <EOL> if ( candidate in exclude ) { <EOL> continue <EOL> } <EOL> exclude . add ( candidate ) <EOL> if ( candidate == this ) { <EOL> return true <EOL> } <EOL> if ( this . isSupertypeOf ( candidate , exclude ) ) { <EOL> return true <EOL> } <EOL> } <EOL> return false <EOL> } <EOL> return isSupertypeOf ( other , mutableSetOf ( ) ) <EOL> }

/**
 * Returns true if this is a supertype of other.
 */


fun FirTypeRef . toRegularClassSymbol ( session : FirSession ) : FirRegularClassSymbol ?

{ <EOL> return coneType . toRegularClassSymbol ( session ) <EOL> }

/**
 * Returns the FirRegularClass associated with this
 * or null of something goes wrong.
 */


fun FirBasedSymbol < * > . getContainingClassSymbol ( session : FirSession ) : FirClassLikeSymbol < * > ?

= when ( this ) { <EOL> is FirCallableSymbol < * > -> containingClassLookupTag ( ) ? . toSymbol ( session ) <EOL> is FirClassLikeSymbol < * > -> getContainingClassLookupTag ( ) ? . toSymbol ( session ) <EOL> is FirAnonymousInitializerSymbol -> containingDeclarationSymbol as? FirClassLikeSymbol < * > <EOL> else -> null <EOL> }

/**
 * Returns the ClassLikeDeclaration where the Fir object has been defined
 * or null if no proper declaration has been found.
 */


fun FirCallableSymbol < * > . getContainingSymbol ( session : FirSession ) : FirBasedSymbol < * > ?

{ <EOL> return getContainingClassSymbol ( session ) <EOL> ? : session . firProvider . getFirCallableContainerFile ( this ) ? . symbol <EOL> }

/**
 * Returns the containing class or file if the callable is top-level.
 */


fun CheckerContext . findClosestClassOrObject ( ) : FirClass ?

{ <EOL> for ( it in containingDeclarations . asReversed ( ) ) { <EOL> if ( it is FirRegularClass || it is FirAnonymousObject ) { <EOL> @ Suppress ( "<STR_LIT>" ) <EOL> return it as FirClass <EOL> } <EOL> } <EOL> return null <EOL> }

/**
 * Returns the closest to the end of context.containingDeclarations
 * item like FirRegularClass or FirAnonymousObject
 * or null if no such item could be found.
 */


fun FirClass . modality ( ) : Modality ?

{ <EOL> return when ( this ) { <EOL> is FirRegularClass -> modality <EOL> else -> Modality . FINAL <EOL> } <EOL> }

/**
 * Returns the modality of the class
 */


fun FirMemberDeclaration . redundantModalities ( context : CheckerContext ) : Set < Modality >

{ <EOL> if ( this is FirRegularClass ) { <EOL> return when ( classKind ) { <EOL> ClassKind . INTERFACE -> setOf ( Modality . ABSTRACT , Modality . OPEN ) <EOL> else -> setOf ( Modality . FINAL ) <EOL> } <EOL> } <EOL> val containingClass = context . findClosestClassOrObject ( ) ? : return setOf ( Modality . FINAL ) <EOL> return when { <EOL> isOverride && ! containingClass . isFinal -> setOf ( Modality . OPEN ) <EOL> containingClass . isInterface -> when { <EOL> hasBody ( ) -> setOf ( Modality . OPEN ) <EOL> else -> setOf ( Modality . ABSTRACT , Modality . OPEN ) <EOL> } <EOL> else -> setOf ( Modality . FINAL ) <EOL> } <EOL> }

/**
 * Returns a set of [Modality] modifiers which are redundant for the given [FirMemberDeclaration]. If a modality modifier is redundant, the
 * declaration's modality won't be changed by the modifier.
 */


fun FirClass . findNonInterfaceSupertype ( context : CheckerContext ) : FirTypeRef ?

{ <EOL> for ( superTypeRef in superTypeRefs ) { <EOL> val lookupTag = ( superTypeRef . coneType as? ConeClassLikeType ) ? . lookupTag ? : continue <EOL> val symbol = lookupTag . toSymbol ( context . session ) as? FirClassSymbol < * > ? : continue <EOL> if ( symbol . classKind != ClassKind . INTERFACE ) { <EOL> return superTypeRef <EOL> } <EOL> } <EOL> return null <EOL> }

/**
 * Finds any non-interface supertype and returns it
 * or null if couldn't find any.
 */


fun FirCallableSymbol < * > . getImplementationStatus ( sessionHolder : SessionHolder , parentClassSymbol : FirClassSymbol < * > ) : ImplementationStatus

{ <EOL> val containingClassSymbol = getContainingClassSymbol ( sessionHolder . session ) <EOL> val symbol = this <EOL> if ( this . multipleDelegatesWithTheSameSignature == true && containingClassSymbol == parentClassSymbol ) { <EOL> return ImplementationStatus . AMBIGUOUSLY_INHERITED <EOL> } <EOL> if ( symbol is FirIntersectionCallableSymbol ) { <EOL> val dispatchReceiverScope = symbol . dispatchReceiverScope ( sessionHolder . session , sessionHolder . scopeSession ) <EOL> val memberWithBaseScope = MemberWithBaseScope ( symbol , dispatchReceiverScope ) <EOL> val nonSubsumed = memberWithBaseScope . getNonSubsumedOverriddenSymbols ( ) <EOL> if ( containingClassSymbol === parentClassSymbol && ! memberWithBaseScope . isTrivialIntersection ( ) && nonSubsumed . subjectToManyNotImplemented ( sessionHolder ) ) { <EOL> return ImplementationStatus . AMBIGUOUSLY_INHERITED <EOL> } <EOL> var hasAbstractFromClass = false <EOL> var hasInterfaceDelegation = false <EOL> var hasAbstractVar = false <EOL> var hasImplementation = false <EOL> var hasImplementationVar = false <EOL> for ( intersection in nonSubsumed ) { <EOL> val unwrapped = intersection . unwrapFakeOverrides ( ) <EOL> val isVar = unwrapped is FirPropertySymbol && unwrapped . isVar <EOL> val isFromClass = unwrapped . getContainingClassSymbol ( sessionHolder . session ) ? . classKind == ClassKind . CLASS <EOL> if ( intersection . isAbstract ) { <EOL> if ( isFromClass ) { <EOL> hasAbstractFromClass = true <EOL> } <EOL> if ( isVar ) { <EOL> hasAbstractVar = true <EOL> } <EOL> } else { <EOL> if ( intersection . origin == FirDeclarationOrigin . Delegated ) { <EOL> hasInterfaceDelegation = true <EOL> } <EOL> if ( isFromClass ) { <EOL> hasImplementation = true <EOL> if ( isVar ) { <EOL> hasImplementationVar = true <EOL> } <EOL> } <EOL> } <EOL> } <EOL> if ( hasAbstractFromClass && ! hasInterfaceDelegation ) { <EOL> return ImplementationStatus . NOT_IMPLEMENTED <EOL> } <EOL> if ( hasAbstractVar && hasImplementation && ! hasImplementationVar ) { <EOL> return ImplementationStatus . VAR_IMPLEMENTED_BY_VAL <EOL> } <EOL> } <EOL> when ( symbol ) { <EOL> is FirNamedFunctionSymbol -> { <EOL> if ( parentClassSymbol is FirRegularClassSymbol && parentClassSymbol . isData && symbol . matchesDataClassSyntheticMemberSignatures ) { <EOL> return ImplementationStatus . INHERITED_OR_SYNTHESIZED <EOL> } <EOL> } <EOL> is FirFieldSymbol -> if ( symbol . isJavaOrEnhancement ) return ImplementationStatus . CANNOT_BE_IMPLEMENTED <EOL> } <EOL> return when { <EOL> isFinal -> ImplementationStatus . CANNOT_BE_IMPLEMENTED <EOL> containingClassSymbol === parentClassSymbol && ( origin == FirDeclarationOrigin . Source || origin == FirDeclarationOrigin . Precompiled ) -> <EOL> ImplementationStatus . ALREADY_IMPLEMENTED <EOL> isAbstract -> ImplementationStatus . NOT_IMPLEMENTED <EOL> else -> ImplementationStatus . INHERITED_OR_SYNTHESIZED <EOL> } <EOL> }

/**
 * Get the [ImplementationStatus] for this member.
 *
 * @param parentClassSymbol the contextual class for this query.
 */


public fun IntRange . toSlice ( ) : Slice

= Slice ( this . first , this . last , <NUM_LIT:1> )

/**
 * Returns Slice containing the first, the last with a step of 1.
 */


public fun ClosedRange < Int > . toSlice ( ) : Slice

= <EOL> when ( this ) { <EOL> is Slice -> this <EOL> is IntRange -> this . toSlice ( ) <EOL> else -> throw IllegalStateException ( "<STR_LIT>" ) <EOL> }


public operator fun SliceStartStub . rangeTo ( that : Int ) : Slice

= Slice ( - <NUM_LIT:1> , that , <NUM_LIT:1> )

/**
 * Returns Slice with stub of the start.
 */


public operator fun Int . rangeTo ( that : SliceEndStub ) : Slice

= Slice ( this , - <NUM_LIT:1> , <NUM_LIT:1> )

/**
 * Returns Slice with stub of the stop.
 */


public operator fun Int . rangeTo ( that : RInt ) : Slice

= Slice ( this , that . data , <NUM_LIT:1> )

/**
 * Returns Slice where stop from RInt.
 */


public operator fun IntRange . rangeTo ( step : Int ) : Slice

{ <EOL> return Slice ( this . first , this . last , step ) <EOL> }

/**
 * Returns a slice at a specified [step].
 */


{ <EOL> _builder . clearBuildName ( ) <EOL> }

/**
 *

 * Renamed from 'build_id' to 'build_name' in 1.9.20
 *

 *
 * optional string build_name = 1;
 */


{ <EOL> return _builder . hasBuildName ( ) <EOL> }

/**
 *

 * Renamed from 'build_id' to 'build_name' in 1.9.20
 *

 *
 * optional string build_name = 1;
 * @return Whether the buildName field is set.
 */


{ <EOL> _builder . clearBuildPath ( ) <EOL> }

/**
 *

 * Added in 1.9.20
 *

 *
 * optional string build_path = 4;
 */


{ <EOL> return _builder . hasBuildPath ( ) <EOL> }

/**
 *

 * Added in 1.9.20
 *

 *
 * optional string build_path = 4;
 * @return Whether the buildPath field is set.
 */


{ <EOL> _builder . clearProjectPath ( ) <EOL> }

/**
 * optional string project_path = 2;
 */


fun hasProjectPath ( ) : kotlin . Boolean

{ <EOL> return _builder . hasProjectPath ( ) <EOL> }

/**
 * optional string project_path = 2;
 * @return Whether the projectPath field is set.
 */


{ <EOL> _builder . clearProjectName ( ) <EOL> }

/**
 * optional string project_name = 3;
 */


fun hasProjectName ( ) : kotlin . Boolean

{ <EOL> return _builder . hasProjectName ( ) <EOL> }

/**
 * optional string project_name = 3;
 * @return Whether the projectName field is set.
 */


public fun mnist ( cacheDirectory : File = File ( "<STR_LIT>" ) ) : Pair < OnHeapDataset , OnHeapDataset >

{ <EOL> return createDataset ( cacheDirectory , TRAIN_IMAGES_ARCHIVE , TRAIN_LABELS_ARCHIVE , TEST_IMAGES_ARCHIVE , TEST_LABELS_ARCHIVE ) <EOL> }

/**
 * Loads the [MNIST dataset](http://yann.lecun.com/exdb/mnist/).
 * This is a dataset of 60,000 28x28 grayscale images of the 10 digits,
 * along with a test set of 10,000 images.
 * More info can be found at the [MNIST homepage](http://yann.lecun.com/exdb/mnist/).
 *
 * NOTE: Yann LeCun and Corinna Cortes hold the copyright of MNIST dataset,
 * which is a derivative work from original NIST datasets.
 * MNIST dataset is made available under the terms of the
 * [Creative Commons Attribution-Share Alike 3.0 license.](https://creativecommons.org/licenses/by-sa/3.0/)
 *
 * @param [cacheDirectory] Cache directory to cached models and datasets.
 *
 * @return Train and test datasets. Each dataset includes X and Y data. X data are uint8 arrays of grayscale image data with shapes
 * (num_samples, 28, 28). Y data uint8 arrays of digit labels (integers in range 0-9) with shapes (num_samples,).
 */


public fun fashionMnist ( cacheDirectory : File = File ( "<STR_LIT>" ) ) : Pair < OnHeapDataset , OnHeapDataset >

{ <EOL> return createDataset ( cacheDirectory , FASHION_TRAIN_IMAGES_ARCHIVE , FASHION_TRAIN_LABELS_ARCHIVE , FASHION_TEST_IMAGES_ARCHIVE , FASHION_TEST_LABELS_ARCHIVE ) <EOL> }

/**
 * Loads the Fashion-MNIST dataset.
 *
 * This is a dataset of 60,000 28x28 grayscale images of 10 fashion categories,
 * along with a test set of 10,000 images. This dataset can be used as
 * a drop-in replacement for MNIST. The class labels are:
 *
 * | Label | Description |
 * |:-----:|-------------|
 * | 0 | T-shirt/top |
 * | 1 | Trousers |
 * | 2 | Pullover |
 * | 3 | Dress |
 * | 4 | Coat |
 * | 5 | Sandals |
 * | 6 | Shirt |
 * | 7 | Sneakers |
 * | 8 | Bag |
 * | 9 | Ankle boots |
 *
 * NOTE: The copyright for Fashion-MNIST is held by Zalando SE.
 * Fashion-MNIST is licensed under the [MIT license](https://github.com/zalandoresearch/fashion-mnist/blob/master/LICENSE).
 *
 * @param [cacheDirectory] Cache directory to cached models and datasets.
 *
 * @return Train and test datasets. Each dataset includes X and Y data. X data are uint8 arrays of grayscale image data with shapes
 * (num_samples, 28, 28). Y data uint8 arrays of digit labels (integers in range 0-9) with shapes (num_samples,).
 */


public fun mnist3D ( cacheDirectory : File = File ( "<STR_LIT>" ) ) : Pair < OnHeapDataset , OnHeapDataset >

{ <EOL> cacheDirectory . existsOrMkdirs ( ) <EOL> return HdfFile ( loadFile ( cacheDirectory , MNIST_3D_DATASET ) ) . use { <EOL> val ( trainData , trainLabels ) = it . extractMnist3DDataset ( "<STR_LIT>" ) <EOL> val ( testData , testLabels ) = it . extractMnist3DDataset ( "<STR_LIT:test>" ) <EOL> val shape = TensorShape ( MNIST_3D_FRAME_SIZE , MNIST_3D_FRAME_SIZE , MNIST_3D_FRAME_SIZE ) <EOL> Pair ( OnHeapDataset . create ( trainData , trainLabels , shape ) , OnHeapDataset . create ( testData , testLabels , shape ) ) <EOL> } <EOL> }

/**
 * Loads the [MNIST 3D dataset](https://www.kaggle.com/daavoo/3d-mnist).
 * This is a dataset of 10,000 16x16x16 grayscale 3D images of the 10 digits,
 * along with a test set of 2,000 3D images.
 *
 * NOTE: Yann LeCun and Corinna Cortes hold the copyright of MNIST dataset,
 * which is a derivative work from original NIST datasets.
 * MNIST dataset is made available under the terms of the
 * [Creative Commons Attribution-Share Alike 3.0 license.](https://creativecommons.org/licenses/by-sa/3.0/)
 * MNIST 3D dataset was created by [daavoo](https://github.com/daavoo) as a transformation of
 * original MNIST dataset to 3D images to provide a simple example of working with 3D images.
 *
 * @param [cacheDirectory] Cache directory to cached models and datasets.
 *
 * @return Train and test datasets. Each dataset includes X and Y data.
 * X data are float arrays of grayscale image data with shapes (num_samples, 16, 16, 16).
 * Y data float arrays of digit labels (integers in range 0-9) with shapes (num_samples,).
 */


private fun extractMnist3DData ( dataset : Dataset )

= <EOL> ( dataset . data as Array < * > ) <EOL> . map { ( it as DoubleArray ) . map ( Double :: toFloat ) . toFloatArray ( ) } <EOL> . toTypedArray ( )

/** Extract mnist3d X data from HD5 file [dataset] */


private fun extractMnist3DLabels ( dataset : Dataset )

= <EOL> ( dataset . data as LongArray ) . map ( Long :: toFloat ) . toFloatArray ( )

/** Extract mnist3d Y labels from HD5 file [dataset] */


private fun HdfFile . extractMnist3DDataset ( label : String ) : Pair < Array < FloatArray > , FloatArray >

= <EOL> Pair ( extractMnist3DData ( getDatasetByPath ( "<STR_LIT>" ) ) , extractMnist3DLabels ( getDatasetByPath ( "<STR_LIT>" ) ) )

/** Extract mnist3d data and labels from HD5 file under specified [label] */


public fun freeSpokenDigits ( cacheDirectory : File = File ( "<STR_LIT>" ) , maxTestIndex : Int = <NUM_LIT:5> ) : Pair < OnHeapDataset , OnHeapDataset >

{ <EOL> cacheDirectory . existsOrMkdirs ( ) <EOL> val path = freeSpokenDigitDatasetPath ( cacheDirectory ) <EOL> val dataset = File ( path ) <EOL> . listFiles ( ) ? . flatMap ( :: extractWavFileSamples ) <EOL> ? : throw IllegalStateException ( "<STR_LIT>" ) <EOL> val maxDataSize = dataset . maxOfOrNull { it . first . size } <EOL> ? : throw IllegalStateException ( "<STR_LIT>" ) <EOL> check ( maxDataSize <= FSDD_SOUND_DATA_SIZE ) { <EOL> "<STR_LIT>" <EOL> } <EOL> val data = dataset . map ( :: extractPaddedDataWithIndex ) <EOL> val labels = dataset . map ( :: extractLabelWithIndex ) <EOL> val ( trainData , testData ) = data . splitToTrainAndTestByIndex ( maxTestIndex ) <EOL> val ( trainLabels , testLabels ) = labels . splitToTrainAndTestByIndex ( maxTestIndex ) <EOL> val shape = TensorShape ( FSDD_SOUND_DATA_SIZE , <NUM_LIT:1> ) <EOL> return Pair ( OnHeapDataset . create ( trainData , trainLabels . toFloatArray ( ) , shape ) , OnHeapDataset . create ( testData , testLabels . toFloatArray ( ) , shape ) ) <EOL> }

/**
 * Loads the [Free Spoken Digits Dataset](https://github.com/Jakobovski/free-spoken-digit-dataset).
 * This is a dataset of wav sound files of the 10 digits spoken by different people many times each.
 * The test set officially consists of the first 10% of the recordings. Recordings numbered 0-4 (inclusive)
 * are in the test, and 5-49 are in the training set.
 *
 * As the input data files have different number of channels of data, we split every input file into separate samples
 * that are threatened as separate samples with the same label.
 *
 * Free Spoken Digits Dataset is made available under the terms of the
 * [Creative Commons Attribution-ShareAlike 4.0 International.](https://creativecommons.org/licenses/by-sa/4.0/)
 *
 * @param [cacheDirectory] Cache directory to cached models and datasets.
 * @param [maxTestIndex] Index of max sample to be selected to test part of data.
 *
 * @return Train and test datasets. Each dataset includes X and Y data. X data are float arrays of sound data with
 * shapes (num_samples, FSDD_SOUND_DATA_SIZE)
 * where FSDD_SOUND_DATA_SIZE is at least as long as the longest input sequence and all
 * sequences are padded with zeros to have equal length. Y data float arrays of digit labels (integers in range 0-9)
 * with shapes (num_samples,).
 */


private fun extractWavFileSamples ( file : File ) : List < Triple < FloatArray , Float , Int > >

= <EOL> WavFile ( file ) . use { <EOL> val data = it . readRemainingFrames ( ) <EOL> val parts = file . name . split ( "<STR_LIT:_>" ) <EOL> val label = parts [ <NUM_LIT:0> ] . toFloat ( ) <EOL> val index = parts [ <NUM_LIT:2> ] . split ( "<STR_LIT:.>" ) [ <NUM_LIT:0> ] . toInt ( ) <EOL> data . map { channel -> Triple ( channel , label , index ) } <EOL> }

/**
 * Extract wav file samples from a given file and return a list of data from all its
 * channels as a triple of (channel_data, label, sample_index).
 *
 * @param [file] to read from the sound data.
 * @return list of triples (channel_data, label, sample_index) from all channels from file.
 */


public fun cifar10Paths ( cacheDirectory : File = File ( "<STR_LIT>" ) ) : Pair < String , String >

{ <EOL> cacheDirectory . existsOrMkdirs ( ) <EOL> val pathToLabel = loadFile ( cacheDirectory , CIFAR_10_LABELS_ARCHIVE ) . absolutePath <EOL> val datasetDirectory = File ( cacheDirectory . absolutePath + "<STR_LIT>" ) <EOL> val toFolder = datasetDirectory . toPath ( ) <EOL> val imageDataDirectory = File ( cacheDirectory . absolutePath + "<STR_LIT>" ) <EOL> if ( ! imageDataDirectory . exists ( ) ) { <EOL> Files . createDirectories ( imageDataDirectory . toPath ( ) ) <EOL> val pathToImageArchive = loadFile ( cacheDirectory , CIFAR_10_IMAGES_ARCHIVE ) <EOL> extractFromZipArchiveToFolder ( pathToImageArchive . toPath ( ) , toFolder ) <EOL> val deleted = pathToImageArchive . delete ( ) <EOL> if ( ! deleted ) <EOL> throw Exception ( "<STR_LIT>" ) <EOL> } <EOL> return Pair ( imageDataDirectory . toPath ( ) . toAbsolutePath ( ) . toString ( ) , pathToLabel ) <EOL> }

/** Returns paths to images and its labels for the Cifar'10 dataset. */


public fun dogsCatsDatasetPath ( cacheDirectory : File = File ( "<STR_LIT>" ) ) : String

= <EOL> unzipDatasetPath ( cacheDirectory , loadFile ( cacheDirectory , DOGS_CATS_IMAGES_ARCHIVE ) , "<STR_LIT>" )

/** Returns path to images of the Dogs-vs-Cats dataset. */


public fun dogsCatsSmallDatasetPath ( cacheDirectory : File = File ( "<STR_LIT>" ) ) : String

= <EOL> unzipDatasetPath ( cacheDirectory , loadFile ( cacheDirectory , DOGS_CATS_SMALL_IMAGES_ARCHIVE ) , "<STR_LIT>" )

/** Returns path to images of the subset of the Dogs-vs-Cats dataset. */


public fun freeSpokenDigitDatasetPath ( cacheDirectory : File = File ( "<STR_LIT>" ) ) : String

= <EOL> unzipDatasetPath ( cacheDirectory , loadFile ( cacheDirectory , FSDD_SOUNDS_ARCHIVE , downloadURLFromRelativePath = { FSS_SOUNDS_SOURCE } ) , "<STR_LIT>" ) . run { <EOL> "<STR_LIT>" <EOL> }

/** Returns path to sound data files from Free Spoken Digits Dataset. */


private fun unzipDatasetPath ( cacheDirectory : File , archive : File , dirRelativePath : String ) : String

{ <EOL> cacheDirectory . existsOrMkdirs ( ) <EOL> val dataDirectory = File ( cacheDirectory . absolutePath + dirRelativePath ) <EOL> val toFolder = dataDirectory . toPath ( ) <EOL> if ( ! dataDirectory . exists ( ) ) Files . createDirectories ( dataDirectory . toPath ( ) ) <EOL> if ( archive . exists ( ) ) { <EOL> extractFromZipArchiveToFolder ( archive . toPath ( ) , toFolder ) <EOL> val deleted = archive . delete ( ) <EOL> if ( ! deleted ) { <EOL> throw Exception ( "<STR_LIT>" ) <EOL> } <EOL> } else { <EOL> throw Exception ( "<STR_LIT>" ) <EOL> } <EOL> return toFolder . toAbsolutePath ( ) . toString ( ) <EOL> }

/**
 * Download the compressed dataset from an external source, decompress the file and remove the downloaded file
 * but leave the decompressed data from dataset.
 *
 * @param [cacheDirectory] The directory where the downloaded files are stored.
 * @param [archive] Archive file.
 * @param [dirRelativePath] The relative path where to store the downloaded archive temporarily and decompress its data.
 * @return The absolute path string to directory where dataset is decompressed.
 */


private fun loadFile ( cacheDirectory : File , relativePathToFile : String , downloadURLFromRelativePath : ( String ) -> String = { "<STR_LIT>" } , loadingMode : LoadingMode = LoadingMode . SKIP_LOADING_IF_EXISTS ) : File

{ <EOL> val fileName = cacheDirectory . absolutePath + "<STR_LIT:/>" + relativePathToFile <EOL> val file = File ( fileName ) <EOL> file . parentFile . mkdirs ( ) <EOL> if ( ! file . exists ( ) || loadingMode == LoadingMode . OVERRIDE_IF_EXISTS ) { <EOL> val urlString = downloadURLFromRelativePath ( relativePathToFile ) <EOL> val inputStream = URL ( urlString ) . openStream ( ) <EOL> Files . copy ( inputStream , Paths . get ( fileName ) , StandardCopyOption . REPLACE_EXISTING ) <EOL> } <EOL> return file <EOL> }

/**
 * Downloads a file from a URL if it not already in the cache.
 *
 * By default, the download location
 * is defined as the concatenation of [AWS_S3_URL] and [relativePathToFile] but can be defined
 * as an arbitrary file location to download file from *
 *
 * @param [cacheDirectory] where the downloaded file is stored
 * @param [relativePathToFile] where the downloaded file is stored in [cacheDirectory] and which can
 * define the location of file to be downloaded
 * @param [downloadURLFromRelativePath] can produce the download URL of the file using.
 * Defaults to [AWS_S3_URL]/[relativePathToFile].
 * @param [loadingMode] of the file to be loaded. Defaults to [LoadingMode.SKIP_LOADING_IF_EXISTS]
 * @return downloaded [File] on a local file system.
 */


@ Throws ( IOException :: class ) <EOL> internal fun extractFromZipArchiveToFolder ( zipArchivePath : Path , toFolder : Path , bufferSize : Int = <NUM_LIT> )

{ <EOL> val zipFile = ZipFile ( zipArchivePath . toFile ( ) ) <EOL> val entries = zipFile . entries ( ) <EOL> while ( entries . hasMoreElements ( ) ) { <EOL> val entry = entries . nextElement ( ) as ZipEntry <EOL> var currentEntry = entry . name <EOL> currentEntry = currentEntry . replace ( '<CHAR_LIT:\\>' , '<CHAR_LIT:/>' ) <EOL> val destFile = File ( toFolder . toFile ( ) , currentEntry ) <EOL> val destinationParent = destFile . parentFile <EOL> destinationParent . mkdirs ( ) <EOL> if ( ! entry . isDirectory && ! destFile . exists ( ) ) { <EOL> val inputStream = BufferedInputStream ( zipFile . getInputStream ( entry ) ) <EOL> var currentByte : Int <EOL> val data = ByteArray ( bufferSize ) <EOL> val fos = FileOutputStream ( destFile ) <EOL> val dest = BufferedOutputStream ( fos , bufferSize ) <EOL> while ( inputStream . read ( data , <NUM_LIT:0> , bufferSize ) . also { currentByte = it } != - <NUM_LIT:1> ) { <EOL> dest . write ( data , <NUM_LIT:0> , currentByte ) <EOL> } <EOL> dest . flush ( ) <EOL> dest . close ( ) <EOL> inputStream . close ( ) <EOL> } <EOL> } <EOL> zipFile . close ( ) <EOL> }

/** Creates file structure archived in zip file with all directories and subdirectories. */


fun FirResolvePhase . isItAllowedToCallLazyResolveTo ( requestedPhase : FirResolvePhase ) : Boolean

= when { <EOL> this > requestedPhase -> true <EOL> this == requestedPhase -> isItAllowedToCallLazyResolveToTheSamePhase <EOL> else -> false <EOL> }

/**
 * See [FirResolvePhase] KDoc for more details about resolution contacts.
 *
 * @param this The current phase
 * @param requestedPhase The requested phase
 *
 * @see FirResolvePhase
 * @see org.jetbrains.kotlin.fir.symbols.FirLazyDeclarationResolver
 * @see org.jetbrains.kotlin.fir.symbols.lazyResolveToPhase
 * @see isItAllowedToCallLazyResolveToTheSamePhase
 */