<commit_before>import numpy as np
import syft.controller
from .base_tensor import BaseTensor

class FloatTensor(BaseTensor):
    def __init__(self, data, autograd=False, data_is_pointer=False, delete_after_use=True):
        self.controller = syft.controller
        self.delete_after_use = delete_after_use
        if (data is not None and not data_is_pointer):

            if (type(data) == list):
                data = np.array(data)

            data = data.astype('float')

            self.data = data
            self.id = int(self.controller.send_json({"objectType": "FloatTensor",
                                                     "functionCall": "create",
                                                     "data": list(data.flatten()),
                                                     "shape": self.data.shape}))
            # self.controller.log("FloatTensor.__init__: {}".format(self.id))

        elif (data_is_pointer):
            self.id = int(data)

        if (autograd):
            self.autograd(True)

    def __del__(self):
        self.delete_tensor()

    def abs(self):
        """
        Returns absolute value of tensor as a new tensor
        Parameters
        ----------
        Returns
        -------
        FloatTensor:
            Output tensor
        """
        return self.no_params_func("abs", return_response=True)

    def abs_(self):
        """
        Replaces tensor values with its absolute value
        Parameters
        ----------
        Returns
        -------
        FloatTensor
            Output tensor
        """
        return self.no_params_func("abs_")

    def acos(self):
        """
        Returns a new Tensor with the arccosine of the elements of input.
        Parameters
        ----------
        Returns
        -------
        FloatTensor
            Output tensor
        """
        return self.no_params_func("acos", return_response=True)

    def acos_(self):
        """
        Performs inplace arccosine operation of the elements of input.
        Parameters
        ----------
        Returns
        -------
        FloatTensor
            Caller with values inplace
        """
        return self.no_params_func("acos_")

    def addmm_(self, x, y):
        """
        Performs a matrix multiplication of the matrices 'x' and 'y'.
        The caller matrix 'self' is added to the final result inplace.
        Parameters
        ----------
        x : FloatTensor
            First tensor for multiplication
        y : FloatTensor
            Second tensor for multiplication
        Returns
        -------
        FloatTensor
            Caller with values inplace
        """
        return self.params_func("addmm_", [x.id, y.id])

    def addmm(self, x, y):
        """
        Performs a matrix multiplication of the matrices 'x' and 'y'.
        The caller matrix 'self' is added to the final result.
        Parameters
        ----------
        x : FloatTensor
            First tensor for multiplication
        y : FloatTensor
            Second tensor for multiplication
        Returns
        -------
        copy : FloatTensor
            Output tensor
        """
        copy = self.copy()
        copy.params_func("addmm_", [x.id, y.id])
        return copy

    def addmv_(self, x, y):
        """
        Performs a matrix-vector product of the matrix x and the vector vec.
        The vector tensor is added to the final result inplace.
        Parameters
        ----------
        x : FloatTensor
            tensor for multiplication
        vec : FloatTensor
            Vector for Matrix-Vector Product
        Returns
        -------
        FloatTensor
            Caller with values inplace
        """
        return self.params_func("addmv_", [x.id, y.id])

    def addmv(self, x, y):
        """
        Performs a matrix-vector product of the matrix x and the vector vec.
        The vector tensor is added to the final result.
        Parameters
        ----------
        x : FloatTensor
            tensor for multiplication
        y : FloatTensor
            Vector for Matrix-Vector Product
        Returns
        -------
        copy : FloatTensor
            Output tensor
        """
        copy = self.copy()
        copy.params_func("addmv_", [x.id, y.id])
        return copy

    def addr(self, beta=1, alpha=1, vec1, vec2):
        """
        Returns a new Tensor as the sum of beta*mat and alpha*(vec1*vec2')

        Parameters
        ----------
        beta: float
            scalar to optionally multiply each element of mat
        self: FloatTensor
            tensor to add to the outer product
        alpha: float
            scalar to optionally multiply each element of the outer product of vec1, vec2
        vec1: FloatTensor
            first vector in outer product with vec2
        vec2: FloatTensor
            second vector in outer product with vec1

        Returns
        -------
        FloatTensor
            Output tensor
        """

        return self.params_func("addr", [beta, alpha, vec1, vec2], return_response=True)

    def addr_(self, beta=1, alpha=1, vec1, vec2):
        """
        Returns Tensor as the sum of beta*self and alpha*(vec1*vec2')

        Parameters
        ----------
        beta: float
            scalar to optionally multiply each element of mat
        self: FloatTensor
            tensor to add to the outer product
        alpha: float
            scalar to optionally multiply each element of the outer product of vec1, vec2
        vec1: FloatTensor
            first vector in outer product with vec2
        vec2: FloatTensor
            second vector in outer product with vec1

        Returns
        -------
        FloatTensor inline
        """

        return self.params_func("addr_",  [beta, alpha, vec1, vec2])

    def asin(self):
        """
        Returns a new Tensor with the arcsine of the elements of input.
        Parameters
        ----------
        Returns
        -------
        FloatTensor
            Output tensor
        """
        return self.no_params_func("asin", return_response=True)

    def asin_(self):
        """
        Performs inplace arcsine operation of the elements of input.<commit_msg>rearrange args to addr funs<commit_after>import numpy as np
import syft.controller
from .base_tensor import BaseTensor

class FloatTensor(BaseTensor):
    def __init__(self, data, autograd=False, data_is_pointer=False, delete_after_use=True):
        self.controller = syft.controller
        self.delete_after_use = delete_after_use
        if (data is not None and not data_is_pointer):

            if (type(data) == list):
                data = np.array(data)

            data = data.astype('float')

            self.data = data
            self.id = int(self.controller.send_json({"objectType": "FloatTensor",
                                                     "functionCall": "create",
                                                     "data": list(data.flatten()),
                                                     "shape": self.data.shape}))
            # self.controller.log("FloatTensor.__init__: {}".format(self.id))

        elif (data_is_pointer):
            self.id = int(data)

        if (autograd):
            self.autograd(True)

    def __del__(self):
        self.delete_tensor()

    def abs(self):
        """
        Returns absolute value of tensor as a new tensor
        Parameters
        ----------
        Returns
        -------
        FloatTensor:
            Output tensor
        """
        return self.no_params_func("abs", return_response=True)

    def abs_(self):
        """
        Replaces tensor values with its absolute value
        Parameters
        ----------
        Returns
        -------
        FloatTensor
            Output tensor
        """
        return self.no_params_func("abs_")

    def acos(self):
        """
        Returns a new Tensor with the arccosine of the elements of input.
        Parameters
        ----------
        Returns
        -------
        FloatTensor
            Output tensor
        """
        return self.no_params_func("acos", return_response=True)

    def acos_(self):
        """
        Performs inplace arccosine operation of the elements of input.
        Parameters
        ----------
        Returns
        -------
        FloatTensor
            Caller with values inplace
        """
        return self.no_params_func("acos_")

    def addmm_(self, x, y):
        """
        Performs a matrix multiplication of the matrices 'x' and 'y'.
        The caller matrix 'self' is added to the final result inplace.
        Parameters
        ----------
        x : FloatTensor
            First tensor for multiplication
        y : FloatTensor
            Second tensor for multiplication
        Returns
        -------
        FloatTensor
            Caller with values inplace
        """
        return self.params_func("addmm_", [x.id, y.id])

    def addmm(self, x, y):
        """
        Performs a matrix multiplication of the matrices 'x' and 'y'.
        The caller matrix 'self' is added to the final result.
        Parameters
        ----------
        x : FloatTensor
            First tensor for multiplication
        y : FloatTensor
            Second tensor for multiplication
        Returns
        -------
        copy : FloatTensor
            Output tensor
        """
        copy = self.copy()
        copy.params_func("addmm_", [x.id, y.id])
        return copy

    def addmv_(self, x, y):
        """
        Performs a matrix-vector product of the matrix x and the vector vec.
        The vector tensor is added to the final result inplace.
        Parameters
        ----------
        x : FloatTensor
            tensor for multiplication
        vec : FloatTensor
            Vector for Matrix-Vector Product
        Returns
        -------
        FloatTensor
            Caller with values inplace
        """
        return self.params_func("addmv_", [x.id, y.id])

    def addmv(self, x, y):
        """
        Performs a matrix-vector product of the matrix x and the vector vec.
        The vector tensor is added to the final result.
        Parameters
        ----------
        x : FloatTensor
            tensor for multiplication
        y : FloatTensor
            Vector for Matrix-Vector Product
        Returns
        -------
        copy : FloatTensor
            Output tensor
        """
        copy = self.copy()
        copy.params_func("addmv_", [x.id, y.id])
        return copy

    def addr(self, vec1, vec2, beta=1, alpha=1):
        """
        Returns a new Tensor as the sum of beta*mat and alpha*(vec1*vec2')

        Parameters
        ----------
        beta: float
            scalar to optionally multiply each element of mat
        self: FloatTensor
            tensor to add to the outer product
        alpha: float
            scalar to optionally multiply each element of the outer product of vec1, vec2
        vec1: FloatTensor
            first vector in outer product with vec2
        vec2: FloatTensor
            second vector in outer product with vec1

        Returns
        -------
        FloatTensor
            Output tensor
        """

        return self.params_func("addr", [vec1.id, vec2.id, beta, alpha], return_response=True)

    def addr_(self, vec1, vec2, beta=1, alpha=1):
        """
        Returns Tensor as the sum of beta*self and alpha*(vec1*vec2')

        Parameters
        ----------
        beta: float
            scalar to optionally multiply each element of mat
        self: FloatTensor
            tensor to add to the outer product
        alpha: float
            scalar to optionally multiply each element of the outer product of vec1, vec2
        vec1: FloatTensor
            first vector in outer product with vec2
        vec2: FloatTensor
            second vector in outer product with vec1

        Returns
        -------
        FloatTensor inline
        """

        return self.params_func("addr_",  [vec1.id, vec2.id, beta, alpha])

    def asin(self):
        """
        Returns a new Tensor with the arcsine of the elements of input.
        Parameters
        ----------
        Returns
        -------
        FloatTensor
            Output tensor
        """
        return self.no_params_func("asin", return_response=True)

    def asin_(self):
        """
        Performs inplace arcsine operation of the elements of input.
{'fraction_non_alphanumeric': 0.0956257982120051, 'fraction_numerical': 0.004469987228607918, 'mean_word_length': 1.4295132829164243, 'pattern_counts': {'":': 8, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 12, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4122841', 'n_tokens_mistral': 3095, 'n_tokens_neox': 3002, 'n_words': 1047}