code: def _try_weakref(arg, remove_callback):
      
      try:
          arg = weakref.ref(arg, remove_callback)
      except TypeError:
          # Not all types can have a weakref. That includes strings
          # and floats and such, so just pass them through directly.
          pass
      return arg
docs: Return a weak reference to arg if possible, or arg itself if not.