code: def validate_callback(callback):
      
      if not(hasattr(callback, '_validated')) or callback._validated == False:
          assert hasattr(callback, 'on_loop_start') \
                 or hasattr(callback, 'on_loop_end'), \
                 'callback must have `on_loop_start` or `on_loop_end` method'
          if hasattr(callback, 'on_loop_start'):
              setattr(callback, 'on_loop_start',
                      validate_callback_data(callback.on_loop_start))
          if hasattr(callback, 'on_loop_end'):
              setattr(callback, 'on_loop_end',
                      validate_callback_data(callback.on_loop_end))
          setattr(callback, '_validated', True)
      return callback
docs: validates a callback's on_loop_start and on_loop_end methods
  
      Parameters
      ----------
      callback : Callback object
  
      Returns
      -------
      validated callback