code: def _instance_usage(self):
          
          # On-Demand instances by type
          ondemand = {}
          for t in self._instance_types():
              ondemand[t] = 0
          az_to_inst = {}
          logger.debug("Getting usage for on-demand instances")
          for inst in self.resource_conn.instances.all():
              if inst.spot_instance_request_id:
                  logger.info("Spot instance found (%s); skipping from "
                              "Running On-Demand Instances count", inst.id)
                  continue
              if inst.state['Name'] in ['stopped', 'terminated']:
                  logger.debug("Ignoring instance %s in state %s", inst.id,
                               inst.state['Name'])
                  continue
              if inst.placement['AvailabilityZone'] not in az_to_inst:
                  az_to_inst[
                      inst.placement['AvailabilityZone']] = deepcopy(ondemand)
              try:
                  az_to_inst[
                      inst.placement['AvailabilityZone']][inst.instance_type] += 1
              except KeyError:
                  logger.error("ERROR - unknown instance type '%s'; not "
                               "counting", inst.instance_type)
          return az_to_inst
docs: Find counts of currently-running EC2 Instances
          (On-Demand or Reserved) by placement (Availability
          Zone) and instance type (size). Return as a nested dict
          of AZ name to dict of instance type to count.
  
          :rtype: dict