__init__.py 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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_tokenizers_available,
  20. is_torch_available,
  21. )
  22. _import_structure = {
  23. "configuration_bloom": ["BloomConfig", "BloomOnnxConfig"],
  24. }
  25. try:
  26. if not is_tokenizers_available():
  27. raise OptionalDependencyNotAvailable()
  28. except OptionalDependencyNotAvailable:
  29. pass
  30. else:
  31. _import_structure["tokenization_bloom_fast"] = ["BloomTokenizerFast"]
  32. try:
  33. if not is_torch_available():
  34. raise OptionalDependencyNotAvailable()
  35. except OptionalDependencyNotAvailable:
  36. pass
  37. else:
  38. _import_structure["modeling_bloom"] = [
  39. "BloomForCausalLM",
  40. "BloomModel",
  41. "BloomPreTrainedModel",
  42. "BloomForSequenceClassification",
  43. "BloomForTokenClassification",
  44. "BloomForQuestionAnswering",
  45. ]
  46. try:
  47. if not is_flax_available():
  48. raise OptionalDependencyNotAvailable()
  49. except OptionalDependencyNotAvailable:
  50. pass
  51. else:
  52. _import_structure["modeling_flax_bloom"] = [
  53. "FlaxBloomForCausalLM",
  54. "FlaxBloomModel",
  55. "FlaxBloomPreTrainedModel",
  56. ]
  57. if TYPE_CHECKING:
  58. from .configuration_bloom import BloomConfig, BloomOnnxConfig
  59. try:
  60. if not is_tokenizers_available():
  61. raise OptionalDependencyNotAvailable()
  62. except OptionalDependencyNotAvailable:
  63. pass
  64. else:
  65. from .tokenization_bloom_fast import BloomTokenizerFast
  66. try:
  67. if not is_torch_available():
  68. raise OptionalDependencyNotAvailable()
  69. except OptionalDependencyNotAvailable:
  70. pass
  71. else:
  72. from .modeling_bloom import (
  73. BloomForCausalLM,
  74. BloomForQuestionAnswering,
  75. BloomForSequenceClassification,
  76. BloomForTokenClassification,
  77. BloomModel,
  78. BloomPreTrainedModel,
  79. )
  80. try:
  81. if not is_flax_available():
  82. raise OptionalDependencyNotAvailable()
  83. except OptionalDependencyNotAvailable:
  84. pass
  85. else:
  86. from .modeling_flax_bloom import FlaxBloomForCausalLM, FlaxBloomModel, FlaxBloomPreTrainedModel
  87. else:
  88. import sys
  89. sys.modules[__name__] = _LazyModule(__name__, globals()["__file__"], _import_structure, module_spec=__spec__)