code: def _ShouldInclude(net_state, layer):
      """A function that reproduces Caffe's inclusion and exclusion rule."""
      ret = len(layer.include) == 0
      # check exclude rules: if any exclusion is met, we shouldn't include.
      ret &= not any(
          [_StateMeetsRule(net_state, rule) for rule in layer.exclude]
      )
      if len(layer.include):
          # check include rules: if any inclusion is met, we should include.
          ret |= any(
              [
                  _StateMeetsRule(net_state, rule)
                  for rule in layer.include
              ]
          )
      return ret
  
imports: import argparse
  import copy
  import logging
  import re
  import numpy
  from caffe2.proto import caffe2_pb2, caffe2_legacy_pb2
  from caffe.proto import caffe_pb2
  from caffe2.python import core, utils, workspace
  from google.protobuf import text_format
label_desc: Use image node_id 2 for calling a global function with example usage: _ShouldInclude(net_state, layer) and returns: ret