get product by attribute in woocommerce

I have products with many attributes. Attribute values can be size,color,… . I am trying to create a custom search but I can’t get the query to pull any product.

    $product_attributes = wc_get_attribute_taxonomies();
    
    $attributes = array();
    foreach ($product_attributes as $attribute) {
        $attribute_name =  $attribute->attribute_name;
        $attribute_value = isset($params[$attribute_name]) ? $params[$attribute_name] : '';
        if (!empty($attribute_value)) {
            $attributes['pa_' .$attribute_name] = $attribute_value;
           
        }
    }
    
    $ordering              = WC()->query->get_catalog_ordering_args();
    $ordering['orderby']   = array_shift(explode(' ', $ordering['orderby']));
    $ordering['orderby']   = stristr($ordering['orderby'], 'price') ? 'meta_value_num' : $ordering['orderby'];
    
    dump($attributes);
    $args = array(
        'status' => 'publish',
        'limit' => -1,
        'return'            => 'ids',
        'stock_status'      => 'instock',
        'visibility'        => 'visible',
        'paginate'          => true,
        'orderby'           => $ordering['orderby'],
        'order'             => 'DESC',

        'attribute' => $attributes,
    );

    $products = wc_get_products($args);

what`s the problem