




import unittest

import torch
from torch import nn

from diffusers.models.activations import get_activation





class 					__lowerCamelCase			(       unittest.TestCase       ):




    """simple docstring"""

    def   a (			self	:	Optional[Any]  ) ->			Optional[int]:
         lowerCAmelCase__            =					get_activation("swish"  )

         self.assertIsInstance(SCREAMING_SNAKE_CASE__  ,      nn.SiLU  )

         self.assertEqual(act(torch.tensor(-100  ,      dtype=torch.floataa  )  ).item()  ,      0  )
         self.assertNotEqual(act(torch.tensor(-1  ,      dtype=torch.floataa  )  ).item()  ,      0  )
         self.assertEqual(act(torch.tensor(0  ,      dtype=torch.floataa  )  ).item()  ,      0  )
         self.assertEqual(act(torch.tensor(20  ,      dtype=torch.floataa  )  ).item()  ,      20  )


    def   a (			self	:	List[str]  ) ->			List[str]:
         lowerCAmelCase__            =					get_activation("silu"  )

         self.assertIsInstance(SCREAMING_SNAKE_CASE__  ,      nn.SiLU  )

         self.assertEqual(act(torch.tensor(-100  ,      dtype=torch.floataa  )  ).item()  ,      0  )
         self.assertNotEqual(act(torch.tensor(-1  ,      dtype=torch.floataa  )  ).item()  ,      0  )
         self.assertEqual(act(torch.tensor(0  ,      dtype=torch.floataa  )  ).item()  ,      0  )
         self.assertEqual(act(torch.tensor(20  ,      dtype=torch.floataa  )  ).item()  ,      20  )


    def   a (			self	:	List[str]  ) ->			Tuple:
         lowerCAmelCase__            =					get_activation("mish"  )

         self.assertIsInstance(SCREAMING_SNAKE_CASE__  ,      nn.Mish  )

         self.assertEqual(act(torch.tensor(-200  ,      dtype=torch.floataa  )  ).item()  ,      0  )
         self.assertNotEqual(act(torch.tensor(-1  ,      dtype=torch.floataa  )  ).item()  ,      0  )
         self.assertEqual(act(torch.tensor(0  ,      dtype=torch.floataa  )  ).item()  ,      0  )
         self.assertEqual(act(torch.tensor(20  ,      dtype=torch.floataa  )  ).item()  ,      20  )


    def   a (			self	:	List[str]  ) ->			Tuple:
         lowerCAmelCase__            =					get_activation("gelu"  )

         self.assertIsInstance(SCREAMING_SNAKE_CASE__  ,      nn.GELU  )

         self.assertEqual(act(torch.tensor(-100  ,      dtype=torch.floataa  )  ).item()  ,      0  )
         self.assertNotEqual(act(torch.tensor(-1  ,      dtype=torch.floataa  )  ).item()  ,      0  )
         self.assertEqual(act(torch.tensor(0  ,      dtype=torch.floataa  )  ).item()  ,      0  )
         self.assertEqual(act(torch.tensor(20  ,      dtype=torch.floataa  )  ).item()  ,      20  )





import socket

def      __lowercase(						):


      """simple docstring"""



      lowerCamelCase             =		socket.socket(socket.AF_INET , socket.SOCK_STREAM			)
      lowerCamelCase             =		socket.gethostname()
      lowerCamelCase             =		12312

      sock.connect((host, port)			)
      sock.send(B"Hello server!"			)

      with open("Received_file" , "wb"			) as out_file:
            print("File opened"			)
            print("Receiving data..."			)
            while True:
                  lowerCamelCase             =		sock.recv(1024			)
                  if not data:
                        break
                  out_file.write(UpperCAmelCase__			)

      print("Successfully received the file"			)
      sock.close()
      print("Connection closed"			)


if __name__ == "__main__":
     main()