code: def _euler_step(
      *,
      i,
      written_count,
      current_state,
      drift_fn,
      volatility_fn,
      wiener_mean,
      num_samples,
      times,
      dt,
      sqrt_dt,
      keep_mask,
      random_type,
      seed,
      normal_draws,
      result,
      record_samples,
  ):
      """Performs one step of Euler scheme."""
      current_time = times[i + 1]
      written_count = tf.cast(written_count, tf.int32)
      if normal_draws is not None:
          dw = normal_draws[i]
      else:
          dw = random.mv_normal_sample(
              (num_samples,),
              mean=wiener_mean,
              random_type=random_type,
              seed=seed,
          )
      dw = dw * sqrt_dt[i]
      dt_inc = dt[i] * drift_fn(
          current_time, current_state
      )  # pylint: disable=not-callable
      dw_inc = tf.linalg.matvec(
          volatility_fn(current_time, current_state), dw
      )  # pylint: disable=not-callable
      next_state = current_state + dt_inc + dw_inc
      if record_samples:
          result = result.write(written_count, next_state)
      else:
          result = next_state
      written_count += tf.cast(keep_mask[i + 1], dtype=tf.int32)
  
      return i + 1, written_count, next_state, result
  
file_path: tf-quant-finance/tf_quant_finance/models/euler_sampling.py
imports: from typing import Callable, List, Optional
  import tensorflow.compat.v2
  from tf_quant_finance import types
  from tf_quant_finance import utils
  from tf_quant_finance.math import custom_loops
  from tf_quant_finance.math import random
  from tf_quant_finance.models import utils
label_desc: Use image node_id 5 for calling a global function with example usage: _euler_step() and returns: unknown,  written_count,  next_state,  result