code: def init_sensor(
      self, sensor_type, transform, attached, sensor_options
  ):
      if sensor_type == "RGBCamera":
          camera_bp = self.world.get_blueprint_library().find(
              "sensor.camera.rgb"
          )
          disp_size = self.display_man.get_display_size()
          camera_bp.set_attribute("image_size_x", str(disp_size[0]))
          camera_bp.set_attribute("image_size_y", str(disp_size[1]))
  
          for key in sensor_options:
              camera_bp.set_attribute(key, sensor_options[key])
  
          camera = self.world.spawn_actor(
              camera_bp, transform, attach_to=attached
          )
          camera.listen(self.save_rgb_image)
  
          return camera
  
      elif sensor_type == "LiDAR":
          lidar_bp = self.world.get_blueprint_library().find(
              "sensor.lidar.ray_cast"
          )
          lidar_bp.set_attribute("range", "100")
          lidar_bp.set_attribute(
              "dropoff_general_rate",
              lidar_bp.get_attribute(
                  "dropoff_general_rate"
              ).recommended_values[0],
          )
          lidar_bp.set_attribute(
              "dropoff_intensity_limit",
              lidar_bp.get_attribute(
                  "dropoff_intensity_limit"
              ).recommended_values[0],
          )
          lidar_bp.set_attribute(
              "dropoff_zero_intensity",
              lidar_bp.get_attribute(
                  "dropoff_zero_intensity"
              ).recommended_values[0],
          )
  
          for key in sensor_options:
              lidar_bp.set_attribute(key, sensor_options[key])
  
          lidar = self.world.spawn_actor(
              lidar_bp, transform, attach_to=attached
          )
  
          lidar.listen(self.save_lidar_image)
  
          return lidar
      elif sensor_type == "SemanticLiDAR":
          lidar_bp = self.world.get_blueprint_library().find(
              "sensor.lidar.ray_cast_semantic"
          )
          lidar_bp.set_attribute("range", "100")
  
          for key in sensor_options:
              lidar_bp.set_attribute(key, sensor_options[key])
  
          lidar = self.world.spawn_actor(
              lidar_bp, transform, attach_to=attached
          )
  
          lidar.listen(self.save_semanticlidar_image)
  
          return lidar
      elif sensor_type == "Radar":
          radar_bp = self.world.get_blueprint_library().find(
              "sensor.other.radar"
          )
          for key in sensor_options:
              radar_bp.set_attribute(key, sensor_options[key])
  
          radar = self.world.spawn_actor(
              radar_bp, transform, attach_to=attached
          )
          radar.listen(self.save_radar_image)
  
          return radar
      else:
          return None
  
imports: import glob
  import os
  import sys
  import carla
  import argparse
  import random
  import time
  import numpy
label_desc: Use image node_id 2 for calling the SensorManager obj's underlying member method code with example usage: obj.init_sensor(sensor_type, transform, attached, sensor_options) and returns: camera, lidar, lidar, radar, None