universal_attention/utils.py
def initialize_hardware() -> None:
    """
    Initialize the hardware for training or evaluation.
    Can only be called once globally.
    """
    global _INITIALIZED  # pylint:disable=global-statement

    if _INITIALIZED:
        raise RuntimeError("Hardware has already been initialized.")

    device = tf.config.list_physical_devices("GPU")[0]
    tf.config.experimental.set_memory_growth(device, True)

    if FLAGS.mixed_precision:
        precision_policy = mixed_precision.experimental.Policy("mixed_float16")
        mixed_precision.experimental.set_policy(precision_policy)

    _INITIALIZED = True

    Initialize the hardware for training or evaluation.
    Can only be called once globally.
    
Initialize the hardware for training or evaluation.
Can only be called once globally.
Initialize the hardware for training or evaluation . Can only be called once globally .
def initialize_hardware() -> None:
    global _INITIALIZED  
    if _INITIALIZED:
        raise RuntimeError("Hardware has already been initialized.")
    device = tf.config.list_physical_devices("GPU")[0]
    tf.config.experimental.set_memory_growth(device, True)
    if FLAGS.mixed_precision:
        precision_policy = mixed_precision.experimental.Policy("mixed_float16")
        mixed_precision.experimental.set_policy(precision_policy)
    _INITIALIZED = True
def initialize_hardware ( ) -> None : global _INITIALIZED if _INITIALIZED : raise RuntimeError ( "Hardware has already been initialized." ) device = tf . config . list_physical_devices ( "GPU" ) [ 0 ] tf . config . experimental . set_memory_growth ( device , True ) if FLAGS . mixed_precision : precision_policy = mixed_precision . experimental . Policy ( "mixed_float16" ) mixed_precision . experimental . set_policy ( precision_policy ) _INITIALIZED = True
Initialize the hardware for training or evaluation.
Initialize the hardware for training or evaluation .
"""
    Initialize the hardware for training or evaluation.
    Can only be called once globally.
    """ # pylint:disable=global-statement