code: def addmetadata(func):
      """Decorator for instance methods which perform a transformation and return
      a new dataset.
  
      Automatically populates the `metadata` field of the new dataset to reflect
      details of the transformation that occurred, e.g.::
  
          {
              'transformer': 'TransformerClass.function_name',
              'params': kwargs_from_init,
              'previous': [all_datasets_used_by_func]
          }
      """
  
      @wraps(func)
      def wrapper(self, *args, **kwargs):
          new_dataset = func(self, *args, **kwargs)
          if isinstance(new_dataset, Dataset):
              new_dataset.metadata = new_dataset.metadata.copy()
              new_dataset.metadata.update(
                  {
                      "transformer": "{}.{}".format(
                          type(self).__name__, func.__name__
                      ),
                      "params": self._params,
                      "previous": [
                          a for a in args if isinstance(a, Dataset)
                      ],
                  }
              )
          return new_dataset
  
      return wrapper
  
file_path: AIF360/aif360/algorithms/transformer.py
imports: from abc import abstractmethod
  from functools import wraps
  from aif360.datasets import Dataset
  from aif360.decorating_metaclass import ApplyDecorator
label_desc: Use image node_id 1 for calling a global function with example usage: addmetadata(func) and returns: wrapper, new_dataset