code: 
  import csv
  import dataclasses
  import json
  from dataclasses import dataclass
  from typing import List, Optional, Union
  
  from ...utils import is_tf_available, is_torch_available, logging
  
  
  lowercase_								=    logging.get_logger(__name__)
  
  
  
  
  @dataclass
  class 					_UpperCamelCase :
  
  
  
  
  
  
  
  							'''simple docstring'''
  							_A  				=  4_2
  							_A  				=  4_2
  							_A  				=  None
  							_A  				=  None
  
  
  
  
  
  
  
  							def 		_UpperCAmelCase	(		self  :				Optional[Any]		):
  													return json.dumps(dataclasses.asdict(self		)		,				indent=2		) + "\n"
  
  
  
  
  @dataclass(frozen=A_	)
  class 					_UpperCamelCase :
  
  
  
  
  
  
  
  							'''simple docstring'''
  							_A  				=  4_2
  							_A  				=  None
  							_A  				=  None
  							_A  				=  None
  
  
  
  
  
  
  
  							def 		_UpperCAmelCase	(		self  :				int		):
  													return json.dumps(dataclasses.asdict(self		)		) + "\n"
  
  
  
  
  class 					_UpperCamelCase :
  
  
  
  
  
  
  
  							'''simple docstring'''
  
  
  
  
  
  
  
  							def 		_UpperCAmelCase	(		self  :				int		,				SCREAMING_SNAKE_CASE_  :				str		):
  													raise NotImplementedError()
  
  
  
  
  
  
  
  							def 		_UpperCAmelCase	(		self  :				List[Any]		,				SCREAMING_SNAKE_CASE_  :				Any		):
  													raise NotImplementedError()
  
  
  
  
  
  
  
  							def 		_UpperCAmelCase	(		self  :				Dict		,				SCREAMING_SNAKE_CASE_  :				List[str]		):
  													raise NotImplementedError()
  
  
  
  
  
  
  
  							def 		_UpperCAmelCase	(		self  :				str		,				SCREAMING_SNAKE_CASE_  :				Dict		):
  													raise NotImplementedError()
  
  
  
  
  
  
  
  							def 		_UpperCAmelCase	(		self  :				Any		):
  													raise NotImplementedError()
  
  
  
  
  
  
  
  							def 		_UpperCAmelCase	(		self  :				List[Any]		,				SCREAMING_SNAKE_CASE_  :				str		):
  
  
  
  													if len(self.get_labels()		) > 1:
  																			_a     =			self.get_labels()[int(example.label		)]
  													return example
  
  
  
  
  
  
  
  							@classmethod
  							def 		_UpperCAmelCase	(		cls  :				List[Any]		,				SCREAMING_SNAKE_CASE_  :				int		,				SCREAMING_SNAKE_CASE_  :				List[str]=None		):
  
  
  
  													with open(SCREAMING_SNAKE_CASE_		,				'r'		,				encoding='utf-8-sig'		) as f:
  																			return list(csv.reader(SCREAMING_SNAKE_CASE_		,				delimiter='\t'		,				quotechar=SCREAMING_SNAKE_CASE_		)		)
  
  
  
  
  class 					_UpperCamelCase (      A_	):
  
  
  
  
  
  
  
  							'''simple docstring'''
  
  
  
  
  
  
  
  							def __init__(		self  :				List[Any]		,				SCREAMING_SNAKE_CASE_  :				Any=None		,				SCREAMING_SNAKE_CASE_  :				Optional[int]=None		,				SCREAMING_SNAKE_CASE_  :				Union[str, Any]="classification"		,				SCREAMING_SNAKE_CASE_  :				Optional[Any]=False		):
  													_a     =			[] if labels is None else labels
  													_a     =			[] if examples is None else examples
  													_a     =			mode
  													_a     =			verbose
  
  
  
  
  
  
  
  							def __len__(		self  :				List[str]		):
  													return len(self.examples		)
  
  
  
  
  
  
  
  							def __getitem__(		self  :				Any		,				SCREAMING_SNAKE_CASE_  :				List[Any]		):
  
  
  
  													if isinstance(SCREAMING_SNAKE_CASE_		,				SCREAMING_SNAKE_CASE_		):
  																			return SingleSentenceClassificationProcessor(labels=self.labels		,				examples=self.examples[idx]		)
  													return self.examples[idx]
  
  
  
  
  
  
  
  							@classmethod
  							def 		_UpperCAmelCase	(		cls  :				Union[str, Any]		,				SCREAMING_SNAKE_CASE_  :				Optional[int]		,				SCREAMING_SNAKE_CASE_  :				Tuple=""		,				SCREAMING_SNAKE_CASE_  :				List[Any]=0		,				SCREAMING_SNAKE_CASE_  :				str=1		,				SCREAMING_SNAKE_CASE_  :				Dict=None		,				SCREAMING_SNAKE_CASE_  :				str=False		,				**SCREAMING_SNAKE_CASE_  :				Any		):
  													_a     =			cls(**SCREAMING_SNAKE_CASE_		)
  													processor.add_examples_from_csv(
  													    SCREAMING_SNAKE_CASE_		,				split_name=SCREAMING_SNAKE_CASE_		,				column_label=SCREAMING_SNAKE_CASE_		,				column_text=SCREAMING_SNAKE_CASE_		,				column_id=SCREAMING_SNAKE_CASE_		,				skip_first_row=SCREAMING_SNAKE_CASE_		,				overwrite_labels=SCREAMING_SNAKE_CASE_		,				overwrite_examples=SCREAMING_SNAKE_CASE_		,				)
  													return processor
  
  
  
  
  
  
  
  							@classmethod
  							def 		_UpperCAmelCase	(		cls  :				List[str]		,				SCREAMING_SNAKE_CASE_  :				int		,				SCREAMING_SNAKE_CASE_  :				Tuple=None		,				**SCREAMING_SNAKE_CASE_  :				Union[str, Any]		):
  													_a     =			cls(**SCREAMING_SNAKE_CASE_		)
  													processor.add_examples(SCREAMING_SNAKE_CASE_		,				labels=SCREAMING_SNAKE_CASE_		)
  													return processor
  
  
  
  
  
  
  
  							def 		_UpperCAmelCase	(		self  :				Optional[int]		,				SCREAMING_SNAKE_CASE_  :				Union[str, Any]		,				SCREAMING_SNAKE_CASE_  :				Optional[Any]=""		,				SCREAMING_SNAKE_CASE_  :				List[Any]=0		,				SCREAMING_SNAKE_CASE_  :				Optional[Any]=1		,				SCREAMING_SNAKE_CASE_  :				Tuple=None		,				SCREAMING_SNAKE_CASE_  :				int=False		,				SCREAMING_SNAKE_CASE_  :				Optional[int]=False		,				SCREAMING_SNAKE_CASE_  :				List[str]=False		,				):
  													_a     =			self._read_tsv(SCREAMING_SNAKE_CASE_		)
  													if skip_first_row:
  																			_a     =			lines[1:]
  													_a     =			[]
  													_a     =			[]
  													_a     =			[]
  													for i, line in enumerate(SCREAMING_SNAKE_CASE_		):
  																			texts.append(line[column_text]		)
  																			labels.append(line[column_label]		)
  																			if column_id is not None:
  																									ids.append(line[column_id]		)
  																			else:
  																									_a     =			f"""{split_name}-{i}""" if split_name else str(SCREAMING_SNAKE_CASE_		)
  																									ids.append(SCREAMING_SNAKE_CASE_		)
  
  													return self.add_examples(
  													    SCREAMING_SNAKE_CASE_		,				SCREAMING_SNAKE_CASE_		,				SCREAMING_SNAKE_CASE_		,				overwrite_labels=SCREAMING_SNAKE_CASE_		,				overwrite_examples=SCREAMING_SNAKE_CASE_		)
  
  
  
  
  
  
  
  							def 		_UpperCAmelCase	(		self  :				Dict		,				SCREAMING_SNAKE_CASE_  :				Dict		,				SCREAMING_SNAKE_CASE_  :				Optional[int]=None		,				SCREAMING_SNAKE_CASE_  :				List[str]=None		,				SCREAMING_SNAKE_CASE_  :				List[str]=False		,				SCREAMING_SNAKE_CASE_  :				Union[str, Any]=False		):
  
  
  
  													if labels is not None and len(SCREAMING_SNAKE_CASE_		) != len(SCREAMING_SNAKE_CASE_		):
  																			raise ValueError(
  																			    f"""Text and labels have mismatched lengths {len(SCREAMING_SNAKE_CASE_		)} and {len(SCREAMING_SNAKE_CASE_		)}"""		)
  													if ids is not None and len(SCREAMING_SNAKE_CASE_		) != len(SCREAMING_SNAKE_CASE_		):
  																			raise ValueError(f"""Text and ids have mismatched lengths {len(SCREAMING_SNAKE_CASE_		)} and {len(SCREAMING_SNAKE_CASE_		)}"""		)
  													if ids is None:
  																			_a     =			[None] * len(SCREAMING_SNAKE_CASE_		)
  													if labels is None:
  																			_a     =			[None] * len(SCREAMING_SNAKE_CASE_		)
  													_a     =			[]
  													_a     =			set()
  													for text_or_text_and_label, label, guid in zip(SCREAMING_SNAKE_CASE_		,				SCREAMING_SNAKE_CASE_		,				SCREAMING_SNAKE_CASE_		):
  																			if isinstance(SCREAMING_SNAKE_CASE_		,				(tuple, list)		) and label is None:
  																									_a     =			text_or_text_and_label
  																			else:
  																									_a     =			text_or_text_and_label
  																			added_labels.add(SCREAMING_SNAKE_CASE_		)
  																			examples.append(InputExample(guid=SCREAMING_SNAKE_CASE_		,				text_a=SCREAMING_SNAKE_CASE_		,				text_b=SCREAMING_SNAKE_CASE_		,				label=SCREAMING_SNAKE_CASE_		)		)
  
  													# Update examples
  													if overwrite_examples:
  																			_a     =			examples
  													else:
  																			self.examples.extend(SCREAMING_SNAKE_CASE_		)
  
  													# Update labels
  													if overwrite_labels:
  																			_a     =			list(SCREAMING_SNAKE_CASE_		)
  													else:
  																			_a     =			list(set(self.labels		).union(SCREAMING_SNAKE_CASE_		)		)
  
  													return self.examples
  
  
  
  
  
  
  
  							def 		_UpperCAmelCase	(		self  :				str		,				SCREAMING_SNAKE_CASE_  :				Optional[int]		,				SCREAMING_SNAKE_CASE_  :				Union[str, Any]=None		,				SCREAMING_SNAKE_CASE_  :				int=False		,				SCREAMING_SNAKE_CASE_  :				Tuple=0		,				SCREAMING_SNAKE_CASE_  :				Tuple=True		,				SCREAMING_SNAKE_CASE_  :				Union[str, Any]=None		,				):
  
  
  
  													if max_length is None:
  																			_a     =			tokenizer.max_len
  
  													_a     =			{label: i for i, label in enumerate(self.labels		)}
  
  													_a     =			[]
  													for ex_index, example in enumerate(self.examples		):
  																			if ex_index % 1_0_0_0_0 == 0:
  																									logger.info(f"""Tokenizing example {ex_index}"""		)
  
  																			_a     =			tokenizer.encode(
  																			    example.text_a		,				add_special_tokens=SCREAMING_SNAKE_CASE_		,				max_length=min(SCREAMING_SNAKE_CASE_		,				tokenizer.max_len		)		,				)
  																			all_input_ids.append(SCREAMING_SNAKE_CASE_		)
  
  													_a     =			max(len(SCREAMING_SNAKE_CASE_		) for input_ids in all_input_ids		)
  
  													_a     =			[]
  													for ex_index, (input_ids, example) in enumerate(zip(SCREAMING_SNAKE_CASE_		,				self.examples		)		):
  																			if ex_index % 1_0_0_0_0 == 0:
  																									logger.info(f"""Writing example {ex_index}/{len(self.examples		)}"""		)
  																			# The mask has 1 for real tokens and 0 for padding tokens. Only real
  																			# tokens are attended to.
  																			_a     =			[1 if mask_padding_with_zero else 0] * len(SCREAMING_SNAKE_CASE_		)
  
  																			# Zero-pad up to the sequence length.
  																			_a     =			batch_length - len(SCREAMING_SNAKE_CASE_		)
  																			if pad_on_left:
  																									_a     =			([pad_token] * padding_length) + input_ids
  																									_a     =			([0 if mask_padding_with_zero else 1] * padding_length) + attention_mask
  																			else:
  																									_a     =			input_ids + ([pad_token] * padding_length)
  																									_a     =			attention_mask + ([0 if mask_padding_with_zero else 1] * padding_length)
  
  																			if len(SCREAMING_SNAKE_CASE_		) != batch_length:
  																									raise ValueError(f"""Error with input length {len(SCREAMING_SNAKE_CASE_		)} vs {batch_length}"""		)
  																			if len(SCREAMING_SNAKE_CASE_		) != batch_length:
  																									raise ValueError(f"""Error with input length {len(SCREAMING_SNAKE_CASE_		)} vs {batch_length}"""		)
  
  																			if self.mode == "classification":
  																									_a     =			label_map[example.label]
  																			elif self.mode == "regression":
  																									_a     =			float(example.label		)
  																			else:
  																									raise ValueError(self.mode		)
  
  																			if ex_index < 5 and self.verbose:
  																									logger.info('*** Example ***'		)
  																									logger.info(f"""guid: {example.guid}"""		)
  																									logger.info(f"""input_ids: {' '.join([str(SCREAMING_SNAKE_CASE_		) for x in input_ids]		)}"""		)
  																									logger.info(f"""attention_mask: {' '.join([str(SCREAMING_SNAKE_CASE_		) for x in attention_mask]		)}"""		)
  																									logger.info(f"""label: {example.label} (id = {label})"""		)
  
  																			features.append(InputFeatures(input_ids=SCREAMING_SNAKE_CASE_		,				attention_mask=SCREAMING_SNAKE_CASE_		,				label=SCREAMING_SNAKE_CASE_		)		)
  
  													if return_tensors is None:
  																			return features
  													elif return_tensors == "tf":
  																			if not is_tf_available():
  																									raise RuntimeError('return_tensors set to \'tf\' but TensorFlow 2.0 can\'t be imported'		)
  																			import tensorflow as tf
  
  																			def gen():
  																									for ex in features:
  																															yield ({"input_ids": ex.input_ids, "attention_mask": ex.attention_mask}, ex.label)
  
  																			_a     =			tf.data.Dataset.from_generator(
  																			    SCREAMING_SNAKE_CASE_		,				({'input_ids': tf.intaa, 'attention_mask': tf.intaa}, tf.intaa)		,				({'input_ids': tf.TensorShape([None]		), 'attention_mask': tf.TensorShape([None]		)}, tf.TensorShape([]		))		,				)
  																			return dataset
  													elif return_tensors == "pt":
  																			if not is_torch_available():
  																									raise RuntimeError('return_tensors set to \'pt\' but PyTorch can\'t be imported'		)
  																			import torch
  																			from torch.utils.data import TensorDataset
  
  																			_a     =			torch.tensor([f.input_ids for f in features]		,				dtype=torch.long		)
  																			_a     =			torch.tensor([f.attention_mask for f in features]		,				dtype=torch.long		)
  																			if self.mode == "classification":
  																									_a     =			torch.tensor([f.label for f in features]		,				dtype=torch.long		)
  																			elif self.mode == "regression":
  																									_a     =			torch.tensor([f.label for f in features]		,				dtype=torch.float		)
  
  																			_a     =			TensorDataset(SCREAMING_SNAKE_CASE_		,				SCREAMING_SNAKE_CASE_		,				SCREAMING_SNAKE_CASE_		)
  																			return dataset
  													else:
  																			raise ValueError('return_tensors should be one of \'tf\' or \'pt\''		)
  
  
  
style_context: 
  
  
  def 							SCREAMING_SNAKE_CASE					(  _UpperCAmelCase				)    ->  bool:
  						# must be
  						_a     =			[list(_UpperCAmelCase				) for row in matrix]
  						if matrix and isinstance(_UpperCAmelCase							,     _UpperCAmelCase				):
  												if isinstance(matrix[0]							,     _UpperCAmelCase				):
  																		_a     =			0
  																		for row in matrix:
  																								if prev_len == 0:
  																														_a     =			len(_UpperCAmelCase				)
  																														_a     =			True
  																								else:
  																														_a     =			prev_len == len(_UpperCAmelCase				)
  												else:
  																		_a     =			True
  						else:
  												_a     =			False
  
  						return result
  
  
  def 							SCREAMING_SNAKE_CASE					(  _UpperCAmelCase				)    ->  None:
  						if check_matrix(_UpperCAmelCase				) and len(_UpperCAmelCase				) > 0:
  												_a     =			[list(_UpperCAmelCase				) for row in a]
  												_a     =			len(_UpperCAmelCase				)
  												if isinstance(a[0]							,     _UpperCAmelCase				):
  																		_a     =			len(a[0]				)
  												else:
  																		for dat in a:
  																								print(_UpperCAmelCase				)
  																		return
  
  												# horizotal printing increasing
  												for i in range(0							,     _UpperCAmelCase				):
  																		print(a[0][i]				)
  												# vertical printing down
  												for i in range(1							,     _UpperCAmelCase				):
  																		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]				)
  												_a     =			[row[1 : mat_col - 1] for row in a[1 : mat_row - 1]]
  												if len(_UpperCAmelCase				) > 0:
  																		spiral_print_clockwise(_UpperCAmelCase				)
  												else:
  																		return
  						else:
  												print('Not a valid matrix'				)
  												return
  
  
  def 							SCREAMING_SNAKE_CASE					(  _UpperCAmelCase				)    ->  list[int]:
  						if matrix:
  												return list(matrix.pop(0				)				) + spiral_traversal(list(zip(*_UpperCAmelCase				)				)[::-1]				)
  						else:
  												return []
  
  
  # driver code
  if __name__ == "__main__":
  		import doctest
  
  		doctest.testmod()
  
  		lowercase_								=    [[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12]]
  		spiral_print_clockwise(a)
  
  
  