__init__.py 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. # Copyright 2023 Mistral AI and The HuggingFace Inc. team. All rights reserved.
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License");
  4. # you may not use this file except in compliance with the License.
  5. # You may obtain a copy of the License at
  6. #
  7. # http://www.apache.org/licenses/LICENSE-2.0
  8. #
  9. # Unless required by applicable law or agreed to in writing, software
  10. # distributed under the License is distributed on an "AS IS" BASIS,
  11. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. # See the License for the specific language governing permissions and
  13. # limitations under the License.
  14. from typing import TYPE_CHECKING
  15. from ...utils import (
  16. OptionalDependencyNotAvailable,
  17. _LazyModule,
  18. is_flax_available,
  19. is_tf_available,
  20. is_torch_available,
  21. )
  22. _import_structure = {
  23. "configuration_mistral": ["MistralConfig"],
  24. }
  25. try:
  26. if not is_torch_available():
  27. raise OptionalDependencyNotAvailable()
  28. except OptionalDependencyNotAvailable:
  29. pass
  30. else:
  31. _import_structure["modeling_mistral"] = [
  32. "MistralForCausalLM",
  33. "MistralForQuestionAnswering",
  34. "MistralModel",
  35. "MistralPreTrainedModel",
  36. "MistralForSequenceClassification",
  37. "MistralForTokenClassification",
  38. ]
  39. try:
  40. if not is_flax_available():
  41. raise OptionalDependencyNotAvailable()
  42. except OptionalDependencyNotAvailable:
  43. pass
  44. else:
  45. _import_structure["modeling_flax_mistral"] = [
  46. "FlaxMistralForCausalLM",
  47. "FlaxMistralModel",
  48. "FlaxMistralPreTrainedModel",
  49. ]
  50. try:
  51. if not is_tf_available():
  52. raise OptionalDependencyNotAvailable()
  53. except OptionalDependencyNotAvailable:
  54. pass
  55. else:
  56. _import_structure["modeling_tf_mistral"] = [
  57. "TFMistralModel",
  58. "TFMistralForCausalLM",
  59. "TFMistralForSequenceClassification",
  60. "TFMistralPreTrainedModel",
  61. ]
  62. if TYPE_CHECKING:
  63. from .configuration_mistral import MistralConfig
  64. try:
  65. if not is_torch_available():
  66. raise OptionalDependencyNotAvailable()
  67. except OptionalDependencyNotAvailable:
  68. pass
  69. else:
  70. from .modeling_mistral import (
  71. MistralForCausalLM,
  72. MistralForQuestionAnswering,
  73. MistralForSequenceClassification,
  74. MistralForTokenClassification,
  75. MistralModel,
  76. MistralPreTrainedModel,
  77. )
  78. try:
  79. if not is_flax_available():
  80. raise OptionalDependencyNotAvailable()
  81. except OptionalDependencyNotAvailable:
  82. pass
  83. else:
  84. from .modeling_flax_mistral import (
  85. FlaxMistralForCausalLM,
  86. FlaxMistralModel,
  87. FlaxMistralPreTrainedModel,
  88. )
  89. try:
  90. if not is_tf_available():
  91. raise OptionalDependencyNotAvailable()
  92. except OptionalDependencyNotAvailable:
  93. pass
  94. else:
  95. from .modeling_tf_mistral import (
  96. TFMistralForCausalLM,
  97. TFMistralForSequenceClassification,
  98. TFMistralModel,
  99. TFMistralPreTrainedModel,
  100. )
  101. else:
  102. import sys
  103. sys.modules[__name__] = _LazyModule(__name__, globals()["__file__"], _import_structure, module_spec=__spec__)