As a software engineering in ML, do yourself a favor and do NOT use chatGPT for coding. The idea is to imitate humans, not produce correct code. By design it makes mistakes as often as humans do. As the query is complicated more, it produces pure garbage