code: def get_instance_state(
      self, instance_id: str, region: str
  ) -> InstanceState:
      client = self.session.client("ec2", region_name=region)
      try:
          response = client.describe_instances(
              InstanceIds=[instance_id]
          )
          state = response["Reservations"][0]["Instances"][0]["State"][
              "Name"
          ]
      except botocore.exceptions.ClientError as e:
          if (
              e.response["Error"]["Code"]
              == "InvalidInstanceID.NotFound"
          ):
              return InstanceState.NOT_FOUND
          else:
              raise e
      return {
          "pending": InstanceState.PROVISIONING,
          "running": InstanceState.RUNNING,
          "shutting-down": InstanceState.STOPPING,
          "terminated": InstanceState.TERMINATED,
          "stopping": InstanceState.STOPPING,
          "stopped": InstanceState.STOPPED,
      }[state]
  
imports: from concurrent.futures import ThreadPoolExecutor, as_completed
  from typing import Dict, List, Optional
  import boto3
  import botocore.client
  import botocore.exceptions
  import dstack._internal.core.backends.aws.resources
  import dstack.version
  from dstack._internal import settings
  from dstack._internal.core.backends.aws.config import AWSConfig
  from dstack._internal.core.backends.base.compute import Compute, get_gateway_user_data, get_instance_name, get_user_data
  from dstack._internal.core.backends.base.offers import get_catalog_offers
  from dstack._internal.core.errors import NoCapacityError
  from dstack._internal.core.models.backends.aws import AWSAccessKeyCreds
  from dstack._internal.core.models.backends.base import BackendType
  from dstack._internal.core.models.instances import InstanceAvailability, InstanceOffer, InstanceOfferWithAvailability, InstanceState, LaunchedGatewayInfo, LaunchedInstanceInfo
  from dstack._internal.core.models.runs import Job, Requirements, Run
  from dstack._internal.utils.logging import get_logger
label_desc: Use image node_id 3 for calling the AWSCompute obj's underlying member method code with example usage: obj.get_instance_state(instance_id, region) and returns: dict, InstanceState