code: def update_lr(
      optimizer,
      epoch,
      l2_reg=1e-4,
      lr_warmup_val=None,
      lr_init=0.1,
      lr_decay_scheme="cosine",
      lr_max=0.002,
      lr_min=0.000000001,
      lr_T_0=4,
      lr_T_mul=1,
      sync_replicas=False,
      num_aggregate=None,
      num_replicas=None,
  ):
      if lr_decay_scheme == "cosine":
          assert lr_max is not None, "Need lr_max to use lr_cosine"
          assert lr_min is not None, "Need lr_min to use lr_cosine"
          assert lr_T_0 is not None, "Need lr_T_0 to use lr_cosine"
          assert lr_T_mul is not None, "Need lr_T_mul to use lr_cosine"
  
          T_i = lr_T_0
          t_epoch = epoch
          last_reset = 0
          while True:
              t_epoch -= T_i
              if t_epoch < 0:
                  break
              last_reset += T_i
              T_i *= lr_T_mul
  
          T_curr = epoch - last_reset
  
          def _update():
              rate = T_curr / T_i * 3.1415926
              lr = lr_min + 0.5 * (lr_max - lr_min) * (
                  1.0 + math.cos(rate)
              )
              return lr
  
          learning_rate = _update()
      else:
          raise ValueError(
              "Unknown learning rate decay scheme {}".format(
                  lr_decay_scheme
              )
          )
  
      # update lr in optimizer
      for params_group in optimizer.param_groups:
          params_group["lr"] = learning_rate
      return learning_rate
  
imports: import sys
  import os
  import logging
  import pickle
  import shutil
  import random
  import math
  import time
  import datetime
  import argparse
  import distutils.util
  import numpy
  import torch
  from torch import nn
  from torch import optim
  from torch.utils.data import DataLoader
  import torch.nn.functional
  from model import Model
  from nni.nas.pytorch.fixed import apply_fixed_architecture
  from dataloader import read_data_sst
label_desc: Use image node_id 7 for calling a global function with example usage: update_lr(optimizer, epoch, l2_reg, lr_warmup_val, lr_init, lr_decay_scheme, lr_max, lr_min, lr_T_0, lr_T_mul, sync_replicas, num_aggregate, num_replicas) and returns: learning_rate, lr