code: def get_legacy_sgd(learning_rate):
      if hasattr(tf.keras.optimizers, "legacy"):
          return tf.keras.optimizers.legacy.SGD(learning_rate)
      return tf.keras.optimizers.SGD(learning_rate)
  
file_path: addons/tensorflow_addons/callbacks/tests/avg_model_checkpoint_test.py
imports: import os
  import pytest
  import tensorflow
  from tensorflow import keras
  from tensorflow_addons.callbacks import AverageModelCheckpoint
  from tensorflow_addons.optimizers import MovingAverage
label_desc: Use image node_id 1 for calling a global function with example usage: get_legacy_sgd(learning_rate) and returns: tf, tf