import inspect
import unittest

from transformers import ResNetConfig
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_backbone_common import BackboneTesterMixin
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 ResNetBackbone, ResNetForImageClassification, ResNetModel
   from transformers.models.resnet.modeling_resnet import RESNET_PRETRAINED_MODEL_ARCHIVE_LIST


if is_vision_available():
   from PIL import Image

   from transformers import AutoImageProcessor
class SCREAMING_SNAKE_CASE_		:







   def __init__(    self	:	Optional[Any]      ,      lowerCamelCase_	:	int      ,      lowerCamelCase_	:	List[str]=3      ,      lowerCamelCase_	:	Dict=32      ,      lowerCamelCase_	:	Dict=3      ,      lowerCamelCase_	:	Optional[Any]=10      ,      lowerCamelCase_	:	List[str]=[10, 20, 30, 40]      ,      lowerCamelCase_	:	int=[1, 1, 2, 1]      ,      lowerCamelCase_	:	Optional[int]=True      ,      lowerCamelCase_	:	Optional[Any]=True      ,      lowerCamelCase_	:	Dict="relu"      ,      lowerCamelCase_	:	List[Any]=3      ,      lowerCamelCase_	:	Any=None      ,      lowerCamelCase_	:	Optional[Any]=["stage2", "stage3", "stage4"]      ,      lowerCamelCase_	:	int=[2, 3, 4]      ,      ):





    """simple docstring"""


    UpperCamelCase      =			parent
    UpperCamelCase      =			batch_size
    UpperCamelCase      =			image_size
    UpperCamelCase      =			num_channels
    UpperCamelCase      =			embeddings_size
    UpperCamelCase      =			hidden_sizes
    UpperCamelCase      =			depths
    UpperCamelCase      =			is_training
    UpperCamelCase      =			use_labels
    UpperCamelCase      =			hidden_act
    UpperCamelCase      =			num_labels
    UpperCamelCase      =			scope
    UpperCamelCase      =			len(lowerCamelCase_							)
    UpperCamelCase      =			out_features
    UpperCamelCase      =			out_indices







   def 	lowerCamelCase_  (    self	:	str							):





    """simple docstring"""


    UpperCamelCase      =			floats_tensor([self.batch_size, self.num_channels, self.image_size, self.image_size]							)

    UpperCamelCase      =			None
    if self.use_labels:
     UpperCamelCase      =			ids_tensor([self.batch_size]      ,      self.num_labels							)

    UpperCamelCase      =			self.get_config()

    return config, pixel_values, labels







   def 	lowerCamelCase_  (    self	:	Tuple							):





    """simple docstring"""


    return ResNetConfig(
        num_channels=self.num_channels      ,      embeddings_size=self.embeddings_size      ,      hidden_sizes=self.hidden_sizes      ,      depths=self.depths      ,      hidden_act=self.hidden_act      ,      num_labels=self.num_labels      ,      out_features=self.out_features      ,      out_indices=self.out_indices      ,      )







   def 	lowerCamelCase_  (    self	:	Tuple      ,      lowerCamelCase_	:	int      ,      lowerCamelCase_	:	List[str]      ,      lowerCamelCase_	:	Any							):





    """simple docstring"""


    UpperCamelCase      =			ResNetModel(config=lowerCamelCase_							)
    model.to(lowerCamelCase_							)
    model.eval()
    UpperCamelCase      =			model(lowerCamelCase_							)
    # expected last hidden states: B, C, H // 32, W // 32
    self.parent.assertEqual(
        result.last_hidden_state.shape      ,      (self.batch_size, self.hidden_sizes[-1], self.image_size // 32, self.image_size // 32)      ,      )







   def 	lowerCamelCase_  (    self	:	Union[str, Any]      ,      lowerCamelCase_	:	str      ,      lowerCamelCase_	:	List[str]      ,      lowerCamelCase_	:	Any							):





    """simple docstring"""


    UpperCamelCase      =			self.num_labels
    UpperCamelCase      =			ResNetForImageClassification(lowerCamelCase_							)
    model.to(lowerCamelCase_							)
    model.eval()
    UpperCamelCase      =			model(lowerCamelCase_      ,      labels=lowerCamelCase_							)
    self.parent.assertEqual(result.logits.shape      ,      (self.batch_size, self.num_labels)							)







   def 	lowerCamelCase_  (    self	:	str      ,      lowerCamelCase_	:	str      ,      lowerCamelCase_	:	str      ,      lowerCamelCase_	:	Tuple							):





    """simple docstring"""


    UpperCamelCase      =			ResNetBackbone(config=lowerCamelCase_							)
    model.to(lowerCamelCase_							)
    model.eval()
    UpperCamelCase      =			model(lowerCamelCase_							)

    # verify feature maps
    self.parent.assertEqual(len(result.feature_maps							)      ,      len(config.out_features							)							)
    self.parent.assertListEqual(list(result.feature_maps[0].shape							)      ,      [self.batch_size, self.hidden_sizes[1], 4, 4]							)

    # verify channels
    self.parent.assertEqual(len(model.channels							)      ,      len(config.out_features							)							)
    self.parent.assertListEqual(model.channels      ,      config.hidden_sizes[1:]							)

    # verify backbone works with out_features=None
    UpperCamelCase      =			None
    UpperCamelCase      =			ResNetBackbone(config=lowerCamelCase_							)
    model.to(lowerCamelCase_							)
    model.eval()
    UpperCamelCase      =			model(lowerCamelCase_							)

    # verify feature maps
    self.parent.assertEqual(len(result.feature_maps							)      ,      1							)
    self.parent.assertListEqual(list(result.feature_maps[0].shape							)      ,      [self.batch_size, self.hidden_sizes[-1], 1, 1]							)

    # verify channels
    self.parent.assertEqual(len(model.channels							)      ,      1							)
    self.parent.assertListEqual(model.channels      ,      [config.hidden_sizes[-1]]							)







   def 	lowerCamelCase_  (    self	:	Any							):





    """simple docstring"""


    UpperCamelCase      =			self.prepare_config_and_inputs()
    UpperCamelCase      =			config_and_inputs
    UpperCamelCase      =			{"pixel_values": pixel_values}
    return config, inputs_dict





@require_torch
class SCREAMING_SNAKE_CASE_		(			A__     ,    A__     ,    unittest.TestCase		):
   __lowerCAmelCase											=							(
       (
           ResNetModel,
           ResNetForImageClassification,
           ResNetBackbone,
       )
       if is_torch_available()
       else ()
   )
   __lowerCAmelCase											=							(
       {'''feature-extraction''': ResNetModel, '''image-classification''': ResNetForImageClassification}
       if is_torch_available()
       else {}
   )

   __lowerCAmelCase											=							True
   __lowerCAmelCase											=							False
   __lowerCAmelCase											=							False
   __lowerCAmelCase											=							False
   __lowerCAmelCase											=							False







   def 	lowerCamelCase_  (    self	:	Optional[int]							):





    """simple docstring"""


    UpperCamelCase      =			ResNetModelTester(self							)
    UpperCamelCase      =			ConfigTester(self      ,      config_class=lowerCamelCase_      ,      has_text_modality=lowerCamelCase_							)







   def 	lowerCamelCase_  (    self	:	Dict							):





    """simple docstring"""


    self.create_and_test_config_common_properties()
    self.config_tester.create_and_test_config_to_json_string()
    self.config_tester.create_and_test_config_to_json_file()
    self.config_tester.create_and_test_config_from_and_save_pretrained()
    self.config_tester.create_and_test_config_with_num_labels()
    self.config_tester.check_config_can_be_init_without_params()
    self.config_tester.check_config_arguments_init()







   def 	lowerCamelCase_  (    self	:	int							):





    """simple docstring"""


    return







   @unittest.skip(reason="""ResNet does not use inputs_embeds"""							)
   def 	lowerCamelCase_  (    self	:	Tuple							):





    """simple docstring"""


    pass







   @unittest.skip(reason="""ResNet does not support input and output embeddings"""							)
   def 	lowerCamelCase_  (    self	:	int							):





    """simple docstring"""


    pass







   def 	lowerCamelCase_  (    self	:	Union[str, Any]							):





    """simple docstring"""


    UpperCamelCase      =			self.model_tester.prepare_config_and_inputs_for_common()

    for model_class in self.all_model_classes:
     UpperCamelCase      =			model_class(lowerCamelCase_							)
     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]      ,      lowerCamelCase_							)







   def 	lowerCamelCase_  (    self	:	List[str]							):





    """simple docstring"""


    UpperCamelCase      =			self.model_tester.prepare_config_and_inputs()
    self.model_tester.create_and_check_model(*lowerCamelCase_							)







   def 	lowerCamelCase_  (    self	:	List[Any]							):





    """simple docstring"""


    UpperCamelCase      =			self.model_tester.prepare_config_and_inputs()
    self.model_tester.create_and_check_backbone(*lowerCamelCase_							)







   def 	lowerCamelCase_  (    self	:	Any							):





    """simple docstring"""


    UpperCamelCase      =			self.model_tester.prepare_config_and_inputs_for_common()

    for model_class in self.all_model_classes:
     UpperCamelCase      =			model_class(config=lowerCamelCase_							)
     for name, module in model.named_modules():
      if isinstance(lowerCamelCase_      ,      (nn.BatchNormad, nn.GroupNorm)							):
       self.assertTrue(
           torch.all(module.weight == 1							)      ,      msg=f"""Parameter {name} of model {model_class} seems not properly initialized"""      ,      )
       self.assertTrue(
           torch.all(module.bias == 0							)      ,      msg=f"""Parameter {name} of model {model_class} seems not properly initialized"""      ,      )







   def 	lowerCamelCase_  (    self	:	int							):





    """simple docstring"""


    def check_hidden_states_output(lowerCamelCase_	:	List[Any]      ,      lowerCamelCase_	:	Optional[int]      ,      lowerCamelCase_	:	Optional[int]							):
     UpperCamelCase      =			model_class(lowerCamelCase_							)
     model.to(lowerCamelCase_							)
     model.eval()

     with torch.no_grad():
      UpperCamelCase      =			model(**self._prepare_for_class(lowerCamelCase_      ,      lowerCamelCase_							)							)

     UpperCamelCase      =			outputs.encoder_hidden_states if config.is_encoder_decoder else outputs.hidden_states

     UpperCamelCase      =			self.model_tester.num_stages
     self.assertEqual(len(lowerCamelCase_							)      ,      expected_num_stages + 1							)

     # ResNet's feature maps are of shape (batch_size, num_channels, height, width)
     self.assertListEqual(
         list(hidden_states[0].shape[-2:]							)      ,      [self.model_tester.image_size // 4, self.model_tester.image_size // 4]      ,      )

    UpperCamelCase      =			self.model_tester.prepare_config_and_inputs_for_common()
    UpperCamelCase      =			["basic", "bottleneck"]
    for model_class in self.all_model_classes:
     for layer_type in layers_type:
      UpperCamelCase      =			layer_type
      UpperCamelCase      =			True
      check_hidden_states_output(lowerCamelCase_      ,      lowerCamelCase_      ,      lowerCamelCase_							)

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

      check_hidden_states_output(lowerCamelCase_      ,      lowerCamelCase_      ,      lowerCamelCase_							)







   @unittest.skip(reason="""ResNet does not use feedforward chunking"""							)
   def 	lowerCamelCase_  (    self	:	Optional[int]							):





    """simple docstring"""


    pass







   def 	lowerCamelCase_  (    self	:	int							):





    """simple docstring"""


    UpperCamelCase      =			self.model_tester.prepare_config_and_inputs()
    self.model_tester.create_and_check_for_image_classification(*lowerCamelCase_							)







   @slow
   def 	lowerCamelCase_  (    self	:	Dict							):





    """simple docstring"""


    for model_name in RESNET_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
     UpperCamelCase      =			ResNetModel.from_pretrained(lowerCamelCase_							)
     self.assertIsNotNone(lowerCamelCase_							)





def  lowercase(  )		->  int:







 '''simple docstring'''
 UpperCamelCase      =			Image.open("""./tests/fixtures/tests_samples/COCO/000000039769.png"""					)
 return image
@require_torch
@require_vision
class SCREAMING_SNAKE_CASE_		(			unittest.TestCase		):







   @cached_property
   def 	lowerCamelCase_  (    self	:	Optional[Any]							):





    """simple docstring"""


    return (
        AutoImageProcessor.from_pretrained(RESNET_PRETRAINED_MODEL_ARCHIVE_LIST[0]							)
        if is_vision_available()
        else None
    )







   @slow
   def 	lowerCamelCase_  (    self	:	Union[str, Any]							):





    """simple docstring"""


    UpperCamelCase      =			ResNetForImageClassification.from_pretrained(RESNET_PRETRAINED_MODEL_ARCHIVE_LIST[0]							).to(lowerCamelCase_							)

    UpperCamelCase      =			self.default_image_processor
    UpperCamelCase      =			prepare_img()
    UpperCamelCase      =			image_processor(images=lowerCamelCase_      ,      return_tensors="""pt"""							).to(lowerCamelCase_							)

    # forward pass
    with torch.no_grad():
     UpperCamelCase      =			model(**lowerCamelCase_							)

    # verify the logits
    UpperCamelCase      =			torch.Size((1, 1000)							)
    self.assertEqual(outputs.logits.shape      ,      lowerCamelCase_							)

    UpperCamelCase      =			torch.tensor([-11.1069, -9.7_8_7_7, -8.3_7_7_7]							).to(lowerCamelCase_							)

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





@require_torch
class SCREAMING_SNAKE_CASE_		(			A__     ,    unittest.TestCase		):
   __lowerCAmelCase											=							(ResNetBackbone,) if is_torch_available() else ()
   __lowerCAmelCase											=							False
   __lowerCAmelCase											=							ResNetConfig







   def 	lowerCamelCase_  (    self	:	Optional[int]							):





    """simple docstring"""


    UpperCamelCase      =			ResNetModelTester(self							)

import unittest

from transformers.testing_utils import is_torch_available, require_torch, tooslow

from ...generation.test_utils import torch_device
from ...test_configuration_common import ConfigTester
from ...test_modeling_common import ModelTesterMixin, ids_tensor
from ...test_pipeline_mixin import PipelineTesterMixin


if is_torch_available():
     import torch

     from transformers import (
         CpmAntConfig,
         CpmAntForCausalLM,
         CpmAntModel,
         CpmAntTokenizer,
     )
@require_torch
class SCREAMING_SNAKE_CASE_		:







   def __init__(    self	:	Optional[int]      ,      lowerCamelCase_	:	List[str]      ,      lowerCamelCase_	:	Tuple=2      ,      lowerCamelCase_	:	List[Any]=8      ,      lowerCamelCase_	:	Any=True      ,      lowerCamelCase_	:	int=False      ,      lowerCamelCase_	:	Optional[Any]=False      ,      lowerCamelCase_	:	Optional[int]=False      ,      lowerCamelCase_	:	Any=False      ,      lowerCamelCase_	:	List[Any]=99      ,      lowerCamelCase_	:	Optional[int]=32      ,      lowerCamelCase_	:	List[str]=3      ,      lowerCamelCase_	:	List[str]=4      ,      lowerCamelCase_	:	Tuple=37      ,      lowerCamelCase_	:	str=32      ,      lowerCamelCase_	:	Any=128      ,      lowerCamelCase_	:	List[str]=8      ,      lowerCamelCase_	:	Union[str, Any]=8      ,      lowerCamelCase_	:	Any=8      ,      lowerCamelCase_	:	Optional[int]=1.0      ,      lowerCamelCase_	:	int=True      ,      ):





    """simple docstring"""


    UpperCamelCase      =			parent
    UpperCamelCase      =			batch_size
    UpperCamelCase      =			seq_length
    UpperCamelCase      =			is_training
    UpperCamelCase      =			use_token_type_ids
    UpperCamelCase      =			use_input_mask
    UpperCamelCase      =			use_labels
    UpperCamelCase      =			use_mc_token_ids
    UpperCamelCase      =			vocab_size
    UpperCamelCase      =			hidden_size
    UpperCamelCase      =			num_hidden_layers
    UpperCamelCase      =			num_attention_heads
    UpperCamelCase      =			intermediate_size
    UpperCamelCase      =			num_buckets
    UpperCamelCase      =			max_distance
    UpperCamelCase      =			prompt_length
    UpperCamelCase      =			prompt_types
    UpperCamelCase      =			segment_types
    UpperCamelCase      =			init_std
    UpperCamelCase      =			return_dict







   def 	lowerCamelCase_  (    self	:	List[str]							):





    """simple docstring"""


    UpperCamelCase      =			{}
    UpperCamelCase      =			ids_tensor([self.batch_size, self.seq_length]      ,      self.vocab_size							).type(torch.intaa							)
    UpperCamelCase      =			False

    UpperCamelCase      =			self.get_config()

    return (config, input_ids)







   def 	lowerCamelCase_  (    self	:	Optional[Any]							):





    """simple docstring"""


    return CpmAntConfig(
        vocab_size=self.vocab_size      ,      hidden_size=self.hidden_size      ,      num_hidden_layers=self.num_hidden_layers      ,      num_attention_heads=self.num_attention_heads      ,      dim_ff=self.intermediate_size      ,      position_bias_num_buckets=self.num_buckets      ,      position_bias_max_distance=self.max_distance      ,      prompt_types=self.prompt_types      ,      prompt_length=self.prompt_length      ,      segment_types=self.segment_types      ,      use_cache=lowerCamelCase_      ,      init_std=self.init_std      ,      return_dict=self.return_dict      ,      )







   def 	lowerCamelCase_  (    self	:	Optional[int]      ,      lowerCamelCase_	:	List[str]      ,      lowerCamelCase_	:	List[str]      ,      *lowerCamelCase_	:	str							):





    """simple docstring"""


    UpperCamelCase      =			CpmAntModel(config=lowerCamelCase_							)
    model.to(lowerCamelCase_							)
    model.eval()

    UpperCamelCase      =			model(**lowerCamelCase_							).last_hidden_state

    self.parent.assertEqual(hidden_states.shape      ,      (self.batch_size, self.seq_length, config.hidden_size)							)







   def 	lowerCamelCase_  (    self	:	Any      ,      lowerCamelCase_	:	Dict      ,      lowerCamelCase_	:	Optional[Any]      ,      *lowerCamelCase_	:	str							):





    """simple docstring"""


    UpperCamelCase      =			CpmAntForCausalLM(lowerCamelCase_							)
    model.to(lowerCamelCase_							)
    UpperCamelCase      =			input_ids["""input_ids"""].to(lowerCamelCase_							)
    model.eval()

    UpperCamelCase      =			model(**lowerCamelCase_							)
    self.parent.assertEqual(
        model_output.logits.shape      ,      (self.batch_size, self.seq_length, config.vocab_size + config.prompt_types * config.prompt_length)      ,      )







   def 	lowerCamelCase_  (    self	:	str							):





    """simple docstring"""


    UpperCamelCase     ,    UpperCamelCase      =			self.prepare_config_and_inputs()
    return config, inputs_dict





@require_torch
class SCREAMING_SNAKE_CASE_		(			__lowerCAmelCase     ,    __lowerCAmelCase     ,    unittest.TestCase		):
   __lowerCAmelCase											=							(CpmAntModel, CpmAntForCausalLM) if is_torch_available() else ()
   __lowerCAmelCase											=							(
       {"""feature-extraction""": CpmAntModel, """text-generation""": CpmAntForCausalLM} if is_torch_available() else {}
   )

   __lowerCAmelCase											=							False
   __lowerCAmelCase											=							False
   __lowerCAmelCase											=							False
   __lowerCAmelCase											=							False
   __lowerCAmelCase											=							False







   def 	lowerCamelCase_  (    self	:	List[Any]							):





    """simple docstring"""


    UpperCamelCase      =			CpmAntModelTester(self							)
    UpperCamelCase      =			ConfigTester(self      ,      config_class=lowerCamelCase_							)







   def 	lowerCamelCase_  (    self	:	str							):





    """simple docstring"""


    self.config_tester.create_and_test_config_common_properties()
    self.config_tester.create_and_test_config_to_json_string()
    self.config_tester.create_and_test_config_to_json_file()
    self.config_tester.create_and_test_config_from_and_save_pretrained()
    self.config_tester.check_config_can_be_init_without_params()
    self.config_tester.check_config_arguments_init()







   def 	lowerCamelCase_  (    self	:	int							):





    """simple docstring"""


    unittest.skip("""CPMAnt doesn't support input_embeds."""							)(self.test_inputs_embeds							)







   def 	lowerCamelCase_  (    self	:	Tuple							):





    """simple docstring"""


    unittest.skip(
        """CPMAnt doesn't support retain grad in hidden_states or attentions, because prompt management will peel off the output.hidden_states from graph.\
                 So is attentions. We strongly recommand you use loss to tune model."""							)(self.test_retain_grad_hidden_states_attentions							)







   def 	lowerCamelCase_  (    self	:	Optional[int]							):





    """simple docstring"""


    UpperCamelCase     ,    UpperCamelCase      =			self.model_tester.prepare_config_and_inputs()
    self.model_tester.create_and_check_cpmant_model(lowerCamelCase_      ,      lowerCamelCase_							)







   def 	lowerCamelCase_  (    self	:	str							):





    """simple docstring"""


    UpperCamelCase     ,    UpperCamelCase      =			self.model_tester.prepare_config_and_inputs()
    self.model_tester.create_and_check_lm_head_model(lowerCamelCase_      ,      lowerCamelCase_							)





@require_torch
class SCREAMING_SNAKE_CASE_		(			unittest.TestCase		):







   @tooslow
   def 	lowerCamelCase_  (    self	:	List[str]							):





    """simple docstring"""


    UpperCamelCase      =			"""今天天气真好！"""
    UpperCamelCase      =			"""openbmb/cpm-ant-10b"""
    UpperCamelCase      =			CpmAntModel.from_pretrained(lowerCamelCase_							)
    UpperCamelCase      =			CpmAntTokenizer.from_pretrained(lowerCamelCase_							)
    UpperCamelCase      =			tokenizer(lowerCamelCase_      ,      return_tensors="""pt"""							)
    UpperCamelCase      =			model(**lowerCamelCase_							).last_hidden_state

    UpperCamelCase      =			torch.tensor(
        [[[6.1_7_0_8, 5.9_2_4_4, 1.0_8_3_5], [6.5_2_0_7, 6.2_8_9_3, -1_1.3_3_2_4], [-1.0_1_0_7, -0.0_5_7_6, -5.9_5_7_7]]]      ,      )
    self.assertTrue(torch.allclose(hidden_states[:, :3, :3]      ,      lowerCamelCase_      ,      atol=1E-2							)							)





@require_torch
class SCREAMING_SNAKE_CASE_		(			unittest.TestCase		):







   @tooslow
   def 	lowerCamelCase_  (    self	:	str							):





    """simple docstring"""


    UpperCamelCase      =			"""今天天气真好！"""
    UpperCamelCase      =			"""openbmb/cpm-ant-10b"""
    UpperCamelCase      =			CpmAntForCausalLM.from_pretrained(lowerCamelCase_							)
    UpperCamelCase      =			CpmAntTokenizer.from_pretrained(lowerCamelCase_							)
    UpperCamelCase      =			tokenizer(lowerCamelCase_      ,      return_tensors="""pt"""							)
    UpperCamelCase      =			model(**lowerCamelCase_							).logits

    UpperCamelCase      =			torch.tensor(
        [[[-6.4_2_6_7, -6.4_0_8_3, -6.3_9_5_8], [-5.8_8_0_2, -5.9_4_4_7, -5.7_8_1_1], [-5.3_8_9_6, -5.4_8_2_0, -5.4_2_9_5]]]      ,      )
    self.assertTrue(torch.allclose(hidden_states[:, :3, :3]      ,      lowerCamelCase_      ,      atol=1E-2							)							)







   @tooslow
   def 	lowerCamelCase_  (    self	:	Dict							):





    """simple docstring"""


    UpperCamelCase      =			"""openbmb/cpm-ant-10b"""
    UpperCamelCase      =			CpmAntForCausalLM.from_pretrained(lowerCamelCase_							)
    UpperCamelCase      =			CpmAntTokenizer.from_pretrained(lowerCamelCase_							)
    UpperCamelCase      =			"""今天天气不错，"""
    UpperCamelCase      =			"""今天天气不错，阳光明媚，我和妈妈一起去超市买东西。\n在超市里，我看到了一个很好玩的玩具，它的名字叫“机器人”。它有一个圆圆的脑袋，两只圆圆的眼睛，还有一个圆圆的"""
    UpperCamelCase      =			tokenizer(lowerCamelCase_      ,      return_tensors="""pt"""							)
    UpperCamelCase      =			model.generate(**lowerCamelCase_							)
    UpperCamelCase      =			tokenizer.batch_decode(lowerCamelCase_							)
    self.assertEqual(lowerCamelCase_      ,      lowerCamelCase_							)







   @tooslow
   def 	lowerCamelCase_  (    self	:	int							):





    """simple docstring"""


    UpperCamelCase      =			"""openbmb/cpm-ant-10b"""
    UpperCamelCase      =			CpmAntForCausalLM.from_pretrained(lowerCamelCase_							)
    UpperCamelCase      =			CpmAntTokenizer.from_pretrained(lowerCamelCase_							)
    UpperCamelCase      =			["""今天天气不错，""", """新年快乐，万事如意！"""]
    UpperCamelCase      =			[
        """今天天气不错，阳光明媚，我和妈妈一起去超市买东西。\n在超市里，我看到了一个很好玩的玩具，它的名字叫“机器人”。它有一个圆圆的脑袋，两只圆圆的眼睛，还有一个圆圆的""",
        """新年快乐，万事如意！在这辞旧迎新的美好时刻，我谨代表《农村新技术》杂志社全体同仁，向一直以来关心、支持《农村新技术》杂志发展的各级领导、各界朋友和广大读者致以最诚挚的""",
    ]
    UpperCamelCase      =			tokenizer(lowerCamelCase_      ,      return_tensors="""pt"""      ,      padding=lowerCamelCase_							)
    UpperCamelCase      =			model.generate(**lowerCamelCase_							)
    UpperCamelCase      =			tokenizer.batch_decode(lowerCamelCase_							)
    self.assertEqual(lowerCamelCase_      ,      lowerCamelCase_							)
