code: def check(cls, model, require_extra=False):
          
          class_capable = isinstance(model, cls)
  
          f_name = model.extra_capability_checks.get(cls, None) \
              if model.extra_capability_checks is not None \
              else False
  
          if f_name:
              f = getattr(model, f_name)
              instance_capable = f()
          elif not require_extra:
              instance_capable = True
          else:
              instance_capable = False
          return class_capable and instance_capable
docs: Check whether the provided model has this capability.
  
          By default, uses isinstance.  If `require_extra`, also requires that an
          instance check be present in `model.extra_capability_checks`.