__init__.py 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. # Copyright 2022 The HuggingFace 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_tokenizers_available,
  21. is_torch_available,
  22. )
  23. _import_structure = {"configuration_opt": ["OPTConfig"]}
  24. try:
  25. if not is_torch_available():
  26. raise OptionalDependencyNotAvailable()
  27. except OptionalDependencyNotAvailable:
  28. pass
  29. else:
  30. _import_structure["modeling_opt"] = [
  31. "OPTForCausalLM",
  32. "OPTModel",
  33. "OPTPreTrainedModel",
  34. "OPTForSequenceClassification",
  35. "OPTForQuestionAnswering",
  36. ]
  37. try:
  38. if not is_tf_available():
  39. raise OptionalDependencyNotAvailable()
  40. except OptionalDependencyNotAvailable:
  41. pass
  42. else:
  43. _import_structure["modeling_tf_opt"] = ["TFOPTForCausalLM", "TFOPTModel", "TFOPTPreTrainedModel"]
  44. try:
  45. if not is_flax_available():
  46. raise OptionalDependencyNotAvailable()
  47. except OptionalDependencyNotAvailable:
  48. pass
  49. else:
  50. _import_structure["modeling_flax_opt"] = [
  51. "FlaxOPTForCausalLM",
  52. "FlaxOPTModel",
  53. "FlaxOPTPreTrainedModel",
  54. ]
  55. if TYPE_CHECKING:
  56. from .configuration_opt import OPTConfig
  57. try:
  58. if not is_torch_available():
  59. raise OptionalDependencyNotAvailable()
  60. except OptionalDependencyNotAvailable:
  61. pass
  62. else:
  63. from .modeling_opt import (
  64. OPTForCausalLM,
  65. OPTForQuestionAnswering,
  66. OPTForSequenceClassification,
  67. OPTModel,
  68. OPTPreTrainedModel,
  69. )
  70. try:
  71. if not is_tf_available():
  72. raise OptionalDependencyNotAvailable()
  73. except OptionalDependencyNotAvailable:
  74. pass
  75. else:
  76. from .modeling_tf_opt import TFOPTForCausalLM, TFOPTModel, TFOPTPreTrainedModel
  77. try:
  78. if not is_flax_available():
  79. raise OptionalDependencyNotAvailable()
  80. except OptionalDependencyNotAvailable:
  81. pass
  82. else:
  83. from .modeling_flax_opt import FlaxOPTForCausalLM, FlaxOPTModel, FlaxOPTPreTrainedModel
  84. else:
  85. import sys
  86. sys.modules[__name__] = _LazyModule(__name__, globals()["__file__"], _import_structure, module_spec=__spec__)