code: def is_model_factory(node):
      
      try:
          parent_classes = node.expr.inferred()
      except:  # noqa: E722, pylint: disable=bare-except
          return False
  
      parents = ('factory.declarations.LazyFunction',
                 'factory.declarations.SubFactory',
                 'factory.django.DjangoModelFactory')
  
      for parent_class in parent_classes:
          try:
              if parent_class.qname() in parents:
                  return True
  
              if node_is_subclass(parent_class, *parents):
                  return True
          except AttributeError:
              continue
  
      return False
docs: Checks that node is derivative of DjangoModelFactory or SubFactory class.