code: def _check_callback(callback):
      
      # If the callback is a class, create an instance of it first
      if inspect.isclass(callback):
          callback_object = callback()
          if not callable(callback_object):
              raise ValueError(
                  "Callback must be a class that implements __call__ or a function."
              )
      elif callable(callback):
          callback_object = callback
      else:
          raise ValueError(
              "Callback must be a class that implements __call__ or a function."
          )
  
      return callback_object
docs: Turns a callback that is potentially a class into a callable object.
  
      Args:
          callback (object): An object that might be a class, method, or function.
          if the object is a class, this creates an instance of it.
  
      Raises:
          ValueError: If an instance can't be created or it isn't a callable object.
          TypeError: If the class requires arguments to be instantiated.
  
      Returns:
          callable: A callable object suitable for use as the consumer callback.