code: def replace_nans(data: dict, nan=0.0, pos_inf=0.0, neg_inf=0.0):
      """In-place replacement of non-numerical values, i.e. NaNs and +/- infinity"""
      for key, value in data.items():
          if np.isnan(value).any() or np.isinf(value).any():
              data[key] = np.nan_to_num(
                  value, nan=nan, posinf=pos_inf, neginf=neg_inf
              )
  
      return data
  
imports: import os
  import cv2
  import math
  import random
  import numpy
  import carla
  import pygame
  import threading
  import datetime
  from typing import Union
  from tensorforce.agents import Agent
label_desc: Use image node_id 18 for calling a global function with example usage: replace_nans(data, nan, pos_inf, neg_inf) and returns: data