code: def cosine_scheduler(
      initial_lr,
      epochs,
      steps,
      warmup_epochs=1,
      end_lr_rate=1e-6,
      train_writer=None,
  ):
      """custom learning rate scheduler"""
      assert warmup_epochs < epochs
      warmup = np.linspace(
          start=1e-8, stop=initial_lr, num=warmup_epochs * steps
      )
      remainder_steps = (epochs - warmup_epochs) * steps
      cosine = initial_lr * np.array(
          [
              cosine_rate(i, remainder_steps, end_lr_rate)
              for i in range(remainder_steps)
          ]
      )
      lr_list = np.concatenate([warmup, cosine])
  
      for i in range(len(lr_list)):
          new_lr = lr_list[i]
          if train_writer is not None:
              # writing lr into tensorboard
              with train_writer.as_default():
                  tf.summary.scalar(
                      "learning rate", data=new_lr, step=i
                  )
          yield new_lr
  
file_path: deep-learning-for-image-processing/tensorflow_classification/ConvNeXt/utils.py
imports: import os
  import json
  import random
  import math
  import numpy
  import tensorflow
  import matplotlib.pyplot
label_desc: Use image node_id 4 for calling a global function with example usage: cosine_scheduler(initial_lr, epochs, steps, warmup_epochs, end_lr_rate, train_writer) without return types