




"""simple docstring"""

from typing import TYPE_CHECKING

from ...utils import (
    OptionalDependencyNotAvailable,
    _LazyModule,
    is_tf_available,
    is_torch_available,
    is_vision_available,
)


_lowerCamelCase	:      Tuple   =							{
    'configuration_segformer': ['SEGFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP', 'SegformerConfig', 'SegformerOnnxConfig']
}

try:
		if not is_vision_available():
				raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
		pass
else:
		_lowerCamelCase	:      Any   =							['SegformerFeatureExtractor']
		_lowerCamelCase	:      int   =							['SegformerImageProcessor']

try:
		if not is_torch_available():
				raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
		pass
else:
		_lowerCamelCase	:      str   =							[
		    'SEGFORMER_PRETRAINED_MODEL_ARCHIVE_LIST',
		    'SegformerDecodeHead',
		    'SegformerForImageClassification',
		    'SegformerForSemanticSegmentation',
		    'SegformerLayer',
		    'SegformerModel',
		    'SegformerPreTrainedModel',
		]

try:
		if not is_tf_available():
				raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
		pass
else:
		_lowerCamelCase	:      Union[str, Any]   =							[
		    'TF_SEGFORMER_PRETRAINED_MODEL_ARCHIVE_LIST',
		    'TFSegformerDecodeHead',
		    'TFSegformerForImageClassification',
		    'TFSegformerForSemanticSegmentation',
		    'TFSegformerModel',
		    'TFSegformerPreTrainedModel',
		]


if TYPE_CHECKING:
		from .configuration_segformer import SEGFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP, SegformerConfig, SegformerOnnxConfig

		try:
				if not is_vision_available():
						raise OptionalDependencyNotAvailable()
		except OptionalDependencyNotAvailable:
				pass
		else:
				from .feature_extraction_segformer import SegformerFeatureExtractor
				from .image_processing_segformer import SegformerImageProcessor

		try:
				if not is_torch_available():
						raise OptionalDependencyNotAvailable()
		except OptionalDependencyNotAvailable:
				pass
		else:
				from .modeling_segformer import (
				    SEGFORMER_PRETRAINED_MODEL_ARCHIVE_LIST,
				    SegformerDecodeHead,
				    SegformerForImageClassification,
				    SegformerForSemanticSegmentation,
				    SegformerLayer,
				    SegformerModel,
				    SegformerPreTrainedModel,
				)
		try:
				if not is_tf_available():
						raise OptionalDependencyNotAvailable()
		except OptionalDependencyNotAvailable:
				pass
		else:
				from .modeling_tf_segformer import (
				    TF_SEGFORMER_PRETRAINED_MODEL_ARCHIVE_LIST,
				    TFSegformerDecodeHead,
				    TFSegformerForImageClassification,
				    TFSegformerForSemanticSegmentation,
				    TFSegformerModel,
				    TFSegformerPreTrainedModel,
				)

else:
		import sys

		_lowerCamelCase	:      Optional[int]   =							_LazyModule(__name__, globals()['__file__'], _import_structure, module_spec=__spec__)







"""simple docstring"""







def       __UpperCAmelCase		(		a_      :		list[list[int]]					)  ->							bool:
   # must be
   _UpperCAmelCase 						=       [list(a_					) for row in matrix]
   if matrix and isinstance(a_     ,	a_					):
      if isinstance(matrix[0]     ,	a_					):
         _UpperCAmelCase 						=       0
         for row in matrix:
            if prev_len == 0:
               _UpperCAmelCase 						=       len(a_					)
               _UpperCAmelCase 						=       True
            else:
               _UpperCAmelCase 						=       prev_len == len(a_					)
      else:
         _UpperCAmelCase 						=       True
   else:
      _UpperCAmelCase 						=       False

   return result
def       __UpperCAmelCase		(		a_      :		list[list[int]]					)  ->							None:
   if check_matrix(a_					) and len(a_					) > 0:
      _UpperCAmelCase 						=       [list(a_					) for row in a]
      _UpperCAmelCase 						=       len(a_					)
      if isinstance(a[0]     ,	a_					):
         _UpperCAmelCase 						=       len(a[0]					)
      else:
         for dat in a:
            print(a_					)
         return

      # horizotal printing increasing
      for i in range(0     ,	a_					):
         print(a[0][i]					)
      # vertical printing down
      for i in range(1     ,	a_					):
         print(a[i][mat_col - 1]					)
      # horizotal printing decreasing
      if mat_row > 1:
         for i in range(mat_col - 2     ,	-1     ,	-1					):
            print(a[mat_row - 1][i]					)
        # vertical printing up
      for i in range(mat_row - 2     ,	0     ,	-1					):
         print(a[i][0]					)
      _UpperCAmelCase 						=       [row[1 : mat_col - 1] for row in a[1 : mat_row - 1]]
      if len(a_					) > 0:
         spiral_print_clockwise(a_					)
      else:
         return
   else:
      print("Not a valid matrix"					)
      return
def       __UpperCAmelCase		(		a_      :		list[list]					)  ->							list[int]:
   if matrix:
      return list(matrix.pop(0					)					) + spiral_traversal(list(zip(*a_					)					)[::-1]					)
   else:
      return []


# driver code
if __name__ == "__main__":
  import doctest

  doctest.testmod()

  SCREAMING_SNAKE_CASE_  					= [[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12]]
  spiral_print_clockwise(a)

