code: def _add_slots(cls, is_frozen, weakref_slot):
      # Need to create a new class, since we can't set __slots__
      #  after a class has been created.
  
      # Make sure __slots__ isn't already set.
      if "__slots__" in cls.__dict__:
          raise TypeError(f"{cls.__name__} already specifies __slots__")
  
      # Create a new dict for our new class.
      cls_dict = dict(cls.__dict__)
      field_names = tuple(f.name for f in fields(cls))
      # Make sure slots don't overlap with those in base classes.
      inherited_slots = set(
          itertools.chain.from_iterable(
              map(_get_slots, cls.__mro__[1:-1])
          )
      )
      # The slots for our class.  Remove slots from our base classes.  Add
      # '__weakref__' if weakref_slot was given, unless it is already present.
      cls_dict["__slots__"] = tuple(
          itertools.filterfalse(
              inherited_slots.__contains__,
              itertools.chain(
                  # gh-93521: '__weakref__' also needs to be filtered out if
                  # already present in inherited_slots
                  field_names,
                  ("__weakref__",) if weakref_slot else (),
              ),
          ),
      )
  
      for field_name in field_names:
          # Remove our attributes, if present. They'll still be
          #  available in _MARKER.
          cls_dict.pop(field_name, None)
  
      # Remove __dict__ itself.
      cls_dict.pop("__dict__", None)
  
      # Clear existing `__weakref__` descriptor, it belongs to a previous type:
      cls_dict.pop("__weakref__", None)  # gh-102069
  
      # And finally create the class.
      qualname = getattr(cls, "__qualname__", None)
      cls = type(cls)(cls.__name__, cls.__bases__, cls_dict)
      if qualname is not None:
          cls.__qualname__ = qualname
  
      if is_frozen:
          # Need this for pickling frozen classes with slots.
          if "__getstate__" not in cls_dict:
              cls.__getstate__ = _dataclass_getstate
          if "__setstate__" not in cls_dict:
              cls.__setstate__ = _dataclass_setstate
  
      return cls
  
imports: import re
  import sys
  import copy
  import types
  import inspect
  import keyword
  import builtins
  import functools
  import itertools
  import abc
  import _thread
  from types import FunctionType, GenericAlias
label_desc: Use image node_id 28 for calling a global function with example usage: _add_slots(cls, is_frozen, weakref_slot) and returns: cls