code: def __init__(
      self,
      level: LevelSelection,
      seed: int,
      frame_skip: int,
      human_control: bool,
      custom_reward_threshold: Union[int, float],
      visualization_parameters: VisualizationParameters,
      server_height: int,
      server_width: int,
      camera_height: int,
      camera_width: int,
      verbose: bool,
      experiment_suite: ExperimentSuite,
      config: str,
      episode_max_time: int,
      allow_braking: bool,
      quality: CarlaEnvironmentParameters.Quality,
      cameras: List[CameraTypes],
      weather_id: List[int],
      experiment_path: str,
      separate_actions_for_throttle_and_brake: bool,
      num_speedup_steps: int,
      max_speed: float,
      target_success_rate: float = 1.0,
      **kwargs,
  ):
      super().__init__(
          level,
          seed,
          frame_skip,
          human_control,
          custom_reward_threshold,
          visualization_parameters,
          target_success_rate,
      )
  
      # server configuration
      self.server_height = server_height
      self.server_width = server_width
      self.port = get_open_port()
      self.host = "localhost"
      self.map_name = CarlaLevel[level.upper()].value["map_name"]
      self.map_path = CarlaLevel[level.upper()].value["map_path"]
      self.experiment_path = experiment_path
  
      # client configuration
      self.verbose = verbose
      self.quality = quality
      self.cameras = cameras
      self.weather_id = weather_id
      self.episode_max_time = episode_max_time
      self.allow_braking = allow_braking
      self.separate_actions_for_throttle_and_brake = (
          separate_actions_for_throttle_and_brake
      )
      self.camera_width = camera_width
      self.camera_height = camera_height
  
      # setup server settings
      self.experiment_suite = experiment_suite
      self.config = config
      if self.config:
          # load settings from file
          with open(self.config, "r") as fp:
              self.settings = fp.read()
      else:
          # hard coded settings
          self.settings = CarlaSettings()
          self.settings.set(
              SynchronousMode=True,
              SendNonPlayerAgentsInfo=False,
              NumberOfVehicles=15,
              NumberOfPedestrians=30,
              WeatherId=random.choice(force_list(self.weather_id)),
              QualityLevel=self.quality.value,
              SeedVehicles=seed,
              SeedPedestrians=seed,
          )
          if seed is None:
              self.settings.randomize_seeds()
  
          self.settings = self._add_cameras(
              self.settings,
              self.cameras,
              self.camera_width,
              self.camera_height,
          )
  
      # open the server
      self.server = self._open_server()
  
      logging.disable(40)
  
      # open the client
      self.game = CarlaClient(self.host, self.port, timeout=99999999)
      self.game.connect()
      if self.experiment_suite:
          self.current_experiment_idx = 0
          self.current_experiment = (
              self.experiment_suite.get_experiments()[
                  self.current_experiment_idx
              ]
          )
          self.scene = self.game.load_settings(
              self.current_experiment.conditions
          )
      else:
          self.scene = self.game.load_settings(self.settings)
  
      # get available start positions
      self.positions = self.scene.player_start_spots
      self.num_positions = len(self.positions)
      self.current_start_position_idx = 0
      self.current_pose = 0
  
      # state space
      self.state_space = StateSpace(
          {
              "measurements": VectorObservationSpace(
                  4, measurements_names=["forward_speed", "x", "y", "z"]
              )
          }
      )
      for camera in self.scene.sensors:
          self.state_space[camera.name] = ImageObservationSpace(
              shape=np.array(
                  [self.camera_height, self.camera_width, 3]
              ),
              high=255,
          )
  
      # action space
      if self.separate_actions_for_throttle_and_brake:
          self.action_space = BoxActionSpace(
              shape=3,
              low=np.array([-1, 0, 0]),
              high=np.array([1, 1, 1]),
              descriptions=["steer", "gas", "brake"],
          )
      else:
          self.action_space = BoxActionSpace(
              shape=2,
              low=np.array([-1, -1]),
              high=np.array([1, 1]),
              descriptions=["steer", "gas_and_brake"],
          )
  
      # human control
      if self.human_control:
          # convert continuous action space to discrete
          self.steering_strength = 0.5
          self.gas_strength = 1.0
          self.brake_strength = 0.5
          # TODO: reverse order of actions
          self.action_space = PartialDiscreteActionSpaceMap(
              target_actions=[
                  [0.0, 0.0],
                  [0.0, -self.steering_strength],
                  [0.0, self.steering_strength],
                  [self.gas_strength, 0.0],
                  [-self.brake_strength, 0],
                  [self.gas_strength, -self.steering_strength],
                  [self.gas_strength, self.steering_strength],
                  [self.brake_strength, -self.steering_strength],
                  [self.brake_strength, self.steering_strength],
              ],
              descriptions=[
                  "NO-OP",
                  "TURN_LEFT",
                  "TURN_RIGHT",
                  "GAS",
                  "BRAKE",
                  "GAS_AND_TURN_LEFT",
                  "GAS_AND_TURN_RIGHT",
                  "BRAKE_AND_TURN_LEFT",
                  "BRAKE_AND_TURN_RIGHT",
              ],
          )
  
          # map keyboard keys to actions
          for idx, action in enumerate(self.action_space.descriptions):
              for key in key_map.keys():
                  if action == key:
                      self.key_to_action[key_map[key]] = idx
  
      self.num_speedup_steps = num_speedup_steps
      self.max_speed = max_speed
  
      # measurements
      self.autopilot = None
      self.planner = Planner(self.map_name)
  
      # env initialization
      self.reset_internal_state(True)
  
      # render
      if self.is_rendered:
          image = self.get_rendered_image()
          self.renderer.create_screen(image.shape[1], image.shape[0])
  
      self.target_success_rate = target_success_rate
  
imports: import random
  import sys
  from os import path, environ
  from rl_coach.logger import screen
  from rl_coach.filters.action.partial_discrete_action_space_map import PartialDiscreteActionSpaceMap
  from rl_coach.filters.observation.observation_rgb_to_y_filter import ObservationRGBToYFilter
  from rl_coach.filters.observation.observation_to_uint8_filter import ObservationToUInt8Filter
  import os
  import signal
  import logging
  import subprocess
  import numpy
  from rl_coach.environments.environment import Environment, EnvironmentParameters, LevelSelection
  from rl_coach.spaces import BoxActionSpace, ImageObservationSpace, StateSpace, VectorObservationSpace
  from rl_coach.utils import get_open_port, force_list
  from enum import Enum
  from typing import List, Union
  from rl_coach.base_parameters import VisualizationParameters
  from rl_coach.filters.filter import InputFilter, NoOutputFilter
  from rl_coach.filters.observation.observation_rescale_to_size_filter import ObservationRescaleToSizeFilter
  from rl_coach.filters.observation.observation_stacking_filter import ObservationStackingFilter
label_desc: Use image node_id 1 to create a new CarlaEnvironment object from inherited base classes: Environment with example: obj = CarlaEnvironment(level, seed, frame_skip, human_control, custom_reward_threshold, visualization_parameters, server_height, server_width, camera_height, camera_width, verbose, experiment_suite, config, episode_max_time, allow_braking, quality, cameras, weather_id, experiment_path, separate_actions_for_throttle_and_brake, num_speedup_steps, max_speed, target_success_rate)