How to retrieve attributes details by attribute set id Magento 2?

Get all assigned attributes from the attribute set id in Magento 2 useful to know the list of available attributes for the given attribute set.

Let’s take an example, We want to fetch all the assigned attributes from the Default Attribute set in Magento 2.
The Default Attribute set id is 4 in Native Magento.

We required to interface to fetch all the attribute is, Magento\Catalog\Api\ProductAttributeManagementInterface

Base Definition of the method,
public function getAttributes($attributeSetId);
$attributeSetId is the attribute set id we want to explore related attributes.

We need to call the method and iterate over a loop to fetch all the attributes from the attribute set.

Output:

On Success, \Magento\Catalog\Api\Data\ProductAttributeInterface[]

On Error, No such entity with id.