"""simple docstring"""


import copy
import inspect
import unittest

import numpy as np
from huggingface_hub import hf_hub_download

from transformers import VideoMAEConfig
from transformers.models.auto import get_values
from transformers.testing_utils import require_torch, require_vision, slow, torch_device
from transformers.utils import cached_property, is_torch_available, is_vision_available

from ...test_configuration_common import ConfigTester
from ...test_modeling_common import ModelTesterMixin, floats_tensor, ids_tensor
from ...test_pipeline_mixin import PipelineTesterMixin


if is_torch_available():
    import torch
    from torch import nn

    from transformers import (
        MODEL_FOR_VIDEO_CLASSIFICATION_MAPPING,
        VideoMAEForPreTraining,
        VideoMAEForVideoClassification,
        VideoMAEModel,
    )
    from transformers.models.videomae.modeling_videomae import VIDEOMAE_PRETRAINED_MODEL_ARCHIVE_LIST


if is_vision_available():
    from transformers import VideoMAEImageProcessor


class 							a					:


    def __init__(       self						:	List[str] ,					__lowerCAmelCase						:	Dict ,					__lowerCAmelCase						:	Optional[int]=13 ,					__lowerCAmelCase						:	Dict=10 ,					__lowerCAmelCase						:	str=3 ,					__lowerCAmelCase						:	List[Any]=2 ,					__lowerCAmelCase						:	List[Any]=2 ,					__lowerCAmelCase						:	Optional[int]=2 ,					__lowerCAmelCase						:	Optional[Any]=True ,					__lowerCAmelCase						:	Dict=True ,					__lowerCAmelCase						:	List[str]=32 ,					__lowerCAmelCase						:	Any=5 ,					__lowerCAmelCase						:	Union[str, Any]=4 ,					__lowerCAmelCase						:	Optional[Any]=37 ,					__lowerCAmelCase						:	List[Any]="gelu" ,					__lowerCAmelCase						:	Optional[Any]=0.1 ,					__lowerCAmelCase						:	Union[str, Any]=0.1 ,					__lowerCAmelCase						:	Dict=10 ,					__lowerCAmelCase						:	Union[str, Any]=0.02 ,					__lowerCAmelCase						:	Any=0.9 ,					__lowerCAmelCase						:	Union[str, Any]=None ,					):
      _UpperCAmelCase    			=   parent
      _UpperCAmelCase    			=   batch_size
      _UpperCAmelCase    			=   image_size
      _UpperCAmelCase    			=   num_channels
      _UpperCAmelCase    			=   patch_size
      _UpperCAmelCase    			=   tubelet_size
      _UpperCAmelCase    			=   num_frames
      _UpperCAmelCase    			=   is_training
      _UpperCAmelCase    			=   use_labels
      _UpperCAmelCase    			=   hidden_size
      _UpperCAmelCase    			=   num_hidden_layers
      _UpperCAmelCase    			=   num_attention_heads
      _UpperCAmelCase    			=   intermediate_size
      _UpperCAmelCase    			=   hidden_act
      _UpperCAmelCase    			=   hidden_dropout_prob
      _UpperCAmelCase    			=   attention_probs_dropout_prob
      _UpperCAmelCase    			=   type_sequence_label_size
      _UpperCAmelCase    			=   initializer_range
      _UpperCAmelCase    			=   mask_ratio
      _UpperCAmelCase    			=   scope

      # in VideoMAE, the number of tokens equals num_frames/tubelet_size * num_patches per frame
      _UpperCAmelCase    			=   (image_size // patch_size) ** 2
      _UpperCAmelCase    			=   (num_frames // tubelet_size) * self.num_patches_per_frame

      # use this variable to define bool_masked_pos
      _UpperCAmelCase    			=   int(mask_ratio * self.seq_length       )


    def   lowerCAmelCase_	(       self						:	Dict       ):
      _UpperCAmelCase    			=   floats_tensor(
          [self.batch_size, self.num_frames, self.num_channels, self.image_size, self.image_size]       )

      _UpperCAmelCase    			=   None
      if self.use_labels:
        _UpperCAmelCase    			=   ids_tensor([self.batch_size] ,					self.type_sequence_label_size       )

      _UpperCAmelCase    			=   self.get_config()

      return config, pixel_values, labels


    def   lowerCAmelCase_	(       self						:	List[str]       ):
      return VideoMAEConfig(
          image_size=self.image_size ,					patch_size=self.patch_size ,					num_channels=self.num_channels ,					num_frames=self.num_frames ,					tubelet_size=self.tubelet_size ,					hidden_size=self.hidden_size ,					num_hidden_layers=self.num_hidden_layers ,					num_attention_heads=self.num_attention_heads ,					intermediate_size=self.intermediate_size ,					hidden_act=self.hidden_act ,					hidden_dropout_prob=self.hidden_dropout_prob ,					attention_probs_dropout_prob=self.attention_probs_dropout_prob ,					is_decoder=_SCREAMING_SNAKE_CASE ,					initializer_range=self.initializer_range ,					)


    def   lowerCAmelCase_	(       self						:	int ,					__lowerCAmelCase						:	str ,					__lowerCAmelCase						:	Union[str, Any] ,					__lowerCAmelCase						:	List[str]       ):
      _UpperCAmelCase    			=   VideoMAEModel(config=_SCREAMING_SNAKE_CASE       )
      model.to(_SCREAMING_SNAKE_CASE       )
      model.eval()
      _UpperCAmelCase    			=   model(_SCREAMING_SNAKE_CASE       )
      self.parent.assertEqual(result.last_hidden_state.shape ,					(self.batch_size, self.seq_length, self.hidden_size)       )


    def   lowerCAmelCase_	(       self						:	Optional[int] ,					__lowerCAmelCase						:	List[Any] ,					__lowerCAmelCase						:	Optional[int] ,					__lowerCAmelCase						:	int       ):
      _UpperCAmelCase    			=   VideoMAEForPreTraining(_SCREAMING_SNAKE_CASE       )
      model.to(_SCREAMING_SNAKE_CASE       )
      model.eval()
      # important: each video needs to have the same number of masked patches
      # hence we define a single mask, which we then repeat for each example in the batch
      _UpperCAmelCase    			=   torch.ones((self.num_masks,)       )
      _UpperCAmelCase    			=   torch.cat([mask, torch.zeros(self.seq_length - mask.size(0       )       )]       )
      _UpperCAmelCase    			=   mask.expand(self.batch_size ,					-1       ).bool()

      _UpperCAmelCase    			=   model(_SCREAMING_SNAKE_CASE ,					_SCREAMING_SNAKE_CASE       )
      # model only returns predictions for masked patches
      _UpperCAmelCase    			=   mask.sum().item()
      _UpperCAmelCase    			=   3 * self.tubelet_size * self.patch_size**2
      self.parent.assertEqual(result.logits.shape ,					(self.batch_size, num_masked_patches, decoder_num_labels)       )


    def   lowerCAmelCase_	(       self						:	Tuple       ):
      _UpperCAmelCase    			=   self.prepare_config_and_inputs()
      _UpperCAmelCase			,					_UpperCAmelCase			,					_UpperCAmelCase    			=   config_and_inputs
      _UpperCAmelCase    			=   {"""pixel_values""": pixel_values}
      return config, inputs_dict



@require_torch
class 							a					(		__lowerCAmelCase						,				__lowerCAmelCase						,				unittest.TestCase ):
    _snake_case  :	List[str]  				=				(
        (VideoMAEModel, VideoMAEForPreTraining, VideoMAEForVideoClassification) if is_torch_available() else ()
    )
    _snake_case  :	List[str]  				=				(
        {"""feature-extraction""": VideoMAEModel, """video-classification""": VideoMAEForVideoClassification}
        if is_torch_available()
        else {}
    )

    _snake_case  :	Tuple  				=				False
    _snake_case  :	Union[str, Any]  				=				False
    _snake_case  :	int  				=				False
    _snake_case  :	Any  				=				False


    def   lowerCAmelCase_	(       self						:	Optional[int]       ):
      _UpperCAmelCase    			=   VideoMAEModelTester(self       )
      _UpperCAmelCase    			=   ConfigTester(self ,					config_class=_SCREAMING_SNAKE_CASE ,					has_text_modality=_SCREAMING_SNAKE_CASE ,					hidden_size=37       )


    def   lowerCAmelCase_	(       self						:	List[str] ,					__lowerCAmelCase						:	Optional[Any] ,					__lowerCAmelCase						:	Any ,					__lowerCAmelCase						:	Dict=False       ):
      _UpperCAmelCase    			=   copy.deepcopy(_SCREAMING_SNAKE_CASE       )

      if model_class == VideoMAEForPreTraining:
        # important: each video needs to have the same number of masked patches
        # hence we define a single mask, which we then repeat for each example in the batch
        _UpperCAmelCase    			=   torch.ones((self.model_tester.num_masks,)       )
        _UpperCAmelCase    			=   torch.cat([mask, torch.zeros(self.model_tester.seq_length - mask.size(0       )       )]       )
        _UpperCAmelCase    			=   mask.expand(self.model_tester.batch_size ,					-1       ).bool()
        _UpperCAmelCase    			=   bool_masked_pos.to(_SCREAMING_SNAKE_CASE       )

      if return_labels:
        if model_class in [
            *get_values(_SCREAMING_SNAKE_CASE       ),
        ]:
          _UpperCAmelCase    			=   torch.zeros(
              self.model_tester.batch_size ,					dtype=torch.long ,					device=_SCREAMING_SNAKE_CASE       )

      return inputs_dict


    def   lowerCAmelCase_	(       self						:	Tuple       ):
      self.config_tester.run_common_tests()


    @unittest.skip(reason="""VideoMAE does not use inputs_embeds"""       )
    def   lowerCAmelCase_	(       self						:	Optional[int]       ):
      pass


    def   lowerCAmelCase_	(       self						:	Optional[int]       ):
      _UpperCAmelCase			,					_UpperCAmelCase    			=   self.model_tester.prepare_config_and_inputs_for_common()

      for model_class in self.all_model_classes:
        _UpperCAmelCase    			=   model_class(_SCREAMING_SNAKE_CASE       )
        self.assertIsInstance(model.get_input_embeddings() ,					(nn.Module)       )
        _UpperCAmelCase    			=   model.get_output_embeddings()
        self.assertTrue(x is None or isinstance(_SCREAMING_SNAKE_CASE ,					nn.Linear       )       )


    def   lowerCAmelCase_	(       self						:	List[Any]       ):
      _UpperCAmelCase			,					_UpperCAmelCase    			=   self.model_tester.prepare_config_and_inputs_for_common()

      for model_class in self.all_model_classes:
        _UpperCAmelCase    			=   model_class(_SCREAMING_SNAKE_CASE       )
        _UpperCAmelCase    			=   inspect.signature(model.forward       )
        # signature.parameters is an OrderedDict => so arg_names order is deterministic
        _UpperCAmelCase    			=   [*signature.parameters.keys()]

        _UpperCAmelCase    			=   ["""pixel_values"""]
        self.assertListEqual(arg_names[:1] ,					_SCREAMING_SNAKE_CASE       )


    def   lowerCAmelCase_	(       self						:	str       ):
      _UpperCAmelCase    			=   self.model_tester.prepare_config_and_inputs()
      self.model_tester.create_and_check_model(*_SCREAMING_SNAKE_CASE       )


    def   lowerCAmelCase_	(       self						:	str       ):
      _UpperCAmelCase    			=   self.model_tester.prepare_config_and_inputs()
      self.model_tester.create_and_check_for_pretraining(*_SCREAMING_SNAKE_CASE       )


    @slow
    def   lowerCAmelCase_	(       self						:	Union[str, Any]       ):
      for model_name in VIDEOMAE_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
        _UpperCAmelCase    			=   VideoMAEModel.from_pretrained(_SCREAMING_SNAKE_CASE       )
        self.assertIsNotNone(_SCREAMING_SNAKE_CASE       )


    def   lowerCAmelCase_	(       self						:	Dict       ):
      if not self.has_attentions:
        pass

      else:
        _UpperCAmelCase			,					_UpperCAmelCase    			=   self.model_tester.prepare_config_and_inputs_for_common()
        _UpperCAmelCase    			=   True

        for model_class in self.all_model_classes:
          _UpperCAmelCase    			=   self.model_tester.seq_length - self.model_tester.num_masks
          _UpperCAmelCase    			=   (
              num_visible_patches if model_class == VideoMAEForPreTraining else self.model_tester.seq_length
          )

          _UpperCAmelCase    			=   True
          _UpperCAmelCase    			=   False
          _UpperCAmelCase    			=   True
          _UpperCAmelCase    			=   model_class(_SCREAMING_SNAKE_CASE       )
          model.to(_SCREAMING_SNAKE_CASE       )
          model.eval()
          with torch.no_grad():
            _UpperCAmelCase    			=   model(**self._prepare_for_class(_SCREAMING_SNAKE_CASE ,					_SCREAMING_SNAKE_CASE       )       )
          _UpperCAmelCase    			=   outputs.attentions
          self.assertEqual(len(_SCREAMING_SNAKE_CASE       ) ,					self.model_tester.num_hidden_layers       )

          # check that output_attentions also work using config
          del inputs_dict["output_attentions"]
          _UpperCAmelCase    			=   True
          _UpperCAmelCase    			=   model_class(_SCREAMING_SNAKE_CASE       )
          model.to(_SCREAMING_SNAKE_CASE       )
          model.eval()
          with torch.no_grad():
            _UpperCAmelCase    			=   model(**self._prepare_for_class(_SCREAMING_SNAKE_CASE ,					_SCREAMING_SNAKE_CASE       )       )
          _UpperCAmelCase    			=   outputs.attentions
          self.assertEqual(len(_SCREAMING_SNAKE_CASE       ) ,					self.model_tester.num_hidden_layers       )

          self.assertListEqual(
              list(attentions[0].shape[-3:]       ) ,					[self.model_tester.num_attention_heads, seq_len, seq_len] ,					)
          _UpperCAmelCase    			=   len(_SCREAMING_SNAKE_CASE       )

          # Check attention is always last and order is fine
          _UpperCAmelCase    			=   True
          _UpperCAmelCase    			=   True
          _UpperCAmelCase    			=   model_class(_SCREAMING_SNAKE_CASE       )
          model.to(_SCREAMING_SNAKE_CASE       )
          model.eval()
          with torch.no_grad():
            _UpperCAmelCase    			=   model(**self._prepare_for_class(_SCREAMING_SNAKE_CASE ,					_SCREAMING_SNAKE_CASE       )       )

          self.assertEqual(out_len + 1 ,					len(_SCREAMING_SNAKE_CASE       )       )

          _UpperCAmelCase    			=   outputs.attentions

          self.assertEqual(len(_SCREAMING_SNAKE_CASE       ) ,					self.model_tester.num_hidden_layers       )
          self.assertListEqual(
              list(self_attentions[0].shape[-3:]       ) ,					[self.model_tester.num_attention_heads, seq_len, seq_len] ,					)


    def   lowerCAmelCase_	(       self						:	List[Any]       ):
      def check_hidden_states_output(__lowerCAmelCase						:	str ,					__lowerCAmelCase						:	List[Any] ,					__lowerCAmelCase						:	Any       ):
        _UpperCAmelCase    			=   model_class(_SCREAMING_SNAKE_CASE       )
        model.to(_SCREAMING_SNAKE_CASE       )
        model.eval()

        with torch.no_grad():
          _UpperCAmelCase    			=   model(**self._prepare_for_class(_SCREAMING_SNAKE_CASE ,					_SCREAMING_SNAKE_CASE       )       )

        _UpperCAmelCase    			=   outputs.hidden_states
        _UpperCAmelCase    			=   self.model_tester.num_hidden_layers + 1
        self.assertEqual(len(_SCREAMING_SNAKE_CASE       ) ,					_SCREAMING_SNAKE_CASE       )

        _UpperCAmelCase    			=   self.model_tester.seq_length - self.model_tester.num_masks
        _UpperCAmelCase    			=   num_visible_patches if model_class == VideoMAEForPreTraining else self.model_tester.seq_length

        self.assertListEqual(
            list(hidden_states[0].shape[-2:]       ) ,					[seq_length, self.model_tester.hidden_size] ,					)

      _UpperCAmelCase			,					_UpperCAmelCase    			=   self.model_tester.prepare_config_and_inputs_for_common()

      for model_class in self.all_model_classes:
        _UpperCAmelCase    			=   True
        check_hidden_states_output(_SCREAMING_SNAKE_CASE ,					_SCREAMING_SNAKE_CASE ,					_SCREAMING_SNAKE_CASE       )

        # check that output_hidden_states also work using config
        del inputs_dict["output_hidden_states"]
        _UpperCAmelCase    			=   True

        check_hidden_states_output(_SCREAMING_SNAKE_CASE ,					_SCREAMING_SNAKE_CASE ,					_SCREAMING_SNAKE_CASE       )


    @unittest.skip("""Will be fixed soon by reducing the size of the model used for common tests."""       )
    def   lowerCAmelCase_	(       self						:	Union[str, Any]       ):
      pass






def      __UpperCAmelCase       (      ):







  """simple docstring"""
  _UpperCAmelCase    			=   hf_hub_download(
      repo_id="""hf-internal-testing/spaghetti-video""" ,filename="""eating_spaghetti.npy""" ,repo_type="""dataset"""		)
  _UpperCAmelCase    			=   np.load(_UpperCamelCase		)
  return list(_UpperCamelCase		)


@require_torch
@require_vision
class 							a					(		unittest.TestCase ):


    @cached_property
    def   lowerCAmelCase_	(       self						:	Dict       ):
      # logits were tested with a different mean and std, so we use the same here
      return (
          VideoMAEImageProcessor(image_mean=[0.5, 0.5, 0.5] ,					image_std=[0.5, 0.5, 0.5]       )
          if is_vision_available()
          else None
      )


    @slow
    def   lowerCAmelCase_	(       self						:	Optional[int]       ):
      _UpperCAmelCase    			=   VideoMAEForVideoClassification.from_pretrained("""MCG-NJU/videomae-base-finetuned-kinetics"""       ).to(
          _SCREAMING_SNAKE_CASE       )

      _UpperCAmelCase    			=   self.default_image_processor
      _UpperCAmelCase    			=   prepare_video()
      _UpperCAmelCase    			=   image_processor(_SCREAMING_SNAKE_CASE ,					return_tensors="""pt"""       ).to(_SCREAMING_SNAKE_CASE       )

      # forward pass
      with torch.no_grad():
        _UpperCAmelCase    			=   model(**_SCREAMING_SNAKE_CASE       )

      # verify the logits
      _UpperCAmelCase    			=   torch.Size((1, 400)       )
      self.assertEqual(outputs.logits.shape ,					_SCREAMING_SNAKE_CASE       )

      _UpperCAmelCase    			=   torch.tensor([0.3_669, -0.0_688, -0.2_421]       ).to(_SCREAMING_SNAKE_CASE       )

      self.assertTrue(torch.allclose(outputs.logits[0, :3] ,					_SCREAMING_SNAKE_CASE ,					atol=1e-4       )       )


    @slow
    def   lowerCAmelCase_	(       self						:	int       ):
      _UpperCAmelCase    			=   VideoMAEForPreTraining.from_pretrained("""MCG-NJU/videomae-base-short"""       ).to(_SCREAMING_SNAKE_CASE       )

      _UpperCAmelCase    			=   self.default_image_processor
      _UpperCAmelCase    			=   prepare_video()
      _UpperCAmelCase    			=   image_processor(_SCREAMING_SNAKE_CASE ,					return_tensors="""pt"""       ).to(_SCREAMING_SNAKE_CASE       )

      # add boolean mask, indicating which patches to mask
      _UpperCAmelCase    			=   hf_hub_download(repo_id="""hf-internal-testing/bool-masked-pos""" ,					filename="""bool_masked_pos.pt"""       )
      _UpperCAmelCase    			=   torch.load(_SCREAMING_SNAKE_CASE       )

      # forward pass
      with torch.no_grad():
        _UpperCAmelCase    			=   model(**_SCREAMING_SNAKE_CASE       )

      # verify the logits
      _UpperCAmelCase    			=   torch.Size([1, 1408, 1536]       )
      _UpperCAmelCase    			=   torch.tensor(
          [[0.7_994, 0.9_612, 0.8_508], [0.7_401, 0.8_958, 0.8_302], [0.5_862, 0.7_468, 0.7_325]] ,					device=_SCREAMING_SNAKE_CASE       )
      self.assertEqual(outputs.logits.shape ,					_SCREAMING_SNAKE_CASE       )
      self.assertTrue(torch.allclose(outputs.logits[0, :3, :3] ,					_SCREAMING_SNAKE_CASE ,					atol=1e-4       )       )

      # verify the loss (`config.norm_pix_loss` = `True`)
      _UpperCAmelCase    			=   torch.tensor([0.5_142] ,					device=_SCREAMING_SNAKE_CASE       )
      self.assertTrue(torch.allclose(outputs.loss ,					_SCREAMING_SNAKE_CASE ,					atol=1e-4       )       )

      # verify the loss (`config.norm_pix_loss` = `False`)
      _UpperCAmelCase    			=   VideoMAEForPreTraining.from_pretrained("""MCG-NJU/videomae-base-short""" ,					norm_pix_loss=_SCREAMING_SNAKE_CASE       ).to(
          _SCREAMING_SNAKE_CASE       )

      with torch.no_grad():
        _UpperCAmelCase    			=   model(**_SCREAMING_SNAKE_CASE       )

      _UpperCAmelCase    			=   torch.tensor(torch.tensor([0.6_469]       ) ,					device=_SCREAMING_SNAKE_CASE       )
      self.assertTrue(torch.allclose(outputs.loss ,					_SCREAMING_SNAKE_CASE ,					atol=1e-4       )       )






'''simple docstring'''





from pathlib import Path
from typing import List

from transformers import is_torch_available, is_vision_available
from transformers.testing_utils import get_tests_dir, is_tool_test
from transformers.tools.agent_types import AGENT_TYPE_MAPPING, AgentAudio, AgentImage, AgentText


if is_torch_available():
   import torch

if is_vision_available():
   from PIL import Image


UpperCamelCase_		:     int          =		['''text''', '''image''', '''audio''']





def       __a      (  _UpperCamelCase:       List[str]       )		->					Dict:

     """simple docstring"""




     _snake_case				= []

     for input_type in input_types:
          if input_type == "text":
               inputs.append("Text input"       )
          elif input_type == "image":
               inputs.append(
                   Image.open(Path(get_tests_dir("fixtures/tests_samples/COCO"       )       ) / "000000039769.png"       ).resize((512, 512)       )       )
          elif input_type == "audio":
               inputs.append(torch.ones(3_000       )       )
          elif isinstance(_UpperCamelCase   ,		_UpperCamelCase       ):
               inputs.append(create_inputs(_UpperCamelCase       )       )
          else:
               raise ValueError(F"""Invalid type requested: {input_type}"""       )

     return inputs





def       __a      (  _UpperCamelCase:       List       )		->					Dict:

     """simple docstring"""




     _snake_case				= []

     for output in outputs:
          if isinstance(_UpperCamelCase   ,		(str, AgentText)       ):
               output_types.append("text"       )
          elif isinstance(_UpperCamelCase   ,		(Image.Image, AgentImage)       ):
               output_types.append("image"       )
          elif isinstance(_UpperCamelCase   ,		(torch.Tensor, AgentAudio)       ):
               output_types.append("audio"       )
          else:
               raise ValueError(F"""Invalid output: {output}"""       )

     return output_types





@is_tool_test
class   _a							:






     def 							_lowercase      (					self       )				->     Any:
          self.assertTrue(hasattr(self.tool   ,"inputs"       )       )
          self.assertTrue(hasattr(self.tool   ,"outputs"       )       )

          _snake_case				= self.tool.inputs
          for _input in inputs:
               if isinstance(_input   ,_SCREAMING_SNAKE_CASE       ):
                    for __input in _input:
                         self.assertTrue(__input in authorized_types       )
               else:
                    self.assertTrue(_input in authorized_types       )

          _snake_case				= self.tool.outputs
          for _output in outputs:
               self.assertTrue(_output in authorized_types       )






     def 							_lowercase      (					self       )				->     Any:
          _snake_case				= create_inputs(self.tool.inputs       )
          _snake_case				= self.tool(*_SCREAMING_SNAKE_CASE       )

          # There is a single output
          if len(self.tool.outputs       ) == 1:
               _snake_case				= [outputs]

          self.assertListEqual(output_types(_SCREAMING_SNAKE_CASE       )   ,self.tool.outputs       )






     def 							_lowercase      (					self       )				->     str:
          self.assertTrue(hasattr(self.tool   ,"description"       )       )
          self.assertTrue(hasattr(self.tool   ,"default_checkpoint"       )       )
          self.assertTrue(self.tool.description.startswith("This is a tool that"       )       )






     def 							_lowercase      (					self       )				->     Tuple:
          _snake_case				= create_inputs(self.tool.inputs       )
          _snake_case				= self.tool(*_SCREAMING_SNAKE_CASE       )

          if not isinstance(_SCREAMING_SNAKE_CASE   ,_SCREAMING_SNAKE_CASE       ):
               _snake_case				= [outputs]

          self.assertEqual(len(_SCREAMING_SNAKE_CASE       )   ,len(self.tool.outputs       )       )

          for output, output_type in zip(_SCREAMING_SNAKE_CASE   ,self.tool.outputs       ):
               _snake_case				= AGENT_TYPE_MAPPING[output_type]
               self.assertTrue(isinstance(_SCREAMING_SNAKE_CASE   ,_SCREAMING_SNAKE_CASE       )       )






     def 							_lowercase      (					self       )				->     Optional[Any]:
          _snake_case				= create_inputs(self.tool.inputs       )

          _snake_case				= []

          for _input, input_type in zip(_SCREAMING_SNAKE_CASE   ,self.tool.inputs       ):
               if isinstance(_SCREAMING_SNAKE_CASE   ,_SCREAMING_SNAKE_CASE       ):
                    _inputs.append([AGENT_TYPE_MAPPING[_input_type](_input       ) for _input_type in input_type]       )
               else:
                    _inputs.append(AGENT_TYPE_MAPPING[input_type](_input       )       )

        # Should not raise an error
          _snake_case				= self.tool(*_SCREAMING_SNAKE_CASE       )

          if not isinstance(_SCREAMING_SNAKE_CASE   ,_SCREAMING_SNAKE_CASE       ):
               _snake_case				= [outputs]

          self.assertEqual(len(_SCREAMING_SNAKE_CASE       )   ,len(self.tool.outputs       )       )


