<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def sensor(sensor_type, cfg):
 """ Creates a Kinect2 sensor of the specified type. Parameters sensor_type : :obj:`str` the type of the sensor (real or virtual) cfg : :obj:`YamlConfig` dictionary of parameters for sensor initialization """

        sensor_type = sensor_type.lower()
        if sensor_type == 'real':
            s = Kinect2Sensor(packet_pipeline_mode=cfg['pipeline_mode'],
                              device_num=cfg['device_num'],
                              frame=cfg['frame'])
        elif sensor_type == 'virtual':
            s = VirtualKinect2Sensor(cfg['image_dir'],
                                     frame=cfg['frame'])
        elif sensor_type == 'bridged':
            s = KinectSensorBridged(quality=cfg['quality'], frame=cfg['frame'])
        else:
            raise ValueError('Kinect2 sensor type %s not supported' %(sensor_type))
        return s