


'''simple docstring'''




from __future__ import annotations

import unittest

from transformers import AlbertConfig, is_tf_available
from transformers.models.auto import get_values
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 import TF_MODEL_FOR_PRETRAINING_MAPPING
   from transformers.models.albert.modeling_tf_albert import (
       TF_ALBERT_PRETRAINED_MODEL_ARCHIVE_LIST,
       TFAlbertForMaskedLM,
       TFAlbertForMultipleChoice,
       TFAlbertForPreTraining,
       TFAlbertForQuestionAnswering,
       TFAlbertForSequenceClassification,
       TFAlbertForTokenClassification,
       TFAlbertModel,
   )




class  _lowercase   :
   def __init__(	self					:			Tuple					,      SCREAMING_SNAKE_CASE_					:			List[Any]					,      SCREAMING_SNAKE_CASE_					:			int=13					,      SCREAMING_SNAKE_CASE_					:			Tuple=7					,      SCREAMING_SNAKE_CASE_					:			Union[str, Any]=True					,      SCREAMING_SNAKE_CASE_					:			str=True					,      SCREAMING_SNAKE_CASE_					:			Union[str, Any]=True					,      SCREAMING_SNAKE_CASE_					:			int=True					,      SCREAMING_SNAKE_CASE_					:			List[str]=99					,      SCREAMING_SNAKE_CASE_					:			Any=16					,      SCREAMING_SNAKE_CASE_					:			Dict=32					,      SCREAMING_SNAKE_CASE_					:			List[str]=2					,      SCREAMING_SNAKE_CASE_					:			str=4					,      SCREAMING_SNAKE_CASE_					:			List[str]=37					,      SCREAMING_SNAKE_CASE_					:			List[str]="gelu"					,      SCREAMING_SNAKE_CASE_					:			List[Any]=0.1					,      SCREAMING_SNAKE_CASE_					:			List[str]=0.1					,      SCREAMING_SNAKE_CASE_					:			Optional[int]=512					,      SCREAMING_SNAKE_CASE_					:			Union[str, Any]=16					,      SCREAMING_SNAKE_CASE_					:			Tuple=2					,      SCREAMING_SNAKE_CASE_					:			Optional[Any]=0.0_2					,      SCREAMING_SNAKE_CASE_					:			Union[str, Any]=3					,      SCREAMING_SNAKE_CASE_					:			Union[str, Any]=4					,      SCREAMING_SNAKE_CASE_					:			Optional[Any]=None					,      )   ->       Tuple:
        __snake_case    			=	parent
        __snake_case    			=	13
        __snake_case    			=	7
        __snake_case    			=	True
        __snake_case    			=	True
        __snake_case    			=	True
        __snake_case    			=	True
        __snake_case    			=	99
        __snake_case    			=	16
        __snake_case    			=	32
        __snake_case    			=	2
        __snake_case    			=	4
        __snake_case    			=	37
        __snake_case    			=	'gelu'
        __snake_case    			=	0.1
        __snake_case    			=	0.1
        __snake_case    			=	512
        __snake_case    			=	16
        __snake_case    			=	2
        __snake_case    			=	0.0_2
        __snake_case    			=	3
        __snake_case    			=	4
        __snake_case    			=	None
   def a     (	self					:			Optional[int]			)   ->       Optional[int]:
        __snake_case    			=	ids_tensor([self.batch_size, self.seq_length]					,      self.vocab_size			)

        __snake_case    			=	None
        if self.use_input_mask:
             __snake_case    			=	random_attention_mask([self.batch_size, self.seq_length]			)

        __snake_case    			=	None
        if self.use_token_type_ids:
             __snake_case    			=	ids_tensor([self.batch_size, self.seq_length]					,      self.type_vocab_size			)

        __snake_case    			=	None
        __snake_case    			=	None
        __snake_case    			=	None
        if self.use_labels:
             __snake_case    			=	ids_tensor([self.batch_size]					,      self.type_sequence_label_size			)
             __snake_case    			=	ids_tensor([self.batch_size, self.seq_length]					,      self.num_labels			)
             __snake_case    			=	ids_tensor([self.batch_size]					,      self.num_choices			)

        __snake_case    			=	AlbertConfig(
            vocab_size=self.vocab_size					,      hidden_size=self.hidden_size					,      embedding_size=self.embedding_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					,      max_position_embeddings=self.max_position_embeddings					,      type_vocab_size=self.type_vocab_size					,      initializer_range=self.initializer_range					,      )

        return config, input_ids, token_type_ids, input_mask, sequence_labels, token_labels, choice_labels
   def a     (	self					:			Union[str, Any]					,      SCREAMING_SNAKE_CASE_					:			str					,      SCREAMING_SNAKE_CASE_					:			Any					,      SCREAMING_SNAKE_CASE_					:			Union[str, Any]					,      SCREAMING_SNAKE_CASE_					:			int					,      SCREAMING_SNAKE_CASE_					:			List[str]					,      SCREAMING_SNAKE_CASE_					:			Union[str, Any]					,      SCREAMING_SNAKE_CASE_					:			Tuple			)   ->       List[Any]:
        __snake_case    			=	TFAlbertModel(config=SCREAMING_SNAKE_CASE_			)
        # inputs = {'input_ids': input_ids,
        #           'attention_mask': input_mask,
        #           'token_type_ids': token_type_ids}
        # sequence_output, pooled_output = model(**inputs)
        __snake_case    			=	{'input_ids': input_ids, 'attention_mask': input_mask, 'token_type_ids': token_type_ids}
        __snake_case    			=	model(SCREAMING_SNAKE_CASE_			)

        __snake_case    			=	[input_ids, input_mask]
        __snake_case    			=	model(SCREAMING_SNAKE_CASE_			)

        __snake_case    			=	model(SCREAMING_SNAKE_CASE_			)

        self.parent.assertEqual(result.last_hidden_state.shape					,      (self.batch_size, self.seq_length, self.hidden_size)			)
        self.parent.assertEqual(result.pooler_output.shape					,      (self.batch_size, self.hidden_size)			)
   def a     (	self					:			Tuple					,      SCREAMING_SNAKE_CASE_					:			Tuple					,      SCREAMING_SNAKE_CASE_					:			Any					,      SCREAMING_SNAKE_CASE_					:			Dict					,      SCREAMING_SNAKE_CASE_					:			List[str]					,      SCREAMING_SNAKE_CASE_					:			Any					,      SCREAMING_SNAKE_CASE_					:			List[Any]					,      SCREAMING_SNAKE_CASE_					:			Tuple			)   ->       Optional[int]:
        __snake_case    			=	self.num_labels
        __snake_case    			=	TFAlbertForPreTraining(config=SCREAMING_SNAKE_CASE_			)
        __snake_case    			=	{'input_ids': input_ids, 'attention_mask': input_mask, 'token_type_ids': token_type_ids}
        __snake_case    			=	model(SCREAMING_SNAKE_CASE_			)
        self.parent.assertEqual(result.prediction_logits.shape					,      (self.batch_size, self.seq_length, self.vocab_size)			)
        self.parent.assertEqual(result.sop_logits.shape					,      (self.batch_size, self.num_labels)			)
   def a     (	self					:			Union[str, Any]					,      SCREAMING_SNAKE_CASE_					:			Tuple					,      SCREAMING_SNAKE_CASE_					:			Optional[int]					,      SCREAMING_SNAKE_CASE_					:			Optional[Any]					,      SCREAMING_SNAKE_CASE_					:			Any					,      SCREAMING_SNAKE_CASE_					:			int					,      SCREAMING_SNAKE_CASE_					:			Tuple					,      SCREAMING_SNAKE_CASE_					:			Optional[Any]			)   ->       int:
        __snake_case    			=	TFAlbertForMaskedLM(config=SCREAMING_SNAKE_CASE_			)
        __snake_case    			=	{'input_ids': input_ids, 'attention_mask': input_mask, 'token_type_ids': token_type_ids}
        __snake_case    			=	model(SCREAMING_SNAKE_CASE_			)
        self.parent.assertEqual(result.logits.shape					,      (self.batch_size, self.seq_length, self.vocab_size)			)
   def a     (	self					:			List[str]					,      SCREAMING_SNAKE_CASE_					:			Union[str, Any]					,      SCREAMING_SNAKE_CASE_					:			int					,      SCREAMING_SNAKE_CASE_					:			Tuple					,      SCREAMING_SNAKE_CASE_					:			Tuple					,      SCREAMING_SNAKE_CASE_					:			Tuple					,      SCREAMING_SNAKE_CASE_					:			Union[str, Any]					,      SCREAMING_SNAKE_CASE_					:			Any			)   ->       Dict:
        __snake_case    			=	self.num_labels
        __snake_case    			=	TFAlbertForSequenceClassification(config=SCREAMING_SNAKE_CASE_			)
        __snake_case    			=	{'input_ids': input_ids, 'attention_mask': input_mask, 'token_type_ids': token_type_ids}
        __snake_case    			=	model(SCREAMING_SNAKE_CASE_			)
        self.parent.assertEqual(result.logits.shape					,      (self.batch_size, self.num_labels)			)
   def a     (	self					:			Union[str, Any]					,      SCREAMING_SNAKE_CASE_					:			int					,      SCREAMING_SNAKE_CASE_					:			Dict					,      SCREAMING_SNAKE_CASE_					:			Any					,      SCREAMING_SNAKE_CASE_					:			Dict					,      SCREAMING_SNAKE_CASE_					:			Optional[int]					,      SCREAMING_SNAKE_CASE_					:			Tuple					,      SCREAMING_SNAKE_CASE_					:			List[Any]			)   ->       Optional[Any]:
        __snake_case    			=	TFAlbertForQuestionAnswering(config=SCREAMING_SNAKE_CASE_			)
        __snake_case    			=	{'input_ids': input_ids, 'attention_mask': input_mask, 'token_type_ids': token_type_ids}
        __snake_case    			=	model(SCREAMING_SNAKE_CASE_			)
        self.parent.assertEqual(result.start_logits.shape					,      (self.batch_size, self.seq_length)			)
        self.parent.assertEqual(result.end_logits.shape					,      (self.batch_size, self.seq_length)			)
   def a     (	self					:			int					,      SCREAMING_SNAKE_CASE_					:			Optional[Any]					,      SCREAMING_SNAKE_CASE_					:			List[Any]					,      SCREAMING_SNAKE_CASE_					:			Any					,      SCREAMING_SNAKE_CASE_					:			Dict					,      SCREAMING_SNAKE_CASE_					:			Dict					,      SCREAMING_SNAKE_CASE_					:			Tuple					,      SCREAMING_SNAKE_CASE_					:			Any			)   ->       Union[str, Any]:
        __snake_case    			=	self.num_choices
        __snake_case    			=	TFAlbertForMultipleChoice(config=SCREAMING_SNAKE_CASE_			)
        __snake_case    			=	tf.tile(tf.expand_dims(SCREAMING_SNAKE_CASE_					,      1			)					,      (1, self.num_choices, 1)			)
        __snake_case    			=	tf.tile(tf.expand_dims(SCREAMING_SNAKE_CASE_					,      1			)					,      (1, self.num_choices, 1)			)
        __snake_case    			=	tf.tile(tf.expand_dims(SCREAMING_SNAKE_CASE_					,      1			)					,      (1, self.num_choices, 1)			)
        __snake_case    			=	{
            'input_ids': multiple_choice_inputs_ids,
            'attention_mask': multiple_choice_input_mask,
            'token_type_ids': multiple_choice_token_type_ids,
        }
        __snake_case    			=	model(SCREAMING_SNAKE_CASE_			)
        self.parent.assertListEqual(list(result['logits'].shape			)					,      [self.batch_size, self.num_choices]			)
   def a     (	self					:			Dict					,      SCREAMING_SNAKE_CASE_					:			List[Any]					,      SCREAMING_SNAKE_CASE_					:			Optional[int]					,      SCREAMING_SNAKE_CASE_					:			str					,      SCREAMING_SNAKE_CASE_					:			Optional[Any]					,      SCREAMING_SNAKE_CASE_					:			int					,      SCREAMING_SNAKE_CASE_					:			Union[str, Any]					,      SCREAMING_SNAKE_CASE_					:			List[Any]			)   ->       Optional[Any]:
        __snake_case    			=	self.num_labels
        __snake_case    			=	TFAlbertForTokenClassification(config=SCREAMING_SNAKE_CASE_			)
        __snake_case    			=	{
            'input_ids': input_ids,
            'attention_mask': input_mask,
            'token_type_ids': token_type_ids,
        }
        __snake_case    			=	model(SCREAMING_SNAKE_CASE_			)
        self.parent.assertListEqual(list(result['logits'].shape			)					,      [self.batch_size, self.seq_length, self.num_labels]			)





   def a     (	self					:			str			)   ->       Tuple:
        __snake_case    			=	self.prepare_config_and_inputs()
        (
            (
            __snake_case					
        )			,					(
            __snake_case					
        )			,					(
            __snake_case					
        )			,					(
            __snake_case					
        )			,					(
            __snake_case					
        )			,					(
            __snake_case					
        )			,					(
            __snake_case					
        )			,										
        )    			=	config_and_inputs
        __snake_case    			=	{'input_ids': input_ids, 'token_type_ids': token_type_ids, 'attention_mask': input_mask}
        return config, inputs_dict




@require_tf
class  _lowercase   (  __lowercase	,				__lowercase	,				unittest.TestCase       ):
   _SCREAMING_SNAKE_CASE     :     Optional[Any]									=  (
       (
           TFAlbertModel,
           TFAlbertForPreTraining,
           TFAlbertForMaskedLM,
           TFAlbertForSequenceClassification,
           TFAlbertForQuestionAnswering,
           TFAlbertForTokenClassification,
           TFAlbertForMultipleChoice,
       )
       if is_tf_available()
       else ()
   )
   _SCREAMING_SNAKE_CASE     :     Optional[int]									=  (
       {
           "feature-extraction": TFAlbertModel,
           "fill-mask": TFAlbertForMaskedLM,
           "question-answering": TFAlbertForQuestionAnswering,
           "text-classification": TFAlbertForSequenceClassification,
           "token-classification": TFAlbertForTokenClassification,
           "zero-shot": TFAlbertForSequenceClassification,
       }
       if is_tf_available()
       else {}
   )
   _SCREAMING_SNAKE_CASE     :     Dict									=  False
   _SCREAMING_SNAKE_CASE     :     Optional[int]									=  False
   def a     (	self					:			Optional[int]					,      SCREAMING_SNAKE_CASE_					:			List[Any]					,      SCREAMING_SNAKE_CASE_					:			Optional[Any]					,      SCREAMING_SNAKE_CASE_					:			Union[str, Any]=False			)   ->       List[Any]:
        __snake_case    			=	super()._prepare_for_class(SCREAMING_SNAKE_CASE_					,      SCREAMING_SNAKE_CASE_					,      return_labels=SCREAMING_SNAKE_CASE_			)

        if return_labels:
             if model_class in get_values(SCREAMING_SNAKE_CASE_			):
                  __snake_case    			=	tf.zeros(self.model_tester.batch_size					,      dtype=tf.intaa			)

        return inputs_dict
   def a     (	self					:			Union[str, Any]			)   ->       Union[str, Any]:
        __snake_case    			=	TFAlbertModelTester(self			)
        __snake_case    			=	ConfigTester(self					,      config_class=SCREAMING_SNAKE_CASE_					,      hidden_size=37			)
   def a     (	self					:			List[str]			)   ->       int:
        self.config_tester.run_common_tests()
   def a     (	self					:			Tuple			)   ->       Union[str, Any]:
        __snake_case    			=	self.model_tester.prepare_config_and_inputs()
        self.model_tester.create_and_check_albert_model(*SCREAMING_SNAKE_CASE_			)
   def a     (	self					:			List[str]			)   ->       Optional[int]:
        __snake_case    			=	self.model_tester.prepare_config_and_inputs()
        self.model_tester.create_and_check_albert_for_pretraining(*SCREAMING_SNAKE_CASE_			)
   def a     (	self					:			List[Any]			)   ->       Any:
        __snake_case    			=	self.model_tester.prepare_config_and_inputs()
        self.model_tester.create_and_check_albert_for_masked_lm(*SCREAMING_SNAKE_CASE_			)
   def a     (	self					:			Optional[Any]			)   ->       Optional[Any]:
        __snake_case    			=	self.model_tester.prepare_config_and_inputs()
        self.model_tester.create_and_check_albert_for_multiple_choice(*SCREAMING_SNAKE_CASE_			)
   def a     (	self					:			List[str]			)   ->       int:
        __snake_case    			=	self.model_tester.prepare_config_and_inputs()
        self.model_tester.create_and_check_albert_for_sequence_classification(*SCREAMING_SNAKE_CASE_			)
   def a     (	self					:			str			)   ->       Any:
        __snake_case    			=	self.model_tester.prepare_config_and_inputs()
        self.model_tester.create_and_check_albert_for_question_answering(*SCREAMING_SNAKE_CASE_			)





   @slow
   def a     (	self					:			int			)   ->       List[str]:
        for model_name in TF_ALBERT_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
             __snake_case    			=	TFAlbertModel.from_pretrained(SCREAMING_SNAKE_CASE_			)
             self.assertIsNotNone(SCREAMING_SNAKE_CASE_			)




@require_tf
class  _lowercase   (  unittest.TestCase       ):
   @slow
   def a     (	self					:			Dict			)   ->       List[Any]:
        __snake_case    			=	TFAlbertForPreTraining.from_pretrained('albert-base-v2'			)
        __snake_case    			=	tf.constant([[0, 1, 2, 3, 4, 5]]			)
        __snake_case    			=	model(SCREAMING_SNAKE_CASE_			)[0]

        __snake_case    			=	[1, 6, 3_0000]
        self.assertEqual(output.shape					,      SCREAMING_SNAKE_CASE_			)

        __snake_case    			=	tf.constant(
            [
                [
                    [4.5_9_5_6_6_8, 0.7_4_4_6_2_7_5_4, -1.8_1_8_1_4_7],
                    [4.5_9_5_4_3_4_7, 0.7_4_5_4_1_8_4, -1.8_1_8_8_2_5_8],
                    [4.5_9_5_4_9_0_5, 0.7_4_4_8_2_3_5, -1.8_1_8_2_3_1_6],
                ]
            ]			)
        tf.debugging.assert_near(output[:, :3, :3]					,      SCREAMING_SNAKE_CASE_					,      atol=1e-4			)








'''simple docstring'''




from functools import partial
from typing import Any, Callable, Dict, List, Type, TypeVar, Union, overload

import torch
import torch.nn as nn
import torch.types





def      _a		(lowercase__ :      torch.Tensor       ,      lowercase__ :      torch.Tensor       ,      lowercase__ :      bool	) -> torch.Tensor:






     """simple docstring"""
     # The first operation in a checkpoint can't be in-place, but it's
     # nice to have in-place addition during inference. Thus...
     if not inplace:
          __snake_case    			=	ma + ma
     else:
          ma += ma

     return ma





def      _a		(lowercase__ :      torch.Tensor       ,      lowercase__ :      List[int]	) -> torch.Tensor:






     """simple docstring"""
     __snake_case    			=	-1 * len(lowercase__	)
     __snake_case    			=	list(range(len(tensor.shape[:zero_index]	)	)	)
     return tensor.permute(first_inds + [zero_index + i for i in inds]	)





def      _a		(lowercase__ :      torch.Tensor       ,      lowercase__ :      int	) -> torch.Tensor:






     """simple docstring"""
     return t.reshape(t.shape[:-no_dims] + (-1,)	)





def      _a		(lowercase__ :      torch.Tensor       ,      lowercase__ :      torch.Tensor       ,      lowercase__ :      int       ,      lowercase__ :      float = 1e-4	) -> torch.Tensor:






     """simple docstring"""
     __snake_case    			=	mask.expand(*value.shape	)
     return torch.sum(mask * value       ,      dim=lowercase__	) / (eps + torch.sum(lowercase__       ,      dim=lowercase__	))





def      _a		(lowercase__ :      torch.Tensor       ,      lowercase__ :      torch.types.Number = 2.31_25       ,      lowercase__ :      torch.types.Number = 21.68_75       ,      lowercase__ :      int = 6_4	) -> torch.Tensor:






     """simple docstring"""
     __snake_case    			=	torch.linspace(lowercase__       ,      lowercase__       ,      no_bins - 1       ,      device=pts.device	)
     __snake_case    			=	torch.sqrt(torch.sum((pts.unsqueeze(-2	) - pts.unsqueeze(-3	)) ** 2       ,      dim=-1	)	)
     return torch.bucketize(lowercase__       ,      lowercase__	)





def      _a		(lowercase__ :      Callable[[list], Any]       ,      lowercase__ :      List[dict]	) -> dict:






     """simple docstring"""
     __snake_case    			=	dicts[0]
     __snake_case    			=	{}
     for k, v in first.items():
          __snake_case    			=	[d[k] for d in dicts]
          if isinstance(lowercase__       ,      lowercase__	):
               __snake_case    			=	dict_multimap(lowercase__       ,      lowercase__	)
          else:
               __snake_case    			=	fn(lowercase__	)

     return new_dict





def      _a		(lowercase__ :      torch.Tensor       ,      lowercase__ :      torch.Tensor	) -> torch.Tensor:






     """simple docstring"""
     __snake_case    			=	v_bins.view(((1,) * len(x.shape	)) + (len(lowercase__	),)	)
     __snake_case    			=	x[..., None] - reshaped_bins
     __snake_case    			=	torch.argmin(torch.abs(lowercase__	)       ,      dim=-1	)
     return nn.functional.one_hot(lowercase__       ,      num_classes=len(lowercase__	)	).float()





def      _a		(lowercase__ :      torch.Tensor       ,      lowercase__ :      torch.Tensor       ,      lowercase__ :      int = 0       ,      lowercase__ :      int = 0	) -> torch.Tensor:






     """simple docstring"""
     __snake_case    			=	[]
     for i, s in enumerate(data.shape[:no_batch_dims]	):
          __snake_case    			=	torch.arange(lowercase__	)
          __snake_case    			=	r.view(*(*((1,) * i), -1, *((1,) * (len(inds.shape	) - i - 1)))	)
          ranges.append(lowercase__	)

     __snake_case    			=	[slice(lowercase__	) for _ in range(len(data.shape	) - no_batch_dims	)]
     __snake_case    			=	inds
     ranges.extend(lowercase__	)
     # Matt note: Editing this to get around the behaviour of using a list as an array index changing
     # in recent Numpy versions
     return data[tuple(lowercase__	)]


_a      :      str       				=      TypeVar("T")





def      _a		(lowercase__ :      Callable[[T], Any]       ,      lowercase__ :      Dict[Any, Union[dict, list, tuple, T]]       ,      lowercase__ :      Type[T]	) -> Dict[Any, Union[dict, list, tuple, Any]]:






     """simple docstring"""
     __snake_case    			=	{}
     for k, v in dic.items():
          if isinstance(lowercase__       ,      lowercase__	):
               __snake_case    			=	dict_map(lowercase__       ,      lowercase__       ,      lowercase__	)
          else:
               __snake_case    			=	tree_map(lowercase__       ,      lowercase__       ,      lowercase__	)

     return new_dict





@overload
def      _a		(lowercase__ :      Callable[[T], Any]       ,      lowercase__ :      T       ,      lowercase__ :      Type[T]	) -> Any:






     """simple docstring"""
     ...





@overload
def      _a		(lowercase__ :      Callable[[T], Any]       ,      lowercase__ :      dict       ,      lowercase__ :      Type[T]	) -> dict:






     """simple docstring"""
     ...





@overload
def      _a		(lowercase__ :      Callable[[T], Any]       ,      lowercase__ :      list       ,      lowercase__ :      Type[T]	) -> list:






     """simple docstring"""
     ...





@overload
def      _a		(lowercase__ :      Callable[[T], Any]       ,      lowercase__ :      tuple       ,      lowercase__ :      Type[T]	) -> tuple:






     """simple docstring"""
     ...





def      _a		(lowercase__ :      str       ,      lowercase__ :      Any       ,      lowercase__ :      Dict	) -> Union[str, Any]:






     """simple docstring"""
     if isinstance(lowercase__       ,      lowercase__	):
          return dict_map(lowercase__       ,      lowercase__       ,      lowercase__	)
     elif isinstance(lowercase__       ,      lowercase__	):
          return [tree_map(lowercase__       ,      lowercase__       ,      lowercase__	) for x in tree]
     elif isinstance(lowercase__       ,      lowercase__	):
          return tuple(tree_map(lowercase__       ,      lowercase__       ,      lowercase__	) for x in tree	)
     elif isinstance(lowercase__       ,      lowercase__	):
          return fn(lowercase__	)
     else:
          print(type(lowercase__	)	)
          raise ValueError('Not supported'	)


_a      :      Union[str, Any]       				=      partial(tree_map, leaf_type=torch.Tensor)




