How to get Grouped Product id from child product id in Magento 2?

You can get Parent Grouped Product id from child product id. Using Magento 2, You can fetch Parent product Ids as an array from child id of the product.

For Fetch Parent product id, You need Child Item Id associated with Grouped Product. Using Magento\GroupedProduct\Model\Product\Type\Grouped Magento Core class you can fetch parent product Id.

Used function getParentIdsByChild($childProductId)

You need to pass first parameter as $childProductId for getting parent product ID of child item id.

$childIds = 33;
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$parentId = $objectManager->create('Magento\GroupedProduct\Model\Product\Type\Grouped')->getParentIdsByChild($childIds);
echo "<pre>";print_r($parentId);

You can call Grouped Class in your Block __construct function, Create Block class,

public function __construct(
        \Magento\Framework\View\Element\Template\Context $context,
        \Magento\GroupedProduct\Model\Product\Type\Grouped $groupedProduct,
        array $data = []
    ) {
        $this->groupedProduct = $groupedProduct;
        parent::__construct($context, $data);
    }
    /**
      * $childId Child Item id
      */
    public function getGroupedProductId($childId) {
    	$this->groupedProduct->getParentIdsByChild($childId);
    }

Call from a template file,

$childId = 33;
echo $block->getGroupedProductId($childId)