(_, expr)
return torch_contract
Build a torch function based on ``arrays`` and ``expr``.
Build a torch function based on ``arrays`` and ``expr``.
Build a torch function based on arrays and expr .
def build_expression(_, expr):  # pragma: no cover
    """Build a torch function based on ``arrays`` and ``expr``."""

    def torch_contract(*arrays):
        torch_arrays = [to_torch(x) for x in arrays]
        torch_out = expr._contract(torch_arrays, backend="torch")

        if torch_out.device.type == "cpu":
            return torch_out.numpy()

        return torch_out.cpu().numpy()

    return torch_contract
def build_expression ( _ , expr ) : # pragma: no cover def torch_contract ( * arrays ) : torch_arrays = [ to_torch ( x ) for x in arrays ] torch_out = expr . _contract ( torch_arrays , backend = "torch" ) if torch_out . device . type == "cpu" : return torch_out . numpy ( ) return torch_out . cpu ( ) . numpy ( ) return torch_contract