






"""simple docstring"""


from __future__ import annotations

from collections.abc import Generator



def    lowerCAmelCase							(       __UpperCamelCase					):




  """simple docstring"""







  if not isinstance(__UpperCamelCase						,			__UpperCamelCase					) or n < 1:
    raise Exception('''Sequence only defined for positive integers'''					)

  yield n
  while n != 1:
    if n % 2 == 0:
      n //= 2
    else:
      __A		     =					3 * n + 1
    yield n



def    lowerCAmelCase							(       ):




  """simple docstring"""







  __A		     =					4_3
  __A		     =					tuple(collatz_sequence(__UpperCamelCase					)					)
  print(__UpperCamelCase					)
  print(f'Collatz sequence from {n} took {len(__UpperCamelCase					)} steps.'					)


if __name__ == "__main__":
       main()





import unittest
from dataclasses import dataclass
from typing import List, Union

import numpy as np
import PIL.Image

from diffusers.utils.outputs import BaseOutput




@dataclass
class  __lowerCAmelCase	(							a_    ):



 '''simple docstring'''
 _lowerCamelCase    :						Union[List[PIL.Image.Image], np.ndarray]







class  __lowerCAmelCase	(							unittest.TestCase    ):



 '''simple docstring'''

 def        __snake_case       (      self							:		int	)			->				Tuple:
        _UpperCamelCase  :							str	    =	CustomOutput(images=np.random.rand(1							,      3							,      4							,      4	)	)

        # check every way of getting the attribute
        assert isinstance(outputs.images							,      np.ndarray	)
        assert outputs.images.shape == (1, 3, 4, 4)
        assert isinstance(outputs['images']							,      np.ndarray	)
        assert outputs["images"].shape == (1, 3, 4, 4)
        assert isinstance(outputs[0]							,      np.ndarray	)
        assert outputs[0].shape == (1, 3, 4, 4)

        # test with a non-tensor attribute
        _UpperCamelCase  :							str	    =	CustomOutput(images=[PIL.Image.new('RGB'							,      (4, 4)	)]	)

        # check every way of getting the attribute
        assert isinstance(outputs.images							,      lowerCamelCase	)
        assert isinstance(outputs.images[0]							,      PIL.Image.Image	)
        assert isinstance(outputs['images']							,      lowerCamelCase	)
        assert isinstance(outputs['images'][0]							,      PIL.Image.Image	)
        assert isinstance(outputs[0]							,      lowerCamelCase	)
        assert isinstance(outputs[0][0]							,      PIL.Image.Image	)

 def        __snake_case       (      self							:		Any	)			->				Dict:
        # test output reinitialization with a `dict` for compatibility with `accelerate`
        _UpperCamelCase  :							Tuple	    =	CustomOutput({'images': np.random.rand(1							,      3							,      4							,      4	)}	)

        # check every way of getting the attribute
        assert isinstance(outputs.images							,      np.ndarray	)
        assert outputs.images.shape == (1, 3, 4, 4)
        assert isinstance(outputs['images']							,      np.ndarray	)
        assert outputs["images"].shape == (1, 3, 4, 4)
        assert isinstance(outputs[0]							,      np.ndarray	)
        assert outputs[0].shape == (1, 3, 4, 4)

        # test with a non-tensor attribute
        _UpperCamelCase  :							int	    =	CustomOutput({'images': [PIL.Image.new('RGB'							,      (4, 4)	)]}	)

        # check every way of getting the attribute
        assert isinstance(outputs.images							,      lowerCamelCase	)
        assert isinstance(outputs.images[0]							,      PIL.Image.Image	)
        assert isinstance(outputs['images']							,      lowerCamelCase	)
        assert isinstance(outputs['images'][0]							,      PIL.Image.Image	)
        assert isinstance(outputs[0]							,      lowerCamelCase	)
        assert isinstance(outputs[0][0]							,      PIL.Image.Image	)



