code: def _update_sample_weight_mode(model, mode, inputs):
      """Updates the sample_weight_mode of a given model."""
      # Add a quick return to prevent us from calling model._feed_targets that
      # accesses certain model properties that may not be set in the `PREDICT` mode.
      if mode == ModeKeys.PREDICT:
          return
  
      sample_weights = None
      # `inputs` is the model's inputs + targets + sample_weights +
      # learning phase placeholder if specified. To update the sample_weight_mode
      # we need to determine if the user has passed sample weights as part of the
      # input.
      if not callable(inputs):
          sample_weights = inputs[
              len(model._feed_inputs) + len(model._feed_targets) :
          ]
          has_learning_phase_pl = (
              mode == ModeKeys.TRAIN
              and not isinstance(backend.symbolic_learning_phase(), int)
          )
          if has_learning_phase_pl:
              sample_weights = sample_weights[:-1]
          model._update_sample_weight_modes(
              sample_weights=sample_weights
          )
  
      # Call the DistributionStrategy specific function to update the
      # sample_weight_mode on the model.
      if model._distribution_strategy:
          distributed_training_utils_v1._update_sample_weight_modes(
              model, mode, sample_weights
          )
  
imports: import functools
  import numpy
  from tensorflow.python.data.ops import iterator_ops
  from tensorflow.python.eager import context
  from tensorflow.python.framework import errors
  from tensorflow.python.keras import backend
  from tensorflow.python.keras import callbacks
  from tensorflow.python.keras.distribute import distributed_training_utils_v1
  from tensorflow.python.keras.engine import training_utils_v1
  from tensorflow.python.keras.utils.generic_utils import make_batches
  from tensorflow.python.keras.utils.generic_utils import slice_arrays
  from tensorflow.python.keras.utils.mode_keys import ModeKeys
  from tensorflow.python.platform import tf_logging
  from tensorflow.python.types import data
  from tensorflow.python.util import nest
label_desc: Use image node_id 9 for calling a global function with example usage: _update_sample_weight_mode(model, mode, inputs) without return types