@ SinceKotlin ( "<STR_LIT:1.2>" ) <EOL> @ kotlin . internal . InlineOnly <EOL> public actual inline fun Float . toRawBits ( ) : Int

= java . lang . Float . floatToRawIntBits ( this )

/**
 * Returns a bit representation of the specified floating-point value as [Int]
 * according to the IEEE 754 floating-point "single format" bit layout,
 * preserving `NaN` values exact layout.
 */


@ SinceKotlin ( "<STR_LIT:1.2>" ) <EOL> @ kotlin . internal . InlineOnly <EOL> public actual inline fun Float . Companion . fromBits ( bits : Int ) : Float

= java . lang . Float . intBitsToFloat ( bits )

/**
 * Returns the [Float] value corresponding to a given bit representation.
 */


@ SinceKotlin ( "<STR_LIT:1.4>" ) <EOL> @ kotlin . internal . InlineOnly <EOL> public actual inline fun Int . countOneBits ( ) : Int

= Integer . bitCount ( this )

/**
 * Counts the number of set bits in the binary representation of this [Int] number.
 */


@ SinceKotlin ( "<STR_LIT:1.4>" ) <EOL> @ kotlin . internal . InlineOnly <EOL> public actual inline fun Int . countLeadingZeroBits ( ) : Int

= Integer . numberOfLeadingZeros ( this )

/**
 * Counts the number of consecutive most significant bits that are zero in the binary representation of this [Int] number.
 */


@ SinceKotlin ( "<STR_LIT:1.4>" ) <EOL> @ kotlin . internal . InlineOnly <EOL> public actual inline fun Int . countTrailingZeroBits ( ) : Int

= Integer . numberOfTrailingZeros ( this )

/**
 * Counts the number of consecutive least significant bits that are zero in the binary representation of this [Int] number.
 */


@ SinceKotlin ( "<STR_LIT:1.4>" ) <EOL> @ kotlin . internal . InlineOnly <EOL> public actual inline fun Int . takeHighestOneBit ( ) : Int

= Integer . highestOneBit ( this )

/**
 * Returns a number having a single bit set in the position of the most significant set bit of this [Int] number,
 * or zero, if this number is zero.
 */


@ SinceKotlin ( "<STR_LIT:1.4>" ) <EOL> @ kotlin . internal . InlineOnly <EOL> public actual inline fun Int . takeLowestOneBit ( ) : Int

= Integer . lowestOneBit ( this )

/**
 * Returns a number having a single bit set in the position of the least significant set bit of this [Int] number,
 * or zero, if this number is zero.
 */


@ SinceKotlin ( "<STR_LIT:1.6>" ) <EOL> @ WasExperimental ( ExperimentalStdlibApi :: class ) <EOL> @ kotlin . internal . InlineOnly <EOL> public actual inline fun Int . rotateLeft ( bitCount : Int ) : Int

= Integer . rotateLeft ( this , bitCount )

/**
 * Rotates the binary representation of this [Int] number left by the specified [bitCount] number of bits.
 * The most significant bits pushed out from the left side reenter the number as the least significant bits on the right side.
 *
 * Rotating the number left by a negative bit count is the same as rotating it right by the negated bit count:
 * `number.rotateLeft(-n) == number.rotateRight(n)`
 *
 * Rotating by a multiple of [Int.SIZE_BITS] (32) returns the same number, or more generally
 * `number.rotateLeft(n) == number.rotateLeft(n % 32)`
 */


@ SinceKotlin ( "<STR_LIT:1.6>" ) <EOL> @ WasExperimental ( ExperimentalStdlibApi :: class ) <EOL> @ kotlin . internal . InlineOnly <EOL> public actual inline fun Int . rotateRight ( bitCount : Int ) : Int

= Integer . rotateRight ( this , bitCount )

/**
 * Rotates the binary representation of this [Int] number right by the specified [bitCount] number of bits.
 * The least significant bits pushed out from the right side reenter the number as the most significant bits on the left side.
 *
 * Rotating the number right by a negative bit count is the same as rotating it left by the negated bit count:
 * `number.rotateRight(-n) == number.rotateLeft(n)`
 *
 * Rotating by a multiple of [Int.SIZE_BITS] (32) returns the same number, or more generally
 * `number.rotateRight(n) == number.rotateRight(n % 32)`
 */


@ SinceKotlin ( "<STR_LIT:1.4>" ) <EOL> @ kotlin . internal . InlineOnly <EOL> public actual inline fun Long . countOneBits ( ) : Int

= java . lang . Long . bitCount ( this )

/**
 * Counts the number of set bits in the binary representation of this [Long] number.
 */


@ SinceKotlin ( "<STR_LIT:1.4>" ) <EOL> @ kotlin . internal . InlineOnly <EOL> public actual inline fun Long . countLeadingZeroBits ( ) : Int

= java . lang . Long . numberOfLeadingZeros ( this )

/**
 * Counts the number of consecutive most significant bits that are zero in the binary representation of this [Long] number.
 */


@ SinceKotlin ( "<STR_LIT:1.4>" ) <EOL> @ kotlin . internal . InlineOnly <EOL> public actual inline fun Long . countTrailingZeroBits ( ) : Int

= java . lang . Long . numberOfTrailingZeros ( this )

/**
 * Counts the number of consecutive least significant bits that are zero in the binary representation of this [Long] number.
 */


@ SinceKotlin ( "<STR_LIT:1.4>" ) <EOL> @ kotlin . internal . InlineOnly <EOL> public actual inline fun Long . takeHighestOneBit ( ) : Long

= java . lang . Long . highestOneBit ( this )

/**
 * Returns a number having a single bit set in the position of the most significant set bit of this [Long] number,
 * or zero, if this number is zero.
 */


@ SinceKotlin ( "<STR_LIT:1.4>" ) <EOL> @ kotlin . internal . InlineOnly <EOL> public actual inline fun Long . takeLowestOneBit ( ) : Long

= java . lang . Long . lowestOneBit ( this )

/**
 * Returns a number having a single bit set in the position of the least significant set bit of this [Long] number,
 * or zero, if this number is zero.
 */


@ SinceKotlin ( "<STR_LIT:1.6>" ) <EOL> @ WasExperimental ( ExperimentalStdlibApi :: class ) <EOL> @ kotlin . internal . InlineOnly <EOL> public actual inline fun Long . rotateLeft ( bitCount : Int ) : Long

= java . lang . Long . rotateLeft ( this , bitCount )

/**
 * Rotates the binary representation of this [Long] number left by the specified [bitCount] number of bits.
 * The most significant bits pushed out from the left side reenter the number as the least significant bits on the right side.
 *
 * Rotating the number left by a negative bit count is the same as rotating it right by the negated bit count:
 * `number.rotateLeft(-n) == number.rotateRight(n)`
 *
 * Rotating by a multiple of [Long.SIZE_BITS] (64) returns the same number, or more generally
 * `number.rotateLeft(n) == number.rotateLeft(n % 64)`
 */


@ SinceKotlin ( "<STR_LIT:1.6>" ) <EOL> @ WasExperimental ( ExperimentalStdlibApi :: class ) <EOL> @ kotlin . internal . InlineOnly <EOL> public actual inline fun Long . rotateRight ( bitCount : Int ) : Long

= java . lang . Long . rotateRight ( this , bitCount )

/**
 * Rotates the binary representation of this [Long] number right by the specified [bitCount] number of bits.
 * The least significant bits pushed out from the right side reenter the number as the most significant bits on the left side.
 *
 * Rotating the number right by a negative bit count is the same as rotating it left by the negated bit count:
 * `number.rotateRight(-n) == number.rotateLeft(n)`
 *
 * Rotating by a multiple of [Long.SIZE_BITS] (64) returns the same number, or more generally
 * `number.rotateRight(n) == number.rotateRight(n % 64)`
 */


protected abstract fun read ( ) : Double

/**
 * This protected method should be overridden to return the current reading of the time source expressed as a [Double] number
 * in the unit specified by the [unit] property.
 */


public operator fun plusAssign ( duration : Duration )

{ <EOL> val longDelta = duration . toLong ( unit ) <EOL> if ( ! longDelta . isSaturated ( ) ) { <EOL> val newReading = reading + longDelta <EOL> if ( reading xor longDelta >= <NUM_LIT:0> && reading xor newReading < <NUM_LIT:0> ) overflow ( duration ) <EOL> reading = newReading <EOL> } else { <EOL> val half = duration / <NUM_LIT:2> <EOL> if ( ! half . toLong ( unit ) . isSaturated ( ) ) { <EOL> val readingBefore = reading <EOL> try { <EOL> plusAssign ( half ) <EOL> plusAssign ( duration - half ) <EOL> } catch ( e : IllegalStateException ) { <EOL> reading = readingBefore <EOL> throw e <EOL> } <EOL> } else { <EOL> overflow ( duration ) <EOL> } <EOL> } <EOL> }

/**
 * Advances the current reading value of this time source by the specified [duration].
 *
 * [duration] value is rounded down towards zero when converting it to a [Long] number of nanoseconds.
 * For example, if the duration being added is `0.6.nanoseconds`, the reading doesn't advance because
 * the duration value is rounded to zero nanoseconds.
 *
 * @throws IllegalStateException when the reading value overflows as the result of this operation.
 */


public fun readAtMostTo ( sink : Buffer , byteCount : Long ) : Long

/**
 * Removes at least 1, and up to [byteCount] bytes from this source and appends them to [sink].
 * Returns the number of bytes read, or -1 if this source is exhausted.
 *
 * @param sink the destination to write the data from this source.
 * @param byteCount the number of bytes to read.
 *
 * @throws IllegalArgumentException when [byteCount] is negative.
 * @throws IllegalStateException when the source is closed.
 *
 * @sample kotlinx.io.samples.KotlinxIoCoreCommonSamples.readAtMostToSink
 */


override fun close ( )

/**
 * Closes this source and releases the resources held by this source. It is an error to read a
 * closed source. It is safe to close a source more than once.
 */


@ ExperimentalCoroutinesApi <EOL> @ Suppress ( "<STR_LIT:FunctionName>" ) <EOL> public fun UnconfinedTestDispatcher ( scheduler : TestCoroutineScheduler ? = null , name : String ? = null ) : TestDispatcher

= UnconfinedTestDispatcherImpl ( scheduler ? : TestMainDispatcher . currentTestScheduler ? : TestCoroutineScheduler ( ) , name )

/**
 * Creates an instance of an unconfined [TestDispatcher].
 *
 * This dispatcher is similar to [Dispatchers.Unconfined]: the tasks that it executes are not confined to any particular
 * thread and form an event loop; it's different in that it skips delays, as all [TestDispatcher]s do.
 *
 * Like [Dispatchers.Unconfined], this one does not provide guarantees about the execution order when several coroutines
 * are queued in this dispatcher. However, we ensure that the [launch] and [async] blocks at the top level of [runTest]
 * are entered eagerly. This allows launching child coroutines and not calling [runCurrent] for them to start executing.
 *
 * ```
 * @Test
 * fun testEagerlyEnteringChildCoroutines() = runTest(UnconfinedTestDispatcher()) {
 * var entered = false
 * val deferred = CompletableDeferred<Unit>()
 * var completed = false
 * launch {
 * entered = true
 * deferred.await()
 * completed = true
 * }
 * assertTrue(entered) // `entered = true` already executed.
 * assertFalse(completed) // however, the child coroutine then suspended, so it is enqueued.
 * deferred.complete(Unit) // resume the coroutine.
 * assertTrue(completed) // now the child coroutine is immediately completed.
 * }
 * ```
 *
 * Using this [TestDispatcher] can greatly simplify writing tests where it's not important which thread is used when and
 * in which order the queued coroutines are executed.
 * Another typical use case for this dispatcher is launching child coroutines that are resumed immediately, without
 * going through a dispatch; this can be helpful for testing [Channel] and [StateFlow] usages.
 *
 * ```
 * @Test
 * fun testUnconfinedDispatcher() = runTest {
 * val values = mutableListOf<Int>()
 * val stateFlow = MutableStateFlow(0)
 * val job = launch(UnconfinedTestDispatcher(testScheduler)) {
 * stateFlow.collect {
 * values.add(it)
 * }
 * }
 * stateFlow.value = 1
 * stateFlow.value = 2
 * stateFlow.value = 3
 * job.cancel()
 * // each assignment will immediately resume the collecting child coroutine,
 * // so no values will be skipped.
 * assertEquals(listOf(0, 1, 2, 3), values)
 * }
 * ```
 *
 * Please be aware that, like [Dispatchers.Unconfined], this is a specific dispatcher with execution order
 * guarantees that are unusual and not shared by most other dispatchers, so it can only be used reliably for testing
 * functionality, not the specific order of actions.
 * See [Dispatchers.Unconfined] for a discussion of the execution order guarantees.
 *
 * In order to support delay skipping, this dispatcher is linked to a [TestCoroutineScheduler], which is used to control
 * the virtual time and can be shared among many test dispatchers.
 * If no [scheduler] is passed as an argument, [Dispatchers.Main] is checked, and if it was mocked with a
 * [TestDispatcher] via [Dispatchers.setMain], the [TestDispatcher.scheduler] of the mock dispatcher is used; if
 * [Dispatchers.Main] is not mocked with a [TestDispatcher], a new [TestCoroutineScheduler] is created.
 *
 * Additionally, [name] can be set to distinguish each dispatcher instance when debugging.
 *
 * @see StandardTestDispatcher for a more predictable [TestDispatcher].
 */


@ Suppress ( "<STR_LIT:FunctionName>" ) <EOL> public fun StandardTestDispatcher ( scheduler : TestCoroutineScheduler ? = null , name : String ? = null ) : TestDispatcher

= StandardTestDispatcherImpl ( scheduler ? : TestMainDispatcher . currentTestScheduler ? : TestCoroutineScheduler ( ) , name )

/**
 * Creates an instance of a [TestDispatcher] whose tasks are run inside calls to the [scheduler].
 *
 * This [TestDispatcher] instance does not itself execute any of the tasks. Instead, it always sends them to its
 * [scheduler], which can then be accessed via [TestCoroutineScheduler.runCurrent],
 * [TestCoroutineScheduler.advanceUntilIdle], or [TestCoroutineScheduler.advanceTimeBy], which will then execute these
 * tasks in a blocking manner.
 *
 * In practice, this means that [launch] or [async] blocks will not be entered immediately (unless they are
 * parameterized with [CoroutineStart.UNDISPATCHED]), and one should either call [TestCoroutineScheduler.runCurrent] to
 * run these pending tasks, which will block until there are no more tasks scheduled at this point in time, or, when
 * inside [runTest], call [yield] to yield the (only) thread used by [runTest] to the newly-launched coroutines.
 *
 * If no [scheduler] is passed as an argument, [Dispatchers.Main] is checked, and if it was mocked with a
 * [TestDispatcher] via [Dispatchers.setMain], the [TestDispatcher.scheduler] of the mock dispatcher is used; if
 * [Dispatchers.Main] is not mocked with a [TestDispatcher], a new [TestCoroutineScheduler] is created.
 *
 * One can additionally pass a [name] in order to more easily distinguish this dispatcher during debugging.
 *
 * @see UnconfinedTestDispatcher for a dispatcher that is not confined to any particular thread.
 */


= resnet50Prediction ( )


@ OptionalJsName ( TRACE_FORMAT_FORMAT_FUNCTION ) <EOL> public open fun format ( index : Int , event : Any ) : String

= "<STR_LIT>"

/**
 * Formats trace at the given [index] with the given [event] of Any type.
 */


@ InlineOnly <EOL> public inline fun TraceFormat ( crossinline format : ( index : Int , event : Any ) -> String ) : TraceFormat

= <EOL> object : TraceFormat ( ) { <EOL> override fun format ( index : Int , event : Any ) : String = format ( index , event ) <EOL> }

/**
 * Creates trace string formatter with the given [format] code block.
 */


internal fun assertEstimations ( exampleFrame : AnyFrame , expectedNullable : Boolean , hasNulls : Boolean )

{ <EOL> fun iBatch ( iFrame : Int ) : Int { <EOL> val firstBatchSize = <NUM_LIT:100> <EOL> return if ( iFrame < firstBatchSize ) iFrame else iFrame - firstBatchSize <EOL> } <EOL> fun expectedNull ( rowNumber : Int ) : Boolean { <EOL> return ( rowNumber + <NUM_LIT:1> ) % <NUM_LIT:5> == <NUM_LIT:0> <EOL> } <EOL> fun assertValueOrNull ( rowNumber : Int , actual : Any ? , expected : Any ) { <EOL> if ( hasNulls && expectedNull ( rowNumber ) ) { <EOL> actual shouldBe null <EOL> } else { <EOL> actual shouldBe expected <EOL> } <EOL> } <EOL> val asciiStringCol = exampleFrame [ "<STR_LIT>" ] as DataColumn < String ? > <EOL> asciiStringCol . type ( ) shouldBe typeOf < String > ( ) . withNullability ( expectedNullable ) <EOL> asciiStringCol . forEachIndexed { i , element -> <EOL> assertValueOrNull ( iBatch ( i ) , element , "<STR_LIT>" ) <EOL> } <EOL> val utf8StringCol = exampleFrame [ "<STR_LIT>" ] as DataColumn < String ? > <EOL> utf8StringCol . type ( ) shouldBe typeOf < String > ( ) . withNullability ( expectedNullable ) <EOL> utf8StringCol . forEachIndexed { i , element -> <EOL> assertValueOrNull ( iBatch ( i ) , element , "<STR_LIT>" ) <EOL> } <EOL> val largeStringCol = exampleFrame [ "<STR_LIT>" ] as DataColumn < String ? > <EOL> largeStringCol . type ( ) shouldBe typeOf < String > ( ) . withNullability ( expectedNullable ) <EOL> largeStringCol . forEachIndexed { i , element -> <EOL> assertValueOrNull ( iBatch ( i ) , element , "<STR_LIT>" ) <EOL> } <EOL> val booleanCol = exampleFrame [ "<STR_LIT>" ] as DataColumn < Boolean ? > <EOL> booleanCol . type ( ) shouldBe typeOf < Boolean > ( ) . withNullability ( expectedNullable ) <EOL> booleanCol . forEachIndexed { i , element -> <EOL> assertValueOrNull ( iBatch ( i ) , element , iBatch ( i ) % <NUM_LIT:2> == <NUM_LIT:0> ) <EOL> } <EOL> val byteCol = exampleFrame [ "<STR_LIT>" ] as DataColumn < Byte ? > <EOL> byteCol . type ( ) shouldBe typeOf < Byte > ( ) . withNullability ( expectedNullable ) <EOL> byteCol . forEachIndexed { i , element -> <EOL> assertValueOrNull ( iBatch ( i ) , element , ( iBatch ( i ) * <NUM_LIT:10> ) . toByte ( ) ) <EOL> } <EOL> val shortCol = exampleFrame [ "<STR_LIT>" ] as DataColumn < Short ? > <EOL> shortCol . type ( ) shouldBe typeOf < Short > ( ) . withNullability ( expectedNullable ) <EOL> shortCol . forEachIndexed { i , element -> <EOL> assertValueOrNull ( iBatch ( i ) , element , ( iBatch ( i ) * <NUM_LIT> ) . toShort ( ) ) <EOL> } <EOL> val intCol = exampleFrame [ "<STR_LIT>" ] as DataColumn < Int ? > <EOL> intCol . type ( ) shouldBe typeOf < Int > ( ) . withNullability ( expectedNullable ) <EOL> intCol . forEachIndexed { i , element -> <EOL> assertValueOrNull ( iBatch ( i ) , element , iBatch ( i ) * <NUM_LIT> ) <EOL> } <EOL> val longCol = exampleFrame [ "<STR_LIT>" ] as DataColumn < Long ? > <EOL> longCol . type ( ) shouldBe typeOf < Long > ( ) . withNullability ( expectedNullable ) <EOL> longCol . forEachIndexed { i , element -> <EOL> assertValueOrNull ( iBatch ( i ) , element , iBatch ( i ) * <NUM_LIT> ) <EOL> } <EOL> val unsignedByteCol = exampleFrame [ "<STR_LIT>" ] as DataColumn < Short ? > <EOL> unsignedByteCol . type ( ) shouldBe typeOf < Short > ( ) . withNullability ( expectedNullable ) <EOL> unsignedByteCol . forEachIndexed { i , element -> <EOL> assertValueOrNull ( iBatch ( i ) , element , ( iBatch ( i ) * <NUM_LIT:10> % ( Byte . MIN_VALUE . toShort ( ) * <NUM_LIT:2> ) . absoluteValue ) . toShort ( ) ) <EOL> } <EOL> val unsignedShortCol = exampleFrame [ "<STR_LIT>" ] as DataColumn < Int ? > <EOL> unsignedShortCol . type ( ) shouldBe typeOf < Int > ( ) . withNullability ( expectedNullable ) <EOL> unsignedShortCol . forEachIndexed { i , element -> <EOL> assertValueOrNull ( iBatch ( i ) , element , iBatch ( i ) * <NUM_LIT> % ( Short . MIN_VALUE . toInt ( ) * <NUM_LIT:2> ) . absoluteValue ) <EOL> } <EOL> val unsignedIntCol = exampleFrame [ "<STR_LIT>" ] as DataColumn < Long ? > <EOL> unsignedIntCol . type ( ) shouldBe typeOf < Long > ( ) . withNullability ( expectedNullable ) <EOL> unsignedIntCol . forEachIndexed { i , element -> <EOL> assertValueOrNull ( iBatch ( i ) , element , iBatch ( i ) . toLong ( ) * <NUM_LIT> % ( Int . MIN_VALUE . toLong ( ) * <NUM_LIT:2> ) . absoluteValue ) <EOL> } <EOL> val unsignedLongIntCol = exampleFrame [ "<STR_LIT>" ] as DataColumn < BigInteger ? > <EOL> unsignedLongIntCol . type ( ) shouldBe typeOf < BigInteger > ( ) . withNullability ( expectedNullable ) <EOL> unsignedLongIntCol . forEachIndexed { i , element -> <EOL> assertValueOrNull ( iBatch ( i ) , element , iBatch ( i ) . toBigInteger ( ) * <NUM_LIT> . toBigInteger ( ) % ( Long . MIN_VALUE . toBigInteger ( ) * <NUM_LIT:2> . toBigInteger ( ) ) . abs ( ) ) <EOL> } <EOL> val floatCol = exampleFrame [ "<STR_LIT>" ] as DataColumn < Float ? > <EOL> floatCol . type ( ) shouldBe typeOf < Float > ( ) . withNullability ( expectedNullable ) <EOL> floatCol . forEachIndexed { i , element -> <EOL> assertValueOrNull ( iBatch ( i ) , element , <NUM_LIT> . pow ( iBatch ( i ) . toFloat ( ) ) ) <EOL> } <EOL> val doubleCol = exampleFrame [ "<STR_LIT>" ] as DataColumn < Double ? > <EOL> doubleCol . type ( ) shouldBe typeOf < Double > ( ) . withNullability ( expectedNullable ) <EOL> doubleCol . forEachIndexed { i , element -> <EOL> assertValueOrNull ( iBatch ( i ) , element , <NUM_LIT:2.0> . pow ( iBatch ( i ) ) ) <EOL> } <EOL> val dateCol = exampleFrame [ "<STR_LIT>" ] as DataColumn < LocalDate ? > <EOL> dateCol . type ( ) shouldBe typeOf < LocalDate > ( ) . withNullability ( expectedNullable ) <EOL> dateCol . forEachIndexed { i , element -> <EOL> assertValueOrNull ( iBatch ( i ) , element , LocalDate . ofEpochDay ( iBatch ( i ) . toLong ( ) * <NUM_LIT> ) ) <EOL> } <EOL> val datetimeCol = exampleFrame [ "<STR_LIT>" ] as DataColumn < LocalDateTime ? > <EOL> datetimeCol . type ( ) shouldBe typeOf < LocalDateTime > ( ) . withNullability ( expectedNullable ) <EOL> datetimeCol . forEachIndexed { i , element -> <EOL> assertValueOrNull ( iBatch ( i ) , element , LocalDateTime . ofEpochSecond ( iBatch ( i ) . toLong ( ) * <NUM_LIT> * <NUM_LIT> * <NUM_LIT> * <NUM_LIT> , <NUM_LIT:0> , ZoneOffset . UTC ) ) <EOL> } <EOL> val timeSecCol = exampleFrame [ "<STR_LIT>" ] as DataColumn < LocalTime ? > <EOL> timeSecCol . type ( ) shouldBe typeOf < LocalTime > ( ) . withNullability ( expectedNullable ) <EOL> timeSecCol . forEachIndexed { i , element -> <EOL> assertValueOrNull ( iBatch ( i ) , element , LocalTime . ofSecondOfDay ( iBatch ( i ) . toLong ( ) ) ) <EOL> } <EOL> val timeMilliCol = exampleFrame [ "<STR_LIT>" ] as DataColumn < LocalTime ? > <EOL> timeMilliCol . type ( ) shouldBe typeOf < LocalTime > ( ) . withNullability ( expectedNullable ) <EOL> timeMilliCol . forEachIndexed { i , element -> <EOL> assertValueOrNull ( iBatch ( i ) , element , LocalTime . ofNanoOfDay ( iBatch ( i ) . toLong ( ) * <NUM_LIT> ) ) <EOL> } <EOL> val timeMicroCol = exampleFrame [ "<STR_LIT>" ] as DataColumn < LocalTime ? > <EOL> timeMicroCol . type ( ) shouldBe typeOf < LocalTime > ( ) . withNullability ( expectedNullable ) <EOL> timeMicroCol . forEachIndexed { i , element -> <EOL> assertValueOrNull ( iBatch ( i ) , element , LocalTime . ofNanoOfDay ( iBatch ( i ) . toLong ( ) * <NUM_LIT> ) ) <EOL> } <EOL> val timeNanoCol = exampleFrame [ "<STR_LIT>" ] as DataColumn < LocalTime ? > <EOL> timeNanoCol . type ( ) shouldBe typeOf < LocalTime > ( ) . withNullability ( expectedNullable ) <EOL> timeNanoCol . forEachIndexed { i , element -> <EOL> assertValueOrNull ( iBatch ( i ) , element , LocalTime . ofNanoOfDay ( iBatch ( i ) . toLong ( ) ) ) <EOL> } <EOL> exampleFrame . getColumnOrNull ( "<STR_LIT>" ) ? . let { nullCol -> <EOL> nullCol . type ( ) shouldBe nothingType ( hasNulls ) <EOL> assert ( hasNulls ) <EOL> nullCol . values ( ) . forEach { <EOL> assert ( it == null ) <EOL> } <EOL> } <EOL> }

/**
 * Assert that we have got the same data that was originally saved on example creation.
 * Example generation project is currently located at https://github.com/Kopilov/arrow_example
 */


public inline fun < T > PersistentSet < T > . mutate ( mutator : ( MutableSet < T > ) -> Unit ) : PersistentSet < T >

= builder ( ) . apply ( mutator ) . build ( )

/**
 * Returns the result of applying the provided modifications on this set.
 *
 * The mutable set passed to the [mutator] closure has the same contents as this persistent set.
 *
 * @return a new persistent set with the provided modifications applied;
 * or this instance if no modifications were made in the result of this operation.
 */


public inline fun < T > PersistentList < T > . mutate ( mutator : ( MutableList < T > ) -> Unit ) : PersistentList < T >

/**
 * Returns the result of applying the provided modifications on this list.
 *
 * The mutable list passed to the [mutator] closure has the same contents as this persistent list.
 *
 * @return a new persistent list with the provided modifications applied;
 * or this instance if no modifications were made in the result of this operation.
 */


@ Suppress ( "<STR_LIT:UNCHECKED_CAST>" ) <EOL> public inline fun < K , V > PersistentMap < out K , V > . mutate ( mutator : ( MutableMap < K , V > ) -> Unit ) : PersistentMap < K , V >

= <EOL> ( this as PersistentMap < K , V > ) . builder ( ) . apply ( mutator ) . build ( )

/**
 * Returns the result of applying the provided modifications on this map.
 *
 * The mutable map passed to the [mutator] closure has the same contents as this persistent map.
 *
 * @return a new persistent map with the provided modifications applied;
 * or this instance if no modifications were made in the result of this operation.
 */


public inline operator fun < E > PersistentCollection < E > . plus ( element : E ) : PersistentCollection < E >

= add ( element )

/**
 * Returns the result of adding the specified [element] to this collection.
 *
 * @returns a new persistent collection with the specified [element] added;
 * or this instance if this collection does not support duplicates and it already contains the element.
 */


public inline operator fun < E > PersistentCollection < E > . minus ( element : E ) : PersistentCollection < E >

= remove ( element )

/**
 * Returns the result of removing a single appearance of the specified [element] from this collection.
 *
 * @return a new persistent collection with a single appearance of the specified [element] removed;
 * or this instance if there is no such element in this collection.
 */


public operator fun < E > PersistentCollection < E > . plus ( elements : Iterable < E > ) : PersistentCollection < E > <EOL>

= if ( elements is Collection ) addAll ( elements ) else builder ( ) . also { it . addAll ( elements ) } . build ( )

/**
 * Returns the result of adding all elements of the specified [elements] collection to this collection.
 *
 * @return a new persistent collection with elements of the specified [elements] collection added;
 * or this instance if no modifications were made in the result of this operation.
 */


public operator fun < E > PersistentCollection < E > . plus ( elements : Array < out E > ) : PersistentCollection < E > <EOL>

= builder ( ) . also { it . addAll ( elements ) } . build ( )

/**
 * Returns the result of adding all elements of the specified [elements] array to this collection.
 *
 * @return a new persistent collection with elements of the specified [elements] array added;
 * or this instance if no modifications were made in the result of this operation.
 */


public operator fun < E > PersistentCollection < E > . plus ( elements : Sequence < E > ) : PersistentCollection < E > <EOL>

/**
 * Returns the result of adding all elements of the specified [elements] sequence to this collection.
 *
 * @return a new persistent collection with elements of the specified [elements] sequence added;
 * or this instance if no modifications were made in the result of this operation.
 */


public operator fun < E > PersistentCollection < E > . minus ( elements : Iterable < E > ) : PersistentCollection < E > <EOL>

= if ( elements is Collection ) removeAll ( elements ) else builder ( ) . also { it . removeAll ( elements ) } . build ( )

/**
 * Returns the result of removing all elements in this collection that are also
 * contained in the specified [elements] collection.
 *
 * @return a new persistent collection with elements in this collection that are also
 * contained in the specified [elements] collection removed;
 * or this instance if no modifications were made in the result of this operation.
 */


public operator fun < E > PersistentCollection < E > . minus ( elements : Array < out E > ) : PersistentCollection < E > <EOL>

= builder ( ) . also { it . removeAll ( elements ) } . build ( )

/**
 * Returns the result of removing all elements in this collection that are also
 * contained in the specified [elements] array.
 *
 * @return a new persistent collection with elements in this collection that are also
 * contained in the specified [elements] array removed;
 * or this instance if no modifications were made in the result of this operation.
 */


public operator fun < E > PersistentCollection < E > . minus ( elements : Sequence < E > ) : PersistentCollection < E > <EOL>

/**
 * Returns the result of removing all elements in this collection that are also
 * contained in the specified [elements] sequence.
 *
 * @return a new persistent collection with elements in this collection that are also
 * contained in the specified [elements] sequence removed;
 * or this instance if no modifications were made in the result of this operation.
 */


public inline operator fun < E > PersistentList < E > . plus ( element : E ) : PersistentList < E >

= add ( element )

/**
 * Returns a new persistent list with the specified [element] appended.
 */


public inline operator fun < E > PersistentList < E > . minus ( element : E ) : PersistentList < E >

= remove ( element )

/**
 * Returns the result of removing the first appearance of the specified [element] from this list.
 *
 * @return a new persistent list with the first appearance of the specified [element] removed;
 * or this instance if there is no such element in this list.
 */


public operator fun < E > PersistentList < E > . plus ( elements : Iterable < E > ) : PersistentList < E > <EOL>

= if ( elements is Collection ) addAll ( elements ) else mutate { it . addAll ( elements ) }

/**
 * Returns the result of appending all elements of the specified [elements] collection to this list.
 *
 * The elements are appended in the order they appear in the specified collection.
 *
 * @return a new persistent list with elements of the specified [elements] collection appended;
 * or this instance if the specified collection is empty.
 */


public operator fun < E > PersistentList < E > . plus ( elements : Array < out E > ) : PersistentList < E > <EOL>

= mutate { it . addAll ( elements ) }

/**
 * Returns the result of appending all elements of the specified [elements] array to this list.
 *
 * The elements are appended in the order they appear in the specified array.
 *
 * @return a new persistent list with elements of the specified [elements] array appended;
 * or this instance if the specified array is empty.
 */


public operator fun < E > PersistentList < E > . plus ( elements : Sequence < E > ) : PersistentList < E > <EOL>

= mutate { it . addAll ( elements ) }

/**
 * Returns the result of appending all elements of the specified [elements] sequence to this list.
 *
 * The elements are appended in the order they appear in the specified sequence.
 *
 * @return a new persistent list with elements of the specified [elements] sequence appended;
 * or this instance if the specified sequence is empty.
 */


public operator fun < E > PersistentList < E > . minus ( elements : Iterable < E > ) : PersistentList < E > <EOL>

= if ( elements is Collection ) removeAll ( elements ) else mutate { it . removeAll ( elements ) }

/**
 * Returns the result of removing all elements in this list that are also
 * contained in the specified [elements] collection.
 *
 * @return a new persistent list with elements in this list that are also
 * contained in the specified [elements] collection removed;
 * or this instance if no modifications were made in the result of this operation.
 */


public operator fun < E > PersistentList < E > . minus ( elements : Array < out E > ) : PersistentList < E > <EOL>

= mutate { it . removeAll ( elements ) }

/**
 * Returns the result of removing all elements in this list that are also
 * contained in the specified [elements] array.
 *
 * @return a new persistent list with elements in this list that are also
 * contained in the specified [elements] array removed;
 * or this instance if no modifications were made in the result of this operation.
 */


public operator fun < E > PersistentList < E > . minus ( elements : Sequence < E > ) : PersistentList < E > <EOL>

/**
 * Returns the result of removing all elements in this list that are also
 * contained in the specified [elements] sequence.
 *
 * @return a new persistent list with elements in this list that are also
 * contained in the specified [elements] sequence removed;
 * or this instance if no modifications were made in the result of this operation.
 */


public inline operator fun < E > PersistentSet < E > . plus ( element : E ) : PersistentSet < E >

= add ( element )

/**
 * Returns the result of adding the specified [element] to this set.
 *
 * @return a new persistent set with the specified [element] added;
 * or this instance if it already contains the element.
 */


public inline operator fun < E > PersistentSet < E > . minus ( element : E ) : PersistentSet < E >

= remove ( element )

/**
 * Returns the result of removing the specified [element] from this set.
 *
 * @return a new persistent set with the specified [element] removed;
 * or this instance if there is no such element in this set.
 */


public operator fun < E > PersistentSet < E > . plus ( elements : Iterable < E > ) : PersistentSet < E > <EOL>

/**
 * Returns the result of adding all elements of the specified [elements] collection to this set.
 *
 * @return a new persistent set with elements of the specified [elements] collection added;
 * or this instance if it already contains every element of the specified collection.
 */


public operator fun < E > PersistentSet < E > . plus ( elements : Array < out E > ) : PersistentSet < E > <EOL>

= mutate { it . addAll ( elements ) }

/**
 * Returns the result of adding all elements of the specified [elements] array to this set.
 *
 * @return a new persistent set with elements of the specified [elements] array added;
 * or this instance if it already contains every element of the specified array.
 */


public operator fun < E > PersistentSet < E > . plus ( elements : Sequence < E > ) : PersistentSet < E > <EOL>

= mutate { it . addAll ( elements ) }

/**
 * Returns the result of adding all elements of the specified [elements] sequence to this set.
 *
 * @return a new persistent set with elements of the specified [elements] sequence added;
 * or this instance if it already contains every element of the specified sequence.
 */


public operator fun < E > PersistentSet < E > . minus ( elements : Iterable < E > ) : PersistentSet < E > <EOL>

/**
 * Returns the result of removing all elements in this set that are also
 * contained in the specified [elements] collection.
 *
 * @return a new persistent set with elements in this set that are also
 * contained in the specified [elements] collection removed;
 * or this instance if no modifications were made in the result of this operation.
 */


public operator fun < E > PersistentSet < E > . minus ( elements : Array < out E > ) : PersistentSet < E > <EOL>

/**
 * Returns the result of removing all elements in this set that are also
 * contained in the specified [elements] array.
 *
 * @return a new persistent set with elements in this set that are also
 * contained in the specified [elements] array removed;
 * or this instance if no modifications were made in the result of this operation.
 */


public operator fun < E > PersistentSet < E > . minus ( elements : Sequence < E > ) : PersistentSet < E > <EOL>

/**
 * Returns the result of removing all elements in this set that are also
 * contained in the specified [elements] sequence.
 *
 * @return a new persistent set with elements in this set that are also
 * contained in the specified [elements] sequence removed;
 * or this instance if no modifications were made in the result of this operation.
 */


public infix fun < E > PersistentSet < E > . intersect ( elements : Iterable < E > ) : PersistentSet < E > <EOL>

= if ( elements is Collection ) retainAll ( elements ) else mutate { it . retainAll ( elements ) }

/**
 * Returns all elements in this set that are also
 * contained in the specified [elements] collection.
 *
 * @return a new persistent set with elements in this set that are also
 * contained in the specified [elements] collection;
 * or this instance if no modifications were made in the result of this operation.
 */


public infix fun < E > PersistentCollection < E > . intersect ( elements : Iterable < E > ) : PersistentSet < E > <EOL>

= this . toPersistentSet ( ) . intersect ( elements )

/**
 * Returns all elements in this collection that are also
 * contained in the specified [elements] collection.
 *
 * @return a new persistent set with elements in this collection that are also
 * contained in the specified [elements] collection
 */


@ Suppress ( "<STR_LIT:UNCHECKED_CAST>" ) <EOL> public inline operator fun < K , V > PersistentMap < out K , V > . plus ( pair : Pair < K , V > ) : PersistentMap < K , V > <EOL>

= ( this as PersistentMap < K , V > ) . put ( pair . first , pair . second )

/**
 * Returns the result of adding an entry to this map from the specified key-value [pair].
 *
 * If this map already contains a mapping for the key,
 * the old value is replaced by the value from the specified [pair].
 *
 * @return a new persistent map with an entry from the specified key-value [pair] added;
 * or this instance if no modifications were made in the result of this operation.
 */


public inline operator fun < K , V > PersistentMap < out K , V > . plus ( pairs : Iterable < Pair < K , V > > ) : PersistentMap < K , V >

= putAll ( pairs )

/**
 * Returns the result of replacing or adding entries to this map from the specified key-value pairs.
 *
 * @return a new persistent map with entries from the specified key-value pairs added;
 * or this instance if no modifications were made in the result of this operation.
 */


public inline operator fun < K , V > PersistentMap < out K , V > . plus ( pairs : Array < out Pair < K , V > > ) : PersistentMap < K , V >

= putAll ( pairs )


public inline operator fun < K , V > PersistentMap < out K , V > . plus ( pairs : Sequence < Pair < K , V > > ) : PersistentMap < K , V >

= putAll ( pairs )


public inline operator fun < K , V > PersistentMap < out K , V > . plus ( map : Map < out K , V > ) : PersistentMap < K , V >

= putAll ( map )

/**
 * Returns the result of merging the specified [map] with this map.
 *
 * The effect of this call is equivalent to that of calling `put(k, v)` once for each
 * mapping from key `k` to value `v` in the specified map.
 *
 * @return a new persistent map with keys and values from the specified [map] associated;
 * or this instance if no modifications were made in the result of this operation.
 */


@ Suppress ( "<STR_LIT:UNCHECKED_CAST>" ) <EOL> public fun < K , V > PersistentMap < out K , V > . putAll ( map : Map < out K , V > ) : PersistentMap < K , V >

= <EOL> ( this as PersistentMap < K , V > ) . putAll ( map )


public fun < K , V > PersistentMap < out K , V > . putAll ( pairs : Iterable < Pair < K , V > > ) : PersistentMap < K , V > <EOL>

= mutate { it . putAll ( pairs ) }


public fun < K , V > PersistentMap < out K , V > . putAll ( pairs : Array < out Pair < K , V > > ) : PersistentMap < K , V > <EOL>

= mutate { it . putAll ( pairs ) }


public fun < K , V > PersistentMap < out K , V > . putAll ( pairs : Sequence < Pair < K , V > > ) : PersistentMap < K , V > <EOL>

= mutate { it . putAll ( pairs ) }


@ Suppress ( "<STR_LIT:UNCHECKED_CAST>" ) <EOL> public operator fun < K , V > PersistentMap < out K , V > . minus ( key : K ) : PersistentMap < K , V > <EOL>

= ( this as PersistentMap < K , V > ) . remove ( key )

/**
 * Returns the result of removing the specified [key] and its corresponding value from this map.
 *
 * @return a new persistent map with the specified [key] and its corresponding value removed;
 * or this instance if it contains no mapping for the key.
 */


public operator fun < K , V > PersistentMap < out K , V > . minus ( keys : Iterable < K > ) : PersistentMap < K , V > <EOL>

= mutate { it . minusAssign ( keys ) }

/**
 * Returns the result of removing the specified [keys] and their corresponding values from this map.
 *
 * @return a new persistent map with the specified [keys] and their corresponding values removed;
 * or this instance if no modifications were made in the result of this operation.
 */


public operator fun < K , V > PersistentMap < out K , V > . minus ( keys : Array < out K > ) : PersistentMap < K , V > <EOL>

= mutate { it . minusAssign ( keys ) }


public operator fun < K , V > PersistentMap < out K , V > . minus ( keys : Sequence < K > ) : PersistentMap < K , V > <EOL>

= mutate { it . minusAssign ( keys ) }


public fun < E > persistentListOf ( vararg elements : E ) : PersistentList < E >

= persistentVectorOf < E > ( ) . addAll ( elements . asList ( ) )

/**
 * Returns a new persistent list of the specified elements.
 */


public fun < E > persistentListOf ( ) : PersistentList < E >

= persistentVectorOf ( )

/**
 * Returns an empty persistent list.
 */


public fun < E > persistentSetOf ( vararg elements : E ) : PersistentSet < E >

= PersistentOrderedSet . emptyOf < E > ( ) . addAll ( elements . asList ( ) )

/**
 * Returns a new persistent set with the given elements.
 *
 * Elements of the returned set are iterated in the order they were specified.
 */


public fun < E > persistentSetOf ( ) : PersistentSet < E >

= PersistentOrderedSet . emptyOf < E > ( )

/**
 * Returns an empty persistent set.
 */


public fun < E > persistentHashSetOf ( vararg elements : E ) : PersistentSet < E >

= PersistentHashSet . emptyOf < E > ( ) . addAll ( elements . asList ( ) )

/**
 * Returns a new persistent set with the given elements.
 *
 * Order of the elements in the returned set is unspecified.
 */


public fun < E > persistentHashSetOf ( ) : PersistentSet < E >

= PersistentHashSet . emptyOf ( )


public fun < K , V > persistentMapOf ( vararg pairs : Pair < K , V > ) : PersistentMap < K , V >

= PersistentOrderedMap . emptyOf < K , V > ( ) . mutate { it += pairs }

/**
 * Returns a new persistent map with the specified contents, given as a list of pairs
 * where the first component is the key and the second is the value.
 *
 * If multiple pairs have the same key, the resulting map will contain the value from the last of those pairs.
 *
 * Entries of the map are iterated in the order they were specified.
 */


public fun < K , V > persistentMapOf ( ) : PersistentMap < K , V >

= PersistentOrderedMap . emptyOf ( )

/**
 * Returns an empty persistent map.
 */


public fun < K , V > persistentHashMapOf ( vararg pairs : Pair < K , V > ) : PersistentMap < K , V >

= PersistentHashMap . emptyOf < K , V > ( ) . mutate { it += pairs }

/**
 * Returns a new persistent map with the specified contents, given as a list of pairs
 * where the first component is the key and the second is the value.
 *
 * If multiple pairs have the same key, the resulting map will contain the value from the last of those pairs.
 *
 * Order of the entries in the returned map is unspecified.
 */


public fun < K , V > persistentHashMapOf ( ) : PersistentMap < K , V >

= PersistentHashMap . emptyOf ( )


@ Deprecated ( "<STR_LIT>" , ReplaceWith ( "<STR_LIT>" ) ) <EOL> public fun < E > immutableListOf ( vararg elements : E ) : PersistentList < E >

= persistentListOf ( * elements )


@ Deprecated ( "<STR_LIT>" , ReplaceWith ( "<STR_LIT>" ) ) <EOL> public fun < E > immutableListOf ( ) : PersistentList < E >

= persistentListOf ( )


@ Deprecated ( "<STR_LIT>" , ReplaceWith ( "<STR_LIT>" ) ) <EOL> public fun < E > immutableSetOf ( vararg elements : E ) : PersistentSet < E >

= persistentSetOf ( * elements )


@ Deprecated ( "<STR_LIT>" , ReplaceWith ( "<STR_LIT>" ) ) <EOL> public fun < E > immutableSetOf ( ) : PersistentSet < E >

= persistentSetOf ( )


@ Deprecated ( "<STR_LIT>" , ReplaceWith ( "<STR_LIT>" ) ) <EOL> public fun < E > immutableHashSetOf ( vararg elements : E ) : PersistentSet < E >

= persistentHashSetOf ( * elements )


@ Deprecated ( "<STR_LIT>" , ReplaceWith ( "<STR_LIT>" ) ) <EOL> public fun < K , V > immutableMapOf ( vararg pairs : Pair < K , V > ) : PersistentMap < K , V >

= persistentMapOf ( * pairs )


@ Deprecated ( "<STR_LIT>" , ReplaceWith ( "<STR_LIT>" ) ) <EOL> public fun < K , V > immutableHashMapOf ( vararg pairs : Pair < K , V > ) : PersistentMap < K , V >

= persistentHashMapOf ( * pairs )


public fun < T > Iterable < T > . toImmutableList ( ) : ImmutableList < T >

= <EOL> this as? ImmutableList <EOL> ? : this . toPersistentList ( )

/**
 * Returns an immutable list containing all elements of this collection.
 *
 * If the receiver is already an immutable list, returns it as is.
 */


public fun < T > Array < out T > . toImmutableList ( ) : ImmutableList < T >

= toPersistentList ( )

/**
 * Returns an immutable list containing all elements of this array.
 */


public fun < T > Sequence < T > . toImmutableList ( ) : ImmutableList < T >

= toPersistentList ( )

/**
 * Returns an immutable list containing all elements of this sequence.
 */


public fun CharSequence . toImmutableList ( ) : ImmutableList < Char >

= toPersistentList ( )

/**
 * Returns an immutable list containing all characters.
 */


public fun < T > Iterable < T > . toPersistentList ( ) : PersistentList < T >

= <EOL> this as? PersistentList <EOL> ? : ( this as? PersistentList . Builder ) ? . build ( ) <EOL> ? : persistentListOf < T > ( ) + this

/**
 * Returns a persistent list containing all elements of this collection.
 *
 * If the receiver is already a persistent list, returns it as is.
 * If the receiver is a persistent list builder, calls `build` on it and returns the result.
 */


public fun < T > Array < out T > . toPersistentList ( ) : PersistentList < T >

= persistentListOf < T > ( ) + this

/**
 * Returns a persistent list containing all elements of this array.
 */


public fun < T > Sequence < T > . toPersistentList ( ) : PersistentList < T >

= persistentListOf < T > ( ) + this

/**
 * Returns a persistent list containing all elements of this sequence.
 */


public fun CharSequence . toPersistentList ( ) : PersistentList < Char >

= <EOL> persistentListOf < Char > ( ) . mutate { this . toCollection ( it ) }

/**
 * Returns a persistent list containing all characters.
 */


public fun < T > Iterable < T > . toImmutableSet ( ) : ImmutableSet < T >

= <EOL> this as? ImmutableSet < T > <EOL> ? : ( this as? PersistentSet . Builder ) ? . build ( ) <EOL> ? : persistentSetOf < T > ( ) + this

/**
 * Returns an immutable set of all elements of this collection.
 *
 * If the receiver is already an immutable set, returns it as is.
 *
 * Elements of the returned set are iterated in the same order as in this collection.
 */


public fun < T > Array < out T > . toImmutableSet ( ) : ImmutableSet < T >

= toPersistentSet ( )

/**
 * Returns an immutable set of all elements of this array.
 *
 * Elements of the returned set are iterated in the same order as in this array.
 */


public fun < T > Sequence < T > . toImmutableSet ( ) : ImmutableSet < T >

= toPersistentSet ( )

/**
 * Returns an immutable set of all elements of this sequence.
 *
 * Elements of the returned set are iterated in the same order as in this sequence.
 */


public fun CharSequence . toImmutableSet ( ) : PersistentSet < Char >

= toPersistentSet ( )

/**
 * Returns an immutable set of all characters.
 *
 * Elements of the returned set are iterated in the same order as in this char sequence.
 */


public fun < T > Iterable < T > . toPersistentSet ( ) : PersistentSet < T >

= <EOL> this as? PersistentOrderedSet < T > <EOL> ? : ( this as? PersistentOrderedSetBuilder ) ? . build ( ) <EOL> ? : PersistentOrderedSet . emptyOf < T > ( ) + this

/**
 * Returns a persistent set of all elements of this collection.
 *
 * If the receiver is already a persistent set, returns it as is.
 * If the receiver is a persistent set builder, calls `build` on it and returns the result.
 *
 * Elements of the returned set are iterated in the same order as in this collection.
 */


public fun < T > Array < out T > . toPersistentSet ( ) : PersistentSet < T >

= persistentSetOf < T > ( ) + this

/**
 * Returns a persistent set of all elements of this array.
 *
 * Elements of the returned set are iterated in the same order as in this array.
 */


public fun < T > Sequence < T > . toPersistentSet ( ) : PersistentSet < T >

= persistentSetOf < T > ( ) + this

/**
 * Returns a persistent set of all elements of this sequence.
 *
 * Elements of the returned set are iterated in the same order as in this sequence.
 */


public fun CharSequence . toPersistentSet ( ) : PersistentSet < Char >

= <EOL> persistentSetOf < Char > ( ) . mutate { this . toCollection ( it ) }

/**
 * Returns a persistent set of all characters.
 *
 * Elements of the returned set are iterated in the same order as in this char sequence.
 */


public fun < T > Iterable < T > . toPersistentHashSet ( ) : PersistentSet < T > <EOL>

= this as? PersistentHashSet <EOL> ? : ( this as? PersistentHashSetBuilder < T > ) ? . build ( ) <EOL> ? : PersistentHashSet . emptyOf < T > ( ) + this

/**
 * Returns a persistent set containing all elements from this set.
 *
 * If the receiver is already a persistent hash set, returns it as is.
 * If the receiver is a persistent hash set builder, calls `build` on it and returns the result.
 *
 * Order of the elements in the returned set is unspecified.
 */


public fun < T > Array < out T > . toPersistentHashSet ( ) : PersistentSet < T >

= persistentHashSetOf < T > ( ) + this

/**
 * Returns a persistent set of all elements of this array.
 *
 * Order of the elements in the returned set is unspecified.
 */


public fun < T > Sequence < T > . toPersistentHashSet ( ) : PersistentSet < T >

= persistentHashSetOf < T > ( ) + this

/**
 * Returns a persistent set of all elements of this sequence.
 *
 * Order of the elements in the returned set is unspecified.
 */


public fun CharSequence . toPersistentHashSet ( ) : PersistentSet < Char >

= <EOL> persistentHashSetOf < Char > ( ) . mutate { this . toCollection ( it ) }

/**
 * Returns a persistent set of all characters.
 *
 * Order of the elements in the returned set is unspecified.
 */


public fun < K , V > Map < K , V > . toImmutableMap ( ) : ImmutableMap < K , V > <EOL>

= this as? ImmutableMap <EOL> ? : ( this as? PersistentMap . Builder ) ? . build ( ) <EOL> ? : persistentMapOf < K , V > ( ) . putAll ( this )

/**
 * Returns an immutable map containing all entries from this map.
 *
 * If the receiver is already an immutable map, returns it as is.
 *
 * Entries of the returned map are iterated in the same order as in this map.
 */


public fun < K , V > Map < K , V > . toPersistentMap ( ) : PersistentMap < K , V > <EOL>

= this as? PersistentOrderedMap < K , V > <EOL> ? : ( this as? PersistentOrderedMapBuilder < K , V > ) ? . build ( ) <EOL> ? : PersistentOrderedMap . emptyOf < K , V > ( ) . putAll ( this )

/**
 * Returns a persistent map containing all entries from this map.
 *
 * If the receiver is already a persistent map, returns it as is.
 * If the receiver is a persistent map builder, calls `build` on it and returns the result.
 *
 * Entries of the returned map are iterated in the same order as in this map.
 */


public fun < K , V > Map < K , V > . toPersistentHashMap ( ) : PersistentMap < K , V > <EOL>

= this as? PersistentHashMap <EOL> ? : ( this as? PersistentHashMapBuilder < K , V > ) ? . build ( ) <EOL> ? : PersistentHashMap . emptyOf < K , V > ( ) . putAll ( this )

/**
 * Returns an immutable map containing all entries from this map.
 *
 * If the receiver is already a persistent hash map, returns it as is.
 * If the receiver is a persistent hash map builder, calls `build` on it and returns the result.
 *
 * Order of the entries in the returned map is unspecified.
 */


@ FormatStringsInDatetimeFormats <EOL> public fun DateTimeFormatBuilder . byUnicodePattern ( pattern : String )

{ <EOL> val directives = UnicodeFormat . parse ( pattern ) <EOL> fun rec ( builder : DateTimeFormatBuilder , format : UnicodeFormat ) { <EOL> when ( format ) { <EOL> is UnicodeFormat . StringLiteral -> builder . chars ( format . literal ) <EOL> is UnicodeFormat . Sequence -> format . formats . forEach { rec ( builder , it ) } <EOL> is UnicodeFormat . OptionalGroup -> builder . alternativeParsing ( { } ) { <EOL> rec ( this , format . format ) <EOL> } <EOL> is UnicodeFormat . Directive -> { <EOL> when ( format ) { <EOL> is UnicodeFormat . Directive . TimeBased -> { <EOL> require ( builder is DateTimeFormatBuilder . WithTime ) { <EOL> "<STR_LIT>" <EOL> } <EOL> format . addToFormat ( builder ) <EOL> } <EOL> is UnicodeFormat . Directive . DateBased -> { <EOL> require ( builder is DateTimeFormatBuilder . WithDate ) { <EOL> "<STR_LIT>" <EOL> } <EOL> format . addToFormat ( builder ) <EOL> } <EOL> is UnicodeFormat . Directive . ZoneBased -> { <EOL> require ( builder is DateTimeFormatBuilder . WithDateTimeComponents ) { <EOL> "<STR_LIT>" <EOL> } <EOL> format . addToFormat ( builder ) <EOL> } <EOL> is UnicodeFormat . Directive . OffsetBased -> { <EOL> require ( builder is DateTimeFormatBuilder . WithUtcOffset ) { <EOL> "<STR_LIT>" <EOL> } <EOL> format . addToFormat ( builder ) <EOL> } <EOL> is UnknownUnicodeDirective -> { <EOL> throw IllegalArgumentException ( "<STR_LIT>" ) <EOL> } <EOL> } <EOL> } <EOL> } <EOL> } <EOL> rec ( this , directives ) <EOL> }

/**
 * Appends a Unicode date/time format string to the [DateTimeFormatBuilder].
 *
 * This is the format string syntax used by the Java Time's `DateTimeFormatter` class, Swift's and Objective-C's
 * `NSDateFormatter` class, and the ICU library.
 * The syntax is specified at
 * <https://unicode-org.github.io/icu/userguide/format_parse/datetime/#datetime-format-syntax>.
 *
 * Currently, locale-aware directives are not supported, due to no locale support in Kotlin.
 *
 * In addition to the standard syntax, this function also supports the following extensions:
 * * `[]` denote optional sections. For example, `hh:mm[:ss]` will allow parsing seconds optionally.
 * This is similar to what is supported by the Java Time's `DateTimeFormatter` class.
 *
 * Usage example:
 * ```
 * DateTimeComponents.Format {
 * // 2023-01-20T23:53:16.312+03:30[Asia/Tehran]
 * byUnicodePattern("uuuu-MM-dd'T'HH:mm[:ss[.SSS]]xxxxx'['VV']'")
 * }
 * ```
 *
 * The list of supported directives is as follows:
 *
 * | **Directive** | **Meaning** |
 * | `'string'` | literal `string`, without quotes |
 * | `'''` | literal char `'` |
 * | `[fmt]` | equivalent to `fmt` during formatting, but during parsing also accepts the empty string |
 * | `u` | ISO year without padding |
 * | `uu` | last two digits of the ISO year, with the base year 2000 |
 * | `uuuu` | ISO year, zero-padded to four digits |
 * | `M`, `L` | month number (1-12), without padding |
 * | `MM`, `LL` | month number (01-12), zero-padded to two digits |
 * | `d` | day-of-month (1-31), without padding |
 * | `H` | hour-of-day (0-23), without padding |
 * | `HH` | hour-of-day (00-23), zero-padded to two digits |
 * | `m` | minute-of-hour (0-59), without padding |
 * | `mm` | minute-of-hour (00-59), zero-padded to two digits |
 * | `s` | second-of-hour (0-59), without padding |
 * | `ss` | second-of-hour (00-59), zero-padded to two digits |
 * | `S`, `SS`, `SSS`... | fraction-of-second without a leading dot, with as many digits as the format length |
 * | `VV` | timezone name (for example, `Europe/Berlin`) |
 *
 * The UTC offset is formatted using one of the following directives. In every one of these formats, hours, minutes,
 * and seconds are zero-padded to two digits. Also, hours are unconditionally present.
 *
 * | **Directive** | **Minutes** | **Seconds** | **Separator** | **Representation of zero** |
 * | `X` | unless zero | never | none | `Z` |
 * | `XX` | always | never | none | `Z` |
 * | `XXX` | always | never | colon | `Z` |
 * | `XXXX` | always | unless zero | none | `Z` |
 * | `XXXXX`, `ZZZZZ` | always | unless zero | colon | `Z` |
 * | `x` | unless zero | never | none | `+00` |
 * | `xx`, `Z`, `ZZ`, `ZZZ` | always | never | none | `+0000` |
 * | `xxx` | always | never | colon | `+00:00` |
 * | `xxxx` | always | unless zero | none | `+0000` |
 * | `xxxxx` | always | unless zero | colon | `+00:00` |
 *
 * Additionally, because the `y` directive is very often used instead of `u`, they are taken to mean the same.
 * This may lead to unexpected results if the year is negative: `y` would always produce a positive number, whereas
 * `u` may sometimes produce a negative one. For example:
 * ```
 * LocalDate(-10, 1, 5).format { byUnicodeFormat("yyyy-MM-dd") } // -0010-01-05
 * LocalDate(-10, 1, 5).toJavaLocalDate().format(java.time.format.DateTimeFormatter.ofPattern("yyyy-MM-dd")) // 0011-01-05
 * ```
 *
 * Note that, when the format includes the era directive, [byUnicodePattern] will fail with an exception, so almost all
 * of the intentional usages of `y` will correctly report an error instead of behaving slightly differently.
 *
 * @throws IllegalArgumentException if the pattern is invalid or contains unsupported directives.
 * @throws IllegalArgumentException if the builder is incompatible with the specified directives.
 * @throws UnsupportedOperationException if the kotlinx-datetime library does not support the specified directives.
 */


abstract fun accepts ( startIndex : Int , testString : CharSequence ) : Int

/** Returns "shift", the number of accepted chars. Commonly internal function, but called by quantifiers. */


override fun matches ( startIndex : Int , testString : CharSequence , matchResult : MatchResultImpl ) : Int

{ <EOL> if ( startIndex + charCount > testString . length ) { <EOL> return - <NUM_LIT:1> <EOL> } <EOL> val shift = accepts ( startIndex , testString ) <EOL> if ( shift < <NUM_LIT:0> ) { <EOL> return - <NUM_LIT:1> <EOL> } <EOL> return next . matches ( startIndex + shift , testString , matchResult ) <EOL> }

/**
 * Checks if we can enter this state and pass the control to the next one.
 * Return positive value if match succeeds, negative otherwise.
 */


public fun < A : AutoCloseable , R > List < A > . use ( block : ( List < A > ) -> R ) : R

{ <EOL> if ( isEmpty ( ) ) return block ( this ) <EOL> var exception : Throwable ? = null <EOL> try { <EOL> return block ( this ) <EOL> } catch ( e : Throwable ) { <EOL> exception = e <EOL> throw e <EOL> } finally { <EOL> closeSafely ( exception ) <EOL> } <EOL> }

/**
 * Executes the given [block] function on this resource list and closes the resources correctly
 * even when exception is thrown from the block. Similar to [kotlin.use] extension.
 */


public fun < K , A : AutoCloseable , R > Map < K , A > . use ( block : ( Map < K , A > ) -> R ) : R

{ <EOL> if ( isEmpty ( ) ) return block ( this ) <EOL> var exception : Throwable ? = null <EOL> try { <EOL> return block ( this ) <EOL> } catch ( e : Throwable ) { <EOL> exception = e <EOL> throw e <EOL> } finally { <EOL> values . closeSafely ( exception ) <EOL> } <EOL> }

/**
 * Executes the given [block] function on this resources map and closes the resources correctly
 * even when exception is thrown from the block. Similar to [kotlin.use] extension.
 */


private fun ConeInferenceContext . getCompatibility ( upperBounds : Set < ConeClassLikeType > , lowerBounds : Set < ConeClassLikeType > , compatibilityUpperBound : Compatibility , checkedTypeParameters : MutableSet < FirTypeParameterSymbol > = mutableSetOf ( ) , ) : Compatibility

{ <EOL> val upperBoundClasses : Set < FirClassWithSuperClasses > = upperBounds . mapNotNull { it . toFirClassWithSuperClasses ( this ) } . toSet ( ) <EOL> if ( lowerBounds . isEmpty ( ) && ( upperBounds . size < <NUM_LIT:2> || this . areClassesOrInterfacesCompatible ( upperBoundClasses , compatibilityUpperBound ) == Compatibility . COMPATIBLE ) ) { <EOL> return Compatibility . COMPATIBLE <EOL> } <EOL> if ( upperBounds . any { it . classId == javaClassClassId || it . classId == kotlinClassClassId } ) return Compatibility . COMPATIBLE <EOL> val leafClassesOrInterfaces = computeLeafClassesOrInterfaces ( upperBoundClasses ) <EOL> this . areClassesOrInterfacesCompatible ( leafClassesOrInterfaces , compatibilityUpperBound ) ? . let { return it } <EOL> if ( ! lowerBounds . all { lowerBoundType -> <EOL> val classesSatisfyingLowerBounds = <EOL> lowerBoundType . toFirClassWithSuperClasses ( this ) ? . thisAndAllSuperClasses ? : emptySet ( ) <EOL> leafClassesOrInterfaces . all { it in classesSatisfyingLowerBounds } <EOL> } ) { <EOL> return compatibilityUpperBound <EOL> } <EOL> if ( upperBounds . size < <NUM_LIT:2> ) return Compatibility . COMPATIBLE <EOL> val typeArgumentMapping = mutableMapOf < FirTypeParameterSymbol , BoundTypeArguments > ( ) . apply { <EOL> for ( type in upperBounds ) { <EOL> collectTypeArgumentMapping ( type , this @ getCompatibility , compatibilityUpperBound ) <EOL> } <EOL> } <EOL> var result = Compatibility . COMPATIBLE <EOL> val typeArgsCompatibility = typeArgumentMapping . asSequence ( ) <EOL> . map { ( paramRef , boundTypeArguments ) -> <EOL> val ( upper , lower , compatibility ) = boundTypeArguments <EOL> if ( paramRef in checkedTypeParameters ) { <EOL> Compatibility . COMPATIBLE <EOL> } else { <EOL> checkedTypeParameters . add ( paramRef ) <EOL> getCompatibility ( upper , lower , compatibility , checkedTypeParameters ) <EOL> } <EOL> } <EOL> for ( compatibility in typeArgsCompatibility ) { <EOL> if ( compatibility == compatibilityUpperBound ) return compatibility <EOL> if ( compatibility > result ) { <EOL> result = compatibility <EOL> } <EOL> } <EOL> return result <EOL> }

/**
 * @param compatibilityUpperBound the max compatibility result that can be returned by this method. For example, if this is set to
 * [Compatibility.SOFT_INCOMPATIBLE], then even if the given bounds don't match the hard way (for example, incompatible primitives) the
 * method should still return [Compatibility.SOFT_INCOMPATIBLE]. This is useful for checking type parameters since we don't want to
 * dictate what semantics a type parameter may have in user code. In other words, if user wants to compare `MyCustom<out String>` with
 * `MyCustom<out Int>`, we let them do so since we do not know what class `MyCustom` uses the type parameter for. Empty containers are
 * another example: `emptyList<Int>() == emptyList<String>()`.
 */


private fun computeLeafClassesOrInterfaces ( upperBoundClasses : Set < FirClassWithSuperClasses > ) : Set < FirClassWithSuperClasses >

{ <EOL> val isLeaf = mutableMapOf < FirClassWithSuperClasses , Boolean > ( ) <EOL> upperBoundClasses . associateWithTo ( isLeaf ) { true } <EOL> val queue = ArrayDeque ( upperBoundClasses ) <EOL> while ( queue . isNotEmpty ( ) ) { <EOL> for ( superClass in queue . removeFirst ( ) . superClasses ) { <EOL> when ( isLeaf [ superClass ] ) { <EOL> true -> isLeaf [ superClass ] = false <EOL> false -> { <EOL> } <EOL> else -> { <EOL> isLeaf [ superClass ] = false <EOL> queue . addLast ( superClass ) <EOL> } <EOL> } <EOL> } <EOL> } <EOL> return isLeaf . filterValues { it } . keys <EOL> }

/**
 * Puts the upper bound classes into the class hierarchy and count hows many subclasses are there for each encountered class. Then
 * output a list of leaf classes or interfaces in the class hierarchy.
 */


private fun ConeInferenceContext . areClassesOrInterfacesCompatible ( classesOrInterfaces : Collection < FirClassWithSuperClasses > , compatibilityUpperBound : Compatibility ) : Compatibility ?

{ <EOL> val classes = classesOrInterfaces . filter { ! it . isInterface } <EOL> if ( classes . size >= <NUM_LIT:2> ) { <EOL> return if ( classes . any { it . getHasPredefinedEqualityContract ( this ) } ) { <EOL> compatibilityUpperBound <EOL> } else { <EOL> Compatibility . SOFT_INCOMPATIBLE <EOL> } <EOL> } <EOL> val finalClass = classes . firstOrNull { it . isFinal } ? : return null <EOL> if ( classesOrInterfaces . size > classes . size ) { <EOL> return if ( finalClass . getHasPredefinedEqualityContract ( this ) ) { <EOL> compatibilityUpperBound <EOL> } else { <EOL> Compatibility . SOFT_INCOMPATIBLE <EOL> } <EOL> } <EOL> return null <EOL> }

/**
 * Checks whether the given classes are compatible. In other words, check if it's possible for objects of the given classes to be
 * considered equal by [Any.equals].
 *
 * @return null if this check is inconclusive
 */


private fun MutableMap < FirTypeParameterSymbol , BoundTypeArguments > . collectTypeArgumentMapping ( coneType : ConeClassLikeType , ctx : ConeInferenceContext , compatibilityUpperBound : Compatibility )

{ <EOL> val queue = ArrayDeque < TypeArgumentMapping > ( ) <EOL> queue . addLast ( coneType . toTypeArgumentMapping ( ctx ) ? : return ) <EOL> while ( queue . isNotEmpty ( ) ) { <EOL> val ( typeParameterOwner , mapping ) = queue . removeFirst ( ) <EOL> val superTypes = typeParameterOwner . getSuperTypes ( ) <EOL> for ( superType in superTypes ) { <EOL> queue . addLast ( superType . toTypeArgumentMapping ( ctx , mapping ) ? : continue ) <EOL> } <EOL> for ( ( firTypeParameterRef , boundTypeArgument ) in mapping ) { <EOL> this . collect ( ctx , typeParameterOwner , firTypeParameterRef , boundTypeArgument , compatibilityUpperBound ) <EOL> } <EOL> } <EOL> }

/**
 * For each type parameters appeared in the class hierarchy, collect all type arguments that eventually mapped to it. For example,
 * given type `List<String>`, the returned map contains
 *
 * - type parameter of `List` -> upper:[`String`], lower:[]
 * - type parameter of `Collection` -> upper:[`String`], lower:[]
 * - type parameter of `Iterable` -> upper:[`String`], lower:[]
 *
 * If later `Collection<Int>` is passed to this method with the same receiver map, the receiver map would become:
 *
 * - type parameter of `List` -> upper:[`String`], lower:[]
 * - type parameter of `Collection` -> upper:[`String`, `Int`], lower:[]
 * - type parameter of `Iterable` -> upper:[`String`, `Int`], lower:[]
 */


private fun ConeClassLikeType . toTypeArgumentMapping ( ctx : ConeInferenceContext , envMapping : Map < FirTypeParameterSymbol , BoundTypeArgument > = emptyMap ( ) , ) : TypeArgumentMapping ?

{ <EOL> val typeParameterOwner = getClassLikeElement ( ctx ) ? : return null <EOL> val mapping = buildMap < FirTypeParameterSymbol , BoundTypeArgument > { <EOL> typeArguments . forEachIndexed { index , coneTypeProjection -> <EOL> val typeParameter = typeParameterOwner . getTypeParameter ( index ) ? : return@forEachIndexed <EOL> var boundTypeArgument : BoundTypeArgument = when ( coneTypeProjection ) { <EOL> ConeStarProjection -> return@forEachIndexed <EOL> is ConeKotlinTypeProjectionIn -> BoundTypeArgument ( coneTypeProjection . type , Variance . IN_VARIANCE ) <EOL> is ConeKotlinTypeProjectionOut -> BoundTypeArgument ( coneTypeProjection . type , Variance . OUT_VARIANCE ) <EOL> is ConeKotlinTypeConflictingProjection -> BoundTypeArgument ( coneTypeProjection . type , Variance . INVARIANT ) <EOL> is ConeKotlinType -> <EOL> when ( typeParameter . variance ) { <EOL> Variance . IN_VARIANCE -> BoundTypeArgument ( coneTypeProjection . type , Variance . IN_VARIANCE ) <EOL> Variance . OUT_VARIANCE -> BoundTypeArgument ( coneTypeProjection . type , Variance . OUT_VARIANCE ) <EOL> else -> BoundTypeArgument ( coneTypeProjection . type , Variance . INVARIANT ) <EOL> } <EOL> } <EOL> val coneKotlinType = boundTypeArgument . type <EOL> if ( coneKotlinType is ConeTypeParameterType ) { <EOL> val envTypeParameter = coneKotlinType . lookupTag . typeParameterSymbol <EOL> val envTypeArgument = envMapping [ envTypeParameter ] <EOL> if ( envTypeArgument != null ) { <EOL> boundTypeArgument = envTypeArgument <EOL> } <EOL> } <EOL> put ( typeParameter , boundTypeArgument ) <EOL> } <EOL> } <EOL> return TypeArgumentMapping ( typeParameterOwner , mapping ) <EOL> }

/** Converts type arguments in a [ConeClassLikeType] to a [TypeArgumentMapping]. */


fun getHasPredefinedEqualityContract ( ctx : ConeInferenceContext ) : Boolean

{ <EOL> return ( ctx . prohibitComparisonOfIncompatibleEnums && ( firClass . isEnumClass || firClass . classId == StandardClassIds . Enum ) ) || <EOL> firClass . isPrimitiveType ( ) || <EOL> ( ctx . prohibitComparisonOfIncompatibleClasses && firClass . classId == StandardClassIds . KClass ) || <EOL> firClass . classId == StandardClassIds . String || firClass . classId == StandardClassIds . Unit || <EOL> ( firClass is FirRegularClassSymbol && ( firClass . isData || firClass . isInline ) ) <EOL> }

/**
 * The following are considered to have a predefined equality contract:
 * - enums
 * - primitives (including unsigned integer types)
 * - classes
 * - strings
 * - objects of data classes
 * - objects of inline classes
 * - kotlin.Unit
 */


public open fun onEpochBegin ( epoch : Int , logs : TrainingHistory )

/**
 * Called at the start of an epoch during training phase.
 *
 * @param [epoch] index of epoch.
 * @param [logs] training history, containing full information about previous epochs.
 */


public open fun onEpochEnd ( epoch : Int , event : EpochTrainingEvent , logs : TrainingHistory )

/**
 * Called at the end of an epoch during training phase.
 *
 * @param [epoch] index of epoch.
 * @param [event] metric results for this training epoch, and for the
 * validation epoch if validation is performed.
 * @param [logs] training history, containing full information about previous epochs.
 */


public open fun onTrainBatchBegin ( batch : Int , batchSize : Int , logs : TrainingHistory )

/**
 * Called at the beginning of a batch during training phase.
 *
 * @param [batch] the batch index.
 * @param [batchSize] Number of samples in the current batch.
 * @param [logs] training history, containing full information about previous epochs.
 */


public open fun onTrainBatchEnd ( batch : Int , batchSize : Int , event : BatchTrainingEvent , logs : TrainingHistory )

/**
 * Called at the end of a batch during training phase.
 *
 * @param [batch] index of batch within the current epoch.
 * @param [batchSize] Number of samples in the current batch.
 * @param [event] Metric and loss values for this batch.
 * @param [logs] training history, containing full information about previous epochs.
 */


/**
 * Called at the beginning of training.
 */


public open fun onTrainEnd ( logs : TrainingHistory )

/**
 * Called at the end of training. This method is empty. Extend this class to
 * handle this event.
 *
 * @param [logs] training history, containing full information about previous epochs.
 */


public open fun onTestBatchBegin ( batch : Int , batchSize : Int , logs : History )

/**
 * Called at the beginning of a batch during evaluation phase. Also called at
 * the beginning of a validation batch during validation phase, if validation
 * data is provided.
 *
 * @param [batch] the batch number
 * @param [batchSize] Number of samples in the current batch.
 * @param [logs] training history, containing full information about previous epochs.
 */


public open fun onTestBatchEnd ( batch : Int , batchSize : Int , event : BatchEvent ? , logs : History )

/**
 * Called at the end of a batch during evaluation phase. Also called at the
 * end of a validation batch during validation phase, if validation data is
 * provided.
 *
 * @param [batch] the batch number
 * @param [batchSize] Number of samples in the current batch.
 * @param [event] Metric and loss values for this batch.
 * @param [logs] training history, containing full information about previous epochs.
 */


/**
 * Called at the beginning of evaluation or validation.
 */


public open fun onTestEnd ( logs : History )

/**
 * Called at the end of evaluation or validation.
 *
 * @param [logs] evaluation history, containing full information about previous batches.
 */


public open fun onPredictBatchBegin ( batch : Int , batchSize : Int )

/**
 * Called at the beginning of a batch during prediction phase.
 *
 * @param [batch] index of batch.
 * @param [batchSize] Number of samples in the current batch.
 */


public open fun onPredictBatchEnd ( batch : Int , batchSize : Int )

/**
 * Called at the end of a batch during prediction phase.
 *
 * @param [batch] index of batch within the current epoch.
 * @param [batchSize] Number of samples in the current batch.
 */


/**
 * Called at the beginning of prediction.
 */


/**
 * Called at the end of prediction.
 */


suspend fun eval ( snippet : LinkedSnippet < out CompiledSnippetT > , configuration : ScriptEvaluationConfiguration ) : ResultWithDiagnostics < LinkedSnippet < EvaluatedSnippetT > >

/**
 * Evaluates compiled snippet and returns result for it.
 * Should assert that snippet sequence is valid.
 * @param snippet Snippet to evaluate.
 * @param configuration Evaluation configuration used.
 * @return Evaluation result
 */


protected fun declarationsWithSignature ( signature : Signature ) : Set < Declaration >

= <EOL> declarationsBySignature [ signature ] ? : emptySet ( )

/**
 * Returns all the declarations that have [signature] previously recorded by [trackDeclaration].
 */


fun trackDeclaration ( declaration : Declaration , rawSignature : Signature )

{ <EOL> declarationsBySignature . computeIfAbsent ( rawSignature ) { SmartSet . create ( ) } . add ( declaration ) <EOL> }

/**
 * Records the declaration, so it could later participate in signature clash detection.
 */


protected abstract fun reportSignatureConflict ( signature : Signature , declarations : Collection < Declaration > , diagnosticReporter : IrDiagnosticReporter , )

/**
 * Invoked by [reportErrorsTo] whenever at least two declarations with the same [signature] are detected.
 *
 * Use [reportSignatureClashTo] in the implementation to report a diagnostic.
 */


open fun reportErrorsTo ( diagnosticReporter : IrDiagnosticReporter )

{ <EOL> for ( ( signature , declarations ) in declarationsBySignature ) { <EOL> if ( declarations . size <= <NUM_LIT:1> ) continue <EOL> reportSignatureConflict ( signature , declarations , diagnosticReporter ) <EOL> } <EOL> }

/**
 * Reports all detected signature clashes.
 */


public fun ColumnSet < * > . colsInGroups ( predicate : ColumnFilter < * > = { true } ) : TransformableColumnSet < * >

= <EOL> transform { it . flatMap { it . cols ( ) . filter { predicate ( it ) } } }

/**
 * @include [ColsInGroupsDocs]
 * @set [ColsInGroupsDocs.ExampleArg]
 *
 * `df.`[select][DataFrame.select]` { `[cols][ColumnsSelectionDsl.cols]` { .. }.`[colsInGroups][ColumnSet.colsInGroups]` { "my" `[in][String.contains]` it.`[name][DataColumn.name]` } }`
 *
 * `df.`[select][DataFrame.select]` { `[colsOf][ColumnsSelectionDsl.colsOf]`<`[DataRow][DataRow]`<MyGroupType>>().`[colsInGroups][ColumnSet.colsInGroups]`() }`
 */


public fun ColumnsSelectionDsl < * > . colsInGroups ( predicate : ColumnFilter < * > = { true } ) : TransformableColumnSet < * >

= <EOL> asSingleColumn ( ) . colsInGroups ( predicate )

/**
 * @include [ColsInGroupsDocs]
 * @set [ColsInGroupsDocs.ExampleArg]
 *
 * `df.`[select][DataFrame.select]` { `[colsInGroups][ColumnSet.colsInGroups]` { "my" `[in][String.contains]` it.`[name][DataColumn.name]` } }`
 *
 * `df.`[select][DataFrame.select]` { `[colsInGroups][ColumnSet.colsInGroups]`() }`
 */


public fun SingleColumn < DataRow < * > > . colsInGroups ( predicate : ColumnFilter < * > = { true } ) : TransformableColumnSet < * >

= <EOL> ensureIsColumnGroup ( ) . allColumnsInternal ( ) . colsInGroups ( predicate )

/**
 * @include [ColsInGroupsDocs]
 * @set [ColsInGroupsDocs.ExampleArg]
 *
 * `df.`[select][DataFrame.select]` { myColumnGroup.`[colsInGroups][SingleColumn.colsInGroups]`() }`
 *
 * `df.`[select][DataFrame.select]` { myColumnGroup.`[colsInGroups][SingleColumn.colsInGroups]` { it.`[any][ColumnWithPath.any]` { it == "Alice" } } }`
 */


public fun String . colsInGroups ( predicate : ColumnFilter < * > = { true } ) : TransformableColumnSet < * >

= <EOL> columnGroup ( this ) . colsInGroups ( predicate )

/**
 * @include [ColsInGroupsDocs]
 * @set [ColsInGroupsDocs.ExampleArg]
 *
 * `df.`[select][DataFrame.select]` { "myColumnGroup".`[colsInGroups][String.colsInGroups]`() }`
 */


public fun KProperty < * > . colsInGroups ( predicate : ColumnFilter < * > = { true } ) : TransformableColumnSet < * >

/**
 * @include [ColsInGroupsDocs]
 * @set [ColsInGroupsDocs.ExampleArg]
 *
 * `df.`[select][DataFrame.select]` { Type::myColumnGroup.`[colsInGroups][KProperty.colsInGroups]`() }`
 *
 * `df.`[select][DataFrame.select]` { DataSchemaType::myColumnGroup.`[colsInGroups][KProperty.colsInGroups]`() }`
 */


public fun ColumnPath . colsInGroups ( predicate : ColumnFilter < * > = { true } ) : TransformableColumnSet < * >

/**
 * @include [ColsInGroupsDocs]
 * @set [ColsInGroupsDocs.ExampleArg]
 *
 * `df.`[select][DataFrame.select]` { "pathTo"["myColumnGroup"].`[colsInGroups][ColumnPath.colsInGroups]`() }`
 */


fun loadModelWithoutWeightsInitAndEvaluate ( )

{ <EOL> val ( _ , test ) = fashionMnist ( ) <EOL> val jsonConfigFile = getJSONConfigFile ( ) <EOL> val model = Sequential . loadModelConfiguration ( jsonConfigFile ) <EOL> model . use { <EOL> it . compile ( optimizer = Adam ( ) , loss = Losses . SOFT_MAX_CROSS_ENTROPY_WITH_LOGITS , metric = Metrics . ACCURACY ) <EOL> it . init ( ) <EOL> it . logSummary ( ) <EOL> val accuracy = it . evaluate ( dataset = test , batchSize = <NUM_LIT:100> ) . metrics [ Metrics . ACCURACY ] <EOL> println ( "<STR_LIT>" ) <EOL> } <EOL> }

/**
 * This example demonstrates the weird inference case:
 * - Weights are not loaded, but initialized via initialized defined in configuration, configuration is loaded from .json file.
 * - Model is evaluated after loading to obtain accuracy value.
 * - No additional training.
 * - No new layers are added.
 *
 * NOTE: Model and weights are resources in `examples` module.
 */


= loadModelWithoutWeightsInitAndEvaluate ( )


public fun format ( value : T ) : String

/**
 * Formats the given [value] into a string, using this format.
 */


public fun < A : Appendable > formatTo ( appendable : A , value : T ) : A

/**
 * Formats the given [value] into the given [appendable] using this format.
 */


public fun parse ( input : CharSequence ) : T

/**
 * Parses the given [input] string as [T] using this format.
 *
 * @throws IllegalArgumentException if the input string is not in the expected format or the value is invalid.
 */


public fun parseOrNull ( input : CharSequence ) : T ?

/**
 * Parses the given [input] string as [T] using this format.
 *
 * @return the parsed value, or `null` if the input string is not in the expected format or the value is invalid.
 */


public fun formatAsKotlinBuilderDsl ( format : DateTimeFormat < * > ) : String

= when ( format ) { <EOL> is AbstractDateTimeFormat < * , * > -> format . actualFormat . builderString ( allFormatConstants ) <EOL> }

/**
 * Produces Kotlin code that, when pasted into a Kotlin source file, creates a [DateTimeFormat] instance that
 * behaves identically to [format].
 *
 * The typical use case for this is to create a [DateTimeFormat] instance using a non-idiomatic approach and
 * then convert it to a builder DSL.
 */


public fun updateThreadContext ( context : CoroutineContext ) : S

/**
 * Updates context of the current thread.
 * This function is invoked before the coroutine in the specified [context] is resumed in the current thread
 * when the context of the coroutine this element.
 * The result of this function is the old value of the thread-local state that will be passed to [restoreThreadContext].
 * This method should handle its own exceptions and do not rethrow it. Thrown exceptions will leave coroutine which
 * context is updated in an undefined state and may crash an application.
 *
 * @param context the coroutine context.
 */


public fun restoreThreadContext ( context : CoroutineContext , oldState : S )

/**
 * Restores context of the current thread.
 * This function is invoked after the coroutine in the specified [context] is suspended in the current thread
 * if [updateThreadContext] was previously invoked on resume of this coroutine.
 * The value of [oldState] is the result of the previous invocation of [updateThreadContext] and it should
 * be restored in the thread-local state by this function.
 * This method should handle its own exceptions and do not rethrow it. Thrown exceptions will leave coroutine which
 * context is updated in an undefined state and may crash an application.
 *
 * @param context the coroutine context.
 * @param oldState the value returned by the previous invocation of [updateThreadContext].
 */


public fun copyForChild ( ) : CopyableThreadContextElement < S >

/**
 * Returns a [CopyableThreadContextElement] to replace `this` `CopyableThreadContextElement` in the child
 * coroutine's context that is under construction if the added context does not contain an element with the same [key].
 *
 * This function is called on the element each time a new coroutine inherits a context containing it,
 * and the returned value is folded into the context given to the child.
 *
 * Since this method is called whenever a new coroutine is launched in a context containing this
 * [CopyableThreadContextElement], implementations are performance-sensitive.
 */


public fun mergeForChild ( overwritingElement : CoroutineContext . Element ) : CoroutineContext

/**
 * Returns a [CopyableThreadContextElement] to replace `this` `CopyableThreadContextElement` in the child
 * coroutine's context that is under construction if the added context does contain an element with the same [key].
 *
 * This method is invoked on the original element, accepting as the parameter
 * the element that is supposed to overwrite it.
 */


public fun < T > ThreadLocal < T > . asContextElement ( value : T = get ( ) ) : ThreadContextElement < T >

= <EOL> ThreadLocalElement ( value , this )

/**
 * Wraps [ThreadLocal] into [ThreadContextElement]. The resulting [ThreadContextElement]
 * maintains the given [value] of the given [ThreadLocal] for coroutine regardless of the actual thread its is resumed on.
 * By default [ThreadLocal.get] is used as a value for the thread-local variable, but it can be overridden with [value] parameter.
 * Beware that context element **does not track** modifications of the thread-local and accessing thread-local from coroutine
 * without the corresponding context element returns **undefined** value. See the examples for a detailed description.
 *
 *
 * Example usage:
 * ```
 * val myThreadLocal = ThreadLocal<String?>()
 * ...
 * println(myThreadLocal.get()) // Prints "null"
 * launch(Dispatchers.Default + myThreadLocal.asContextElement(value = "foo")) {
 * println(myThreadLocal.get()) // Prints "foo"
 * withContext(Dispatchers.Main) {
 * println(myThreadLocal.get()) // Prints "foo", but it's on UI thread
 * }
 * }
 * println(myThreadLocal.get()) // Prints "null"
 * ```
 *
 * The context element does not track modifications of the thread-local variable, for example:
 *
 * ```
 * myThreadLocal.set("main")
 * withContext(Dispatchers.Main) {
 * println(myThreadLocal.get()) // Prints "main"
 * myThreadLocal.set("UI")
 * }
 * println(myThreadLocal.get()) // Prints "main", not "UI"
 * ```
 *
 * Use `withContext` to update the corresponding thread-local variable to a different value, for example:
 * ```
 * withContext(myThreadLocal.asContextElement("foo")) {
 * println(myThreadLocal.get()) // Prints "foo"
 * }
 * ```
 *
 * Accessing the thread-local without corresponding context element leads to undefined value:
 * ```
 * val tl = ThreadLocal.withInitial { "initial" }
 *
 * runBlocking {
 * println(tl.get()) // Will print "initial"
 * // Change context
 * withContext(tl.asContextElement("modified")) {
 * println(tl.get()) // Will print "modified"
 * }
 * // Context is changed again
 * println(tl.get()) // <- WARN: can print either "modified" or "initial"
 * }
 * ```
 * to fix this behaviour use `runBlocking(tl.asContextElement())`
 */


public suspend inline fun ThreadLocal < * > . isPresent ( ) : Boolean

= coroutineContext [ ThreadLocalKey ( this ) ] !== null

/**
 * Return `true` when current thread local is present in the coroutine context, `false` otherwise.
 * Thread local can be present in the context only if it was added via [asContextElement] to the context.
 *
 * Example of usage:
 * ```
 * suspend fun processRequest() {
 * if (traceCurrentRequestThreadLocal.isPresent()) { // Probabilistic tracing
 * // Do some heavy-weight tracing
 * }
 * // Process request regularly
 * }
 * ```
 */


public suspend inline fun ThreadLocal < * > . ensurePresent ( ) : Unit

= <EOL> check ( isPresent ( ) ) { "<STR_LIT>" }

/**
 * Checks whether current thread local is present in the coroutine context and throws [IllegalStateException] if it is not.
 * It is a good practice to validate that thread local is present in the context, especially in large code-bases,
 * to avoid stale thread-local values and to have a strict invariants.
 *
 * E.g. one may use the following method to enforce proper use of the thread locals with coroutines:
 * ```
 * public suspend inline fun <T> ThreadLocal<T>.getSafely(): T {
 * ensurePresent()
 * return get()
 * }
 *
 * // Usage
 * withContext(...) {
 * val value = threadLocal.getSafely() // Fail-fast in case of improper context
 * }
 * ```
 */


= runTest { <EOL> expect ( <NUM_LIT:1> ) <EOL> val result = withTimeout ( <NUM_LIT:10> . seconds ) { <EOL> expect ( <NUM_LIT:2> ) <EOL> "<STR_LIT:OK>" <EOL> } <EOL> assertEquals ( "<STR_LIT:OK>" , result ) <EOL> finish ( <NUM_LIT:3> ) <EOL> }

/**
 * Tests a case of no timeout and no suspension inside.
 */


= runTest { <EOL> expect ( <NUM_LIT:1> ) <EOL> val result = withTimeout ( <NUM_LIT:10> . seconds ) { <EOL> expect ( <NUM_LIT:2> ) <EOL> yield ( ) <EOL> expect ( <NUM_LIT:3> ) <EOL> "<STR_LIT:OK>" <EOL> } <EOL> assertEquals ( "<STR_LIT:OK>" , result ) <EOL> finish ( <NUM_LIT:4> ) <EOL> }

/**
 * Tests a case of no timeout and one suspension inside.
 */


= runTest { <EOL> expect ( <NUM_LIT:1> ) <EOL> launch { <EOL> expect ( <NUM_LIT:4> ) <EOL> yield ( ) <EOL> expect ( <NUM_LIT:7> ) <EOL> } <EOL> expect ( <NUM_LIT:2> ) <EOL> val result = withTimeout ( <NUM_LIT:1> . seconds ) { <EOL> expect ( <NUM_LIT:3> ) <EOL> yield ( ) <EOL> expect ( <NUM_LIT:5> ) <EOL> "<STR_LIT:OK>" <EOL> } <EOL> assertEquals ( "<STR_LIT:OK>" , result ) <EOL> expect ( <NUM_LIT:6> ) <EOL> yield ( ) <EOL> finish ( <NUM_LIT:8> ) <EOL> }

/**
 * Tests proper dispatching of `withTimeout` blocks
 */


@ Test <EOL> fun testYieldBlockingWithTimeout ( )

= runTest ( expected = { it is CancellationException } ) { <EOL> withTimeout ( <NUM_LIT:100> . milliseconds ) { <EOL> while ( true ) { <EOL> yield ( ) <EOL> } <EOL> } <EOL> }

/**
 * Tests that a 100% CPU-consuming loop will react on timeout if it has yields.
 */


@ Test <EOL> fun testWithTimeoutChildWait ( )

= runTest { <EOL> expect ( <NUM_LIT:1> ) <EOL> withTimeout ( <NUM_LIT:100> . milliseconds ) { <EOL> expect ( <NUM_LIT:2> ) <EOL> launch { <EOL> expect ( <NUM_LIT:4> ) <EOL> } <EOL> expect ( <NUM_LIT:3> ) <EOL> } <EOL> finish ( <NUM_LIT:5> ) <EOL> }

/**
 * Tests that [withTimeout] waits for children coroutines to complete.
 */


open fun getAndSemiFixCurrentResultIfTypeVariable ( type : ConeKotlinType ) : ConeKotlinType ?

= null

/**
 * For non-trivial inference session (currently PCLA-only), if the type is a type variable that might be fixed,
 * fix it and return a fixation result.
 *
 * Type variable might be fixed if it doesn't belong to an outer CS and have proper constraints.
 *
 * By semi-fixation we mean that only the relevant EQUALITY constraint is added,
 * [org.jetbrains.kotlin.resolve.calls.inference.components.ConstraintSystemCompletionContext.fixVariable] is not expected to be called.
 *
 * See `getAndSemiFixCurrentResultIfTypeVariable` chapter at [docs/fir/pcla.md]
 *
 * NB: The callee must pay attention that exactly current common CS will be modified.
 */


inline fun outerType ( classLikeType : ConeClassLikeType , session : FirSession , outerClass : ( FirClassLikeSymbol < * > ) -> FirClassLikeSymbol < * > ? , ) : ConeClassLikeType ?

{ <EOL> val fullyExpandedType = classLikeType . fullyExpandedType ( session ) <EOL> val symbol = fullyExpandedType . lookupTag . toSymbol ( session ) ? : return null <EOL> if ( symbol is FirRegularClassSymbol && ! symbol . fir . isInner ) return null <EOL> val containingSymbol = outerClass ( symbol ) ? : return null <EOL> val currentTypeArgumentsNumber = ( symbol as? FirRegularClassSymbol ) ? . fir ? . typeParameters ? . count { it is FirTypeParameter } ? : <NUM_LIT:0> <EOL> return containingSymbol . constructType ( fullyExpandedType . typeArguments . drop ( currentTypeArgumentsNumber ) . toTypedArray ( ) , isNullable = false ) <EOL> }

/**
 * If `classLikeType` is an inner class,
 * then this function returns a type representing
 * only the "outer" part of `classLikeType`:
 * the part with the outer classes and their
 * type arguments. Returns `null` otherwise.
 */


public fun substitute ( type : KtType ) : KtType

= withValidityAssertion { substituteOrNull ( type ) ? : type }

/**
 * substitutes type parameters in a given type corresponding to internal mapping rules.
 *
 * @return substituted type if there was at least one substitution, [type] itself if there was no type parameter to substitute
 */


public fun substituteOrNull ( type : KtType ) : KtType ?

/**
 * substitutes type parameters in a given type corresponding to internal mapping rules.
 *
 * @return substituted type if there was at least one substitution, `null` if there was no type parameter to substitute
 */


fun IrElement . dumpKotlinLike ( options : KotlinLikeDumpOptions = KotlinLikeDumpOptions ( ) ) : String

= <EOL> dumpKotlinLike ( this , KotlinLikeDumper :: printElement , options )

/**
 * Conventions:
 * * For unsupported cases (node, type) it prints a block comment which starts with "/* ERROR:" (*/<- hack for parser)
 * * Conventions for some operators:
 * * IMPLICIT_CAST -- expr /*as Type */
 * * IMPLICIT_NOTNULL -- expr /*!! Type */
 * * IMPLICIT_COERCION_TO_UNIT -- expr /*~> Unit */
 * * IMPLICIT_INTEGER_COERCION -- expr /*~> IntType */
 * * SAM_CONVERSION -- expr /*-> SamType */
 * * IMPLICIT_DYNAMIC_CAST -- expr /*~> dynamic */
 * * REINTERPRET_CAST -- expr /*=> Type */
 */


internal expect fun < E : Throwable > recoverStackTrace ( exception : E , continuation : Continuation < * > ) : E

/**
 * Tries to recover stacktrace for given [exception] and [continuation].
 * Stacktrace recovery tries to restore [continuation] stack frames using its debug metadata with [CoroutineStackFrame] API
 * and then reflectively instantiate exception of given type with original exception as a cause and
 * sets new stacktrace for wrapping exception.
 * Some frames may be missing due to tail-call elimination.
 *
 * Works only on JVM with enabled debug-mode.
 */


@ Suppress ( "<STR_LIT>" ) <EOL> internal expect fun Throwable . initCause ( cause : Throwable )

/**
 * initCause on JVM, nop on other platforms
 */


internal expect fun < E : Throwable > recoverStackTrace ( exception : E ) : E

/**
 * Tries to recover stacktrace for given [exception]. Used in non-suspendable points of awaiting.
 * Stacktrace recovery tries to instantiate exception of given type with original exception as a cause.
 * Wrapping exception will have proper stacktrace as it's instantiated in the right context.
 *
 * Works only on JVM with enabled debug-mode.
 */


@ PublishedApi <EOL> internal expect fun < E : Throwable > unwrap ( exception : E ) : E

/**
 * The opposite of [recoverStackTrace].
 * It is guaranteed that `unwrap(recoverStackTrace(e)) === e`
 */


internal fun findCachedSerializer ( clazz : KClass < Any > , isNullable : Boolean ) : KSerializer < Any ? > ?

{ <EOL> return if ( ! isNullable ) { <EOL> SERIALIZERS_CACHE . get ( clazz ) ? . cast ( ) <EOL> } else { <EOL> SERIALIZERS_CACHE_NULLABLE . get ( clazz ) <EOL> } <EOL> }

/**
 * Find cacheable serializer in the cache.
 * If serializer is cacheable but missed in cache - it will be created, placed into the cache and returned.
 */


internal fun findParametrizedCachedSerializer ( clazz : KClass < Any > , types : List < KType > , isNullable : Boolean ) : Result < KSerializer < Any ? > ? >

{ <EOL> return if ( ! isNullable ) { <EOL> @ Suppress ( "<STR_LIT:UNCHECKED_CAST>" ) <EOL> PARAMETRIZED_SERIALIZERS_CACHE . get ( clazz , types ) as Result < KSerializer < Any ? > ? > <EOL> } else { <EOL> PARAMETRIZED_SERIALIZERS_CACHE_NULLABLE . get ( clazz , types ) <EOL> } <EOL> }

/**
 * Find cacheable parametrized serializer in the cache.
 * If serializer is cacheable but missed in cache - it will be created, placed into the cache and returned.
 */


{ <EOL> }


= clockDay . name


{ <EOL> }

/**
 * A sample extension function
 * When $a \ne 0$, there are two solutions to \(ax^2 + bx + c = 0\) and they are $$x = {-b \pm \sqrt{b^2-4ac} \over 2a}.$$
 * @usesMathJax
 */


{ <EOL> val rnd = Random ( SEED ) <EOL> val data = Array ( <NUM_LIT> ) { doubleArrayOf ( <NUM_LIT:0.0> , <NUM_LIT:0.0> , <NUM_LIT:0.0> , <NUM_LIT:0.0> , <NUM_LIT:0.0> ) } <EOL> for ( i in data . indices ) { <EOL> data [ i ] [ <NUM_LIT:1> ] = <NUM_LIT:2> * ( rnd . nextDouble ( ) - <NUM_LIT> ) <EOL> data [ i ] [ <NUM_LIT:2> ] = <NUM_LIT:2> * ( rnd . nextDouble ( ) - <NUM_LIT> ) <EOL> data [ i ] [ <NUM_LIT:3> ] = <NUM_LIT:2> * ( rnd . nextDouble ( ) - <NUM_LIT> ) <EOL> data [ i ] [ <NUM_LIT:4> ] = <NUM_LIT:2> * ( rnd . nextDouble ( ) - <NUM_LIT> ) <EOL> data [ i ] [ <NUM_LIT:0> ] = data [ i ] [ <NUM_LIT:1> ] - <NUM_LIT:2> * data [ i ] [ <NUM_LIT:2> ] + <NUM_LIT> * data [ i ] [ <NUM_LIT:3> ] - <NUM_LIT> * data [ i ] [ <NUM_LIT:4> ] + rnd . nextDouble ( <NUM_LIT> ) <EOL> } <EOL> data . shuffle ( ) <EOL> fun extractX ( ) : Array < FloatArray > { <EOL> val init : ( index : Int ) -> FloatArray = { index -> <EOL> floatArrayOf ( data [ index ] [ <NUM_LIT:1> ] . toFloat ( ) , data [ index ] [ <NUM_LIT:2> ] . toFloat ( ) , data [ index ] [ <NUM_LIT:3> ] . toFloat ( ) , data [ index ] [ <NUM_LIT:4> ] . toFloat ( ) ) <EOL> } <EOL> return Array ( data . size , init = init ) <EOL> } <EOL> fun extractY ( ) : FloatArray { <EOL> val labels = FloatArray ( data . size ) { <NUM_LIT:0.0f> } <EOL> for ( i in labels . indices ) { <EOL> labels [ i ] = data [ i ] [ <NUM_LIT:0> ] . toFloat ( ) <EOL> } <EOL> return labels <EOL> } <EOL> val dataset = OnHeapDataset . create ( extractX ( ) , extractY ( ) ) <EOL> val ( train , test ) = dataset . split ( <NUM_LIT> ) <EOL> model . use { <EOL> it . compile ( optimizer = Adam ( ) , loss = org . jetbrains . kotlinx . dl . api . core . loss . MSE ( ) , metrics = listOf ( MAE ( ) , MSE ( ) ) ) <EOL> it . logSummary ( ) <EOL> it . fit ( dataset = train , epochs = EPOCHS , batchSize = TRAINING_BATCH_SIZE ) <EOL> repeat ( <NUM_LIT:100> ) { id -> <EOL> val xReal = test . getX ( id ) <EOL> val yReal = test . getY ( id ) <EOL> val yPred = it . predictSoftly ( xReal ) <EOL> println ( "<STR_LIT>" ) <EOL> } <EOL> val mae = it . evaluate ( dataset = test , batchSize = TEST_BATCH_SIZE ) . metrics [ Metrics . MAE ] <EOL> val mse = it . evaluate ( dataset = test , batchSize = TEST_BATCH_SIZE ) . metrics [ Metrics . MSE ] <EOL> println ( "<STR_LIT>" + it . getLayer ( "<STR_LIT>" ) . weights [ "<STR_LIT>" ] . contentDeepToString ( ) ) <EOL> println ( "<STR_LIT>" + it . getLayer ( "<STR_LIT>" ) . weights [ "<STR_LIT>" ] . contentDeepToString ( ) ) <EOL> println ( "<STR_LIT>" ) <EOL> println ( "<STR_LIT>" ) <EOL> repeat ( <NUM_LIT:100> ) { id -> <EOL> val xReal = test . getX ( id ) <EOL> val yReal = test . getY ( id ) <EOL> val yPred = it . predictSoftly ( xReal ) <EOL> println ( "<STR_LIT>" ) <EOL> } <EOL> } <EOL> }

/**
 * This example shows how to do regression from scratch, starting from generated dataset, using simple Dense-based [model] with 1 neuron.
 *
 * It includes:
 * - dataset creation
 * - dataset splitting
 * - model compilation
 * - model training
 * - model evaluation
 * - model weights printing
 */


= linearRegressionWithTwoMetrics ( )


public fun createFunctionBodyFromRequest ( request : BridgeRequest ) : SirFunctionBody

{ <EOL> val callee = request . cDeclarationName ( ) <EOL> val calleeArguments = request . callable . allParameters . map { it . name } <EOL> val callSite = "<STR_LIT>" <EOL> val callStatement = if ( request . callable . returnType . isVoid ) callSite else "<STR_LIT>" <EOL> return SirFunctionBody ( listOf ( callStatement ) ) <EOL> }

/**
 * Generates the body of a function from a given request.
 *
 * @param request the BridgeRequest object that contains information about the function and the bridge
 * @return the generated SirFunctionBody object representing the body of the function
 */


public fun add ( bridge : FunctionBridge )

/**
 * Populate printer with an additional [bridge].
 */


public fun print ( ) : Sequence < String >

/**
 * Outputs the aggregated result.
 */


public fun < T : Number , D : Dimension > MultiArray < T , D > . argMax ( ) : Int

= mk . math . argMax ( this )

/**
 * Returns flat index of maximum element in an ndarray.
 *
 * same as [Math.argMax]
 */


public fun < T : Number , D : Dimension > MultiArray < T , D > . argMin ( ) : Int

= mk . math . argMin ( this )

/**
 * Returns flat index of minimum element in an ndarray.
 *
 * same as [Math.argMin]
 */


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

= mk . math . exp ( this )

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


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

= mk . math . mathEx . expF ( this )

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


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

= mk . math . mathEx . expCF ( this )

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


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

= mk . math . mathEx . expCD ( this )

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


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

= mk . math . mathEx . log ( this )

/**
 * Returns an ndarray of Double 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 < D : Dimension > MultiArray < Float , D > . log ( ) : NDArray < Float , D >

= mk . math . mathEx . logF ( this )

/**
 * Returns an ndarray of Float 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 < D : Dimension > MultiArray < ComplexFloat , D > . log ( ) : NDArray < ComplexFloat , D >

= mk . math . mathEx . logCF ( this )

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