


"""simple docstring"""


from typing import Callable, Dict, Optional, Tuple

import torch
from torch import nn
from torch.distributions import (
    AffineTransform,
    Distribution,
    Independent,
    NegativeBinomial,
    Normal,
    StudentT,
    TransformedDistribution,
)


class 			A__	(						__lowercase):


     """simple docstring"""

     def __init__(	self:						List[Any]     ,		__a:						Distribution     ,		__a:						List[Any]=None     ,		__a:						Optional[int]=None     ,		__a:						Union[str, Any]=0	)->    Any:
           lowerCamelCase					:					Any        =	1.0 if scale is None else scale
           lowerCamelCase					:					int        =	0.0 if loc is None else loc

           super().__init__(__a     ,		[AffineTransform(loc=self.loc     ,		scale=self.scale     ,		event_dim=__a	)]	)

     @property
     def 		a__						(	self:						Tuple	)->    Union[str, Any]:
           return self.base_dist.mean * self.scale + self.loc

     @property
     def 		a__						(	self:						Dict	)->    List[str]:
           return self.base_dist.variance * self.scale**2







     @property
     def 		a__						(	self:						List[str]	)->    int:
           return self.variance.sqrt()


class 			A__	(						nn.Module):


     """simple docstring"""

     def __init__(	self:						Optional[int]     ,		__a:						int     ,		__a:						Dict[str, int]     ,		__a:						Callable[..., Tuple[torch.Tensor]]     ,		**__a:						Optional[Any]	)->    None:
           super().__init__(**__a	)
           lowerCamelCase					:					Optional[int]        =	args_dim
           lowerCamelCase					:					List[str]        =	nn.ModuleList([nn.Linear(__a     ,		__a	) for dim in args_dim.values()]	)
           lowerCamelCase					:					str        =	domain_map







     def 		a__						(	self:						List[str]     ,		__a:						torch.Tensor	)->    Tuple[torch.Tensor]:
           lowerCamelCase					:					List[Any]        =	[proj(__a	) for proj in self.proj]

           return self.domain_map(*__a	)


class 			A__	(						nn.Module):


     """simple docstring"""

     def __init__(	self:						Union[str, Any]     ,		__a:						str	)->    Tuple:
           super().__init__()
           lowerCamelCase					:					Any        =	function







     def 		a__						(	self:						str     ,		__a:						Union[str, Any]     ,		*__a:						Optional[Any]	)->    Any:
           return self.function(__a     ,		*__a	)


class 			A__	:


     """simple docstring"""
     snake_case__	:					type
     snake_case__	:					int
     snake_case__	:					Dict[str, int]

     def __init__(	self:						Dict     ,		__a:						int = 1	)->    None:
           lowerCamelCase					:					List[Any]        =	dim
           lowerCamelCase					:					List[Any]        =	{k: dim * self.args_dim[k] for k in self.args_dim}

     def 		a__						(	self:						List[str]     ,		__a:						Dict	)->    List[Any]:
           if self.dim == 1:
                 return self.distribution_class(*__a	)
           else:
                 return Independent(self.distribution_class(*__a	)     ,		1	)

     def 		a__						(	self:						Any     ,		__a:						str     ,		__a:						Optional[torch.Tensor] = None     ,		__a:						Optional[torch.Tensor] = None     ,		)->    Distribution:
           lowerCamelCase					:					Union[str, Any]        =	self._base_distribution(__a	)
           if loc is None and scale is None:
                 return distr
           else:
                 return AffineTransformed(__a     ,		loc=__a     ,		scale=__a     ,		event_dim=self.event_dim	)

     @property
     def 		a__						(	self:						str	)->    Tuple:
           return () if self.dim == 1 else (self.dim,)

     @property
     def 		a__						(	self:						Union[str, Any]	)->    int:
           return len(self.event_shape	)

     @property
     def 		a__						(	self:						Dict	)->    float:
           return 0.0

     def 		a__						(	self:						Union[str, Any]     ,		__a:						int	)->    nn.Module:
           return ParameterProjection(
               in_features=__a     ,		args_dim=self.args_dim     ,		domain_map=LambdaLayer(self.domain_map	)     ,		)

     def 		a__						(	self:						Any     ,		*__a:						torch.Tensor	)->    str:
           raise NotImplementedError()







     @staticmethod
     def 		a__						(	__a:						torch.Tensor	)->    torch.Tensor:
           return (x + torch.sqrt(torch.square(__a	) + 4.0	)) / 2.0


class 			A__	(						__lowercase):


     """simple docstring"""
     snake_case__	:					Dict[str, int]													={"df": 1, "loc": 1, "scale": 1}
     snake_case__	:					type													=StudentT

     @classmethod
     def 		a__						(	cls:						Optional[Any]     ,		__a:						torch.Tensor     ,		__a:						torch.Tensor     ,		__a:						torch.Tensor	)->    Tuple:
           lowerCamelCase					:					Optional[Any]        =	cls.squareplus(__a	).clamp_min(torch.finfo(scale.dtype	).eps	)
           lowerCamelCase					:					Optional[int]        =	2.0 + cls.squareplus(__a	)
           return df.squeeze(-1	), loc.squeeze(-1	), scale.squeeze(-1	)


class 			A__	(						__lowercase):


     """simple docstring"""
     snake_case__	:					Dict[str, int]													={"loc": 1, "scale": 1}
     snake_case__	:					type													=Normal

     @classmethod
     def 		a__						(	cls:						Optional[int]     ,		__a:						torch.Tensor     ,		__a:						torch.Tensor	)->    str:
           lowerCamelCase					:					int        =	cls.squareplus(__a	).clamp_min(torch.finfo(scale.dtype	).eps	)
           return loc.squeeze(-1	), scale.squeeze(-1	)


class 			A__	(						__lowercase):


     """simple docstring"""
     snake_case__	:					Dict[str, int]													={"total_count": 1, "logits": 1}
     snake_case__	:					type													=NegativeBinomial

     @classmethod
     def 		a__						(	cls:						Tuple     ,		__a:						torch.Tensor     ,		__a:						torch.Tensor	)->    Union[str, Any]:
           lowerCamelCase					:					int        =	cls.squareplus(__a	)
           return total_count.squeeze(-1	), logits.squeeze(-1	)

     def 		a__						(	self:						List[Any]     ,		__a:						Union[str, Any]	)->    Distribution:
           lowerCamelCase     ,			lowerCamelCase					:					Optional[int]        =	distr_args
           if self.dim == 1:
                 return self.distribution_class(total_count=__a     ,		logits=__a	)
           else:
                 return Independent(self.distribution_class(total_count=__a     ,		logits=__a	)     ,		1	)







     def 		a__						(	self:						str     ,		__a:						Any     ,		__a:						Optional[torch.Tensor] = None     ,		__a:						Optional[torch.Tensor] = None	)->    Distribution:
           lowerCamelCase     ,			lowerCamelCase					:					List[str]        =	distr_args

           if scale is not None:
                 # See scaling property of Gamma.
                 logits += scale.log()

           return self._base_distribution((total_count, logits)	)








"""simple docstring"""


import inspect
import unittest

import torch
import torch.nn as nn

from accelerate.hooks import (
    AlignDevicesHook,
    ModelHook,
    SequentialHook,
    add_hook_to_module,
    attach_align_device_hook,
    remove_hook_from_module,
    remove_hook_from_submodules,
)
from accelerate.test_utils import require_multi_gpu


class 			A__	(						nn.Module):


     """simple docstring"""

     def __init__(	self:						Dict	)->    Dict:
           super().__init__()
           lowerCamelCase					:					Tuple        =	nn.Linear(3     ,		4	)
           lowerCamelCase					:					Optional[Any]        =	nn.BatchNormad(4	)
           lowerCamelCase					:					Optional[Any]        =	nn.Linear(4     ,		5	)







     def 		a__						(	self:						List[str]     ,		__a:						List[Any]	)->    Optional[Any]:
           return self.lineara(self.batchnorm(self.lineara(__a	)	)	)


class 			A__	(						__lowercase):


     """simple docstring"""

     def 		a__						(	self:						Tuple     ,		__a:						int     ,		*__a:						Any     ,		**__a:						Tuple	)->    Tuple:
           return (args[0] + 1,) + args[1:], kwargs


class 			A__	(						__lowercase):


     """simple docstring"""

     def 		a__						(	self:						Optional[int]     ,		__a:						List[str]     ,		__a:						List[Any]	)->    List[str]:
           return output + 1


class 			A__	(						unittest.TestCase):


     """simple docstring"""

     def 		a__						(	self:						int	)->    str:
           lowerCamelCase					:					List[str]        =	ModelForTest()
           lowerCamelCase					:					Dict        =	ModelHook()

           add_hook_to_module(__a     ,		__a	)
           self.assertEqual(test_model._hf_hook     ,		__a	)
           self.assertTrue(hasattr(__a     ,		"""_old_forward"""	)	)

           # Check adding the hook did not change the name or the signature
           self.assertEqual(test_model.forward.__name__     ,		"""forward"""	)
           self.assertListEqual(list(inspect.signature(test_model.forward	).parameters	)     ,		["""x"""]	)

           remove_hook_from_module(__a	)
           self.assertFalse(hasattr(__a     ,		"""_hf_hook"""	)	)
           self.assertFalse(hasattr(__a     ,		"""_old_forward"""	)	)

     def 		a__						(	self:						int	)->    str:
           lowerCamelCase					:					List[str]        =	ModelForTest()
           lowerCamelCase					:					Union[str, Any]        =	ModelHook()

           add_hook_to_module(__a     ,		__a	)
           add_hook_to_module(__a     ,		__a     ,		append=__a	)

           self.assertEqual(isinstance(test_model._hf_hook     ,		__a	)     ,		__a	)
           self.assertEqual(len(test_model._hf_hook.hooks	)     ,		2	)
           self.assertTrue(hasattr(__a     ,		"""_old_forward"""	)	)

           # Check adding the hook did not change the name or the signature
           self.assertEqual(test_model.forward.__name__     ,		"""forward"""	)
           self.assertListEqual(list(inspect.signature(test_model.forward	).parameters	)     ,		["""x"""]	)

           remove_hook_from_module(__a	)
           self.assertFalse(hasattr(__a     ,		"""_hf_hook"""	)	)
           self.assertFalse(hasattr(__a     ,		"""_old_forward"""	)	)

     def 		a__						(	self:						List[Any]	)->    List[str]:
           lowerCamelCase					:					str        =	ModelForTest()
           lowerCamelCase					:					Dict        =	torch.randn(2     ,		3	)
           lowerCamelCase					:					Union[str, Any]        =	test_model(x + 1	)
           lowerCamelCase					:					Optional[int]        =	test_model(x + 2	)

           lowerCamelCase					:					List[Any]        =	PreForwardHook()
           add_hook_to_module(__a     ,		__a	)
           lowerCamelCase					:					Optional[int]        =	test_model(__a	)
           self.assertTrue(torch.allclose(__a     ,		__a     ,		atol=1e-5	)	)

           # Attaching a hook to a model when it already has one replaces, does not chain
           lowerCamelCase					:					Dict        =	PreForwardHook()
           add_hook_to_module(__a     ,		__a	)
           lowerCamelCase					:					Tuple        =	test_model(__a	)
           self.assertTrue(torch.allclose(__a     ,		__a     ,		atol=1e-5	)	)

           # You need to use the sequential hook to chain two or more hooks
           lowerCamelCase					:					Any        =	SequentialHook(PreForwardHook()     ,		PreForwardHook()	)
           add_hook_to_module(__a     ,		__a	)

           lowerCamelCase					:					Optional[Any]        =	test_model(__a	)
           assert torch.allclose(__a     ,		__a     ,		atol=1e-5	)

     def 		a__						(	self:						Any	)->    Optional[int]:
           lowerCamelCase					:					str        =	ModelForTest()
           lowerCamelCase					:					List[str]        =	torch.randn(2     ,		3	)
           lowerCamelCase					:					int        =	test_model(__a	)

           lowerCamelCase					:					Dict        =	PostForwardHook()
           add_hook_to_module(__a     ,		__a	)
           lowerCamelCase					:					Tuple        =	test_model(__a	)
           self.assertTrue(torch.allclose(__a     ,		output + 1     ,		atol=1e-5	)	)

           # Attaching a hook to a model when it already has one replaces, does not chain
           lowerCamelCase					:					str        =	PostForwardHook()
           add_hook_to_module(__a     ,		__a	)
           lowerCamelCase					:					Optional[Any]        =	test_model(__a	)
           self.assertTrue(torch.allclose(__a     ,		output + 1     ,		atol=1e-5	)	)

           # You need to use the sequential hook to chain two or more hooks
           lowerCamelCase					:					Union[str, Any]        =	SequentialHook(PostForwardHook()     ,		PostForwardHook()	)
           add_hook_to_module(__a     ,		__a	)

           lowerCamelCase					:					str        =	test_model(__a	)
           assert torch.allclose(__a     ,		output + 2     ,		atol=1e-5	)

     def 		a__						(	self:						int	)->    Dict:
           lowerCamelCase					:					List[Any]        =	ModelForTest()
           lowerCamelCase					:					Optional[int]        =	torch.randn(2     ,		3	)
           lowerCamelCase					:					List[str]        =	test_model(__a	)

           lowerCamelCase					:					Any        =	PostForwardHook()
           add_hook_to_module(__a     ,		__a	)
           lowerCamelCase					:					str        =	test_model(__a	)
           self.assertTrue(torch.allclose(__a     ,		output + 1	)	)
           self.assertTrue(outputa.requires_grad	)

           lowerCamelCase					:					Optional[int]        =	True
           lowerCamelCase					:					Optional[int]        =	test_model(__a	)
           self.assertFalse(outputa.requires_grad	)

     @require_multi_gpu
     def 		a__						(	self:						List[str]	)->    Union[str, Any]:
           lowerCamelCase					:					int        =	ModelForTest()
           # Everything is on CPU
           self.assertEqual(model.lineara.weight.device     ,		torch.device("""cpu"""	)	)
           self.assertEqual(model.batchnorm.weight.device     ,		torch.device("""cpu"""	)	)
           self.assertEqual(model.lineara.weight.device     ,		torch.device("""cpu"""	)	)

           # This will move each submodule on different devices
           add_hook_to_module(model.lineara     ,		AlignDevicesHook(execution_device=0	)	)
           add_hook_to_module(model.batchnorm     ,		AlignDevicesHook(execution_device=0	)	)
           add_hook_to_module(model.lineara     ,		AlignDevicesHook(execution_device=1	)	)

           self.assertEqual(model.lineara.weight.device     ,		torch.device(0	)	)
           self.assertEqual(model.batchnorm.weight.device     ,		torch.device(0	)	)
           self.assertEqual(model.batchnorm.running_mean.device     ,		torch.device(0	)	)
           self.assertEqual(model.lineara.weight.device     ,		torch.device(1	)	)

           # We can still make a forward pass. The input does not need to be on any particular device
           lowerCamelCase					:					str        =	torch.randn(2     ,		3	)
           lowerCamelCase					:					Dict        =	model(__a	)
           self.assertEqual(output.device     ,		torch.device(1	)	)

           # We can add a general hook to put back output on same device as input.
           add_hook_to_module(__a     ,		AlignDevicesHook(io_same_device=__a	)	)
           lowerCamelCase					:					Optional[int]        =	torch.randn(2     ,		3	).to(0	)
           lowerCamelCase					:					str        =	model(__a	)
           self.assertEqual(output.device     ,		torch.device(0	)	)

     def 		a__						(	self:						List[str]	)->    Tuple:
           lowerCamelCase					:					Union[str, Any]        =	ModelForTest()

           # Everything is on CPU
           self.assertEqual(model.lineara.weight.device     ,		torch.device("""cpu"""	)	)
           self.assertEqual(model.batchnorm.weight.device     ,		torch.device("""cpu"""	)	)
           self.assertEqual(model.lineara.weight.device     ,		torch.device("""cpu"""	)	)

           # This will move each submodule on different devices
           lowerCamelCase					:					Tuple        =	{"""execution_device""": 0 if torch.cuda.is_available() else """cpu""", """offload""": True}

           add_hook_to_module(model.lineara     ,		AlignDevicesHook(**__a	)	)
           add_hook_to_module(model.batchnorm     ,		AlignDevicesHook(**__a	)	)
           add_hook_to_module(model.lineara     ,		AlignDevicesHook(**__a	)	)

           # Parameters have been offloaded, so on the meta device
           self.assertEqual(model.lineara.weight.device     ,		torch.device("""meta"""	)	)
           self.assertEqual(model.batchnorm.weight.device     ,		torch.device("""meta"""	)	)
           self.assertEqual(model.lineara.weight.device     ,		torch.device("""meta"""	)	)
           # Buffers are not included in the offload by default, so are on the execution device
           lowerCamelCase					:					List[Any]        =	torch.device(hook_kwargs["""execution_device"""]	)
           self.assertEqual(model.batchnorm.running_mean.device     ,		__a	)

           lowerCamelCase					:					Optional[Any]        =	torch.randn(2     ,		3	)
           lowerCamelCase					:					Optional[Any]        =	model(__a	)
           self.assertEqual(output.device     ,		__a	)

           # Removing hooks loads back the weights in the model.
           remove_hook_from_module(model.lineara	)
           remove_hook_from_module(model.batchnorm	)
           remove_hook_from_module(model.lineara	)
           self.assertEqual(model.lineara.weight.device     ,		torch.device("""cpu"""	)	)
           self.assertEqual(model.batchnorm.weight.device     ,		torch.device("""cpu"""	)	)
           self.assertEqual(model.lineara.weight.device     ,		torch.device("""cpu"""	)	)

           # Now test with buffers included in the offload
           lowerCamelCase					:					Any        =	{
               """execution_device""": 0 if torch.cuda.is_available() else """cpu""",
               """offload""": True,
               """offload_buffers""": True,
           }

           add_hook_to_module(model.lineara     ,		AlignDevicesHook(**__a	)	)
           add_hook_to_module(model.batchnorm     ,		AlignDevicesHook(**__a	)	)
           add_hook_to_module(model.lineara     ,		AlignDevicesHook(**__a	)	)

           # Parameters have been offloaded, so on the meta device, buffers included
           self.assertEqual(model.lineara.weight.device     ,		torch.device("""meta"""	)	)
           self.assertEqual(model.batchnorm.weight.device     ,		torch.device("""meta"""	)	)
           self.assertEqual(model.lineara.weight.device     ,		torch.device("""meta"""	)	)
           self.assertEqual(model.batchnorm.running_mean.device     ,		torch.device("""meta"""	)	)

           lowerCamelCase					:					int        =	torch.randn(2     ,		3	)
           lowerCamelCase					:					Optional[int]        =	model(__a	)
           self.assertEqual(output.device     ,		__a	)

           # Removing hooks loads back the weights in the model.
           remove_hook_from_module(model.lineara	)
           remove_hook_from_module(model.batchnorm	)
           remove_hook_from_module(model.lineara	)
           self.assertEqual(model.lineara.weight.device     ,		torch.device("""cpu"""	)	)
           self.assertEqual(model.batchnorm.weight.device     ,		torch.device("""cpu"""	)	)
           self.assertEqual(model.lineara.weight.device     ,		torch.device("""cpu"""	)	)

     def 		a__						(	self:						Any	)->    List[str]:
           lowerCamelCase					:					int        =	ModelForTest()

           # Everything is on CPU
           self.assertEqual(model.lineara.weight.device     ,		torch.device("""cpu"""	)	)
           self.assertEqual(model.batchnorm.weight.device     ,		torch.device("""cpu"""	)	)
           self.assertEqual(model.lineara.weight.device     ,		torch.device("""cpu"""	)	)

           # This will move each submodule on different devices
           lowerCamelCase					:					int        =	0 if torch.cuda.is_available() else """cpu"""
           attach_align_device_hook(__a     ,		execution_device=__a     ,		offload=__a	)

           # Parameters have been offloaded, so on the meta device
           self.assertEqual(model.lineara.weight.device     ,		torch.device("""meta"""	)	)
           self.assertEqual(model.batchnorm.weight.device     ,		torch.device("""meta"""	)	)
           self.assertEqual(model.lineara.weight.device     ,		torch.device("""meta"""	)	)
           # Buffers are not included in the offload by default, so are on the execution device
           lowerCamelCase					:					List[Any]        =	torch.device(__a	)
           self.assertEqual(model.batchnorm.running_mean.device     ,		__a	)

           lowerCamelCase					:					Dict        =	torch.randn(2     ,		3	)
           lowerCamelCase					:					Optional[Any]        =	model(__a	)
           self.assertEqual(output.device     ,		__a	)

           # Removing hooks loads back the weights in the model.
           remove_hook_from_submodules(__a	)
           self.assertEqual(model.lineara.weight.device     ,		torch.device("""cpu"""	)	)
           self.assertEqual(model.batchnorm.weight.device     ,		torch.device("""cpu"""	)	)
           self.assertEqual(model.lineara.weight.device     ,		torch.device("""cpu"""	)	)

           # Now test with buffers included in the offload
           attach_align_device_hook(__a     ,		execution_device=__a     ,		offload=__a     ,		offload_buffers=__a	)

           # Parameters have been offloaded, so on the meta device, buffers included
           self.assertEqual(model.lineara.weight.device     ,		torch.device("""meta"""	)	)
           self.assertEqual(model.batchnorm.weight.device     ,		torch.device("""meta"""	)	)
           self.assertEqual(model.lineara.weight.device     ,		torch.device("""meta"""	)	)
           self.assertEqual(model.batchnorm.running_mean.device     ,		torch.device("""meta"""	)	)

           lowerCamelCase					:					Optional[int]        =	torch.randn(2     ,		3	)
           lowerCamelCase					:					int        =	model(__a	)
           self.assertEqual(output.device     ,		__a	)

           # Removing hooks loads back the weights in the model.
           remove_hook_from_submodules(__a	)
           self.assertEqual(model.lineara.weight.device     ,		torch.device("""cpu"""	)	)
           self.assertEqual(model.batchnorm.weight.device     ,		torch.device("""cpu"""	)	)
           self.assertEqual(model.lineara.weight.device     ,		torch.device("""cpu"""	)	)







     def 		a__						(	self:						Optional[Any]	)->    List[Any]:
           lowerCamelCase					:					List[Any]        =	ModelForTest()

           # Everything is on CPU
           self.assertEqual(model.lineara.weight.device     ,		torch.device("""cpu"""	)	)
           self.assertEqual(model.batchnorm.weight.device     ,		torch.device("""cpu"""	)	)
           self.assertEqual(model.lineara.weight.device     ,		torch.device("""cpu"""	)	)

           # This will move each submodule on different devices
           lowerCamelCase					:					Any        =	0 if torch.cuda.is_available() else """cpu"""
           attach_align_device_hook(
               __a     ,		execution_device=__a     ,		offload=__a     ,		weights_map=model.state_dict()	)

           # Parameters have been offloaded, so on the meta device
           self.assertEqual(model.lineara.weight.device     ,		torch.device("""meta"""	)	)
           self.assertEqual(model.batchnorm.weight.device     ,		torch.device("""meta"""	)	)
           self.assertEqual(model.lineara.weight.device     ,		torch.device("""meta"""	)	)
           # Buffers are not included in the offload by default, so are on the execution device
           lowerCamelCase					:					List[Any]        =	torch.device(__a	)
           self.assertEqual(model.batchnorm.running_mean.device     ,		__a	)

           lowerCamelCase					:					Dict        =	torch.randn(2     ,		3	)
           lowerCamelCase					:					int        =	model(__a	)
           self.assertEqual(output.device     ,		__a	)

           # Removing hooks loads back the weights in the model.
           remove_hook_from_submodules(__a	)
           self.assertEqual(model.lineara.weight.device     ,		torch.device("""cpu"""	)	)
           self.assertEqual(model.batchnorm.weight.device     ,		torch.device("""cpu"""	)	)
           self.assertEqual(model.lineara.weight.device     ,		torch.device("""cpu"""	)	)

           # Now test with buffers included in the offload
           attach_align_device_hook(
               __a     ,		execution_device=__a     ,		offload=__a     ,		weights_map=model.state_dict()     ,		offload_buffers=__a     ,		)

           # Parameters have been offloaded, so on the meta device, buffers included
           self.assertEqual(model.lineara.weight.device     ,		torch.device("""meta"""	)	)
           self.assertEqual(model.batchnorm.weight.device     ,		torch.device("""meta"""	)	)
           self.assertEqual(model.lineara.weight.device     ,		torch.device("""meta"""	)	)
           self.assertEqual(model.batchnorm.running_mean.device     ,		torch.device("""meta"""	)	)

           lowerCamelCase					:					Tuple        =	torch.randn(2     ,		3	)
           lowerCamelCase					:					Any        =	model(__a	)
           self.assertEqual(output.device     ,		__a	)

           # Removing hooks loads back the weights in the model.
           remove_hook_from_submodules(__a	)
           self.assertEqual(model.lineara.weight.device     ,		torch.device("""cpu"""	)	)
           self.assertEqual(model.batchnorm.weight.device     ,		torch.device("""cpu"""	)	)
           self.assertEqual(model.lineara.weight.device     ,		torch.device("""cpu"""	)	)




