How to fix apple diagnostics error DEC500? For a related question, I was trying to run apple Hardware Test (Apple diagnostics) on my Macbook Pro Retina.

Mackbook details:



I tried restarting with the D key pressed, with the intention of running Apple Hardware Test. 
I was greeted with the following screen:



On pressing R, the error continues further saying:



Pressing S shut it down.

I tried pressing option+D on startup. This starts internet recovery. I select the appropriate network and then it errors saying:



I researched online and a suggestion was that somehow the diagnostics tool is missing. And it was. There was no folder at /System/Library/CoreServices/ called .diagnostics. 

I downloaded the relevant files from 
https://github.com/upekkha/AppleHardwareTest

To copy these files to the correct location I turned off SIP by going into recovery mode. After I copied the files, I restarted with D pressed, but I was met with the same errors. The same errors as above occured with option+D on startup as well.

How do I get apple diagnostics running again?



UPDATE:

I created a bootable USB with the relevant AHT as per the answer below.
On holding option at startup, I'm presented with a screen with three options: Macintosh HD, Windows, and EFI Boot.
I select EFI Boot, and a very quick black screen with a bunch of text appears and then the apple logo and loading bar appears. No AHT. I did the same thing on another machine - an Air, and it loaded the AHT, but said "Machine not supported", when I tried to run it, (which makes sense since the AHT is for a different model). I was able to capture the screen by taking a video of the process and then selecting the still frame. It goes by in less than half a second.
Let's see if we can get Apple Hardware Test working from a bootable USB drive.

The steps to do this are as follows:


Create a bootable USB flash drive by using Disk Utility's Erase function. Make sure you choose OS X Extended for the format and the GUID Partition Map for the scheme. For the purposes of these steps, also give your USB the name AHT when you're erasing it.
Now download the AHT for your particular Mac (i.e. AHT 3A238) from Apple here
Mount the downloaded image (it should mount as AHTCOne)
Now you will need to copy the AHT to your USB flash drive. To start, Launch the Terminal app (usually found within the Utilities folder)
In the Terminal window, enter the following:

cp -r /Volumes/AHTCOne/System /Volumes/AHT/
Now we need to make the USB flash drive bootable, so enter the following line in Terminal:

sudo bless --folder /Volumes/AHT/ --file /Volumes/AHT/System/Library/CoreServices/.diagnostics/diags.efi --label AHT
Enter your Admin password
Leave the USB flash drive plugged in and restart your Mac
Immediately hold down the Option key
Select the AHT option from the list and boot up


Now test to see if your Mac can run Apple Hardware Test or not.


NOTE for other readers: 


Different Macs require different versions of Apple's diagnostic software. So this answer will not apply to you unless your Mac also requires AHT 3A238. Note: Macs introduced after June 2013 use Apple Diagnostics instead.
Likewise, the Terminal commands used in this answer are for this specific question. 
However, assuming you have downloaded the AHT version for your Mac, then this answer can be adapted for your use by replacing the AHTCOne with whatever name your downloaded disk image mounted as at Step 3. For example, if at step 3 your downloaded disk image mounted as AHTCThree, then at Step 5 you would use AHTCThree instead of AHTCOne within the Terminal command.