




from __future__ import annotations

import unittest

from transformers import CTRLConfig, is_tf_available
from transformers.testing_utils import require_tf, slow

from ...test_configuration_common import ConfigTester
from ...test_modeling_tf_common import TFModelTesterMixin, ids_tensor, random_attention_mask
from ...test_pipeline_mixin import PipelineTesterMixin


if is_tf_available():
       import tensorflow as tf

       from transformers.models.ctrl.modeling_tf_ctrl import (
           TF_CTRL_PRETRAINED_MODEL_ARCHIVE_LIST,
           TFCTRLForSequenceClassification,
           TFCTRLLMHeadModel,
           TFCTRLModel,
       )




class 		UpperCamelCase__     (lowerCAmelCase__					):

    '''simple docstring'''



    def __init__(   self					,  UpperCamelCase__					,  )					->				Optional[int]:
           lowerCamelCase       :				Optional[Any]      			= parent
           lowerCamelCase       :				int      			= 13
           lowerCamelCase       :				int      			= 7
           lowerCamelCase       :				str      			= True
           lowerCamelCase       :				Dict      			= True
           lowerCamelCase       :				Dict      			= True
           lowerCamelCase       :				Union[str, Any]      			= True
           lowerCamelCase       :				str      			= True
           lowerCamelCase       :				List[Any]      			= 99
           lowerCamelCase       :				Optional[int]      			= 32
           lowerCamelCase       :				List[str]      			= 2
           lowerCamelCase       :				Tuple      			= 4
           lowerCamelCase       :				str      			= 37
           lowerCamelCase       :				List[str]      			= "gelu"
           lowerCamelCase       :				str      			= 0.1
           lowerCamelCase       :				List[str]      			= 0.1
           lowerCamelCase       :				Optional[Any]      			= 512
           lowerCamelCase       :				str      			= 16
           lowerCamelCase       :				Dict      			= 2
           lowerCamelCase       :				Union[str, Any]      			= 0.02
           lowerCamelCase       :				int      			= 3
           lowerCamelCase       :				Optional[int]      			= 4
           lowerCamelCase       :				Union[str, Any]      			= None
           lowerCamelCase       :				Tuple      			= self.vocab_size - 1







    def    _lowercase					(   self					)					->				Dict:
           lowerCamelCase       :				Dict      			= ids_tensor([self.batch_size, self.seq_length]					,  self.vocab_size					)

           lowerCamelCase       :				Optional[Any]      			= None
           if self.use_input_mask:
                  lowerCamelCase       :				Optional[int]      			= random_attention_mask([self.batch_size, self.seq_length]					)

           lowerCamelCase       :				Optional[Any]      			= None
           if self.use_token_type_ids:
                  lowerCamelCase       :				Tuple      			= ids_tensor([self.batch_size, self.seq_length]					,  self.type_vocab_size					)

           lowerCamelCase       :				Optional[Any]      			= None
           if self.use_mc_token_ids:
                  lowerCamelCase       :				Tuple      			= ids_tensor([self.batch_size, self.num_choices]					,  self.seq_length					)

           lowerCamelCase       :				Any      			= None
           lowerCamelCase       :				Dict      			= None
           lowerCamelCase       :				Any      			= None
           if self.use_labels:
                  lowerCamelCase       :				List[Any]      			= ids_tensor([self.batch_size]					,  self.type_sequence_label_size					)
                  lowerCamelCase       :				Union[str, Any]      			= ids_tensor([self.batch_size, self.seq_length]					,  self.num_labels					)
                  lowerCamelCase       :				List[Any]      			= ids_tensor([self.batch_size]					,  self.num_choices					)

           lowerCamelCase       :				Union[str, Any]      			= CTRLConfig(
               vocab_size=self.vocab_size					,  n_embd=self.hidden_size					,  n_layer=self.num_hidden_layers					,  n_head=self.num_attention_heads					,  n_positions=self.max_position_embeddings					,  pad_token_id=self.pad_token_id					,  )

           lowerCamelCase       :				Union[str, Any]      			= ids_tensor([self.num_hidden_layers, self.num_attention_heads]					,  2					)

           return (
               config,
               input_ids,
               input_mask,
               head_mask,
               token_type_ids,
               mc_token_ids,
               sequence_labels,
               token_labels,
               choice_labels,
           )







    def    _lowercase					(   self					,  UpperCamelCase__					,  UpperCamelCase__					,  UpperCamelCase__					,  UpperCamelCase__					,  UpperCamelCase__					,  *UpperCamelCase__					)					->				Dict:
           lowerCamelCase       :				int      			= TFCTRLModel(config=UpperCamelCase__					)
           lowerCamelCase       :				Optional[Any]      			= {"input_ids": input_ids, "attention_mask": input_mask, "token_type_ids": token_type_ids}
           lowerCamelCase       :				Tuple      			= model(UpperCamelCase__					)

           lowerCamelCase       :				List[str]      			= [input_ids, None, input_mask]  # None is the input for 'past'
           lowerCamelCase       :				Tuple      			= model(UpperCamelCase__					)

           lowerCamelCase       :				Optional[Any]      			= model(UpperCamelCase__					)

           self.parent.assertEqual(result.last_hidden_state.shape					,  (self.batch_size, self.seq_length, self.hidden_size)					)







    def    _lowercase					(   self					,  UpperCamelCase__					,  UpperCamelCase__					,  UpperCamelCase__					,  UpperCamelCase__					,  UpperCamelCase__					,  *UpperCamelCase__					)					->				Tuple:
           lowerCamelCase       :				Any      			= TFCTRLLMHeadModel(config=UpperCamelCase__					)
           lowerCamelCase       :				Dict      			= {"input_ids": input_ids, "attention_mask": input_mask, "token_type_ids": token_type_ids}
           lowerCamelCase       :				Any      			= model(UpperCamelCase__					)
           self.parent.assertEqual(result.logits.shape					,  (self.batch_size, self.seq_length, self.vocab_size)					)







    def    _lowercase					(   self					,  UpperCamelCase__					,  UpperCamelCase__					,  UpperCamelCase__					,  UpperCamelCase__					,  UpperCamelCase__					,  *UpperCamelCase__					)					->				Tuple:
           lowerCamelCase       :				List[Any]      			= self.num_labels
           lowerCamelCase       :				Any      			= ids_tensor([self.batch_size]					,  self.type_sequence_label_size					)
           lowerCamelCase       :				Tuple      			= {
               "input_ids": input_ids,
               "token_type_ids": token_type_ids,
               "labels": sequence_labels,
           }
           lowerCamelCase       :				Union[str, Any]      			= TFCTRLForSequenceClassification(UpperCamelCase__					)
           lowerCamelCase       :				Tuple      			= model(UpperCamelCase__					)
           self.parent.assertEqual(result.logits.shape					,  (self.batch_size, self.num_labels)					)







    def    _lowercase					(   self					)					->				List[str]:
           lowerCamelCase       :				Optional[Any]      			= self.prepare_config_and_inputs()

           (
               lowerCamelCase				
           )       :				Tuple      			= config_and_inputs

           lowerCamelCase       :				Tuple      			= {"input_ids": input_ids, "token_type_ids": token_type_ids, "attention_mask": input_mask}
           return config, inputs_dict




@require_tf
class 		UpperCamelCase__     (lowerCAmelCase__   ,    lowerCAmelCase__   ,    unittest.TestCase					):

    '''simple docstring'''



    lowerCamelCase_     					=				(TFCTRLModel, TFCTRLLMHeadModel, TFCTRLForSequenceClassification) if is_tf_available() else ()
    lowerCamelCase_     					=				(TFCTRLLMHeadModel,) if is_tf_available() else ()
    lowerCamelCase_     					=				(
        {
            """feature-extraction""": TFCTRLModel,
            """text-classification""": TFCTRLForSequenceClassification,
            """text-generation""": TFCTRLLMHeadModel,
            """zero-shot""": TFCTRLForSequenceClassification,
        }
        if is_tf_available()
        else {}
    )
    lowerCamelCase_     					=				False
    lowerCamelCase_     					=				False







    def    _lowercase					(   self					,  UpperCamelCase__					,  UpperCamelCase__					,  UpperCamelCase__					,  UpperCamelCase__					,  UpperCamelCase__					)					->				List[Any]:
           if pipeline_test_casse_name == "ZeroShotClassificationPipelineTests":
                  # Get `tokenizer does not have a padding token` error for both fast/slow tokenizers.
                  # `CTRLConfig` was never used in pipeline tests, either because of a missing checkpoint or because a tiny
                  # config could not be created.
                  return True

           return False







    def    _lowercase					(   self					)					->				str:
           lowerCamelCase       :				Union[str, Any]      			= TFCTRLModelTester(self					)
           lowerCamelCase       :				int      			= ConfigTester(self					,  config_class=UpperCamelCase__					,  n_embd=37					)







    def    _lowercase					(   self					)					->				Optional[int]:
           self.config_tester.run_common_tests()







    def    _lowercase					(   self					)					->				List[Any]:
           lowerCamelCase       :				Tuple      			= self.model_tester.prepare_config_and_inputs()
           self.model_tester.create_and_check_ctrl_model(*UpperCamelCase__					)







    def    _lowercase					(   self					)					->				List[str]:
           lowerCamelCase       :				Dict      			= self.model_tester.prepare_config_and_inputs()
           self.model_tester.create_and_check_ctrl_lm_head(*UpperCamelCase__					)







    def    _lowercase					(   self					)					->				List[str]:
           lowerCamelCase       :				Tuple      			= self.model_tester.prepare_config_and_inputs()
           self.model_tester.create_and_check_ctrl_for_sequence_classification(*UpperCamelCase__					)







    def    _lowercase					(   self					)					->				List[str]:
           lowerCamelCase       :				List[str]      			= self.model_tester.prepare_config_and_inputs_for_common()
           lowerCamelCase       :				Union[str, Any]      			= [TFCTRLLMHeadModel]
           lowerCamelCase       :				int      			= [TFCTRLForSequenceClassification]

           for model_class in self.all_model_classes:
                  lowerCamelCase       :				List[Any]      			= model_class(UpperCamelCase__					)
                  model.build()  # may be needed for the get_bias() call below
                  assert isinstance(model.get_input_embeddings()					,  tf.keras.layers.Layer					)

                  if model_class in list_lm_models:
                         lowerCamelCase       :				List[str]      			= model.get_output_embeddings()
                         assert isinstance(UpperCamelCase__					,  tf.keras.layers.Layer					)
                         lowerCamelCase       :				Dict      			= model.get_bias()
                         assert isinstance(UpperCamelCase__					,  UpperCamelCase__					)
                         for k, v in name.items():
                                assert isinstance(UpperCamelCase__					,  tf.Variable					)
                  elif model_class in list_other_models_with_output_ebd:
                         lowerCamelCase       :				Dict      			= model.get_output_embeddings()
                         assert isinstance(UpperCamelCase__					,  tf.keras.layers.Layer					)
                         lowerCamelCase       :				Any      			= model.get_bias()
                         assert name is None
                  else:
                         lowerCamelCase       :				List[str]      			= model.get_output_embeddings()
                         assert x is None
                         lowerCamelCase       :				Any      			= model.get_bias()
                         assert name is None







    @slow
    def    _lowercase					(   self					)					->				Optional[Any]:
           for model_name in TF_CTRL_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
                  lowerCamelCase       :				Optional[Any]      			= TFCTRLModel.from_pretrained(UpperCamelCase__					)
                  self.assertIsNotNone(UpperCamelCase__					)




@require_tf
class 		UpperCamelCase__     (unittest.TestCase					):

    '''simple docstring'''



    @slow
    def    _lowercase					(   self					)					->				Dict:
           lowerCamelCase       :				Optional[int]      			= TFCTRLLMHeadModel.from_pretrained("ctrl"					)
           lowerCamelCase       :				List[str]      			= tf.convert_to_tensor([[1_1859, 0, 1611, 8]]					,  dtype=tf.intaa					)  # Legal the president is
           lowerCamelCase       :				int      			= [
               1_1859,
               0,
               1611,
               8,
               5,
               150,
               2_6449,
               2,
               19,
               348,
               469,
               3,
               2595,
               48,
               2_0740,
               24_6533,
               24_6533,
               19,
               30,
               5,
           ]  # Legal the president is a good guy and I don't want to lose my job. \n \n I have a

           lowerCamelCase       :				Optional[Any]      			= model.generate(UpperCamelCase__					,  do_sample=UpperCamelCase__					)
           self.assertListEqual(output_ids[0].numpy().tolist()					,  UpperCamelCase__					)












import warnings
from typing import List, Optional, Union

import numpy as np
import PIL
import torch
from PIL import Image

from .configuration_utils import ConfigMixin, register_to_config
from .utils import CONFIG_NAME, PIL_INTERPOLATION, deprecate




class 		UpperCamelCase__     (lowerCAmelCase__					):

    '''simple docstring'''



    lowerCamelCase_				:     Optional[Any]     					=				CONFIG_NAME







    @register_to_config
    def __init__(   self					,  UpperCamelCase__ = True					,  UpperCamelCase__ = 8					,  UpperCamelCase__ = "lanczos"					,  UpperCamelCase__ = True					,  UpperCamelCase__ = False					,  )					->				Optional[int]:
           super().__init__()







    @staticmethod
    def    _lowercase					(   UpperCamelCase__					)					->				PIL.Image.Image:
           if images.ndim == 3:
                  lowerCamelCase       :				str      			= images[None, ...]
           lowerCamelCase       :				Any      			= (images * 255).round().astype("uint8"					)
           if images.shape[-1] == 1:
                  # special case for grayscale (single channel) images
                  lowerCamelCase       :				List[Any]      			= [Image.fromarray(image.squeeze()					,  mode="L"					) for image in images]
           else:
                  lowerCamelCase       :				List[Any]      			= [Image.fromarray(UpperCamelCase__					) for image in images]

           return pil_images







    @staticmethod
    def    _lowercase					(   UpperCamelCase__					)					->				np.ndarray:
           if not isinstance(UpperCamelCase__					,  UpperCamelCase__					):
                  lowerCamelCase       :				List[str]      			= [images]
           lowerCamelCase       :				Union[str, Any]      			= [np.array(UpperCamelCase__					).astype(np.floataa					) / 255.0 for image in images]
           lowerCamelCase       :				List[str]      			= np.stack(UpperCamelCase__					,  axis=0					)

           return images







    @staticmethod
    def    _lowercase					(   UpperCamelCase__					)					->				torch.FloatTensor:
           if images.ndim == 3:
                  lowerCamelCase       :				Union[str, Any]      			= images[..., None]

           lowerCamelCase       :				List[Any]      			= torch.from_numpy(images.transpose(0					,  3					,  1					,  2					)					)
           return images







    @staticmethod
    def    _lowercase					(   UpperCamelCase__					)					->				np.ndarray:
           lowerCamelCase       :				List[str]      			= images.cpu().permute(0					,  2					,  3					,  1					).float().numpy()
           return images







    @staticmethod
    def    _lowercase					(   UpperCamelCase__					)					->				int:
           return 2.0 * images - 1.0







    @staticmethod
    def    _lowercase					(   UpperCamelCase__					)					->				Dict:
           return (images / 2 + 0.5).clamp(0					,  1					)







    @staticmethod
    def    _lowercase					(   UpperCamelCase__					)					->				PIL.Image.Image:
           lowerCamelCase       :				Union[str, Any]      			= image.convert("RGB"					)
           return image







    def    _lowercase					(   self					,  UpperCamelCase__					,  UpperCamelCase__ = None					,  UpperCamelCase__ = None					,  )					->				PIL.Image.Image:
           if height is None:
                  lowerCamelCase       :				Any      			= image.height
           if width is None:
                  lowerCamelCase       :				Union[str, Any]      			= image.width

           lowerCamelCase			,				lowerCamelCase       :				Union[str, Any]      			= (
               x - x % self.config.vae_scale_factor for x in (width, height)
           )  # resize to integer multiple of vae_scale_factor
           lowerCamelCase       :				Optional[Any]      			= image.resize((width, height)					,  resample=PIL_INTERPOLATION[self.config.resample]					)
           return image







    def    _lowercase					(   self					,  UpperCamelCase__					,  UpperCamelCase__ = None					,  UpperCamelCase__ = None					,  )					->				torch.Tensor:
           lowerCamelCase       :				Union[str, Any]      			= (PIL.Image.Image, np.ndarray, torch.Tensor)
           if isinstance(UpperCamelCase__					,  UpperCamelCase__					):
                  lowerCamelCase       :				Optional[int]      			= [image]
           elif not (isinstance(UpperCamelCase__					,  UpperCamelCase__					) and all(isinstance(UpperCamelCase__					,  UpperCamelCase__					) for i in image					)):
                  raise ValueError(
                      F'''Input is in incorrect format: {[type(UpperCamelCase__					) for i in image]}. Currently, we only support {", ".join(UpperCamelCase__					)}'''					)

           if isinstance(image[0]					,  PIL.Image.Image					):
                  if self.config.do_convert_rgb:
                         lowerCamelCase       :				Tuple      			= [self.convert_to_rgb(UpperCamelCase__					) for i in image]
                  if self.config.do_resize:
                         lowerCamelCase       :				Tuple      			= [self.resize(UpperCamelCase__					,  UpperCamelCase__					,  UpperCamelCase__					) for i in image]
                  lowerCamelCase       :				Optional[Any]      			= self.pil_to_numpy(UpperCamelCase__					)  # to np
                  lowerCamelCase       :				List[str]      			= self.numpy_to_pt(UpperCamelCase__					)  # to pt

           elif isinstance(image[0]					,  np.ndarray					):
                  lowerCamelCase       :				Optional[int]      			= np.concatenate(UpperCamelCase__					,  axis=0					) if image[0].ndim == 4 else np.stack(UpperCamelCase__					,  axis=0					)
                  lowerCamelCase       :				Optional[int]      			= self.numpy_to_pt(UpperCamelCase__					)
                  lowerCamelCase			,				lowerCamelCase			,				lowerCamelCase			,				lowerCamelCase       :				Optional[int]      			= image.shape
                  if self.config.do_resize and (
                      height % self.config.vae_scale_factor != 0 or width % self.config.vae_scale_factor != 0
                  ):
                         raise ValueError(
                             F'''Currently we only support resizing for PIL image - please resize your numpy array to be divisible by {self.config.vae_scale_factor}'''
                             F'''currently the sizes are {height} and {width}. You can also pass a PIL image instead to use resize option in VAEImageProcessor'''					)

           elif isinstance(image[0]					,  torch.Tensor					):
                  lowerCamelCase       :				Dict      			= torch.cat(UpperCamelCase__					,  axis=0					) if image[0].ndim == 4 else torch.stack(UpperCamelCase__					,  axis=0					)
                  lowerCamelCase			,				lowerCamelCase			,				lowerCamelCase			,				lowerCamelCase       :				List[Any]      			= image.shape

                  # don't need any preprocess if the image is latents
                  if channel == 4:
                         return image

                  if self.config.do_resize and (
                      height % self.config.vae_scale_factor != 0 or width % self.config.vae_scale_factor != 0
                  ):
                         raise ValueError(
                             F'''Currently we only support resizing for PIL image - please resize your pytorch tensor to be divisible by {self.config.vae_scale_factor}'''
                             F'''currently the sizes are {height} and {width}. You can also pass a PIL image instead to use resize option in VAEImageProcessor'''					)

        # expected range [0,1], normalize to [-1,1]
           lowerCamelCase       :				str      			= self.config.do_normalize
           if image.min() < 0:
                  warnings.warn(
                      "Passing `image` as torch tensor with value range in [-1,1] is deprecated. The expected value range for image tensor is [0,1] "
                      F'''when passing as pytorch tensor or numpy Array. You passed `image` with value range [{image.min()},{image.max()}]'''					,  UpperCamelCase__					,  )
                  lowerCamelCase       :				Optional[Any]      			= False

           if do_normalize:
                  lowerCamelCase       :				int      			= self.normalize(UpperCamelCase__					)

           return image







    def    _lowercase					(   self					,  UpperCamelCase__					,  UpperCamelCase__ = "pil"					,  UpperCamelCase__ = None					,  )					->				Dict:
           if not isinstance(UpperCamelCase__					,  torch.Tensor					):
                  raise ValueError(
                      F'''Input for postprocessing is in incorrect format: {type(UpperCamelCase__					)}. We only support pytorch tensor'''					)
           if output_type not in ["latent", "pt", "np", "pil"]:
                  lowerCamelCase       :				str      			= (
                      F'''the output_type {output_type} is outdated and has been set to `np`. Please make sure to set it to one of these instead: '''
                      "`pil`, `np`, `pt`, `latent`"
                  )
                  deprecate("Unsupported output_type"					,  "1.0.0"					,  UpperCamelCase__					,  standard_warn=UpperCamelCase__					)
                  lowerCamelCase       :				Optional[Any]      			= "np"

           if output_type == "latent":
                  return image

           if do_denormalize is None:
                  lowerCamelCase       :				List[str]      			= [self.config.do_normalize] * image.shape[0]

           lowerCamelCase       :				Dict      			= torch.stack(
               [self.denormalize(image[i]					) if do_denormalize[i] else image[i] for i in range(image.shape[0]					)]					)

           if output_type == "pt":
                  return image

           lowerCamelCase       :				Any      			= self.pt_to_numpy(UpperCamelCase__					)

           if output_type == "np":
                  return image

           if output_type == "pil":
                  return self.numpy_to_pil(UpperCamelCase__					)




class 		UpperCamelCase__     (lowerCAmelCase__					):

    '''simple docstring'''



    lowerCamelCase_				:     Union[str, Any]     					=				CONFIG_NAME







    @register_to_config
    def __init__(   self					,  UpperCamelCase__ = True					,  UpperCamelCase__ = 8					,  UpperCamelCase__ = "lanczos"					,  UpperCamelCase__ = True					,  )					->				Tuple:
           super().__init__()







    @staticmethod
    def    _lowercase					(   UpperCamelCase__					)					->				int:
           if images.ndim == 3:
                  lowerCamelCase       :				Union[str, Any]      			= images[None, ...]
           lowerCamelCase       :				Any      			= (images * 255).round().astype("uint8"					)
           if images.shape[-1] == 1:
                  # special case for grayscale (single channel) images
                  lowerCamelCase       :				Any      			= [Image.fromarray(image.squeeze()					,  mode="L"					) for image in images]
           else:
                  lowerCamelCase       :				Dict      			= [Image.fromarray(image[:, :, :3]					) for image in images]

           return pil_images







    @staticmethod
    def    _lowercase					(   UpperCamelCase__					)					->				Optional[int]:
           return image[:, :, 1] * 2**8 + image[:, :, 2]







    def    _lowercase					(   self					,  UpperCamelCase__					)					->				Any:
           if images.ndim == 3:
                  lowerCamelCase       :				Dict      			= images[None, ...]
           lowerCamelCase       :				Any      			= images[:, :, :, 3:]
           if images.shape[-1] == 6:
                  lowerCamelCase       :				List[str]      			= (images_depth * 255).round().astype("uint8"					)
                  lowerCamelCase       :				Any      			= [
                      Image.fromarray(self.rgblike_to_depthmap(UpperCamelCase__					)					,  mode="I;16"					) for image_depth in images_depth
                  ]
           elif images.shape[-1] == 4:
                  lowerCamelCase       :				Any      			= (images_depth * 65535.0).astype(np.uintaa					)
                  lowerCamelCase       :				Any      			= [Image.fromarray(UpperCamelCase__					,  mode="I;16"					) for image_depth in images_depth]
           else:
                  raise Exception("Not supported"					)

           return pil_images







    def    _lowercase					(   self					,  UpperCamelCase__					,  UpperCamelCase__ = "pil"					,  UpperCamelCase__ = None					,  )					->				Dict:
           if not isinstance(UpperCamelCase__					,  torch.Tensor					):
                  raise ValueError(
                      F'''Input for postprocessing is in incorrect format: {type(UpperCamelCase__					)}. We only support pytorch tensor'''					)
           if output_type not in ["latent", "pt", "np", "pil"]:
                  lowerCamelCase       :				List[str]      			= (
                      F'''the output_type {output_type} is outdated and has been set to `np`. Please make sure to set it to one of these instead: '''
                      "`pil`, `np`, `pt`, `latent`"
                  )
                  deprecate("Unsupported output_type"					,  "1.0.0"					,  UpperCamelCase__					,  standard_warn=UpperCamelCase__					)
                  lowerCamelCase       :				Tuple      			= "np"

           if do_denormalize is None:
                  lowerCamelCase       :				Union[str, Any]      			= [self.config.do_normalize] * image.shape[0]

           lowerCamelCase       :				List[Any]      			= torch.stack(
               [self.denormalize(image[i]					) if do_denormalize[i] else image[i] for i in range(image.shape[0]					)]					)

           lowerCamelCase       :				Union[str, Any]      			= self.pt_to_numpy(UpperCamelCase__					)

           if output_type == "np":
                  if image.shape[-1] == 6:
                         lowerCamelCase       :				List[str]      			= np.stack([self.rgblike_to_depthmap(im[:, :, 3:]					) for im in image]					,  axis=0					)
                  else:
                         lowerCamelCase       :				Optional[Any]      			= image[:, :, :, 3:]
                  return image[:, :, :, :3], image_depth

           if output_type == "pil":
                  return self.numpy_to_pil(UpperCamelCase__					), self.numpy_to_depth(UpperCamelCase__					)
           else:
                  raise Exception(F'''This type {output_type} is not supported'''					)






