code: def is_legal(self, layers=None):
      if layers == None:
          layers = self.layers
  
      for layer in layers:
          if layer.is_delete == False:
              if len(layer.input) != layer.input_size:
                  return False
              if len(layer.output) < layer.output_size:
                  return False
  
      # layer_num <= max_layer_num
      if self.layer_num(layers) > self.max_layer_num:
          return False
  
      if (
          self.is_topology(layers) == False
      ):  # There is loop in graph || some layers can't to arrive
          return False
  
      return True
  
imports: import copy
  import json
  import random
  from enum import Enum, unique
label_desc: Use image node_id 4 for calling the Graph obj's underlying member method code with example usage: obj.is_legal(layers) and returns: True, False, False, False, False