




from collections import OrderedDict
from dataclasses import fields
from typing import Any, Tuple

import numpy as np

from .import_utils import is_torch_available

def 					A				(				_SCREAMING_SNAKE_CASE   )     ->			List[Any]:
       if is_torch_available():
              import torch

              if isinstance(lowercase__			,torch.Tensor   ):
                     return True

       return isinstance(lowercase__			,np.ndarray   )




class 		UpperCamelCase__     (__UpperCAmelCase					):

    '''simple docstring'''



    def    _lowercase					(   self					)					->				List[Any]:
           lowerCamelCase       :				List[str]      			= fields(self					)

           # Safety and consistency checks
           if not len(lowerCamelCase__					):
                  raise ValueError(F'''{self.__class__.__name__} has no fields.'''					)

           lowerCamelCase       :				List[Any]      			= getattr(self					,  class_fields[0].name					)
           lowerCamelCase       :				List[Any]      			= all(getattr(self					,  field.name					) is None for field in class_fields[1:]					)

           if other_fields_are_none and isinstance(lowerCamelCase__					,  lowerCamelCase__					):
                  for key, value in first_field.items():
                         lowerCamelCase       :				Tuple      			= value
           else:
                  for field in class_fields:
                         lowerCamelCase       :				Union[str, Any]      			= getattr(self					,  field.name					)
                         if v is not None:
                                lowerCamelCase       :				Dict      			= v







    def __delitem__(   self					,  *UpperCamelCase__					,  **UpperCamelCase__					)					->				int:
           raise Exception(F'''You cannot use ``__delitem__`` on a {self.__class__.__name__} instance.'''					)







    def    _lowercase					(   self					,  *UpperCamelCase__					,  **UpperCamelCase__					)					->				int:
           raise Exception(F'''You cannot use ``setdefault`` on a {self.__class__.__name__} instance.'''					)







    def    _lowercase					(   self					,  *UpperCamelCase__					,  **UpperCamelCase__					)					->				Optional[int]:
           raise Exception(F'''You cannot use ``pop`` on a {self.__class__.__name__} instance.'''					)







    def    _lowercase					(   self					,  *UpperCamelCase__					,  **UpperCamelCase__					)					->				Optional[int]:
           raise Exception(F'''You cannot use ``update`` on a {self.__class__.__name__} instance.'''					)







    def __getitem__(   self					,  UpperCamelCase__					)					->				int:



           if isinstance(lowerCamelCase__					,  lowerCamelCase__					):
                  lowerCamelCase       :				Optional[Any]      			= dict(self.items()					)
                  return inner_dict[k]
           else:
                  return self.to_tuple()[k]







    def __setattr__(   self					,  UpperCamelCase__					,  UpperCamelCase__					)					->				Optional[int]:



           if name in self.keys() and value is not None:
                  # Don't call self.__setitem__ to avoid recursion errors
                  super().__setitem__(lowerCamelCase__					,  lowerCamelCase__					)
           super().__setattr__(lowerCamelCase__					,  lowerCamelCase__					)







    def __setitem__(   self					,  UpperCamelCase__					,  UpperCamelCase__					)					->				str:
           super().__setitem__(lowerCamelCase__					,  lowerCamelCase__					)
           # Don't call self.__setattr__ to avoid recursion errors
           super().__setattr__(lowerCamelCase__					,  lowerCamelCase__					)







    def    _lowercase					(   self					)					->				Tuple[Any]:
           return tuple(self[k] for k in self.keys()					)












from typing import TYPE_CHECKING

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


SCREAMING_SNAKE_CASE__	:				Optional[int]  =       {
    'configuration_gptsan_japanese': ['GPTSAN_JAPANESE_PRETRAINED_CONFIG_ARCHIVE_MAP', 'GPTSanJapaneseConfig'],
    'tokenization_gptsan_japanese': ['GPTSanJapaneseTokenizer'],
}

try:
       if not is_torch_available():
              raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
       pass
else:
       SCREAMING_SNAKE_CASE__	:				Optional[int]  =       [
           'GPTSAN_JAPANESE_PRETRAINED_MODEL_ARCHIVE_LIST',
           'GPTSanJapaneseForConditionalGeneration',
           'GPTSanJapaneseModel',
           'GPTSanJapanesePreTrainedModel',
       ]
       SCREAMING_SNAKE_CASE__	:				List[str]  =       [
           'GPTSanJapaneseTokenizer',
       ]


if TYPE_CHECKING:
       from .configuration_gptsan_japanese import GPTSAN_JAPANESE_PRETRAINED_CONFIG_ARCHIVE_MAP, GPTSanJapaneseConfig
       from .tokenization_gptsan_japanese import GPTSanJapaneseTokenizer

       try:
              if not is_torch_available():
                     raise OptionalDependencyNotAvailable()
       except OptionalDependencyNotAvailable:
              pass
       else:
              from .modeling_gptsan_japanese import (
                  GPTSAN_JAPANESE_PRETRAINED_MODEL_ARCHIVE_LIST,
                  GPTSanJapaneseForConditionalGeneration,
                  GPTSanJapaneseModel,
                  GPTSanJapanesePreTrainedModel,
              )
              from .tokenization_gptsan_japanese import GPTSanJapaneseTokenizer


else:
       import sys

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






