code: def check_ensemble_build(inst, attr="stack"):
      """Check that layers have been instantiated."""
      if not hasattr(inst, attr):
          # No layer container. This should not happen!
  
          msg = (
              "No layer class attached to instance (%s). (Cannot find a "
              "'Sequential' class instance as attribute [%s].)"
          )
  
          raise AttributeError(msg % (inst.__class__.__name__, attr))
  
      if getattr(inst, attr) is None:
          # No layers instantiated.
  
          if not getattr(inst, "raise_on_exception", True):
              msg = "No Layers in instance (%s). Nothing to fit / predict."
              warnings.warn(
                  msg % inst.__class__.__name__,
                  LayerSpecificationWarning,
              )
              # For PASSED flag on soft fail
              return False
  
          else:
              msg = (
                  "No Layers in instance (%s). Add layers before calling "
                  "'fit' and 'predict'."
              )
              raise LayerSpecificationError(
                  msg % inst.__class__.__name__
              )
  
      # For PASSED flag
      return True
  
imports: import warnings
  from .exceptions import NotFittedError, LayerSpecificationWarning, LayerSpecificationError, ParallelProcessingError, ParallelProcessingWarning
label_desc: Use image node_id 2 for calling a global function with example usage: check_ensemble_build(inst, attr) and returns: True, False