code: def _should_define_operation(cls, operation, base_operation_name):
      if operation not in dir(cls):
          return True
  
      # If the class doesn't override the base operation we stick to whatever
      # parent implementation exists.
      if base_operation_name not in cls.__dict__:
          return False
  
      # At this point we know that the class has the operation defined but it
      # also overrides the base operation. Since this function is called before
      # the operation is defined on the current class, we know that it inherited
      # the operation from a parent. We therefore have three possibilities:
      # 1. A parent class manually defined the operation. That override takes
      #    precedence even if the current class defined the base operation.
      # 2. A parent class has an auto-generated operation, i.e. it is of type
      #    Operation and was created by OperationMixin.__init_subclass__. The
      #    current class must override it so that its base operation is used
      #    rather than the parent's base operation.
      # 3. The method is defined for all classes, i.e. it is a method of object.
      for base_cls in cls.__mro__:
          # We always override methods defined for object.
          if base_cls is object:
              return True
          # The first attribute in the MRO is the one that will be used.
          if operation in base_cls.__dict__:
              return isinstance(base_cls.__dict__[operation], Operation)
  
      # This line should be unreachable since we know the attribute exists
      # somewhere in the MRO if the for loop was entered.
      assert False, "Operation attribute not found in hierarchy."
  
imports: import inspect
label_desc: Use image node_id 2 for calling a global function with example usage: _should_define_operation(cls, operation, base_operation_name) and returns: True, False, True, isinstance