code: def _update(strategy, var, update_fn, args):
      """Applies updates depending on the context."""
      assert (
          distribute_lib.in_cross_replica_context()
      ), "_update can only be called in cross-replica context"
      if distribute_lib.get_update_replica_id() is not None:
          # Call update_fn on var to delegate the implementation. We expect `var` will
          # do the right thing in update context, e.g, if `var` is a MirroredVariable,
          # it should pick its component variable based on `update_replica_id` and
          # only update that.
          return update_fn(var, *args)
      else:
          return strategy.extended.update(var, update_fn, args)
  
imports: from tensorflow.python.distribute import distribute_lib
  from tensorflow.python.distribute import reduce_util
  from tensorflow.python.framework import dtypes
  from tensorflow.python.framework import ops
  from tensorflow.python.framework import tensor
  from tensorflow.python.ops import cond
  from tensorflow.python.ops import control_flow_ops
  from tensorflow.python.ops import init_ops
  from tensorflow.python.ops import math_ops
  from tensorflow.python.ops import state_ops
  from tensorflow.python.ops import variable_scope
  from tensorflow.python.ops import variable_v1
  from tensorflow.python.ops import variables
  from tensorflow.python.training import slot_creator
  from tensorflow.python.util.tf_export import tf_export
  from tensorflow.tools.docs import doc_controls
label_desc: Use image node_id 3 for calling a global function with example usage: _update(strategy, var, update_fn, args) and returns: update_fn, strategy