

import argparse
import json

import requests
import torch
from huggingface_hub import hf_hub_download
from PIL import Image
from torchvision import transforms

from transformers import BitImageProcessor, FocalNetConfig, FocalNetForImageClassification
from transformers.image_utils import IMAGENET_DEFAULT_MEAN, IMAGENET_DEFAULT_STD, PILImageResampling







def 		_lowercase (     lowercase__						):
      __lowerCAmelCase					:						Tuple					=					[2, 2, 6, 2] if '''tiny''' in model_name else [2, 2, 1_8, 2]
      __lowerCAmelCase					:						Union[str, Any]					=					True if '''large''' in model_name or '''huge''' in model_name else False
      __lowerCAmelCase					:						str					=					True if '''large''' in model_name or '''huge''' in model_name else False
      __lowerCAmelCase					:						Union[str, Any]					=					True if '''large''' in model_name or '''huge''' in model_name else False

      if "large" in model_name or "xlarge" in model_name or "huge" in model_name:
            if "fl3" in model_name:
                  __lowerCAmelCase					:						Union[str, Any]					=					[3, 3, 3, 3]
                  __lowerCAmelCase					:						Dict					=					[5, 5, 5, 5]
            elif "fl4" in model_name:
                  __lowerCAmelCase					:						List[Any]					=					[4, 4, 4, 4]
                  __lowerCAmelCase					:						Any					=					[3, 3, 3, 3]

      if "tiny" in model_name or "small" in model_name or "base" in model_name:
            __lowerCAmelCase					:						Optional[Any]					=					[3, 3, 3, 3]
            if "lrf" in model_name:
                  __lowerCAmelCase					:						List[str]					=					[3, 3, 3, 3]
            else:
                  __lowerCAmelCase					:						Optional[Any]					=					[2, 2, 2, 2]

      if "tiny" in model_name:
            __lowerCAmelCase					:						Union[str, Any]					=					9_6
      elif "small" in model_name:
            __lowerCAmelCase					:						List[Any]					=					9_6
      elif "base" in model_name:
            __lowerCAmelCase					:						Optional[Any]					=					1_2_8
      elif "large" in model_name:
            __lowerCAmelCase					:						Dict					=					1_9_2
      elif "xlarge" in model_name:
            __lowerCAmelCase					:						Optional[int]					=					2_5_6
      elif "huge" in model_name:
            __lowerCAmelCase					:						Optional[Any]					=					3_5_2

      # set label information
      __lowerCAmelCase					:						str					=					'''huggingface/label-files'''
      if "large" in model_name or "huge" in model_name:
            __lowerCAmelCase					:						Optional[int]					=					'''imagenet-22k-id2label.json'''
      else:
            __lowerCAmelCase					:						List[Any]					=					'''imagenet-1k-id2label.json'''

      __lowerCAmelCase					:						int					=					json.load(open(hf_hub_download(_SCREAMING_SNAKE_CASE   ,	_SCREAMING_SNAKE_CASE   ,	repo_type='''dataset'''						)   ,	'''r'''						)						)
      __lowerCAmelCase					:						int					=					{int(_SCREAMING_SNAKE_CASE						): v for k, v in idalabel.items()}
      __lowerCAmelCase					:						int					=					{v: k for k, v in idalabel.items()}

      __lowerCAmelCase					:						List[Any]					=					FocalNetConfig(
          embed_dim=_SCREAMING_SNAKE_CASE   ,	depths=_SCREAMING_SNAKE_CASE   ,	focal_levels=_SCREAMING_SNAKE_CASE   ,	focal_windows=_SCREAMING_SNAKE_CASE   ,	use_conv_embed=_SCREAMING_SNAKE_CASE   ,	idalabel=_SCREAMING_SNAKE_CASE   ,	labelaid=_SCREAMING_SNAKE_CASE   ,	use_post_layernorm=_SCREAMING_SNAKE_CASE   ,	use_layerscale=_SCREAMING_SNAKE_CASE   ,	)

      return config







def 		_lowercase (     lowercase__						):


      if "patch_embed.proj" in name:
            __lowerCAmelCase					:						str					=					name.replace('''patch_embed.proj'''   ,	'''embeddings.patch_embeddings.projection'''						)
      if "patch_embed.norm" in name:
            __lowerCAmelCase					:						Optional[int]					=					name.replace('''patch_embed.norm'''   ,	'''embeddings.norm'''						)
      if "layers" in name:
            __lowerCAmelCase					:						str					=					'''encoder.''' + name
      if "encoder.layers" in name:
            __lowerCAmelCase					:						Tuple					=					name.replace('''encoder.layers'''   ,	'''encoder.stages'''						)
      if "downsample.proj" in name:
            __lowerCAmelCase					:						Dict					=					name.replace('''downsample.proj'''   ,	'''downsample.projection'''						)
      if "blocks" in name:
            __lowerCAmelCase					:						Optional[int]					=					name.replace('''blocks'''   ,	'''layers'''						)
      if "modulation.f.weight" in name or "modulation.f.bias" in name:
            __lowerCAmelCase					:						Optional[int]					=					name.replace('''modulation.f'''   ,	'''modulation.projection_in'''						)
      if "modulation.h.weight" in name or "modulation.h.bias" in name:
            __lowerCAmelCase					:						Tuple					=					name.replace('''modulation.h'''   ,	'''modulation.projection_context'''						)
      if "modulation.proj.weight" in name or "modulation.proj.bias" in name:
            __lowerCAmelCase					:						Tuple					=					name.replace('''modulation.proj'''   ,	'''modulation.projection_out'''						)

      if name == "norm.weight":
            __lowerCAmelCase					:						int					=					'''layernorm.weight'''
      if name == "norm.bias":
            __lowerCAmelCase					:						Union[str, Any]					=					'''layernorm.bias'''

      if "head" in name:
            __lowerCAmelCase					:						Tuple					=					name.replace('''head'''   ,	'''classifier'''						)
      else:
            __lowerCAmelCase					:						int					=					'''focalnet.''' + name

      return name







def 		_lowercase (     lowercase__   ,	lowercase__   ,	lowercase__=False						):
      __lowerCAmelCase					:						Optional[Any]					=					{
          '''focalnet-tiny''': '''https://projects4jw.blob.core.windows.net/focalnet/release/classification/focalnet_tiny_srf.pth''',
          '''focalnet-tiny-lrf''': '''https://projects4jw.blob.core.windows.net/focalnet/release/classification/focalnet_tiny_lrf.pth''',
          '''focalnet-small''': '''https://projects4jw.blob.core.windows.net/focalnet/release/classification/focalnet_small_srf.pth''',
          '''focalnet-small-lrf''': '''https://projects4jw.blob.core.windows.net/focalnet/release/classification/focalnet_small_lrf.pth''',
          '''focalnet-base''': '''https://projects4jw.blob.core.windows.net/focalnet/release/classification/focalnet_base_srf.pth''',
          '''focalnet-base-lrf''': '''https://projects4jw.blob.core.windows.net/focalnet/release/classification/focalnet_base_lrf.pth''',
          '''focalnet-large-lrf-fl3''': '''https://projects4jw.blob.core.windows.net/focalnet/release/classification/focalnet_large_lrf_384.pth''',
          '''focalnet-large-lrf-fl4''': '''https://projects4jw.blob.core.windows.net/focalnet/release/classification/focalnet_large_lrf_384_fl4.pth''',
          '''focalnet-xlarge-lrf-fl3''': '''https://projects4jw.blob.core.windows.net/focalnet/release/classification/focalnet_xlarge_lrf_384.pth''',
          '''focalnet-xlarge-lrf-fl4''': '''https://projects4jw.blob.core.windows.net/focalnet/release/classification/focalnet_xlarge_lrf_384_fl4.pth''',
      }
      # fmt: on

      __lowerCAmelCase					:						Any					=					model_name_to_url[model_name]
      print('''Checkpoint URL: '''   ,	_SCREAMING_SNAKE_CASE						)
      __lowerCAmelCase					:						Any					=					torch.hub.load_state_dict_from_url(_SCREAMING_SNAKE_CASE   ,	map_location='''cpu'''						)['''model''']

      # rename keys
      for key in state_dict.copy().keys():
            __lowerCAmelCase					:						str					=					state_dict.pop(_SCREAMING_SNAKE_CASE						)
            __lowerCAmelCase					:						str					=					val

      __lowerCAmelCase					:						List[str]					=					get_focalnet_config(_SCREAMING_SNAKE_CASE						)
      __lowerCAmelCase					:						Optional[Any]					=					FocalNetForImageClassification(_SCREAMING_SNAKE_CASE						)
      model.eval()

      # load state dict
      model.load_state_dict(_SCREAMING_SNAKE_CASE						)

      # verify conversion
      __lowerCAmelCase					:						List[str]					=					'''http://images.cocodataset.org/val2017/000000039769.jpg'''

      __lowerCAmelCase					:						List[str]					=					BitImageProcessor(
          do_resize=_SCREAMING_SNAKE_CASE   ,	size={'''shortest_edge''': 2_5_6}   ,	resample=PILImageResampling.BILINEAR   ,	do_center_crop=_SCREAMING_SNAKE_CASE   ,	crop_size=2_2_4   ,	do_normalize=_SCREAMING_SNAKE_CASE   ,	image_mean=_SCREAMING_SNAKE_CASE   ,	image_std=_SCREAMING_SNAKE_CASE   ,	)
      __lowerCAmelCase					:						Any					=					Image.open(requests.get(_SCREAMING_SNAKE_CASE   ,	stream=_SCREAMING_SNAKE_CASE						).raw						)
      __lowerCAmelCase					:						Dict					=					processor(images=_SCREAMING_SNAKE_CASE   ,	return_tensors='''pt'''						)

      __lowerCAmelCase					:						Any					=					transforms.Compose(
          [
              transforms.Resize(2_5_6						),
              transforms.CenterCrop(2_2_4						),
              transforms.ToTensor(),
              transforms.Normalize(mean=[0.4_8_5, 0.4_5_6, 0.4_0_6]   ,	std=[0.2_2_9, 0.2_2_4, 0.2_2_5]						),
          ]						)

      __lowerCAmelCase					:						Tuple					=					image_transforms(_SCREAMING_SNAKE_CASE						).unsqueeze(0						)

      # verify pixel_values
      assert torch.allclose(inputs.pixel_values   ,	_SCREAMING_SNAKE_CASE   ,	atol=1E-4						)

      __lowerCAmelCase					:						int					=					model(**_SCREAMING_SNAKE_CASE						)

      __lowerCAmelCase					:						Dict					=					outputs.logits.argmax(-1						).item()
      print('''Predicted class:'''   ,	model.config.idalabel[predicted_class_idx]						)

      print('''First values of logits:'''   ,	outputs.logits[0, :3]						)

      if model_name == "focalnet-tiny":
            __lowerCAmelCase					:						Tuple					=					torch.tensor([0.2_1_6_6, -0.4_3_6_8, 0.2_1_9_1]						)
      elif model_name == "focalnet-tiny-lrf":
            __lowerCAmelCase					:						Union[str, Any]					=					torch.tensor([1.1_6_6_9, 0.0_1_2_5, -0.1_6_9_5]						)
      elif model_name == "focalnet-small":
            __lowerCAmelCase					:						List[str]					=					torch.tensor([0.4_9_1_7, -0.0_4_3_0, 0.1_3_4_1]						)
      elif model_name == "focalnet-small-lrf":
            __lowerCAmelCase					:						str					=					torch.tensor([-0.2_5_8_8, -0.5_3_4_2, -0.2_3_3_1]						)
      elif model_name == "focalnet-base":
            __lowerCAmelCase					:						Optional[int]					=					torch.tensor([-0.1_6_5_5, -0.4_0_9_0, -0.1_7_3_0]						)
      elif model_name == "focalnet-base-lrf":
            __lowerCAmelCase					:						List[str]					=					torch.tensor([0.5_3_0_6, -0.0_4_8_3, -0.3_9_2_8]						)
      assert torch.allclose(outputs.logits[0, :3]   ,	_SCREAMING_SNAKE_CASE   ,	atol=1E-4						)
      print('''Looks ok!'''						)

      if pytorch_dump_folder_path is not None:
            print(f"""Saving model and processor of {model_name} to {pytorch_dump_folder_path}"""						)
            model.save_pretrained(_SCREAMING_SNAKE_CASE						)
            processor.save_pretrained(_SCREAMING_SNAKE_CASE						)

      if push_to_hub:
            print(f"""Pushing model and processor of {model_name} to the hub..."""						)
            model.push_to_hub(f"""{model_name}"""						)
            processor.push_to_hub(f"""{model_name}"""						)


if __name__ == "__main__":
 _UpperCamelCase 			=		argparse.ArgumentParser()
 # Required parameters
 parser.add_argument(
     "--model_name",
     default="focalnet-tiny",
     type=str,
     help="Name of the FocalNet model you'd like to convert.",
 )
 parser.add_argument(
     "--pytorch_dump_folder_path", default=None, type=str, help="Path to the output PyTorch model directory."
 )
 parser.add_argument(
     "--push_to_hub",
     action="store_true",
     help="Whether to push the model and processor to the hub.",
 )

 _UpperCamelCase 			=		parser.parse_args()
 convert_focalnet_checkpoint(args.model_name, args.pytorch_dump_folder_path, args.push_to_hub)









import itertools
import os
import random
import tempfile
import unittest

import numpy as np

from transformers import TvltFeatureExtractor, is_datasets_available
from transformers.testing_utils import check_json_file_has_correct_format, require_torch, require_torchaudio
from transformers.utils.import_utils import is_torch_available

from ...test_sequence_feature_extraction_common import SequenceFeatureExtractionTestMixin


if is_torch_available():
      import torch

if is_datasets_available():
      from datasets import load_dataset

SCREAMING_SNAKE_CASE_						   =       random.Random()



def    __lowercase   (      _SCREAMING_SNAKE_CASE ,						_SCREAMING_SNAKE_CASE=1.0 ,						_SCREAMING_SNAKE_CASE=None ,						_SCREAMING_SNAKE_CASE=None	) ->   Tuple:


      '''simple docstring'''


      if rng is None:
            SCREAMING_SNAKE_CASE		=						global_rng

      SCREAMING_SNAKE_CASE		=						[]
      for batch_idx in range(shape[0]	):
            values.append([]	)
            for _ in range(shape[1]	):
                  values[-1].append(rng.random() * scale	)

      return values

class 		UpperCamelCase__ (      unittest.TestCase   ):



     '''simple docstring'''

     def __init__(							self						:    List[Any]						,lowerCamelCase__						:    str						,lowerCamelCase__						:    Optional[int]=7						,lowerCamelCase__						:    Optional[Any]=400						,lowerCamelCase__						:    List[str]=2000						,lowerCamelCase__						:    List[str]=2048						,lowerCamelCase__						:    Any=128						,lowerCamelCase__						:    List[str]=1						,lowerCamelCase__						:    str=512						,lowerCamelCase__						:    Optional[Any]=30						,lowerCamelCase__						:    Tuple=44100						,)     ->		Tuple:




           '''simple docstring'''


           SCREAMING_SNAKE_CASE		=						parent
           SCREAMING_SNAKE_CASE		=						batch_size
           SCREAMING_SNAKE_CASE		=						min_seq_length
           SCREAMING_SNAKE_CASE		=						max_seq_length
           SCREAMING_SNAKE_CASE		=						(self.max_seq_length - self.min_seq_length) // (self.batch_size - 1)
           SCREAMING_SNAKE_CASE		=						spectrogram_length
           SCREAMING_SNAKE_CASE		=						feature_size
           SCREAMING_SNAKE_CASE		=						num_audio_channels
           SCREAMING_SNAKE_CASE		=						hop_length
           SCREAMING_SNAKE_CASE		=						chunk_length
           SCREAMING_SNAKE_CASE		=						sampling_rate






     def 				SCREAMING_SNAKE_CASE__  (							self						:    List[Any]       )     ->		Optional[int]:




           '''simple docstring'''


           return {
               "spectrogram_length": self.spectrogram_length,
               "feature_size": self.feature_size,
               "num_audio_channels": self.num_audio_channels,
               "hop_length": self.hop_length,
               "chunk_length": self.chunk_length,
               "sampling_rate": self.sampling_rate,
           }






     def 				SCREAMING_SNAKE_CASE__  (							self						:    Optional[int]						,lowerCamelCase__						:    Tuple=False						,lowerCamelCase__						:    Union[str, Any]=False       )     ->		str:




           '''simple docstring'''


           def _flatten(lowerCamelCase__						:    List[Any]       ):
                 return list(itertools.chain(*lowerCamelCase__       )       )

           if equal_length:
                 SCREAMING_SNAKE_CASE		=						[floats_list((self.max_seq_length, self.feature_size)       ) for _ in range(self.batch_size       )]
           else:
                 # make sure that inputs increase in size
                 SCREAMING_SNAKE_CASE		=						[
                     floats_list((x, self.feature_size)       )
                     for x in range(self.min_seq_length						,self.max_seq_length						,self.seq_length_diff       )
                 ]
           if numpify:
                 SCREAMING_SNAKE_CASE		=						[np.asarray(lowerCamelCase__       ) for x in speech_inputs]
           return speech_inputs

@require_torch
@require_torchaudio
class 		UpperCamelCase__ (      lowerCAmelCase_							,      unittest.TestCase   ):



     '''simple docstring'''

     __snake_case    :	List[Any]			=			TvltFeatureExtractor






     def 				SCREAMING_SNAKE_CASE__  (							self						:    str       )     ->		Any:




           '''simple docstring'''


           SCREAMING_SNAKE_CASE		=						TvltFeatureExtractionTester(self       )






     def 				SCREAMING_SNAKE_CASE__  (							self						:    List[Any]       )     ->		Any:




           '''simple docstring'''


           SCREAMING_SNAKE_CASE		=						self.feature_extraction_class(**self.feat_extract_dict       )
           self.assertTrue(hasattr(lowerCamelCase__						,"""spectrogram_length"""       )       )
           self.assertTrue(hasattr(lowerCamelCase__						,"""feature_size"""       )       )
           self.assertTrue(hasattr(lowerCamelCase__						,"""num_audio_channels"""       )       )
           self.assertTrue(hasattr(lowerCamelCase__						,"""hop_length"""       )       )
           self.assertTrue(hasattr(lowerCamelCase__						,"""chunk_length"""       )       )
           self.assertTrue(hasattr(lowerCamelCase__						,"""sampling_rate"""       )       )






     def 				SCREAMING_SNAKE_CASE__  (							self						:    str       )     ->		Union[str, Any]:




           '''simple docstring'''


           SCREAMING_SNAKE_CASE		=						self.feature_extraction_class(**self.feat_extract_dict       )

           with tempfile.TemporaryDirectory() as tmpdirname:
                 SCREAMING_SNAKE_CASE		=						feat_extract_first.save_pretrained(lowerCamelCase__       )[0]
                 check_json_file_has_correct_format(lowerCamelCase__       )
                 SCREAMING_SNAKE_CASE		=						self.feature_extraction_class.from_pretrained(lowerCamelCase__       )

           SCREAMING_SNAKE_CASE		=						feat_extract_first.to_dict()
           SCREAMING_SNAKE_CASE		=						feat_extract_second.to_dict()
           SCREAMING_SNAKE_CASE		=						dict_first.pop("""mel_filters"""       )
           SCREAMING_SNAKE_CASE		=						dict_second.pop("""mel_filters"""       )
           self.assertTrue(np.allclose(lowerCamelCase__						,lowerCamelCase__       )       )
           self.assertEqual(lowerCamelCase__						,lowerCamelCase__       )






     def 				SCREAMING_SNAKE_CASE__  (							self						:    Any       )     ->		Any:




           '''simple docstring'''


           SCREAMING_SNAKE_CASE		=						self.feature_extraction_class(**self.feat_extract_dict       )

           with tempfile.TemporaryDirectory() as tmpdirname:
                 SCREAMING_SNAKE_CASE		=						os.path.join(lowerCamelCase__						,"""feat_extract.json"""       )
                 feat_extract_first.to_json_file(lowerCamelCase__       )
                 SCREAMING_SNAKE_CASE		=						self.feature_extraction_class.from_json_file(lowerCamelCase__       )

           SCREAMING_SNAKE_CASE		=						feat_extract_first.to_dict()
           SCREAMING_SNAKE_CASE		=						feat_extract_second.to_dict()
           SCREAMING_SNAKE_CASE		=						dict_first.pop("""mel_filters"""       )
           SCREAMING_SNAKE_CASE		=						dict_second.pop("""mel_filters"""       )
           self.assertTrue(np.allclose(lowerCamelCase__						,lowerCamelCase__       )       )
           self.assertEqual(lowerCamelCase__						,lowerCamelCase__       )






     def 				SCREAMING_SNAKE_CASE__  (							self						:    str       )     ->		Optional[int]:




           '''simple docstring'''


           SCREAMING_SNAKE_CASE		=						self.feature_extraction_class(**self.feat_extract_dict       )

           # create three inputs of length 800, 1000, and 1200
           SCREAMING_SNAKE_CASE		=						[floats_list((1, x)       )[0] for x in range(800						,1400						,200       )]
           SCREAMING_SNAKE_CASE		=						[np.asarray(lowerCamelCase__       ) for speech_input in speech_inputs]

           # Test not batched input
           SCREAMING_SNAKE_CASE		=						feature_extractor(np_speech_inputs[0]						,return_tensors="""np"""						,sampling_rate=44100       ).audio_values

           self.assertTrue(encoded_audios.ndim == 4       )
           self.assertTrue(encoded_audios.shape[-1] == feature_extractor.feature_size       )
           self.assertTrue(encoded_audios.shape[-2] <= feature_extractor.spectrogram_length       )
           self.assertTrue(encoded_audios.shape[-3] == feature_extractor.num_channels       )

           # Test batched
           SCREAMING_SNAKE_CASE		=						feature_extractor(lowerCamelCase__						,return_tensors="""np"""						,sampling_rate=44100       ).audio_values

           self.assertTrue(encoded_audios.ndim == 4       )
           self.assertTrue(encoded_audios.shape[-1] == feature_extractor.feature_size       )
           self.assertTrue(encoded_audios.shape[-2] <= feature_extractor.spectrogram_length       )
           self.assertTrue(encoded_audios.shape[-3] == feature_extractor.num_channels       )

           # Test audio masking
           SCREAMING_SNAKE_CASE		=						feature_extractor(
               lowerCamelCase__						,return_tensors="""np"""						,sampling_rate=44100						,mask_audio=lowerCamelCase__       ).audio_values

           self.assertTrue(encoded_audios.ndim == 4       )
           self.assertTrue(encoded_audios.shape[-1] == feature_extractor.feature_size       )
           self.assertTrue(encoded_audios.shape[-2] <= feature_extractor.spectrogram_length       )
           self.assertTrue(encoded_audios.shape[-3] == feature_extractor.num_channels       )

           # Test 2-D numpy arrays are batched.
           SCREAMING_SNAKE_CASE		=						[floats_list((1, x)       )[0] for x in (800, 800, 800)]
           SCREAMING_SNAKE_CASE		=						np.asarray(lowerCamelCase__       )
           SCREAMING_SNAKE_CASE		=						feature_extractor(lowerCamelCase__						,return_tensors="""np"""						,sampling_rate=44100       ).audio_values
           self.assertTrue(encoded_audios.ndim == 4       )
           self.assertTrue(encoded_audios.shape[-1] == feature_extractor.feature_size       )
           self.assertTrue(encoded_audios.shape[-2] <= feature_extractor.spectrogram_length       )
           self.assertTrue(encoded_audios.shape[-3] == feature_extractor.num_channels       )






     def 				SCREAMING_SNAKE_CASE__  (							self						:    Any						,lowerCamelCase__						:    str       )     ->		Any:




           '''simple docstring'''


           SCREAMING_SNAKE_CASE		=						load_dataset("""hf-internal-testing/librispeech_asr_dummy"""						,"""clean"""						,split="""validation"""       )
           # automatic decoding with librispeech
           SCREAMING_SNAKE_CASE		=						ds.sort("""id"""       ).select(range(lowerCamelCase__       )       )[:num_samples]["""audio"""]

           return [x["array"] for x in speech_samples]






     def 				SCREAMING_SNAKE_CASE__  (							self						:    Tuple       )     ->		Any:




           '''simple docstring'''


           SCREAMING_SNAKE_CASE		=						self._load_datasamples(1       )
           SCREAMING_SNAKE_CASE		=						TvltFeatureExtractor()
           SCREAMING_SNAKE_CASE		=						feature_extractor(lowerCamelCase__						,return_tensors="""pt"""       ).audio_values

           self.assertEquals(audio_values.shape						,(1, 1, 192, 128)       )

           SCREAMING_SNAKE_CASE		=						torch.tensor([[-0.3032, -0.2708], [-0.4434, -0.4007]]       )
           self.assertTrue(torch.allclose(audio_values[0, 0, :2, :2]						,lowerCamelCase__						,atol=1e-4       )       )


