code: def strategy_scope(strategy: Optional[tf.distribute.Strategy]) -> Any:
      """Gets the strategy.scope() for training with strategy.
  
      Example usage:
  
      ```python
      with strategy_scope(strategy):
        model = ...
      ```
  
      Args:
        strategy: Distributed training strategy is used.
  
      Returns:
        ContextManager for the distributed training strategy.
      """
      if strategy is None:
          return NullContextManager()
  
      return strategy.scope()
  
file_path: ranking/tensorflow_ranking/python/keras/strategy_utils.py
imports: import os
  from typing import Any, Optional, Union
  import tensorflow
label_desc: Use image node_id 2 for calling a global function with example usage: strategy_scope(strategy) and returns: strategy, NullContextManager