code: def invalidate(*tables_or_models, **kwargs):
      
      # TODO: Replace with positional arguments when we drop Python 2 support.
      cache_alias = kwargs.pop('cache_alias', None)
      db_alias = kwargs.pop('db_alias', None)
      for k in kwargs:
          raise TypeError(
              "invalidate() got an unexpected keyword argument '%s'" % k)
  
      send_signal = False
      invalidated = set()
      for cache_alias, db_alias, tables in _cache_db_tables_iterator(
              list(_get_tables(tables_or_models)), cache_alias, db_alias):
          cache = cachalot_caches.get_cache(cache_alias, db_alias)
          if not isinstance(cache, AtomicCache):
              send_signal = True
          _invalidate_tables(cache, db_alias, tables)
          invalidated.update(tables)
  
      if send_signal:
          for table in invalidated:
              post_invalidation.send(table, db_alias=db_alias)
docs: Clears what was cached by django-cachalot implying one or more SQL tables
      or models from ``tables_or_models``.
      If ``tables_or_models`` is not specified, all tables found in the database
      (including those outside Django) are invalidated.
  
      If ``cache_alias`` is specified, it only clears the SQL queries stored
      on this cache, otherwise queries from all caches are cleared.
  
      If ``db_alias`` is specified, it only clears the SQL queries executed
      on this database, otherwise queries from all databases are cleared.
  
      :arg tables_or_models: SQL tables names, models or models lookups
                             (or a combination)
      :type tables_or_models: tuple of strings or models
      :arg cache_alias: Alias from the Django ``CACHES`` setting
      :type cache_alias: string or NoneType
      :arg db_alias: Alias from the Django ``DATABASES`` setting
      :type db_alias: string or NoneType
      :returns: Nothing
      :rtype: NoneType