In Magento 2, a VirtualType is a type of object that is created and configured using the dependency injection (DI) mechanism.
A VirtualType is not a concrete class, but rather a way to define a set of arguments and configurations that can be used to generate an instance of an object on-the-fly. This can be useful when you need to create an object that requires a complex set of dependencies or configuration options, but you don't want to create a concrete class for it.
To create a VirtualType in Magento 2, you first need to define it in the di.xml file of your module.
To define a virtual type, you need to specify the following in the di.xml file:
name: The name of the virtual type. This should be a unique identifier that is used to refer to the virtual type in other parts of the Magento 2 codebase.
type: The class that the virtual type is based on.
shared: A Boolean value that indicates whether the virtual type is a singleton or not. If set to true,