code: def once(f):
      """Decorator which ensures a wrapped method is only ever run once.
  
          >>> @snt.once
          ... def f():
          ...   print('Hello, world!')
          >>> f()
          Hello, world!
          >>> f()
          >>> f()
  
      If `f` is a method then it will be evaluated once per instance:
  
          >>> class MyObject:
          ...   @snt.once
          ...   def f(self):
          ...     print('Hello, world!')
  
          >>> o = MyObject()
          >>> o.f()
          Hello, world!
          >>> o.f()
  
          >>> o2 = MyObject()
          >>> o2.f()
          Hello, world!
          >>> o.f()
          >>> o2.f()
  
      If an error is raised during execution of `f` it will be raised to the user.
      Next time the method is run, it will be treated as not having run before.
  
      Args:
        f: A function to wrap which should only be called once.
  
      Returns:
        Wrapped version of `f` which will only evaluate `f` the first time it is
        called.
      """
  
      # TODO(tomhennigan) Perhaps some more human friendly identifier?
      once_id = uuid.uuid4()
  
      @utils.decorator
      def wrapper(wrapped, instance, args, kwargs):
          """Decorator which ensures a wrapped method is only ever run once."""
          if instance is None:
              # NOTE: We can't use the weakset since you can't weakref None.
              if not wrapper.seen_none:
                  _check_no_output(wrapped(*args, **kwargs))
                  wrapper.seen_none = True
              return
  
          # Get or set the `seen` set for this object.
          seen = getattr(instance, _ONCE_PROPERTY, None)
          if seen is None:
              seen = set()
              setattr(instance, _ONCE_PROPERTY, seen)
  
          if once_id not in seen:
              _check_no_output(wrapped(*args, **kwargs))
              seen.add(once_id)
  
      wrapper.seen_none = False
  
      decorated = wrapper(
          f
      )  # pylint: disable=no-value-for-parameter,assignment-from-none
      decorated.__snt_once_wrapped__ = f
      return decorated
  
label_desc: Use image node_id 2 for calling a global function with example usage: once(f) and returns: decorated