__init__.py 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. # flake8: noqa
  2. # There's no way to ignore "F401 '...' imported but unused" warnings in this
  3. # module, but to preserve other warnings. So, don't check this module at all.
  4. # Copyright 2023 The HuggingFace Team. All rights reserved.
  5. #
  6. # Licensed under the Apache License, Version 2.0 (the "License");
  7. # you may not use this file except in compliance with the License.
  8. # You may obtain a copy of the License at
  9. #
  10. # http://www.apache.org/licenses/LICENSE-2.0
  11. #
  12. # Unless required by applicable law or agreed to in writing, software
  13. # distributed under the License is distributed on an "AS IS" BASIS,
  14. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. # See the License for the specific language governing permissions and
  16. # limitations under the License.
  17. from typing import TYPE_CHECKING
  18. from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available
  19. _import_structure = {
  20. "configuration_xmod": [
  21. "XmodConfig",
  22. "XmodOnnxConfig",
  23. ],
  24. }
  25. try:
  26. if not is_torch_available():
  27. raise OptionalDependencyNotAvailable()
  28. except OptionalDependencyNotAvailable:
  29. pass
  30. else:
  31. _import_structure["modeling_xmod"] = [
  32. "XmodForCausalLM",
  33. "XmodForMaskedLM",
  34. "XmodForMultipleChoice",
  35. "XmodForQuestionAnswering",
  36. "XmodForSequenceClassification",
  37. "XmodForTokenClassification",
  38. "XmodModel",
  39. "XmodPreTrainedModel",
  40. ]
  41. if TYPE_CHECKING:
  42. from .configuration_xmod import XmodConfig, XmodOnnxConfig
  43. try:
  44. if not is_torch_available():
  45. raise OptionalDependencyNotAvailable()
  46. except OptionalDependencyNotAvailable:
  47. pass
  48. else:
  49. from .modeling_xmod import (
  50. XmodForCausalLM,
  51. XmodForMaskedLM,
  52. XmodForMultipleChoice,
  53. XmodForQuestionAnswering,
  54. XmodForSequenceClassification,
  55. XmodForTokenClassification,
  56. XmodModel,
  57. XmodPreTrainedModel,
  58. )
  59. else:
  60. import sys
  61. sys.modules[__name__] = _LazyModule(__name__, globals()["__file__"], _import_structure, module_spec=__spec__)