
import unittest

from transformers import is_torch_available
from transformers.testing_utils import require_torch, slow, torch_device

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


if is_torch_available():
							import torch

							from transformers import (
							    RemBertConfig,
							    RemBertForCausalLM,
							    RemBertForMaskedLM,
							    RemBertForMultipleChoice,
							    RemBertForQuestionAnswering,
							    RemBertForSequenceClassification,
							    RemBertForTokenClassification,
							    RemBertModel,
							)
							from transformers.models.rembert.modeling_rembert import REMBERT_PRETRAINED_MODEL_ARCHIVE_LIST







class 							lowercase						:




							def __init__(							self  ,A__  ,A__=1_3  ,A__=7  ,A__=True  ,A__=True  ,A__=True  ,A__=True  ,A__=9_9  ,A__=3_2  ,A__=1_8  ,A__=4_3  ,A__=5  ,A__=4  ,A__=3_7  ,A__="gelu"  ,A__=0.1  ,A__=0.1  ,A__=5_1_2  ,A__=1_6  ,A__=2  ,A__=0.02  ,A__=3  ,A__=4  ,A__=None  ,):
												lowercase		      =		parent
												lowercase		      =		batch_size
												lowercase		      =		seq_length
												lowercase		      =		is_training
												lowercase		      =		use_input_mask
												lowercase		      =		use_token_type_ids
												lowercase		      =		use_labels
												lowercase		      =		vocab_size
												lowercase		      =		hidden_size
												lowercase		      =		input_embedding_size
												lowercase		      =		output_embedding_size
												lowercase		      =		num_hidden_layers
												lowercase		      =		num_attention_heads
												lowercase		      =		intermediate_size
												lowercase		      =		hidden_act
												lowercase		      =		hidden_dropout_prob
												lowercase		      =		attention_probs_dropout_prob
												lowercase		      =		max_position_embeddings
												lowercase		      =		type_vocab_size
												lowercase		      =		type_sequence_label_size
												lowercase		      =		initializer_range
												lowercase		      =		num_labels
												lowercase		      =		num_choices
												lowercase		      =		scope




							def 					A__ (							self):
												lowercase		      =		ids_tensor([self.batch_size, self.seq_length]  ,self.vocab_size)

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

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

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

												lowercase		      =		RemBertConfig(
												    vocab_size=self.vocab_size  ,hidden_size=self.hidden_size  ,input_embedding_size=self.input_embedding_size  ,output_embedding_size=self.output_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  ,is_decoder=A__  ,initializer_range=self.initializer_range  ,)

												return config, input_ids, token_type_ids, input_mask, sequence_labels, token_labels, choice_labels




							def 					A__ (							self):
												(
												    (
												    lowercase
												)      ,		(
												    lowercase
												)      ,		(
												    lowercase
												)      ,		(
												    lowercase
												)      ,		(
												    lowercase
												)      ,		(
												    lowercase
												)      ,		(
												    lowercase
												)      ,		
												)		      =		self.prepare_config_and_inputs()

												lowercase		      =		True
												lowercase		      =		floats_tensor([self.batch_size, self.seq_length, self.hidden_size])
												lowercase		      =		ids_tensor([self.batch_size, self.seq_length]  ,vocab_size=2)

												return (
												    config,
												    input_ids,
												    token_type_ids,
												    input_mask,
												    sequence_labels,
												    token_labels,
												    choice_labels,
												    encoder_hidden_states,
												    encoder_attention_mask,
												)




							def 					A__ (							self  ,A__  ,A__  ,A__  ,A__  ,A__  ,A__  ,A__):
												lowercase		      =		RemBertModel(config=A__)
												model.to(A__)
												model.eval()
												lowercase		      =		model(A__  ,attention_mask=A__  ,token_type_ids=A__)
												lowercase		      =		model(A__  ,token_type_ids=A__)
												lowercase		      =		model(A__)
												self.parent.assertEqual(result.last_hidden_state.shape  ,(self.batch_size, self.seq_length, self.hidden_size))




							def 					A__ (							self  ,A__  ,A__  ,A__  ,A__  ,A__  ,A__  ,A__  ,A__  ,A__  ,):
												lowercase		      =		True
												lowercase		      =		RemBertModel(A__)
												model.to(A__)
												model.eval()
												lowercase		      =		model(
												    A__  ,attention_mask=A__  ,token_type_ids=A__  ,encoder_hidden_states=A__  ,encoder_attention_mask=A__  ,)
												lowercase		      =		model(
												    A__  ,attention_mask=A__  ,token_type_ids=A__  ,encoder_hidden_states=A__  ,)
												lowercase		      =		model(A__  ,attention_mask=A__  ,token_type_ids=A__)
												self.parent.assertEqual(result.last_hidden_state.shape  ,(self.batch_size, self.seq_length, self.hidden_size))




							def 					A__ (							self  ,A__  ,A__  ,A__  ,A__  ,A__  ,A__  ,A__  ,A__  ,A__  ,):
												lowercase		      =		RemBertForCausalLM(config=A__)
												model.to(A__)
												model.eval()
												lowercase		      =		model(A__  ,attention_mask=A__  ,token_type_ids=A__  ,labels=A__)
												self.parent.assertEqual(result.logits.shape  ,(self.batch_size, self.seq_length, self.vocab_size))




							def 					A__ (							self  ,A__  ,A__  ,A__  ,A__  ,A__  ,A__  ,A__):
												lowercase		      =		RemBertForMaskedLM(config=A__)
												model.to(A__)
												model.eval()
												lowercase		      =		model(A__  ,attention_mask=A__  ,token_type_ids=A__  ,labels=A__)
												self.parent.assertEqual(result.logits.shape  ,(self.batch_size, self.seq_length, self.vocab_size))




							def 					A__ (							self  ,A__  ,A__  ,A__  ,A__  ,A__  ,A__  ,A__  ,A__  ,A__  ,):
												lowercase		      =		True
												lowercase		      =		True
												lowercase		      =		RemBertForCausalLM(config=A__)
												model.to(A__)
												model.eval()

												# first forward pass
												lowercase		      =		model(
												    A__  ,attention_mask=A__  ,encoder_hidden_states=A__  ,encoder_attention_mask=A__  ,use_cache=A__  ,)
												lowercase		      =		outputs.past_key_values

												# create hypothetical multiple next token and extent to next_input_ids
												lowercase		      =		ids_tensor((self.batch_size, 3)  ,config.vocab_size)
												lowercase		      =		ids_tensor((self.batch_size, 3)  ,vocab_size=2)

												# append to next input_ids and
												lowercase		      =		torch.cat([input_ids, next_tokens]  ,dim=-1)
												lowercase		      =		torch.cat([input_mask, next_mask]  ,dim=-1)

												lowercase		      =		model(
												    A__  ,attention_mask=A__  ,encoder_hidden_states=A__  ,encoder_attention_mask=A__  ,output_hidden_states=A__  ,)['''hidden_states'''][0]
												lowercase		      =		model(
												    A__  ,attention_mask=A__  ,encoder_hidden_states=A__  ,encoder_attention_mask=A__  ,past_key_values=A__  ,output_hidden_states=A__  ,)['''hidden_states'''][0]

												# select random slice
												lowercase		      =		ids_tensor((1,)  ,output_from_past.shape[-1]).item()
												lowercase		      =		output_from_no_past[:, -3:, random_slice_idx].detach()
												lowercase		      =		output_from_past[:, :, random_slice_idx].detach()

												self.parent.assertTrue(output_from_past_slice.shape[1] == next_tokens.shape[1])

												# test that outputs are equal for slice
												self.parent.assertTrue(torch.allclose(A__  ,A__  ,atol=1E-3))




							def 					A__ (							self  ,A__  ,A__  ,A__  ,A__  ,A__  ,A__  ,A__):
												lowercase		      =		RemBertForQuestionAnswering(config=A__)
												model.to(A__)
												model.eval()
												lowercase		      =		model(
												    A__  ,attention_mask=A__  ,token_type_ids=A__  ,start_positions=A__  ,end_positions=A__  ,)
												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  ,A__  ,A__  ,A__  ,A__  ,A__  ,A__  ,A__):
												lowercase		      =		self.num_labels
												lowercase		      =		RemBertForSequenceClassification(A__)
												model.to(A__)
												model.eval()
												lowercase		      =		model(A__  ,attention_mask=A__  ,token_type_ids=A__  ,labels=A__)
												self.parent.assertEqual(result.logits.shape  ,(self.batch_size, self.num_labels))




							def 					A__ (							self  ,A__  ,A__  ,A__  ,A__  ,A__  ,A__  ,A__):
												lowercase		      =		self.num_labels
												lowercase		      =		RemBertForTokenClassification(config=A__)
												model.to(A__)
												model.eval()
												lowercase		      =		model(A__  ,attention_mask=A__  ,token_type_ids=A__  ,labels=A__)
												self.parent.assertEqual(result.logits.shape  ,(self.batch_size, self.seq_length, self.num_labels))




							def 					A__ (							self  ,A__  ,A__  ,A__  ,A__  ,A__  ,A__  ,A__):
												lowercase		      =		self.num_choices
												lowercase		      =		RemBertForMultipleChoice(config=A__)
												model.to(A__)
												model.eval()
												lowercase		      =		input_ids.unsqueeze(1).expand(-1  ,self.num_choices  ,-1).contiguous()
												lowercase		      =		token_type_ids.unsqueeze(1).expand(-1  ,self.num_choices  ,-1).contiguous()
												lowercase		      =		input_mask.unsqueeze(1).expand(-1  ,self.num_choices  ,-1).contiguous()
												lowercase		      =		model(
												    A__  ,attention_mask=A__  ,token_type_ids=A__  ,labels=A__  ,)
												self.parent.assertEqual(result.logits.shape  ,(self.batch_size, self.num_choices))





							def 					A__ (							self):
												lowercase		      =		self.prepare_config_and_inputs()
												(
												    (
												    lowercase
												)      ,		(
												    lowercase
												)      ,		(
												    lowercase
												)      ,		(
												    lowercase
												)      ,		(
												    lowercase
												)      ,		(
												    lowercase
												)      ,		(
												    lowercase
												)      ,		
												)		      =		config_and_inputs
												lowercase		      =		{'''input_ids''': input_ids, '''token_type_ids''': token_type_ids, '''attention_mask''': input_mask}
												return config, inputs_dict







@require_torch
class 							lowercase						(   SCREAMING_SNAKE_CASE__			,    SCREAMING_SNAKE_CASE__			,    unittest.TestCase						):
							lowercase_			:			str			   =(
							    (
							        RemBertModel,
							        RemBertForMaskedLM,
							        RemBertForCausalLM,
							        RemBertForMultipleChoice,
							        RemBertForQuestionAnswering,
							        RemBertForSequenceClassification,
							        RemBertForTokenClassification,
							    )
							    if is_torch_available()
							    else ()
							)
							lowercase_			:			Optional[Any]			   =(RemBertForCausalLM,) if is_torch_available() else ()
							lowercase_			:			List[Any]			   =(
							    {
							        '''feature-extraction''': RemBertModel,
							        '''fill-mask''': RemBertForMaskedLM,
							        '''question-answering''': RemBertForQuestionAnswering,
							        '''text-classification''': RemBertForSequenceClassification,
							        '''text-generation''': RemBertForCausalLM,
							        '''token-classification''': RemBertForTokenClassification,
							        '''zero-shot''': RemBertForSequenceClassification,
							    }
							    if is_torch_available()
							    else {}
							)




							def 					A__ (							self):
												lowercase		      =		RemBertModelTester(self)
												lowercase		      =		ConfigTester(self  ,config_class=A__  ,hidden_size=3_7)




							def 					A__ (							self):
												self.config_tester.run_common_tests()




							def 					A__ (							self):
												lowercase		      =		self.model_tester.prepare_config_and_inputs()
												self.model_tester.create_and_check_model(*A__)




							def 					A__ (							self):
												lowercase		      =		self.model_tester.prepare_config_and_inputs()
												for type in ["absolute", "relative_key", "relative_key_query"]:
																	lowercase		      =		type
																	self.model_tester.create_and_check_model(*A__)




							def 					A__ (							self):
												lowercase		      =		self.model_tester.prepare_config_and_inputs()
												self.model_tester.create_and_check_for_masked_lm(*A__)




							def 					A__ (							self):
												lowercase		      =		self.model_tester.prepare_config_and_inputs()
												self.model_tester.create_and_check_for_multiple_choice(*A__)




							def 					A__ (							self):
												lowercase		      =		self.model_tester.prepare_config_and_inputs_for_decoder()
												self.model_tester.create_and_check_decoder_model_past_large_inputs(*A__)




							def 					A__ (							self):
												lowercase		      =		self.model_tester.prepare_config_and_inputs()
												self.model_tester.create_and_check_for_question_answering(*A__)




							def 					A__ (							self):
												lowercase		      =		self.model_tester.prepare_config_and_inputs()
												self.model_tester.create_and_check_for_sequence_classification(*A__)




							def 					A__ (							self):
												lowercase		      =		self.model_tester.prepare_config_and_inputs()
												self.model_tester.create_and_check_for_token_classification(*A__)




							def 					A__ (							self):
												lowercase		      =		self.model_tester.prepare_config_and_inputs_for_decoder()
												self.model_tester.create_and_check_model_as_decoder(*A__)




							def 					A__ (							self):
												# This regression test was failing with PyTorch < 1.3
												(
												    (
												    lowercase
												)      ,		(
												    lowercase
												)      ,		(
												    lowercase
												)      ,		(
												    lowercase
												)      ,		(
												    lowercase
												)      ,		(
												    lowercase
												)      ,		(
												    lowercase
												)      ,		(
												    lowercase
												)      ,		(
												    lowercase
												)      ,		
												)		      =		self.model_tester.prepare_config_and_inputs_for_decoder()

												lowercase		      =		None

												self.model_tester.create_and_check_model_as_decoder(
												    A__  ,A__  ,A__  ,A__  ,A__  ,A__  ,A__  ,A__  ,A__  ,)





							@slow
							def 					A__ (							self):
												for model_name in REMBERT_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
																	lowercase		      =		RemBertModel.from_pretrained(A__)
																	self.assertIsNotNone(A__)







@require_torch
class 							lowercase						(   unittest.TestCase						):




							@slow
							def 					A__ (							self):
												# Test exact values at the last hidden layer
												lowercase		      =		RemBertModel.from_pretrained('''google/rembert''')
												lowercase		      =		torch.tensor([[3_1_2, 5_6_4_9_8, 3_1_3, 2_1_2_5, 3_1_3]])
												lowercase		      =		torch.tensor([[0, 0, 0, 1, 1]])
												with torch.no_grad():
																	lowercase		      =		model(A__  ,token_type_ids=A__  ,output_hidden_states=A__)

												lowercase		      =		1_1_5_2

												lowercase		      =		torch.Size((1, 5, hidden_size))
												self.assertEqual(output['''last_hidden_state'''].shape  ,A__)

												lowercase		      =		torch.tensor(
												    [
												        [
												            [0.0754, -0.2022, 0.1904],
												            [-0.3354, -0.3692, -0.4791],
												            [-0.2314, -0.6729, -0.0749],
												            [-0.0396, -0.3105, -0.4234],
												            [-0.1571, -0.0525, 0.5353],
												        ]
												    ])

												# Running on the original tf implementation gives slightly different results here.
												# Not clear why this variations is present
												# TODO: Find reason for discrepancy
												# expected_original_implementation = [[
												#     [0.07630594074726105, -0.20146065950393677, 0.19107051193714142],
												#     [-0.3405614495277405, -0.36971670389175415, -0.4808273911476135],
												#     [-0.22587086260318756, -0.6656315922737122, -0.07844287157058716],
												#     [-0.04145475849509239, -0.3077218234539032, -0.42316967248916626],
												#     [-0.15887849032878876, -0.054529931396245956, 0.5356100797653198]
												# ]]

												self.assertTrue(torch.allclose(output['''last_hidden_state'''][:, :, :3]  ,A__  ,atol=1E-4))






import os
import random
from pathlib import Path
from typing import List

import numpy as np
import torch
from torch.cuda.amp import GradScaler

from .utils import (
    MODEL_NAME,
    OPTIMIZER_NAME,
    RNG_STATE_NAME,
    SCALER_NAME,
    SCHEDULER_NAME,
    get_pretty_name,
    is_tpu_available,
    is_xpu_available,
    save,
)


if is_tpu_available(check_device=False):
							import torch_xla.core.xla_model as xm

from .logging import get_logger
from .state import PartialState


lowercase__						:Optional[Any]					    =       get_logger(__name__)



def 			UpperCamelCase       (				lowerCAmelCase__					,     lowerCAmelCase__					,     lowerCAmelCase__					,     lowerCAmelCase__					,     lowerCAmelCase__					,     lowerCAmelCase__ = None					,     ):
					'''simple docstring'''
					# Model states
					for i, state in enumerate(lowerCAmelCase__						):
										lowercase		      =		f'{MODEL_NAME}.bin' if i == 0 else f'{MODEL_NAME}_{i}.bin'
										lowercase		      =		os.path.join(lowerCAmelCase__					,     lowerCAmelCase__						)
										save(lowerCAmelCase__					,     lowerCAmelCase__						)
										logger.info(f'Model weights saved in {output_model_file}'						)
					# Optimizer states
					for i, opt in enumerate(lowerCAmelCase__						):
										lowercase		      =		opt.state_dict()
										lowercase		      =		f'{OPTIMIZER_NAME}.bin' if i == 0 else f'{OPTIMIZER_NAME}_{i}.bin'
										lowercase		      =		os.path.join(lowerCAmelCase__					,     lowerCAmelCase__						)
										save(lowerCAmelCase__					,     lowerCAmelCase__						)
										logger.info(f'Optimizer state saved in {output_optimizer_file}'						)
					# Scheduler states
					for i, scheduler in enumerate(lowerCAmelCase__						):
										lowercase		      =		scheduler.state_dict()
										lowercase		      =		f'{SCHEDULER_NAME}.bin' if i == 0 else f'{SCHEDULER_NAME}_{i}.bin'
										lowercase		      =		os.path.join(lowerCAmelCase__					,     lowerCAmelCase__						)
										save(lowerCAmelCase__					,     lowerCAmelCase__						)
										logger.info(f'Scheduler state saved in {output_scheduler_file}'						)
					# GradScaler state
					if scaler is not None:
										lowercase		      =		scaler.state_dict()
										lowercase		      =		os.path.join(lowerCAmelCase__					,     lowerCAmelCase__						)
										torch.save(lowerCAmelCase__					,     lowerCAmelCase__						)
										logger.info(f'Gradient scaler state saved in {output_scaler_file}'						)
					# Random number generator states
					lowercase		      =		{}
					lowercase		      =		f'{RNG_STATE_NAME}_{process_index}.pkl'
					lowercase		      =		random.getstate()
					lowercase		      =		np.random.get_state()
					lowercase		      =		torch.get_rng_state()
					if is_xpu_available():
										lowercase		      =		torch.xpu.get_rng_state_all()
					else:
										lowercase		      =		torch.cuda.get_rng_state_all()
					if is_tpu_available():
										lowercase		      =		xm.get_rng_state()
					lowercase		      =		os.path.join(lowerCAmelCase__					,     lowerCAmelCase__						)
					torch.save(lowerCAmelCase__					,     lowerCAmelCase__						)
					logger.info(f'Random states saved in {output_states_file}'						)
					return output_dir



def 			UpperCamelCase       (				lowerCAmelCase__					,     lowerCAmelCase__					,     lowerCAmelCase__					,     lowerCAmelCase__					,     lowerCAmelCase__					,     lowerCAmelCase__=None					,     lowerCAmelCase__=None					,     **lowerCAmelCase__					,     ):
					'''simple docstring'''
					if map_location not in [None, "cpu", "on_device"]:
										raise TypeError(
										    '''Unsupported optimizer map location passed, please choose one of `None`, `\'cpu\'`, or `\'on_device\'`'''						)
					if map_location is None:
										lowercase		      =		'''cpu'''
					elif map_location == "on_device":
										lowercase		      =		PartialState().device
					# Model states
					for i, model in enumerate(lowerCAmelCase__						):
										lowercase		      =		f'{MODEL_NAME}.bin' if i == 0 else f'{MODEL_NAME}_{i}.bin'
										lowercase		      =		os.path.join(lowerCAmelCase__					,     lowerCAmelCase__						)
										models[i].load_state_dict(torch.load(lowerCAmelCase__					,     map_location=lowerCAmelCase__						)					,     **lowerCAmelCase__						)
					logger.info('''All model weights loaded successfully'''						)

					# Optimizer states
					for i, opt in enumerate(lowerCAmelCase__						):
										lowercase		      =		f'{OPTIMIZER_NAME}.bin' if i == 0 else f'{OPTIMIZER_NAME}_{i}.bin'
										lowercase		      =		os.path.join(lowerCAmelCase__					,     lowerCAmelCase__						)
										lowercase		      =		torch.load(lowerCAmelCase__					,     map_location=lowerCAmelCase__						)
										optimizers[i].load_state_dict(lowerCAmelCase__						)
					logger.info('''All optimizer states loaded successfully'''						)

					# Scheduler states
					for i, scheduler in enumerate(lowerCAmelCase__						):
										lowercase		      =		f'{SCHEDULER_NAME}.bin' if i == 0 else f'{SCHEDULER_NAME}_{i}.bin'
										lowercase		      =		os.path.join(lowerCAmelCase__					,     lowerCAmelCase__						)
										scheduler.load_state_dict(torch.load(lowerCAmelCase__						)						)
					logger.info('''All scheduler states loaded successfully'''						)

					# GradScaler state
					if scaler is not None:
										lowercase		      =		os.path.join(lowerCAmelCase__					,     lowerCAmelCase__						)
										scaler.load_state_dict(torch.load(lowerCAmelCase__						)						)
										logger.info('''GradScaler state loaded successfully'''						)

					# Random states
					try:
										lowercase		      =		torch.load(os.path.join(lowerCAmelCase__					,     f'{RNG_STATE_NAME}_{process_index}.pkl'						)						)
										random.setstate(states['''random_state''']						)
										np.random.set_state(states['''numpy_random_seed''']						)
										torch.set_rng_state(states['''torch_manual_seed''']						)
										if is_xpu_available():
															torch.xpu.set_rng_state_all(states['''torch_xpu_manual_seed''']						)
										else:
															torch.cuda.set_rng_state_all(states['''torch_cuda_manual_seed''']						)
										if is_tpu_available():
															xm.set_rng_state(states['''xm_seed''']						)
										logger.info('''All random states loaded successfully'''						)
					except Exception:
										logger.info('''Could not load random states'''						)



def 			UpperCamelCase       (				lowerCAmelCase__					,     lowerCAmelCase__					,     lowerCAmelCase__ = 0						):
					'''simple docstring'''
					lowercase		      =		Path(lowerCAmelCase__						) / f'custom_checkpoint_{index}.pkl'
					logger.info(f'Saving the state of {get_pretty_name(lowerCAmelCase__						)} to {save_location}'						)
					torch.save(obj.state_dict()					,     lowerCAmelCase__						)



def 			UpperCamelCase       (				lowerCAmelCase__					,     lowerCAmelCase__					,     lowerCAmelCase__ = 0						):
					'''simple docstring'''
					lowercase		      =		f'{path}/custom_checkpoint_{index}.pkl'
					logger.info(f'Loading the state of {get_pretty_name(lowerCAmelCase__						)} from {load_location}'						)
					obj.load_state_dict(torch.load(lowerCAmelCase__					,     map_location='''cpu'''						)						)




