code: def get_identity(identity):
      
      if isinstance(identity, AnonymousUser):
          return identity, None
  
      if isinstance(identity, get_user_model()):
          return identity, None
      elif isinstance(identity, Group):
          return None, identity
      else:  # pragma: no cover
          raise NotUserNorGroup(
              'User/AnonymousUser or Group instance is required '
              '(got {})'.format(identity),
          )
docs: Returns a (user_obj, None) tuple or a (None, group_obj) tuple depending on the considered
          instance.