You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

meta_transform.py 502 B

12345678910111213141516171819202122
  1. # -*- coding: utf-8 -*-
  2. from abc import ABC, abstractmethod
  3. from typing import Sequence, Tuple
  4. class Transform(ABC):
  5. r"""Rewrite apply method in subclass."""
  6. def apply_batch(self, inputs: Sequence[Tuple]):
  7. return tuple(self.apply(input) for input in inputs)
  8. @abstractmethod
  9. def apply(self, input: Tuple):
  10. pass
  11. def __repr__(self):
  12. return self.__class__.__name__
  13. class PseudoTransform(Transform):
  14. def apply(self, input: Tuple):
  15. return input