__init__.py 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. # Copyright 2022 Facebook and 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 OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available
  16. _import_structure = {
  17. "configuration_esm": ["EsmConfig"],
  18. "tokenization_esm": ["EsmTokenizer"],
  19. }
  20. try:
  21. if not is_torch_available():
  22. raise OptionalDependencyNotAvailable()
  23. except OptionalDependencyNotAvailable:
  24. pass
  25. else:
  26. _import_structure["modeling_esm"] = [
  27. "EsmForMaskedLM",
  28. "EsmForSequenceClassification",
  29. "EsmForTokenClassification",
  30. "EsmModel",
  31. "EsmPreTrainedModel",
  32. ]
  33. _import_structure["modeling_esmfold"] = ["EsmForProteinFolding", "EsmFoldPreTrainedModel"]
  34. try:
  35. if not is_tf_available():
  36. raise OptionalDependencyNotAvailable()
  37. except OptionalDependencyNotAvailable:
  38. pass
  39. else:
  40. _import_structure["modeling_tf_esm"] = [
  41. "TFEsmForMaskedLM",
  42. "TFEsmForSequenceClassification",
  43. "TFEsmForTokenClassification",
  44. "TFEsmModel",
  45. "TFEsmPreTrainedModel",
  46. ]
  47. if TYPE_CHECKING:
  48. from .configuration_esm import EsmConfig
  49. from .tokenization_esm import EsmTokenizer
  50. try:
  51. if not is_torch_available():
  52. raise OptionalDependencyNotAvailable()
  53. except OptionalDependencyNotAvailable:
  54. pass
  55. else:
  56. from .modeling_esm import (
  57. EsmForMaskedLM,
  58. EsmForSequenceClassification,
  59. EsmForTokenClassification,
  60. EsmModel,
  61. EsmPreTrainedModel,
  62. )
  63. from .modeling_esmfold import EsmFoldPreTrainedModel, EsmForProteinFolding
  64. try:
  65. if not is_tf_available():
  66. raise OptionalDependencyNotAvailable()
  67. except OptionalDependencyNotAvailable:
  68. pass
  69. else:
  70. from .modeling_tf_esm import (
  71. TFEsmForMaskedLM,
  72. TFEsmForSequenceClassification,
  73. TFEsmForTokenClassification,
  74. TFEsmModel,
  75. TFEsmPreTrainedModel,
  76. )
  77. else:
  78. import sys
  79. sys.modules[__name__] = _LazyModule(__name__, globals()["__file__"], _import_structure)