def replace(self, **kwargs):
    """Creates a copy of the object with some parameters replaced."""
    return type(self)(
        shape=kwargs.pop('shape', self.shape),
        dtype=kwargs.pop('dtype', self.dtype),
    )
Creates a copy of the object with some parameters replaced.
trax/shapes.py