code: def singleton(cache_key):
      def inner_fn(fn):
          @wraps(fn)
          def wrapper(self, *args, **kwargs):
              instance = getattr(self, cache_key)
              if instance is not None:
                  return instance
  
              instance = fn(self, *args, **kwargs)
              setattr(self, cache_key, instance)
              return instance
  
          return wrapper
  
      return inner_fn
  
imports: import copy
  import random
  from functools import wraps, partial
  import torch
  from torch import nn, einsum
  import torch.nn.functional
  from torchvision import transforms
  from einops import rearrange, reduce, repeat
label_desc: Use image node_id 3 for calling a global function with example usage: singleton(cache_key) and returns: inner_fn, wrapper, instance, instance