Repository: OpenMined/PySyft

Issue:
Key error in hook_args when calling torch.randn()
```
import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
from torchvision import datasets, transforms
import syft as sy  # <-- NEW: import the Pysyft library
hook = sy.TorchHook(torch)  # <-- NEW: hook PyTorch ie add extra functionalities to support Federated Learning

a=torch.randn_like(torch.ones(1,2))
print(a)
a=torch.randn(1,2)
print(a)
```

`a=torch.randn_like(torch.ones(1,2))`
works properly but error occurres when executing torch.randn()
```
Traceback (most recent call last):
  File "/home/crd/.local/lib/python3.6/site-packages/syft/frameworks/torch/hook_args.py", line 134, in hook_function_args
    hook_args = hook_method_args_functions[attr]
KeyError: 'torch.randn'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "test.py", line 11, in <module>
    a=torch.randn(1,2)
  File "/home/crd/.local/lib/python3.6/site-packages/syft/frameworks/torch/hook.py", line 690, in overloaded_func
    response = TorchTensor.handle_func_command(command)
  File "/home/crd/.local/lib/python3.6/site-packages/syft/frameworks/torch/tensors/interpreters/native.py", line 191, in handle_func_command
    cmd, args, kwargs, return_args_type=True
  File "/home/crd/.local/lib/python3.6/site-packages/syft/frameworks/torch/hook_args.py", line 141, in hook_function_args
    args, return_tuple=True
  File "/home/crd/.local/lib/python3.6/site-packages/syft/frameworks/torch/hook_args.py", line 171, in build_hook_args_function
```


Discussion:
The thing is that we haven't hooked torch.randn yet. Check issue https://github.com/OpenMined/PySyft/issues/2046 we should hopefully get it ready soon. For now what you could do is create a random array in numpy and convert it to a torch tensor. 
Thanks @peter9711 for reporting this issue, don't hesitate tu put the full stacktrace next time, the real message was in the part you cut. I'm issuing a fix in a few minutes!

Resolving patch:
diff --git a/syft/exceptions.py b/syft/exceptions.py
--- a/syft/exceptions.py
+++ b/syft/exceptions.py
@@ -16,8 +16,7 @@ class PureTorchTensorFoundError(BaseException):
         message -- explanation of the error
     """
 
-    def __init__(self, tensor):
-        self.tensor = tensor
+    pass
 
 
 class RemoteTensorFoundError(BaseException):
diff --git a/syft/frameworks/torch/hook_args.py b/syft/frameworks/torch/hook_args.py
--- a/syft/frameworks/torch/hook_args.py
+++ b/syft/frameworks/torch/hook_args.py
@@ -42,10 +42,10 @@
     PointerTensor: lambda p: (_ for _ in ()).throw(RemoteTensorFoundError(p)),
     torch.Tensor: lambda i: i.child
     if hasattr(i, "child")
-    else (_ for _ in ()).throw(PureTorchTensorFoundError(i)),
+    else (_ for _ in ()).throw(PureTorchTensorFoundError),
     torch.nn.Parameter: lambda i: i.child
     if hasattr(i, "child")
-    else (_ for _ in ()).throw(PureTorchTensorFoundError(i)),
+    else (_ for _ in ()).throw(PureTorchTensorFoundError),
     LoggingTensor: lambda i: i.child,
     FixedPrecisionTensor: lambda i: i.child,
     AdditiveSharingTensor: lambda i: i.child,
diff --git a/syft/frameworks/torch/torch_attributes.py b/syft/frameworks/torch/torch_attributes.py
--- a/syft/frameworks/torch/torch_attributes.py
+++ b/syft/frameworks/torch/torch_attributes.py
@@ -98,6 +98,7 @@ def __init__(self, torch: ModuleType, hook: ModuleType) -> None:
             "rand",
             "randint",
             "randn_like",
+            "randn",
             "range",
             "save",
             "short",


Test patch: