code: def DurfeeSquare_metric(bpmn_graph):
      
  
      all_types_count = Counter([node[1]['type'] for node in bpmn_graph.get_nodes() if node[1]['type']])
      length = len(all_types_count)
  
      histogram = [0] * (length + 1)
      for _, count in all_types_count.items():
          histogram[min(count, length)] += 1
  
      sum_ = 0
      for i, count in reversed(list(enumerate(histogram))):
          sum_ += count
          if sum_ >= i:
              return i
  
      return 0
docs: Returns the value of the Durfee Square metric
       ("Durfee Square equals d if there are d types of elements
       which occur at least d times in the model (each),
       and the other types of elements occur no more than d times (each)")
       for the BPMNDiagramGraph instance.
  
      :param bpmn_graph: an instance of BpmnDiagramGraph representing BPMN model.