[docs]defmandelbrot_torch(c:Any)->Any:"""Pure Python implementation of the Mandelbrot set."""xp=array_namespace(c)counter=xp.full(c.shape,200,dtype=xp.int32,device=c.device)z=xp.zeros_like(c)foriinrange(200):z=z*z+cidx=(xp.abs(z)>2)&(counter==200)counter[idx]=ireturncounter