parameters: (extended,
                                                         error_message=None)
docstring: Verify in cross-replica context.
docstring_summary: Verify in cross-replica context.
docstring_tokens: Verify in cross - replica context .
function: def _require_cross_replica_or_default_context_extended(extended,
                                                         error_message=None):
    """Verify in cross-replica context."""
    context = _get_per_thread_mode()
    cross_replica = context.cross_replica_context
    if cross_replica is not None and cross_replica.extended is extended:
      return
    if context is _get_default_replica_mode():
      return
    strategy = extended._container_strategy()  # pylint: disable=protected-access
    # We have an error to report, figure out the right message.
    if context.strategy is not strategy:
      _wrong_strategy_scope(strategy, context)
    assert cross_replica is None
    if not error_message:
      error_message = ("Method requires being in cross-replica context, use "
                       "get_replica_context().merge_call()")
    raise RuntimeError(error_message)
function_tokens: def _require_cross_replica_or_default_context_extended ( extended , error_message = None ) : context = _get_per_thread_mode ( ) cross_replica = context . cross_replica_context if cross_replica is not None and cross_replica . extended is extended : return if context is _get_default_replica_mode ( ) : return strategy = extended . _container_strategy ( ) # pylint: disable=protected-access # We have an error to report, figure out the right message. if context . strategy is not strategy : _wrong_strategy_scope ( strategy , context ) assert cross_replica is None if not error_message : error_message = ( "Method requires being in cross-replica context, use " "get_replica_context().merge_call()" ) raise RuntimeError ( error_message )