code: 
  
  
  import sys
  from collections.abc import Mapping
  
  import numpy as np
  import pyarrow as pa
  
  from .. import config
  from ..utils.py_utils import map_nested
  from .formatting import TensorFormatter
  
  
  
  
  
  class 					snake_case__    ( TensorFormatter[Mapping, np.ndarray, Mapping]       ):
  
  
  
  
  
  	def __init__(  self				,    UpperCamelCase_=None				,    **UpperCamelCase_							)		->			Optional[Any]:
  								"""simple docstring"""
  
  
  
  
  
  
  								super().__init__(features=UpperCamelCase_							)
  								a_       :   Union[str, Any]			=	np_array_kwargs
  
  
  
  
  
  	def     A				(  self				,    UpperCamelCase_							)		->			Dict:
  								"""simple docstring"""
  
  
  
  
  
  
  								if isinstance(UpperCamelCase_				,    UpperCamelCase_							):
  															if column and all(
  															    isinstance(UpperCamelCase_				,    np.ndarray							) and x.shape == column[0].shape and x.dtype == column[0].dtype for x in column							):
  																						return np.stack(UpperCamelCase_							)
  															else:
  																						# don't use np.array(column, dtype=object)
  																						# since it fails in certain cases
  																						# see https://stackoverflow.com/q/51005699
  																						a_       :   Tuple			=	np.empty(len(UpperCamelCase_							)				,    dtype=UpperCamelCase_							)
  																						a_       :   Dict			=	column
  																						return out
  								return column
  
  
  
  
  
  	def     A				(  self				,    UpperCamelCase_							)		->			str:
  								"""simple docstring"""
  
  
  
  
  
  
  								if isinstance(UpperCamelCase_				,    (str, bytes, type(UpperCamelCase_							))							):
  															return value
  								elif isinstance(UpperCamelCase_				,    (np.character, np.ndarray)							) and np.issubdtype(value.dtype				,    np.character							):
  															return value
  								elif isinstance(UpperCamelCase_				,    np.number							):
  															return value
  
  								a_       :   str			=	{}
  
  								if isinstance(UpperCamelCase_				,    np.ndarray							) and np.issubdtype(value.dtype				,    np.integer							):
  															a_       :   Dict			=	{"""dtype""": np.intaa}
  								elif isinstance(UpperCamelCase_				,    np.ndarray							) and np.issubdtype(value.dtype				,    np.floating							):
  															a_       :   Any			=	{"""dtype""": np.floataa}
  								elif config.PIL_AVAILABLE and "PIL" in sys.modules:
  															import PIL.Image
  
  															if isinstance(UpperCamelCase_				,    PIL.Image.Image							):
  																						return np.asarray(UpperCamelCase_				,    **self.np_array_kwargs							)
  
  								return np.asarray(UpperCamelCase_				,    **{**default_dtype, **self.np_array_kwargs}							)
  
  
  
  
  
  	def     A				(  self				,    UpperCamelCase_							)		->			Union[str, Any]:
  								"""simple docstring"""
  
  
  
  
  
  
  								if config.TORCH_AVAILABLE and "torch" in sys.modules:
  															import torch
  
  															if isinstance(UpperCamelCase_				,    torch.Tensor							):
  																						return self._tensorize(data_struct.detach().cpu().numpy()[()]							)
  								if hasattr(UpperCamelCase_				,    """__array__"""							) and not isinstance(UpperCamelCase_				,    (np.ndarray, np.character, np.number)							):
  															a_       :   str			=	data_struct.__array__()
  								# support for nested types like struct of list of struct
  								if isinstance(UpperCamelCase_				,    np.ndarray							):
  															if data_struct.dtype == object:
  																						return self._consolidate([self.recursive_tensorize(UpperCamelCase_							) for substruct in data_struct]							)
  								if isinstance(UpperCamelCase_				,    (list, tuple)							):
  															return self._consolidate([self.recursive_tensorize(UpperCamelCase_							) for substruct in data_struct]							)
  								return self._tensorize(UpperCamelCase_							)
  
  
  
  
  
  	def     A				(  self				,    UpperCamelCase_							)		->			Union[str, Any]:
  								"""simple docstring"""
  
  
  
  
  
  
  								return map_nested(self._recursive_tensorize				,    UpperCamelCase_				,    map_list=UpperCamelCase_							)
  
  
  
  
  
  	def     A				(  self				,    UpperCamelCase_							)		->			List[str]:
  								"""simple docstring"""
  
  
  
  
  
  
  								a_       :   Any			=	self.numpy_arrow_extractor().extract_row(UpperCamelCase_							)
  								a_       :   int			=	self.python_features_decoder.decode_row(UpperCamelCase_							)
  								return self.recursive_tensorize(UpperCamelCase_							)
  
  
  
  
  
  	def     A				(  self				,    UpperCamelCase_							)		->			Optional[Any]:
  								"""simple docstring"""
  
  
  
  
  
  
  								a_       :   Dict			=	self.numpy_arrow_extractor().extract_column(UpperCamelCase_							)
  								a_       :   List[Any]			=	self.python_features_decoder.decode_column(UpperCamelCase_				,    pa_table.column_names[0]							)
  								a_       :   Optional[Any]			=	self.recursive_tensorize(UpperCamelCase_							)
  								a_       :   Optional[Any]			=	self._consolidate(UpperCamelCase_							)
  								return column
  
  
  
  
  
  	def     A				(  self				,    UpperCamelCase_							)		->			Optional[int]:
  								"""simple docstring"""
  
  
  
  
  
  
  								a_       :   Optional[Any]			=	self.numpy_arrow_extractor().extract_batch(UpperCamelCase_							)
  								a_       :   List[Any]			=	self.python_features_decoder.decode_batch(UpperCamelCase_							)
  								a_       :   Union[str, Any]			=	self.recursive_tensorize(UpperCamelCase_							)
  								for column_name in batch:
  															a_       :   str			=	self._consolidate(batch[column_name]							)
  								return batch
  
  
  
style_context: 
  
  
  from ...utils import is_transformers_available
  from .pipeline_latent_diffusion_superresolution import LDMSuperResolutionPipeline
  
  
  if is_transformers_available():
  	from .pipeline_latent_diffusion import LDMBertModel, LDMTextToImagePipeline
  
  
  