(self)
return copied
Create a copy of the model, its attributes, and its parameters. Any child
        layers will also be deep-copied. The copy will receive a distinct `model.id`
        value.
Create a copy of the model, its attributes, and its parameters. Any child
        layers will also be deep-copied. The copy will receive a distinct `model.id`
        value.
Create a copy of the model its attributes and its parameters . Any child layers will also be deep - copied . The copy will receive a distinct model . id value .
def copy(self):
        """
        Create a copy of the model, its attributes, and its parameters. Any child
        layers will also be deep-copied. The copy will receive a distinct `model.id`
        value.
        """
        copied = TransformerModel(self.name, self.attrs["get_spans"])
        params = {}
        for name in self.param_names:
            params[name] = self.get_param(name) if self.has_param(name) else None
        copied.params = copy.deepcopy(params)
        copied.dims = copy.deepcopy(self._dims)
        copied.layers[0] = copy.deepcopy(self.layers[0])
        for name in self.grad_names:
            copied.set_grad(name, self.get_grad(name).copy())
        return copied
def copy ( self ) : copied = TransformerModel ( self . name , self . attrs [ "get_spans" ] ) params = { } for name in self . param_names : params [ name ] = self . get_param ( name ) if self . has_param ( name ) else None copied . params = copy . deepcopy ( params ) copied . dims = copy . deepcopy ( self . _dims ) copied . layers [ 0 ] = copy . deepcopy ( self . layers [ 0 ] ) for name in self . grad_names : copied . set_grad ( name , self . get_grad ( name ) . copy ( ) ) return copied