code: def register_attention(name):
      """Decorator to register a new attention type."""
  
      def register_attention_cls(cls):
          if name in ATTENTION_REGISTRY:
              raise ValueError(
                  "Cannot register duplicate attention ({})".format(
                      name
                  )
              )
          if not issubclass(cls, BaseAttention):
              raise ValueError(
                  "Attention ({} : {}) must extend BaseAttention".format(
                      name, cls.__name__
                  )
              )
          ATTENTION_REGISTRY[name] = cls
          return cls
  
      return register_attention_cls
  
imports: import importlib
  import os
  from pytorch_translate.attention.base_attention import BaseAttention
label_desc: Use image node_id 2 for calling a global function with example usage: register_attention(name) and returns: register_attention_cls, cls