


'''simple docstring'''






import doctest
import logging
import os
import unittest
from pathlib import Path
from typing import List, Union

import transformers
from transformers.testing_utils import require_tf, require_torch, slow


__A :  List[Any]    							=				logging.getLogger()






@unittest.skip('Temporarily disable the doc tests.')
@require_torch
@require_tf
@slow
class        __snake_case	(       unittest.TestCase):







    """simple docstring"""



    def __lowercase       (       self   :  List[Any]   ,						lowerCamelCase   :  Path   ,						lowerCamelCase   :  Union[str, None] = None   ,						lowerCamelCase   :  Union[List[str], None] = None   ,						lowerCamelCase   :  Union[str, List[str], None] = None   ,						lowerCamelCase   :  bool = True   ,						)       ->  Optional[Any]:
      lowerCAmelCase_      :				Optional[int]      =       [file for file in os.listdir(lowerCamelCase		) if os.path.isfile(os.path.join(lowerCamelCase   ,						lowerCamelCase		)		)]

      if identifier is not None:
        lowerCAmelCase_      :				Union[str, Any]      =       [file for file in files if identifier in file]

      if n_identifier is not None:
        if isinstance(lowerCamelCase   ,						lowerCamelCase		):
          for n_ in n_identifier:
            lowerCAmelCase_      :				List[str]      =       [file for file in files if n_ not in file]
        else:
          lowerCAmelCase_      :				List[Any]      =       [file for file in files if n_identifier not in file]

      lowerCAmelCase_      :				Optional[Any]      =       ignore_files or []
      ignore_files.append("""__init__.py"""		)
      lowerCAmelCase_      :				Dict      =       [file for file in files if file not in ignore_files]

      for file in files:
        # Open all files
        print("""Testing"""   ,						lowerCamelCase		)

        if only_modules:
          lowerCAmelCase_      :				Union[str, Any]      =       file.split("""."""		)[0]
          try:
            lowerCAmelCase_      :				Any      =       getattr(lowerCamelCase   ,						lowerCamelCase		)
            lowerCAmelCase_      :				int      =       doctest.DocTestSuite(lowerCamelCase		)
            lowerCAmelCase_      :				Dict      =       unittest.TextTestRunner().run(lowerCamelCase		)
            self.assertIs(len(result.failures		)   ,						0		)
          except AttributeError:
            logger.info(F'{module_identifier} is not a module.'		)
        else:
          lowerCAmelCase_      :				Union[str, Any]      =       doctest.testfile(str("""..""" / directory / file		)   ,						optionflags=doctest.ELLIPSIS		)
          self.assertIs(result.failed   ,						0		)

    def __lowercase       (       self   :  Tuple		)       ->  List[str]:
      lowerCAmelCase_      :				List[str]      =       Path("""src/transformers"""		)
      lowerCAmelCase_      :				List[str]      =       """modeling"""
      lowerCAmelCase_      :				Dict      =       [
          """modeling_ctrl.py""",
          """modeling_tf_ctrl.py""",
      ]
      self.analyze_directory(lowerCamelCase   ,						identifier=lowerCamelCase   ,						ignore_files=lowerCamelCase		)

    def __lowercase       (       self   :  Union[str, Any]		)       ->  Any:
      lowerCAmelCase_      :				str      =       Path("""src/transformers"""		)
      lowerCAmelCase_      :				List[Any]      =       """tokenization"""
      self.analyze_directory(lowerCamelCase   ,						identifier=lowerCamelCase		)

    def __lowercase       (       self   :  Dict		)       ->  List[str]:
      lowerCAmelCase_      :				Optional[Any]      =       Path("""src/transformers"""		)
      lowerCAmelCase_      :				List[Any]      =       """configuration"""
      self.analyze_directory(lowerCamelCase   ,						identifier=lowerCamelCase		)

    def __lowercase       (       self   :  Dict		)       ->  Dict:
      lowerCAmelCase_      :				Any      =       Path("""src/transformers"""		)
      lowerCAmelCase_      :				str      =       ["""configuration""", """modeling""", """tokenization"""]
      self.analyze_directory(lowerCamelCase   ,						n_identifier=lowerCamelCase		)





    def __lowercase       (       self   :  Optional[int]		)       ->  List[str]:
      lowerCAmelCase_      :				Optional[int]      =       Path("""docs/source"""		)
      lowerCAmelCase_      :				Optional[Any]      =       ["""favicon.ico"""]
      self.analyze_directory(lowerCamelCase   ,						ignore_files=lowerCamelCase   ,						only_modules=lowerCamelCase		)







'''simple docstring'''






from ...utils import is_note_seq_available, is_transformers_available, is_torch_available
from ...utils import OptionalDependencyNotAvailable


try:
  if not (is_transformers_available() and is_torch_available()):
    raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
  from ...utils.dummy_torch_and_transformers_objects import *  # noqa F403
else:
  from .notes_encoder import SpectrogramNotesEncoder
  from .continous_encoder import SpectrogramContEncoder
  from .pipeline_spectrogram_diffusion import (
      SpectrogramContEncoder,
      SpectrogramDiffusionPipeline,
      TaFilmDecoder,
  )

try:
  if not (is_transformers_available() and is_torch_available() and is_note_seq_available()):
    raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
  from ...utils.dummy_transformers_and_torch_and_note_seq_objects import *  # noqa F403
else:
  from .midi_utils import MidiProcessor



