



"""simple docstring"""







import unittest

from transformers import JukeboxTokenizer
from transformers.testing_utils import require_torch







class       UpperCamelCase__   (	unittest.TestCase  ):




      """simple docstring"""




      _SCREAMING_SNAKE_CASE  				=     JukeboxTokenizer
      _SCREAMING_SNAKE_CASE  				=     {
          """artist""": """Zac Brown Band""",
          """genres""": """Country""",
          """lyrics""": """I met a traveller from an antique land,
        Who said \"Two vast and trunkless legs of stone
        Stand in the desert. . . . Near them, on the sand,
        Half sunk a shattered visage lies, whose frown,
        And wrinkled lip, and sneer of cold command,
        Tell that its sculptor well those passions read
        Which yet survive, stamped on these lifeless things,
        The hand that mocked them, and the heart that fed;
        And on the pedestal, these words appear:
        My name is Ozymandias, King of Kings;
        Look on my Works, ye Mighty, and despair!
        Nothing beside remains. Round the decay
        Of that colossal Wreck, boundless and bare
        The lone and level sands stretch far away
        """,
      }



      @require_torch
      def      SCREAMING_SNAKE_CASE__ (      self				:      Any       ):
        import torch

        lowerCAmelCase_   :				Dict								= JukeboxTokenizer.from_pretrained('openai/jukebox-1b-lyrics'       )
        lowerCAmelCase_   :				str								= tokenizer(**self.metas       )['input_ids']
        # fmt: off
        lowerCAmelCase_   :				Tuple								= [
            torch.tensor([[
                0, 0, 0, 7_1_6_9, 5_0_7, 9, 7_6, 3_9, 3_1, 4_6, 7_6, 2_7,
                7_6, 4_6, 4_4, 2_7, 4_8, 3_1, 3_8, 3_8, 3_1, 4_4, 7_6, 3_2,
                4_4, 4_1, 3_9, 7_6, 2_7, 4_0, 7_6, 2_7, 4_0, 4_6, 3_5, 4_3,
                4_7, 3_1, 7_6, 3_8, 2_7, 4_0, 3_0, 6_4, 7_8, 7_6, 7_6, 7_6,
                7_6, 7_6, 7_6, 7_6, 7_6, 2_3, 3_4, 4_1, 7_6, 4_5, 2_7, 3_5,
                3_0, 7_6, 7_1, 2_0, 4_9, 4_1, 7_6, 4_8, 2_7, 4_5, 4_6, 7_6,
                2_7, 4_0, 3_0, 7_6, 4_6, 4_4, 4_7, 4_0, 3_7, 3_8, 3_1, 4_5,
                4_5, 7_6, 3_8, 3_1, 3_3, 4_5, 7_6, 4_1, 3_2, 7_6, 4_5, 4_6,
                4_1, 4_0, 3_1, 7_8, 7_6, 7_6, 7_6, 7_6, 7_6, 7_6, 7_6, 7_6,
                1_9, 4_6, 2_7, 4_0, 3_0, 7_6, 3_5, 4_0, 7_6, 4_6, 3_4, 3_1,
                7_6, 3_0, 3_1, 4_5, 3_1, 4_4, 4_6, 6_3, 7_6, 6_3, 7_6, 6_3,
                7_6, 6_3, 7_6, 1_4, 3_1, 2_7, 4_4, 7_6, 4_6, 3_4, 3_1, 3_9,
                6_4, 7_6, 4_1, 4_0, 7_6, 4_6, 3_4, 3_1, 7_6, 4_5, 2_7, 4_0,
                3_0, 6_4, 7_8, 7_6, 7_6, 7_6, 7_6, 7_6, 7_6, 7_6, 7_6, 8,
                2_7, 3_8, 3_2, 7_6, 4_5, 4_7, 4_0, 3_7, 7_6, 2_7, 7_6, 4_5,
                3_4, 2_7, 4_6, 4_6, 3_1, 4_4, 3_1, 3_0, 7_6, 4_8, 3_5, 4_5,
                2_7, 3_3, 3_1, 7_6, 3_8, 3_5, 3_1, 4_5, 6_4, 7_6, 4_9, 3_4,
                4_1, 4_5, 3_1, 7_6, 3_2, 4_4, 4_1, 4_9, 4_0, 6_4, 7_8, 7_6,
                7_6, 7_6, 7_6, 7_6, 7_6, 7_6, 7_6, 1, 4_0, 3_0, 7_6, 4_9,
                4_4, 3_5, 4_0, 3_7, 3_8, 3_1, 3_0, 7_6, 3_8, 3_5, 4_2, 6_4,
                7_6, 2_7, 4_0, 3_0, 7_6, 4_5, 4_0, 3_1, 3_1, 4_4, 7_6, 4_1,
                3_2, 7_6, 2_9, 4_1, 3_8, 3_0, 7_6, 2_9, 4_1, 3_9, 3_9, 2_7,
                4_0, 3_0, 6_4, 7_8, 7_6, 7_6, 7_6, 7_6, 7_6, 7_6, 7_6, 7_6,
                2_0, 3_1, 3_8, 3_8, 7_6, 4_6, 3_4, 2_7, 4_6, 7_6, 3_5, 4_6,
                4_5, 7_6, 4_5, 2_9, 4_7, 3_8, 4_2, 4_6, 4_1, 4_4, 7_6, 4_9,
                3_1, 3_8, 3_8, 7_6, 4_6, 3_4, 4_1, 4_5, 3_1, 7_6, 4_2, 2_7,
                4_5, 4_5, 3_5, 4_1, 4_0, 4_5, 7_6, 4_4, 3_1, 2_7, 3_0, 7_8,
                7_6, 7_6, 7_6, 7_6, 7_6, 7_6, 7_6, 7_6, 2_3, 3_4, 3_5, 2_9,
                3_4, 7_6, 5_1, 3_1, 4_6, 7_6, 4_5, 4_7, 4_4, 4_8, 3_5, 4_8,
                3_1, 6_4, 7_6, 4_5, 4_6, 2_7, 3_9, 4_2, 3_1, 3_0, 7_6, 4_1,
                4_0, 7_6, 4_6, 3_4, 3_1, 4_5, 3_1, 7_6, 3_8, 3_5, 3_2, 3_1,
                3_8, 3_1, 4_5, 4_5, 7_6, 4_6, 3_4, 3_5, 4_0, 3_3, 4_5, 6_4,
                7_8, 7_6, 7_6, 7_6, 7_6, 7_6, 7_6, 7_6, 7_6, 2_0, 3_4, 3_1,
                7_6, 3_4, 2_7, 4_0, 3_0, 7_6, 4_6, 3_4, 2_7, 4_6, 7_6, 3_9,
                4_1, 2_9, 3_7, 3_1, 3_0, 7_6, 4_6, 3_4, 3_1, 3_9, 6_4, 7_6,
                2_7, 4_0, 3_0, 7_6, 4_6, 3_4, 3_1, 7_6, 3_4, 3_1, 2_7, 4_4,
                4_6, 7_6, 4_6, 3_4, 2_7, 4_6, 7_6, 3_2, 3_1, 3_0, 6_6, 7_8,
                7_6, 7_6, 7_6, 7_6, 7_6, 7_6, 7_6, 7_6, 1, 4_0, 3_0, 7_6,
                4_1, 4_0, 7_6, 4_6, 3_4, 3_1, 7_6, 4_2, 3_1, 3_0, 3_1, 4_5,
                4_6, 2_7, 3_8, 6_4, 7_6, 4_6, 3_4, 3_1, 4_5, 3_1, 7_6, 4_9,
                4_1, 4_4, 3_0, 4_5, 7_6, 2_7, 4_2, 4_2, 3_1, 2_7, 4_4, 6_5,
                7_8, 7_6, 7_6, 7_6, 7_6, 7_6, 7_6, 7_6, 7_6, 1_3, 5_1, 7_6,
                4_0, 2_7, 3_9, 3_1, 7_6, 3_5, 4_5, 7_6, 1_5, 5_2, 5_1, 3_9,
                2_7, 4_0, 3_0, 3_5, 2_7, 4_5, 6_4, 7_6, 1_1, 3_5, 4_0, 3_3,
                7_6, 4_1, 3_2, 7_6, 1_1, 3_5, 4_0, 3_3, 4_5, 6_6, 7_8, 7_6,
                7_6, 7_6, 7_6, 7_6, 7_6, 7_6, 7_6, 1_2, 4_1, 4_1, 3_7, 7_6,
                4_1, 4_0, 7_6, 3_9, 5_1, 7_6, 2_3, 4_1, 4_4, 3_7, 4_5, 6_4,
                7_6, 5_1, 3_1, 7_6, 1_3, 3_5, 3_3, 3_4, 4_6, 5_1, 6_4, 7_6,
                2_7, 4_0, 3_0, 7_6, 3_0, 3_1, 4_5, 4_2, 2_7, 3_5, 4_4, 6_7,
                7_8, 7_6, 7_6, 7_6, 7_6, 7_6, 7_6, 7_6, 7_6, 1_4, 4_1, 4_6,
                3_4, 3_5, 4_0, 3_3, 7_6, 2_8, 3_1, 4_5, 3_5, 3_0, 3_1, 7_6,
                4_4, 3_1, 3_9, 2_7, 3_5, 4_0, 4_5, 6_3, 7_6, 1_8, 4_1, 4_7,
                4_0, 3_0, 7_6, 4_6, 3_4, 3_1, 7_6, 3_0, 3_1, 2_9, 2_7, 5_1,
                7_8, 7_6, 7_6, 7_6, 7_6, 7_6, 7_6, 7_6, 7_6, 1_5, 3_2, 7_6,
                4_6, 3_4, 2_7, 4_6, 7_6, 2_9, 4_1, 3_8, 4_1, 4_5, 4_5, 2_7,
                3_8, 7_6, 2_3, 4_4, 3_1, 2_9, 3_7, 6_4, 7_6, 2_8, 4_1, 4_7,
                4_0, 3_0, 3_8, 3_1, 4_5, 4_5, 7_6, 2_7, 4_0, 3_0, 7_6, 2_8,
                2_7, 4_4, 3_1, 7_8, 7_6, 7_6, 7_6, 7_6, 7_6, 7_6, 7_6, 7_6,
                2_0, 3_4, 3_1, 7_6, 3_8, 4_1, 4_0, 3_1, 7_6, 2_7, 4_0, 3_0,
                7_6, 3_8, 3_1, 4_8, 3_1, 3_8, 7_6, 4_5, 2_7, 4_0, 3_0, 4_5,
                7_6, 4_5, 4_6, 4_4, 3_1, 4_6, 2_9, 3_4, 7_6, 3_2, 2_7, 4_4,
                7_6, 2_7, 4_9, 2_7, 5_1, 7_8, 7_6, 7_6, 7_6, 7_6, 7_6, 7_6,
                7_6, 7_6]]       ),
            torch.tensor([[0, 0, 0, 1_0_6_9, 1_1]]       ),
            torch.tensor([[0, 0, 0, 1_0_6_9, 1_1]]       ),
        ]
        # fmt: on
        self.assertTrue(torch.allclose(tokens[0]    ,			EXPECTED_OUTPUT[0]       )       )
        self.assertTrue(torch.allclose(tokens[1]    ,			EXPECTED_OUTPUT[1]       )       )
        self.assertTrue(torch.allclose(tokens[2]    ,			EXPECTED_OUTPUT[2]       )       )





      @require_torch
      def      SCREAMING_SNAKE_CASE__ (      self				:      Any       ):
        import torch

        lowerCAmelCase_   :				List[Any]								= JukeboxTokenizer.from_pretrained('openai/jukebox-5b-lyrics'       )
        lowerCAmelCase_   :				int								= tokenizer(**self.metas       )['input_ids']
        # fmt: off
        lowerCAmelCase_   :				Dict								= [
            torch.tensor([[
                0, 0, 0, 1_0_6_9, 1_1, -1, -1, -1, -1, 9, 7_7, 3_9,
                3_1, 4_6, 7_7, 2_7, 7_7, 4_6, 4_4, 2_7, 4_8, 3_1, 3_8, 3_8,
                3_1, 4_4, 7_7, 3_2, 4_4, 4_1, 3_9, 7_7, 2_7, 4_0, 7_7, 2_7,
                4_0, 4_6, 3_5, 4_3, 4_7, 3_1, 7_7, 3_8, 2_7, 4_0, 3_0, 6_4,
                7_9, 7_7, 7_7, 7_7, 7_7, 7_7, 7_7, 7_7, 7_7, 2_3, 3_4, 4_1,
                7_7, 4_5, 2_7, 3_5, 3_0, 7_7, 7_2, 2_0, 4_9, 4_1, 7_7, 4_8,
                2_7, 4_5, 4_6, 7_7, 2_7, 4_0, 3_0, 7_7, 4_6, 4_4, 4_7, 4_0,
                3_7, 3_8, 3_1, 4_5, 4_5, 7_7, 3_8, 3_1, 3_3, 4_5, 7_7, 4_1,
                3_2, 7_7, 4_5, 4_6, 4_1, 4_0, 3_1, 7_9, 7_7, 7_7, 7_7, 7_7,
                7_7, 7_7, 7_7, 7_7, 1_9, 4_6, 2_7, 4_0, 3_0, 7_7, 3_5, 4_0,
                7_7, 4_6, 3_4, 3_1, 7_7, 3_0, 3_1, 4_5, 3_1, 4_4, 4_6, 6_3,
                7_7, 6_3, 7_7, 6_3, 7_7, 6_3, 7_7, 1_4, 3_1, 2_7, 4_4, 7_7,
                4_6, 3_4, 3_1, 3_9, 6_4, 7_7, 4_1, 4_0, 7_7, 4_6, 3_4, 3_1,
                7_7, 4_5, 2_7, 4_0, 3_0, 6_4, 7_9, 7_7, 7_7, 7_7, 7_7, 7_7,
                7_7, 7_7, 7_7, 8, 2_7, 3_8, 3_2, 7_7, 4_5, 4_7, 4_0, 3_7,
                7_7, 2_7, 7_7, 4_5, 3_4, 2_7, 4_6, 4_6, 3_1, 4_4, 3_1, 3_0,
                7_7, 4_8, 3_5, 4_5, 2_7, 3_3, 3_1, 7_7, 3_8, 3_5, 3_1, 4_5,
                6_4, 7_7, 4_9, 3_4, 4_1, 4_5, 3_1, 7_7, 3_2, 4_4, 4_1, 4_9,
                4_0, 6_4, 7_9, 7_7, 7_7, 7_7, 7_7, 7_7, 7_7, 7_7, 7_7, 1,
                4_0, 3_0, 7_7, 4_9, 4_4, 3_5, 4_0, 3_7, 3_8, 3_1, 3_0, 7_7,
                3_8, 3_5, 4_2, 6_4, 7_7, 2_7, 4_0, 3_0, 7_7, 4_5, 4_0, 3_1,
                3_1, 4_4, 7_7, 4_1, 3_2, 7_7, 2_9, 4_1, 3_8, 3_0, 7_7, 2_9,
                4_1, 3_9, 3_9, 2_7, 4_0, 3_0, 6_4, 7_9, 7_7, 7_7, 7_7, 7_7,
                7_7, 7_7, 7_7, 7_7, 2_0, 3_1, 3_8, 3_8, 7_7, 4_6, 3_4, 2_7,
                4_6, 7_7, 3_5, 4_6, 4_5, 7_7, 4_5, 2_9, 4_7, 3_8, 4_2, 4_6,
                4_1, 4_4, 7_7, 4_9, 3_1, 3_8, 3_8, 7_7, 4_6, 3_4, 4_1, 4_5,
                3_1, 7_7, 4_2, 2_7, 4_5, 4_5, 3_5, 4_1, 4_0, 4_5, 7_7, 4_4,
                3_1, 2_7, 3_0, 7_9, 7_7, 7_7, 7_7, 7_7, 7_7, 7_7, 7_7, 7_7,
                2_3, 3_4, 3_5, 2_9, 3_4, 7_7, 5_1, 3_1, 4_6, 7_7, 4_5, 4_7,
                4_4, 4_8, 3_5, 4_8, 3_1, 6_4, 7_7, 4_5, 4_6, 2_7, 3_9, 4_2,
                3_1, 3_0, 7_7, 4_1, 4_0, 7_7, 4_6, 3_4, 3_1, 4_5, 3_1, 7_7,
                3_8, 3_5, 3_2, 3_1, 3_8, 3_1, 4_5, 4_5, 7_7, 4_6, 3_4, 3_5,
                4_0, 3_3, 4_5, 6_4, 7_9, 7_7, 7_7, 7_7, 7_7, 7_7, 7_7, 7_7,
                7_7, 2_0, 3_4, 3_1, 7_7, 3_4, 2_7, 4_0, 3_0, 7_7, 4_6, 3_4,
                2_7, 4_6, 7_7, 3_9, 4_1, 2_9, 3_7, 3_1, 3_0, 7_7, 4_6, 3_4,
                3_1, 3_9, 6_4, 7_7, 2_7, 4_0, 3_0, 7_7, 4_6, 3_4, 3_1, 7_7,
                3_4, 3_1, 2_7, 4_4, 4_6, 7_7, 4_6, 3_4, 2_7, 4_6, 7_7, 3_2,
                3_1, 3_0, 6_6, 7_9, 7_7, 7_7, 7_7, 7_7, 7_7, 7_7, 7_7, 7_7,
                1, 4_0, 3_0, 7_7, 4_1, 4_0, 7_7, 4_6, 3_4, 3_1, 7_7, 4_2,
                3_1, 3_0, 3_1, 4_5, 4_6, 2_7, 3_8, 6_4, 7_7, 4_6, 3_4, 3_1,
                4_5, 3_1, 7_7, 4_9, 4_1, 4_4, 3_0, 4_5, 7_7, 2_7, 4_2, 4_2,
                3_1, 2_7, 4_4, 6_5, 7_9, 7_7, 7_7, 7_7, 7_7, 7_7, 7_7, 7_7,
                7_7, 1_3, 5_1, 7_7, 4_0, 2_7, 3_9, 3_1, 7_7, 3_5, 4_5, 7_7,
                1_5, 5_2, 5_1, 3_9, 2_7, 4_0, 3_0, 3_5, 2_7, 4_5, 6_4, 7_7,
                1_1, 3_5, 4_0, 3_3, 7_7, 4_1, 3_2, 7_7, 1_1, 3_5, 4_0, 3_3,
                4_5, 6_6, 7_9, 7_7, 7_7, 7_7, 7_7, 7_7, 7_7, 7_7, 7_7, 1_2,
                4_1, 4_1, 3_7, 7_7, 4_1, 4_0, 7_7, 3_9, 5_1, 7_7, 2_3, 4_1,
                4_4, 3_7, 4_5, 6_4, 7_7, 5_1, 3_1, 7_7, 1_3, 3_5, 3_3, 3_4,
                4_6, 5_1, 6_4, 7_7, 2_7, 4_0, 3_0, 7_7, 3_0, 3_1, 4_5, 4_2,
                2_7, 3_5, 4_4, 6_7, 7_9, 7_7, 7_7, 7_7, 7_7, 7_7, 7_7, 7_7,
                7_7, 1_4, 4_1, 4_6, 3_4, 3_5, 4_0, 3_3, 7_7, 2_8, 3_1, 4_5,
                3_5, 3_0, 3_1, 7_7, 4_4, 3_1, 3_9, 2_7, 3_5, 4_0, 4_5, 6_3,
                7_7, 1_8, 4_1, 4_7, 4_0, 3_0, 7_7, 4_6, 3_4, 3_1, 7_7, 3_0,
                3_1, 2_9, 2_7, 5_1, 7_9, 7_7, 7_7, 7_7, 7_7, 7_7, 7_7, 7_7,
                7_7, 1_5, 3_2, 7_7, 4_6, 3_4, 2_7, 4_6, 7_7, 2_9, 4_1, 3_8,
                4_1, 4_5, 4_5, 2_7, 3_8, 7_7, 2_3, 4_4, 3_1, 2_9, 3_7, 6_4,
                7_7, 2_8, 4_1, 4_7, 4_0, 3_0, 3_8, 3_1, 4_5, 4_5, 7_7, 2_7,
                4_0, 3_0, 7_7, 2_8, 2_7, 4_4, 3_1, 7_9, 7_7, 7_7, 7_7, 7_7,
                7_7, 7_7, 7_7, 7_7, 2_0, 3_4, 3_1, 7_7, 3_8, 4_1, 4_0, 3_1,
                7_7, 2_7, 4_0, 3_0, 7_7, 3_8, 3_1, 4_8, 3_1, 3_8, 7_7, 4_5,
                2_7, 4_0, 3_0, 4_5, 7_7, 4_5, 4_6, 4_4, 3_1, 4_6, 2_9, 3_4,
                7_7, 3_2, 2_7, 4_4, 7_7, 2_7, 4_9, 2_7, 5_1, 7_9, 7_7, 7_7,
                7_7, 7_7, 7_7, 7_7, 7_7, 7_7]]       ),
            torch.tensor([[0, 0, 0, 1_0_6_9, 1_1, -1, -1, -1, -1]]       ),
            torch.tensor([[0, 0, 0, 1_0_6_9, 1_1, -1, -1, -1, -1]]       ),
        ]
        # fmt: on
        self.assertTrue(torch.allclose(tokens[0]    ,			EXPECTED_OUTPUT[0]       )       )
        self.assertTrue(torch.allclose(tokens[1]    ,			EXPECTED_OUTPUT[1]       )       )
        self.assertTrue(torch.allclose(tokens[2]    ,			EXPECTED_OUTPUT[2]       )       )










"""simple docstring"""







import collections
import json
import math
import os
import re
import time
from fnmatch import fnmatch
from typing import Dict

import requests
from slack_sdk import WebClient


lowercase__		:				List[str]          =	WebClient(token=os.environ["""CI_SLACK_BOT_TOKEN"""])

def 				UpperCamelCase_    (    lowerCAmelCase__      :				Dict						)						->   Optional[Any]:

  """simple docstring"""




  lowerCAmelCase_   :				List[Any]								= test_results.split(' '						)

  lowerCAmelCase_   :				Tuple								= 0
  lowerCAmelCase_   :				Any								= 0

  # When the output is short enough, the output is surrounded by = signs: "== OUTPUT =="
  # When it is too long, those signs are not present.
  lowerCAmelCase_   :				Any								= expressions[-2] if '=' in expressions[-1] else expressions[-1]

  for i, expression in enumerate(lowerCAmelCase__						):
    if "failed" in expression:
      failed += int(expressions[i - 1]						)
    if "passed" in expression:
      success += int(expressions[i - 1]						)

  return failed, success, time_spent

def 				UpperCamelCase_    (    lowerCAmelCase__      :				Dict						)						->   str:

  """simple docstring"""




  lowerCAmelCase_   :				Optional[Any]								= {}
  lowerCAmelCase_   :				List[str]								= None
  lowerCAmelCase_   :				List[str]								= False
  for line in failures_short_lines.split('\n'						):
    if re.search(R'_ \[doctest\]'    ,   lowerCAmelCase__						):
      lowerCAmelCase_   :				Optional[Any]								= True
      lowerCAmelCase_   :				Union[str, Any]								= line.split(' '						)[2]
    elif in_error and not line.split(' '						)[0].isdigit():
      lowerCAmelCase_   :				Union[str, Any]								= line
      lowerCAmelCase_   :				int								= False

  return failures







class       UpperCamelCase__   :




      """simple docstring"""




      def __init__(      self				:      Optional[Any]    ,			SCREAMING_SNAKE_CASE_				:      str    ,			SCREAMING_SNAKE_CASE_				:      Dict       ):
        lowerCAmelCase_   :				str								= title

        lowerCAmelCase_   :				Optional[int]								= doc_test_results['time_spent'].split(','       )[0]
        lowerCAmelCase_   :				int								= doc_test_results['success']
        lowerCAmelCase_   :				Dict								= doc_test_results['failures']
        lowerCAmelCase_   :				Optional[int]								= self.n_success + self.n_failures

        # Failures and success of the modeling tests
        lowerCAmelCase_   :				Any								= doc_test_results



      @property
      def      SCREAMING_SNAKE_CASE__ (      self				:      List[str]       ):
        lowerCAmelCase_   :				int								= [self._time_spent]
        lowerCAmelCase_   :				Any								= 0

        for time in time_spent:
          lowerCAmelCase_   :				Optional[Any]								= time.split(':'       )

          # Time can be formatted as xx:xx:xx, as .xx, or as x.xx if the time spent was less than a minute.
          if len(SCREAMING_SNAKE_CASE_       ) == 1:
            lowerCAmelCase_   :				Any								= [0, 0, time_parts[0]]

          lowerCAmelCase_						,lowerCAmelCase_						,lowerCAmelCase_   :				List[str]								= int(time_parts[0]       ), int(time_parts[1]       ), float(time_parts[2]       )
          total_secs += hours * 3_6_0_0 + minutes * 6_0 + seconds

        lowerCAmelCase_						,lowerCAmelCase_						,lowerCAmelCase_   :				Union[str, Any]								= total_secs // 3_6_0_0, (total_secs % 3_6_0_0) // 6_0, total_secs % 6_0
        return F"{int(SCREAMING_SNAKE_CASE_       )}h{int(SCREAMING_SNAKE_CASE_       )}m{int(SCREAMING_SNAKE_CASE_       )}s"



      @property
      def      SCREAMING_SNAKE_CASE__ (      self				:      int       ):
        return {"type": "header", "text": {"type": "plain_text", "text": self.title}}



      @property
      def      SCREAMING_SNAKE_CASE__ (      self				:      str       ):
        return {
            "type": "section",
            "text": {
                "type": "plain_text",
                "text": F"🌞 There were no failures: all {self.n_tests} tests passed. The suite ran in {self.time}.",
                "emoji": True,
            },
            "accessory": {
                "type": "button",
                "text": {"type": "plain_text", "text": "Check Action results", "emoji": True},
                "url": F"https://github.com/huggingface/transformers/actions/runs/{os.environ['GITHUB_RUN_ID']}",
            },
        }



      @property
      def      SCREAMING_SNAKE_CASE__ (      self				:      List[Any]       ):
        return {
            "type": "section",
            "text": {
                "type": "plain_text",
                "text": (
                    F"There were {self.n_failures} failures, out of {self.n_tests} tests.\nThe suite ran in"
                    F" {self.time}."
                ),
                "emoji": True,
            },
            "accessory": {
                "type": "button",
                "text": {"type": "plain_text", "text": "Check Action results", "emoji": True},
                "url": F"https://github.com/huggingface/transformers/actions/runs/{os.environ['GITHUB_RUN_ID']}",
            },
        }



      @property
      def      SCREAMING_SNAKE_CASE__ (      self				:      Tuple       ):
        lowerCAmelCase_   :				int								= 4_0
        lowerCAmelCase_   :				List[Any]								= {k: v['failed'] for k, v in doc_test_results.items() if isinstance(SCREAMING_SNAKE_CASE_    ,			SCREAMING_SNAKE_CASE_       )}

        lowerCAmelCase_   :				List[str]								= ''
        for category, failures in category_failures.items():
          if len(SCREAMING_SNAKE_CASE_       ) == 0:
            continue

          if report != "":
            report += "\n\n"

          report += F"*{category} failures*:".ljust(line_length // 2       ).rjust(line_length // 2       ) + "\n"
          report += "`"
          report += "`\n`".join(SCREAMING_SNAKE_CASE_       )
          report += "`"

        return {
            "type": "section",
            "text": {
                "type": "mrkdwn",
                "text": F"The following examples had failures:\n\n\n{report}\n",
            },
        }



      @property
      def      SCREAMING_SNAKE_CASE__ (      self				:      int       ):
        lowerCAmelCase_   :				int								= [self.header]

        if self.n_failures > 0:
          blocks.append(self.failures       )

        if self.n_failures > 0:
          blocks.extend([self.category_failures]       )

        if self.n_failures == 0:
          blocks.append(self.no_failures       )

        return json.dumps(SCREAMING_SNAKE_CASE_       )



      @staticmethod
      def      SCREAMING_SNAKE_CASE__ (      ):
        lowerCAmelCase_   :				Tuple								= [
            {
                'type': 'section',
                'text': {
                    'type': 'plain_text',
                    'text': 'There was an issue running the tests.',
                },
                'accessory': {
                    'type': 'button',
                    'text': {'type': 'plain_text', 'text': 'Check Action results', 'emoji': True},
                    'url': F"https://github.com/huggingface/transformers/actions/runs/{os.environ['GITHUB_RUN_ID']}",
                },
            }
        ]

        print('Sending the following payload'       )
        print(json.dumps({'blocks': json.loads(SCREAMING_SNAKE_CASE_       )}       )       )

        client.chat_postMessage(
            channel=os.environ['CI_SLACK_CHANNEL_ID_DAILY']    ,			text='There was an issue running the tests.'    ,			blocks=SCREAMING_SNAKE_CASE_    ,			)



      def      SCREAMING_SNAKE_CASE__ (      self				:      Union[str, Any]       ):
        print('Sending the following payload'       )
        print(json.dumps({'blocks': json.loads(self.payload       )}       )       )

        lowerCAmelCase_   :				Any								= F"{self.n_failures} failures out of {self.n_tests} tests," if self.n_failures else 'All tests passed.'

        lowerCAmelCase_   :				str								= client.chat_postMessage(
            channel=os.environ['CI_SLACK_CHANNEL_ID_DAILY']    ,			blocks=self.payload    ,			text=SCREAMING_SNAKE_CASE_    ,			)



      def      SCREAMING_SNAKE_CASE__ (      self				:      str    ,			SCREAMING_SNAKE_CASE_				:      int    ,			SCREAMING_SNAKE_CASE_				:      Any    ,			SCREAMING_SNAKE_CASE_				:      Any    ,			SCREAMING_SNAKE_CASE_				:      Dict       ):
        lowerCAmelCase_   :				List[Any]								= ''
        for key, value in failures.items():
          lowerCAmelCase_   :				List[Any]								= value[:2_0_0] + ' [Truncated]' if len(SCREAMING_SNAKE_CASE_       ) > 2_5_0 else value
          failures_text += F"*{key}*\n_{value}_\n\n"

        lowerCAmelCase_   :				int								= job_name
        lowerCAmelCase_   :				Dict								= {'type': 'section', 'text': {'type': 'mrkdwn', 'text': text}}

        if job_link is not None:
          lowerCAmelCase_   :				str								= {
              'type': 'button',
              'text': {'type': 'plain_text', 'text': 'GitHub Action job', 'emoji': True},
              'url': job_link,
          }

        return [
            {"type": "header", "text": {"type": "plain_text", "text": title.upper(), "emoji": True}},
            content,
            {"type": "section", "text": {"type": "mrkdwn", "text": failures_text}},
        ]





      def      SCREAMING_SNAKE_CASE__ (      self				:      Union[str, Any]       ):
        if self.thread_ts is None:
          raise ValueError('Can only post reply if a post has been made.'       )

        lowerCAmelCase_   :				Dict								= self.doc_test_results.pop('job_link'       )
        self.doc_test_results.pop('failures'       )
        self.doc_test_results.pop('success'       )
        self.doc_test_results.pop('time_spent'       )

        lowerCAmelCase_   :				Dict								= sorted(self.doc_test_results.items()    ,			key=lambda SCREAMING_SNAKE_CASE_       : t[0]       )
        for job, job_result in sorted_dict:
          if len(job_result['failures']       ):
            lowerCAmelCase_   :				Tuple								= F"*Num failures* :{len(job_result['failed']       )} \n"
            lowerCAmelCase_   :				List[str]								= job_result['failures']
            lowerCAmelCase_   :				Union[str, Any]								= self.get_reply_blocks(SCREAMING_SNAKE_CASE_    ,			SCREAMING_SNAKE_CASE_    ,			SCREAMING_SNAKE_CASE_    ,			text=SCREAMING_SNAKE_CASE_       )

            print('Sending the following reply'       )
            print(json.dumps({'blocks': blocks}       )       )

            client.chat_postMessage(
                channel=os.environ['CI_SLACK_CHANNEL_ID_DAILY']    ,			text=F"Results for {job}"    ,			blocks=SCREAMING_SNAKE_CASE_    ,			thread_ts=self.thread_ts['ts']    ,			)

            time.sleep(1       )




def 				UpperCamelCase_    (    )						->   str:

  """simple docstring"""




  lowerCAmelCase_   :				Union[str, Any]								= os.environ['GITHUB_RUN_ID']
  lowerCAmelCase_   :				int								= f"https://api.github.com/repos/huggingface/transformers/actions/runs/{run_id}/jobs?per_page=100"
  lowerCAmelCase_   :				str								= requests.get(lowerCAmelCase__						).json()
  lowerCAmelCase_   :				List[str]								= {}

  try:
    jobs.update({job['name']: job['html_url'] for job in result['jobs']}						)
    lowerCAmelCase_   :				Optional[Any]								= math.ceil((result['total_count'] - 100) / 100						)

    for i in range(lowerCAmelCase__						):
      lowerCAmelCase_   :				int								= requests.get(url + f"&page={i + 2}"						).json()
      jobs.update({job['name']: job['html_url'] for job in result['jobs']}						)

    return jobs
  except Exception as e:
    print('Unknown error, could not fetch links.'    ,   lowerCAmelCase__						)

  return {}

def 				UpperCamelCase_    (    lowerCAmelCase__      :				str						)						->   List[Any]:

  """simple docstring"""




  lowerCAmelCase_   :				int								= {}

  if os.path.exists(lowerCAmelCase__						):
    lowerCAmelCase_   :				Tuple								= os.listdir(lowerCAmelCase__						)
    for file in files:
      try:
        with open(os.path.join(lowerCAmelCase__    ,   lowerCAmelCase__						)    ,   encoding='utf-8'						) as f:
          lowerCAmelCase_   :				List[str]								= f.read()
      except UnicodeDecodeError as e:
        raise ValueError(f"Could not open {os.path.join(lowerCAmelCase__    ,   lowerCAmelCase__						)}."						) from e

  return _artifact

def 				UpperCamelCase_    (    )						->   Dict:

  """simple docstring"""




  class       UpperCamelCase__   :




        """simple docstring"""




        def __init__(      self				:      Dict    ,			SCREAMING_SNAKE_CASE_				:      str       ):
          lowerCAmelCase_   :				List[Any]								= name
          lowerCAmelCase_   :				Tuple								= []



        def __str__(      self				:      Optional[Any]       ):
          return self.name





        def      SCREAMING_SNAKE_CASE__ (      self				:      List[Any]    ,			SCREAMING_SNAKE_CASE_				:      str       ):
          self.paths.append({'name': self.name, 'path': path}       )




  lowerCAmelCase_   :				Dict[str, Artifact]								= {}

  lowerCAmelCase_   :				Any								= filter(os.path.isdir    ,   os.listdir()						)
  for directory in directories:
    lowerCAmelCase_   :				int								= directory
    if artifact_name not in _available_artifacts:
      lowerCAmelCase_   :				Optional[Any]								= Artifact(lowerCAmelCase__						)

      _available_artifacts[artifact_name].add_path(lowerCAmelCase__						)

  return _available_artifacts


if __name__ == "__main__":
     lowercase__		:				Optional[int]          =	get_job_links()
     lowercase__		:				Any          =	retrieve_available_artifacts()

     lowercase__		:				str          =	collections.OrderedDict(
         [
             ("""*.py""", """API Examples"""),
             ("""*.md""", """MD Examples"""),
         ]
     )

     # This dict will contain all the information relative to each doc test category:
     # - failed: list of failed tests
     # - failures: dict in the format 'test': 'error_message'
     lowercase__		:				Dict          =	{
         v: {
             """failed""": [],
             """failures""": {},
         }
         for v in docs.values()
     }

     # Link to the GitHub Action job
     lowercase__		:				str          =	github_actions_job_links.get("""run_doctests""")

     lowercase__		:				int          =	available_artifacts["""doc_tests_gpu_test_reports"""].paths[0]
     lowercase__		:				List[str]          =	retrieve_artifact(artifact_path["""name"""])
     if "stats" in artifact:
          lowercase__    ,     lowercase__    ,     lowercase__		:				str          =	handle_test_results(artifact["""stats"""])
          lowercase__		:				Any          =	failed
          lowercase__		:				str          =	success
          lowercase__		:				int          =	time_spent[1:-1] + """, """

          lowercase__		:				Tuple          =	extract_first_line_failure(artifact["""failures_short"""])
          for line in artifact["summary_short"].split("""\n"""):
               if re.search("""FAILED""", line):
                    lowercase__		:				List[str]          =	line.replace("""FAILED """, """""")
                    lowercase__		:				Union[str, Any]          =	line.split()[0].replace("""\n""", """""")

                    if "::" in line:
                         lowercase__    ,     lowercase__		:				Optional[Any]          =	line.split("""::""")
                    else:
                         lowercase__    ,     lowercase__		:				int          =	line, line

                    for file_regex in docs.keys():
                         if fnmatch(file_path, file_regex):
                              lowercase__		:				str          =	docs[file_regex]
                              doc_test_results[category]["failed"].append(test)

                              lowercase__		:				List[Any]          =	all_failures[test] if test in all_failures else """N/A"""
                              lowercase__		:				List[Any]          =	failure
                              break

     lowercase__		:				Union[str, Any]          =	Message("""🤗 Results of the doc tests.""", doc_test_results)
     message.post()
     message.post_reply()





