Repository: OpenMined/PySyft

Issue:
Build Warnings
#1801 seems to have introduced new build warnings which we should address.

```======================================================================================== warnings summary =========================================================================================
test/torch/tensors/test_poly.py::testSigmoid
  /Users/atrask/Laboratory/openmined/PySyft/syft/frameworks/torch/hook.py:743: UserWarning: To copy construct from a tensor, it is recommended to use sourceTensor.clone().detach() or sourceTensor.clone().detach().requires_grad_(True), rather than torch.tensor(sourceTensor).
    current_tensor = hook_self.torch.native_tensor(*args, **kwargs)

test/torch/tensors/test_poly.py::testExp
  /Users/atrask/Laboratory/openmined/PySyft/syft/frameworks/torch/hook.py:743: UserWarning: To copy construct from a tensor, it is recommended to use sourceTensor.clone().detach() or sourceTensor.clone().detach().requires_grad_(True), rather than torch.tensor(sourceTensor).
    current_tensor = hook_self.torch.native_tensor(*args, **kwargs)

test/torch/tensors/test_poly.py::testtanh
  /Users/atrask/Laboratory/openmined/PySyft/syft/frameworks/torch/hook.py:743: UserWarning: To copy construct from a tensor, it is recommended to use sourceTensor.clone().detach() or sourceTensor.clone().detach().requires_grad_(True), rather than torch.tensor(sourceTensor).
    current_tensor = hook_self.torch.native_tensor(*args, **kwargs)

test/torch/tensors/test_poly.py::testinterpolate
  /Users/atrask/Laboratory/openmined/PySyft/syft/frameworks/torch/hook.py:743: UserWarning: To copy construct from a tensor, it is recommended to use sourceTensor.clone().detach() or sourceTensor.clone().detach().requires_grad_(True), rather than torch.tensor(sourceTensor).
    current_tensor = hook_self.torch.native_tensor(*args, **kwargs)

test/torch/tensors/test_poly.py::testcustomfunction
  /Users/atrask/Laboratory/openmined/PySyft/syft/frameworks/torch/hook.py:743: UserWarning: To copy construct from a tensor, it is recommended to use sourceTensor.clone().detach() or sourceTensor.clone().detach().requires_grad_(True), rather than torch.tensor(sourceTensor).
    current_tensor = hook_self.torch.native_tensor(*args, **kwargs)

test/torch/tensors/test_poly.py::testrandomfunction
  /Users/atrask/Laboratory/openmined/PySyft/syft/frameworks/torch/hook.py:743: UserWarning: To copy construct from a tensor, it is recommended to use sourceTensor.clone().detach() or sourceTensor.clone().detach().requires_grad_(True), rather than torch.tensor(sourceTensor).
    current_tensor = hook_self.torch.native_tensor(*args, **kwargs)

test/torch/tensors/test_poly.py::testlogfunction
  /Users/atrask/Laboratory/openmined/PySyft/syft/frameworks/torch/hook.py:743: UserWarning: To copy construct from a tensor, it is recommended to use sourceTensor.clone().detach() or sourceTensor.clone().detach().requires_grad_(True), rather than torch.tensor(sourceTensor).
    current_tensor = hook_self.torch.native_tensor(*args, **kwargs)

test/torch/tensors/test_poly.py::testexptaylor
  /Users/atrask/Laboratory/openmined/PySyft/syft/frameworks/torch/hook.py:743: UserWarning: To copy construct from a tensor, it is recommended to use sourceTensor.clone().detach() or sourceTensor.clone().detach().requires_grad_(True), rather than torch.tensor(sourceTensor).
    current_tensor = hook_self.torch.native_tensor(*args, **kwargs)

test/torch/tensors/test_poly.py::testsigmoidtaylor
  /Users/atrask/Laboratory/openmined/PySyft/syft/frameworks/torch/hook.py:743: UserWarning: To copy construct from a tensor, it is recommended to use sourceTensor.clone().detach() or sourceTensor.clone().detach().requires_grad_(True), rather than torch.tensor(sourceTensor).
    current_tensor = hook_self.torch.native_tensor(*args, **kwargs)

-- Docs: http://doc.pytest.org/en/latest/warnings.html```


Discussion:
Oops ,  I will work on this @iamtrask 
They are now almost removed except one

Resolving patch:
diff --git a/syft/frameworks/torch/differential_privacy/pate.py b/syft/frameworks/torch/differential_privacy/pate.py
--- a/syft/frameworks/torch/differential_privacy/pate.py
+++ b/syft/frameworks/torch/differential_privacy/pate.py
@@ -278,15 +278,15 @@ def perform_analysis(teacher_preds, indices, noise_eps, delta=1e-5, moments=8, b
 
 def tensors_to_literals(tensor_list):
     """Converts list of torch tensors to list of integers/floats. Fix for not having the functionality which converts list of tensors to tensors
-    
+
        Args:
-           
+
            tensor_list[List]: List of torch tensors
-           
+
        Returns:
-           
+
            literal_list[List]: List of floats/integers
-           
+
     """
 
     literal_list = []
@@ -334,14 +334,14 @@ def logmgf_exact_torch(q, priv_eps, l):
 def compute_q_noisy_max_torch(counts, noise_eps):
     """Returns ~ Pr[outcome != winner].
        Args:
-           
+
           counts: a list of scores
           noise_eps: privacy parameter for noisy_max
-          
+
        Returns:
-           
+
           q: the probability that outcome is different from true winner.
-          
+
     """
 
     if type(counts) != torch.tensor:
@@ -349,9 +349,7 @@ def compute_q_noisy_max_torch(counts, noise_eps):
         counts = torch.tensor(tensors_to_literals(counts), dtype=torch.float)
 
     _, winner = counts.max(0)
-    counts_normalized = noise_eps * (
-        torch.tensor(counts, dtype=torch.float) - torch.tensor(counts[winner], dtype=torch.float)
-    )
+    counts_normalized = noise_eps * (counts.clone().detach().type(torch.float) - counts[winner])
 
     counts_normalized = tensors_to_literals(counts_normalized)
     counts_rest = torch.tensor(
@@ -387,7 +385,7 @@ def sens_at_k_torch(counts, noise_eps, l, k):
 
     """Return sensitivity at distane k.
       Args:
-        
+
           counts: an array of scores
           noise_eps: noise parameter used
           l: moment whose sensitivity is being computed
@@ -419,7 +417,7 @@ def sens_at_k_torch(counts, noise_eps, l, k):
 def smooth_sens_torch(counts, noise_eps, l, beta):
 
     """Compute beta-smooth sensitivity.
-    
+
      Args:
          counts: array of scors
          noise_eps: noise parameter


Test patch:
diff --git a/test/torch/differential_privacy/test_pate.py b/test/torch/differential_privacy/test_pate.py
--- a/test/torch/differential_privacy/test_pate.py
+++ b/test/torch/differential_privacy/test_pate.py
@@ -58,5 +58,5 @@ def test_torch_ref_match():
         preds, indices, noise_eps=0.1, delta=1e-5
     )
 
-    assert torch.isclose(data_dep_eps, torch.tensor(data_dep_eps_ref.item()))
-    assert torch.isclose(data_ind_eps, torch.tensor(data_ind_eps_ref.item()))
+    assert torch.isclose(data_dep_eps, torch.tensor(data_dep_eps_ref))
+    assert torch.isclose(data_ind_eps, torch.tensor(data_ind_eps_ref))