The study of the cosmic Dark Ages, Cosmic Dawn, and Epoch of Reionization (EoR) using the all-sky averaged redshifted HI 21cm signal, are some of the key science goals of most of the ongoing or upcoming experiments, for example, EDGES, SARAS, and the SKA. This signal can be detected by averaging over the entire sky, using a single radio telescope, in the form of a Global signal as a function of only redshifted HI 21cm frequencies. One of the major challenges faced while detecting this signal is the dominating, bright foreground. The success of such detection lies in the accuracy of the foreground removal. The presence of instrumental gain fluctuations, chromatic primary beam, radio frequency interference (RFI) and the Earths ionosphere corrupts any observation of radio signals from the Earth. Here, we propose the use of Artificial Neural Networks (ANN) to extract the faint redshifted 21cm Global signal buried in a sea of bright Galactic foregrounds and contaminated by different instrumental models. The most striking advantage of using ANN is the fact that, when the corrupted signal is fed into a trained network, we can simultaneously extract the signal as well as foreground parameters very accurately. Our results show that ANN can detect the Global signal with $gtrsim 92 %$ accuracy even in cases of mock observations where the instrument has some residual time-varying gain across the spectrum.