code: def get_instance_metadatas(pricing):
      instance_types = set()
      instance_mapping = {}
  
      for _, product in pricing["products"].items():
          if product.get("attributes") is None:
              continue
          if product["attributes"].get("instanceType") is None:
              continue
          if product["attributes"].get("servicecode") != "AmazonEC2":
              continue
          if product["attributes"].get("capacitystatus") != "Used":
              continue
  
          instance_type = product["attributes"]["instanceType"]
          instance_types.add(instance_type)
  
          if product["attributes"].get("operation") != "RunInstances":
              continue
          if product["attributes"].get("tenancy") != "Shared":
              continue
          if product["attributes"].get("operatingSystem") != "Linux":
              continue
  
          price_dimensions = list(
              pricing["terms"]["OnDemand"][product["sku"]].values()
          )[0]["priceDimensions"]
  
          price = list(price_dimensions.values())[0]["pricePerUnit"][
              "USD"
          ]
  
          metadata = {
              "cpu": int(product["attributes"]["vcpu"]),
              "mem": int(
                  float(
                      re.sub(
                          "[^0-9\\.]",
                          "",
                          product["attributes"]["memory"].split(" ")[0],
                      )
                  )
                  * 1024
              ),
              "price": float(price),
              "gpu": 0,
          }
          if product["attributes"].get("gpu") is not None:
              metadata["gpu"] = product["attributes"]["gpu"]
          instance_mapping[instance_type] = metadata
  
      return instance_types, instance_mapping
  
file_path: cortex/pkg/lib/aws/gen_resource_metadata.py
imports: import requests
  import re
  from string import Template
label_desc: Use image node_id 1 for calling a global function with example usage: get_instance_metadatas(pricing) and returns: instance_types,  instance_mapping