# Buggy code
def create_pointer(
    self,
    location: BaseWorker = None,
    id_at_location: (str or int) = None,
    register: bool = False,
    owner: BaseWorker = None,
    ptr_id: (str or int) = None,
    garbage_collect_data: bool = True,
    shape=None,
    **kwargs,
) -> PointerTensor:
    """Creates a pointer to the "self" torch.Tensor object.

    Returns:
        A PointerTensor pointer to self. Note that this
        object will likely be wrapped by a torch.Tensor wrapper.
    """
    if id_at_location is None:
        id_at_location = self.id

    if ptr_id is None:
        if location is not None and location.id != self.owner.id:
            ptr_id = self.id
        else:
            ptr_id = syft.ID_PROVIDER.pop()

    if shape is None:
        shape = self.shape

    ptr = syft.PointerTensor.create_pointer(
        self,
        location,
        id_at_location,
        register,
        owner,
        ptr_id,
        garbage_collect_data,
        shape,
    )

    return ptr


# Traceback (PureTorchTensorFoundError)
WARNING: Logging before flag parsing goes to stderr.
W0813 08:46:34.190028 140520788572032 secure_random.py:26] Falling back to insecure randomness since the required custom op could not be found for the installed version of TensorFlow. Fix this by compiling custom ops. Missing file was '/usr/local/lib/python3.6/dist-packages/tf_encrypted/operations/secure_random/secure_random_module_tf_1.14.0.so'
W0813 08:46:34.211576 140520788572032 deprecation_wrapper.py:119] From /usr/local/lib/python3.6/dist-packages/tf_encrypted/session.py:26: The name tf.Session is deprecated. Please use tf.compat.v1.Session instead.

0it [00:00, ?it/s]

Downloading https://www.cs.toronto.edu/~kriz/cifar-10-python.tar.gz to ../data/cifar-10-python.tar.gz

170500096it [00:04, 40609204.86it/s]

---------------------------------------------------------------------------

PureTorchTensorFoundError                 Traceback (most recent call last)

/content/PySyft/syft/frameworks/torch/tensors/interpreters/native.py in handle_func_command(cls, command)
300             new_args, new_kwargs, new_type, args_type = syft.frameworks.torch.hook_args.unwrap_args_from_function(
--> 301                 cmd, args, kwargs, return_args_type=True
302             )

16 frames

PureTorchTensorFoundError:


During handling of the above exception, another exception occurred:

RuntimeError                              Traceback (most recent call last)

/usr/local/lib/python3.6/dist-packages/torch/nn/functional.py in batch_norm(input, running_mean, running_var, weight, bias, training, momentum, eps)
1695     return torch.batch_norm(
1696         input, weight, bias, running_mean, running_var,
-> 1697         training, momentum, eps, torch.backends.cudnn.enabled
1698     )
1699

RuntimeError: running_mean should contain 3 elements not 32

# Fixed code
def create_pointer(
    self,
    location: BaseWorker = None,
    id_at_location: (str or int) = None,
    owner: BaseWorker = None,
    ptr_id: (str or int) = None,
    garbage_collect_data: bool = True,
    shape=None,
    **kwargs,
) -> PointerTensor:
    """Creates a pointer to the "self" torch.Tensor object.

    Returns:
        A PointerTensor pointer to self. Note that this
        object will likely be wrapped by a torch.Tensor wrapper.
    """
    if id_at_location is None:
        id_at_location = self.id

    if ptr_id is None:
        if location is not None and location.id != self.owner.id:
            ptr_id = self.id
        else:
            ptr_id = syft.ID_PROVIDER.pop()

    if shape is None:
        shape = self.shape

    ptr = syft.PointerTensor.create_pointer(
        self, location, id_at_location, owner, ptr_id, garbage_collect_data, shape
    )

    return ptr