| import os | |
| import sys | |
| matformer_root = os.getenv("MATFORMER_ROOT") | |
| if matformer_root: | |
| matformer_root = os.path.abspath(os.path.expanduser(matformer_root)) | |
| if matformer_root not in sys.path: | |
| sys.path.insert(0, matformer_root) | |
| try: | |
| from matformer.modelling_matformer import ( | |
| MatformerForCausalLM, | |
| MatformerForSequenceClassification, | |
| MatformerModel, | |
| MatformerConfig, | |
| register_matformer | |
| ) | |
| register_matformer() | |
| except ImportError as e: | |
| raise ImportError( | |
| "To use this model, please install the Matformer library: " | |
| "`pip install matformer`\\n" | |
| "Alternatively, set the `MATFORMER_ROOT` environment variable to a local clone:\\n" | |
| " export MATFORMER_ROOT=/path/to/matformer" | |
| ) from e |