code: 
  
  
  '''simple docstring'''
  
  
  
  # Lint as: python3
  import sys
  from collections.abc import Mapping
  from typing import TYPE_CHECKING
  
  import numpy as np
  import pyarrow as pa
  
  from .. import config
  from ..utils.py_utils import map_nested
  from .formatting import TensorFormatter
  
  
  if TYPE_CHECKING:
        import tensorflow as tf
  
  
  
  
  
  class      UpperCAmelCase_						(TensorFormatter[Mapping, 'tf.Tensor', Mapping]						):
  
  
  
  
  
      """simple docstring"""
  
  
  
  
  
  
      def __init__(							self    ,  SCREAMING_SNAKE_CASE_=None    ,  **SCREAMING_SNAKE_CASE_			)       ->  Dict:
           super().__init__(features=SCREAMING_SNAKE_CASE_			)
           __lowerCamelCase     :			int              =	tf_tensor_kwargs
           import tensorflow as tf  # noqa: import tf at initialization
  
  
  
  
  
  
  
      def    lowercase_       (							self    ,  SCREAMING_SNAKE_CASE_			)       ->  List[str]:
           import tensorflow as tf
  
           if isinstance(SCREAMING_SNAKE_CASE_    ,  SCREAMING_SNAKE_CASE_			) and column:
                if all(
                    isinstance(SCREAMING_SNAKE_CASE_    ,  tf.Tensor			) and x.shape == column[0].shape and x.dtype == column[0].dtype for x in column			):
                     return tf.stack(SCREAMING_SNAKE_CASE_			)
                elif all(
                    isinstance(SCREAMING_SNAKE_CASE_    ,  (tf.Tensor, tf.RaggedTensor)			) and x.ndim == 1 and x.dtype == column[0].dtype
                    for x in column			):
                     # only rag 1-D tensors, otherwise some dimensions become ragged even though they were consolidated
                     return tf.ragged.stack(SCREAMING_SNAKE_CASE_			)
  
           return column
  
  
  
  
  
  
  
      def    lowercase_       (							self    ,  SCREAMING_SNAKE_CASE_			)       ->  List[str]:
           import tensorflow as tf
  
           if value is None:
                return value
  
           __lowerCamelCase     :			Tuple              =	{}
  
           if isinstance(SCREAMING_SNAKE_CASE_    ,  (np.number, np.ndarray)			) and np.issubdtype(value.dtype    ,  np.integer			):
                __lowerCamelCase     :			Dict              =	{'dtype': tf.intaa}
           elif isinstance(SCREAMING_SNAKE_CASE_    ,  (np.number, np.ndarray)			) and np.issubdtype(value.dtype    ,  np.floating			):
                __lowerCamelCase     :			List[Any]              =	{'dtype': tf.floataa}
           elif config.PIL_AVAILABLE and "PIL" in sys.modules:
                import PIL.Image
  
                if isinstance(SCREAMING_SNAKE_CASE_    ,  PIL.Image.Image			):
                     __lowerCamelCase     :			Optional[Any]              =	np.asarray(SCREAMING_SNAKE_CASE_			)
  
           return tf.convert_to_tensor(SCREAMING_SNAKE_CASE_    ,  **{**default_dtype, **self.tf_tensor_kwargs}			)
  
  
  
  
  
  
  
      def    lowercase_       (							self    ,  SCREAMING_SNAKE_CASE_			)       ->  int:
           import tensorflow as tf
  
           # support for torch, tf, jax etc.
           if config.TORCH_AVAILABLE and "torch" in sys.modules:
                import torch
  
                if isinstance(SCREAMING_SNAKE_CASE_    ,  torch.Tensor			):
                     return self._tensorize(data_struct.detach().cpu().numpy()[()]			)
           if hasattr(SCREAMING_SNAKE_CASE_    ,  '__array__'			) and not isinstance(SCREAMING_SNAKE_CASE_    ,  tf.Tensor			):
                __lowerCamelCase     :			Dict              =	data_struct.__array__()
           # support for nested types like struct of list of struct
           if isinstance(SCREAMING_SNAKE_CASE_    ,  np.ndarray			):
                if data_struct.dtype == object:  # tf tensors cannot be instantied from an array of objects
                     return self._consolidate([self.recursive_tensorize(SCREAMING_SNAKE_CASE_			) for substruct in data_struct]			)
           elif isinstance(SCREAMING_SNAKE_CASE_    ,  (list, tuple)			):
                return self._consolidate([self.recursive_tensorize(SCREAMING_SNAKE_CASE_			) for substruct in data_struct]			)
           return self._tensorize(SCREAMING_SNAKE_CASE_			)
  
  
  
  
  
  
  
      def    lowercase_       (							self    ,  SCREAMING_SNAKE_CASE_			)       ->  Optional[Any]:
           return map_nested(self._recursive_tensorize    ,  SCREAMING_SNAKE_CASE_    ,  map_list=SCREAMING_SNAKE_CASE_			)
  
  
  
  
  
  
  
      def    lowercase_       (							self    ,  SCREAMING_SNAKE_CASE_			)       ->  Mapping:
           __lowerCamelCase     :			Tuple              =	self.numpy_arrow_extractor().extract_row(SCREAMING_SNAKE_CASE_			)
           __lowerCamelCase     :			List[Any]              =	self.python_features_decoder.decode_row(SCREAMING_SNAKE_CASE_			)
           return self.recursive_tensorize(SCREAMING_SNAKE_CASE_			)
  
  
  
  
  
  
  
      def    lowercase_       (							self    ,  SCREAMING_SNAKE_CASE_			)       ->  "tf.Tensor":
           __lowerCamelCase     :			List[str]              =	self.numpy_arrow_extractor().extract_column(SCREAMING_SNAKE_CASE_			)
           __lowerCamelCase     :			Dict              =	self.python_features_decoder.decode_column(SCREAMING_SNAKE_CASE_    ,  pa_table.column_names[0]			)
           __lowerCamelCase     :			Union[str, Any]              =	self.recursive_tensorize(SCREAMING_SNAKE_CASE_			)
           __lowerCamelCase     :			str              =	self._consolidate(SCREAMING_SNAKE_CASE_			)
           return column
  
  
  
  
  
  
  
      def    lowercase_       (							self    ,  SCREAMING_SNAKE_CASE_			)       ->  Mapping:
           __lowerCamelCase     :			Any              =	self.numpy_arrow_extractor().extract_batch(SCREAMING_SNAKE_CASE_			)
           __lowerCamelCase     :			Optional[Any]              =	self.python_features_decoder.decode_batch(SCREAMING_SNAKE_CASE_			)
           __lowerCamelCase     :			Optional[int]              =	self.recursive_tensorize(SCREAMING_SNAKE_CASE_			)
           for column_name in batch:
                __lowerCamelCase     :			str              =	self._consolidate(batch[column_name]			)
           return batch
  
  
  
  
  
  
  
style_context: 
  
  
  '''simple docstring'''
  
  
  
  from typing import TYPE_CHECKING
  
  from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available
  
  
  A__	:      List[str]				=						{
      """configuration_flaubert""": ["""FLAUBERT_PRETRAINED_CONFIG_ARCHIVE_MAP""", """FlaubertConfig""", """FlaubertOnnxConfig"""],
      """tokenization_flaubert""": ["""FlaubertTokenizer"""],
  }
  
  try:
        if not is_torch_available():
              raise OptionalDependencyNotAvailable()
  except OptionalDependencyNotAvailable:
        pass
  else:
        A__	:      int				=						[
            """FLAUBERT_PRETRAINED_MODEL_ARCHIVE_LIST""",
            """FlaubertForMultipleChoice""",
            """FlaubertForQuestionAnswering""",
            """FlaubertForQuestionAnsweringSimple""",
            """FlaubertForSequenceClassification""",
            """FlaubertForTokenClassification""",
            """FlaubertModel""",
            """FlaubertWithLMHeadModel""",
            """FlaubertPreTrainedModel""",
        ]
  
  try:
        if not is_tf_available():
              raise OptionalDependencyNotAvailable()
  except OptionalDependencyNotAvailable:
        pass
  else:
        A__	:      int				=						[
            """TF_FLAUBERT_PRETRAINED_MODEL_ARCHIVE_LIST""",
            """TFFlaubertForMultipleChoice""",
            """TFFlaubertForQuestionAnsweringSimple""",
            """TFFlaubertForSequenceClassification""",
            """TFFlaubertForTokenClassification""",
            """TFFlaubertModel""",
            """TFFlaubertPreTrainedModel""",
            """TFFlaubertWithLMHeadModel""",
        ]
  
  
  if TYPE_CHECKING:
        from .configuration_flaubert import FLAUBERT_PRETRAINED_CONFIG_ARCHIVE_MAP, FlaubertConfig, FlaubertOnnxConfig
        from .tokenization_flaubert import FlaubertTokenizer
  
        try:
              if not is_torch_available():
                    raise OptionalDependencyNotAvailable()
        except OptionalDependencyNotAvailable:
              pass
        else:
              from .modeling_flaubert import (
                  FLAUBERT_PRETRAINED_MODEL_ARCHIVE_LIST,
                  FlaubertForMultipleChoice,
                  FlaubertForQuestionAnswering,
                  FlaubertForQuestionAnsweringSimple,
                  FlaubertForSequenceClassification,
                  FlaubertForTokenClassification,
                  FlaubertModel,
                  FlaubertPreTrainedModel,
                  FlaubertWithLMHeadModel,
              )
  
        try:
              if not is_tf_available():
                    raise OptionalDependencyNotAvailable()
        except OptionalDependencyNotAvailable:
              pass
        else:
              from .modeling_tf_flaubert import (
                  TF_FLAUBERT_PRETRAINED_MODEL_ARCHIVE_LIST,
                  TFFlaubertForMultipleChoice,
                  TFFlaubertForQuestionAnsweringSimple,
                  TFFlaubertForSequenceClassification,
                  TFFlaubertForTokenClassification,
                  TFFlaubertModel,
                  TFFlaubertPreTrainedModel,
                  TFFlaubertWithLMHeadModel,
              )
  
  else:
        import sys
  
        A__	:      Tuple				=						_LazyModule(__name__, globals()["""__file__"""], _import_structure, module_spec=__spec__)
  
  
  
  
  
  
  