I'm lost in minecraft, how do i get back home?

I was mining for diamonds when i fell into a cave and decided to look for more diamonds down there, i ran out of torches but kept wandering and mining when i fell down to this place where it had railroad things and all so i was looking down there and now i'm lost. I think i'm making myself even more lsot trying to find my way out of this place. I don't really have that many supplies and i don't know how to make a compass i know i need redstone but i don't know where to find that. Is there anything i can do to find my way out? I'm playing on my computer and i set it to survival mode.

Make a 4x4 Lava hole! Chuck in all of your diamonds then it teleports back to home or place your visit most above ground

Just go gamemode 1 and fly back through the cave and then back home.

Just dig straight up or build a staircase up to the surface.

Do you have cheats enabled? If you do, great. If you don't, press Escape and click on "Open to LAN". Then click on "Allow Cheats: Off", which will turn it to on, and start LAN world.

Then, type /gamerule keepInventory true (This will allow you to keep your inventory even if you die)
Then just kill yourself or type /kill
Then you can respawn at your spawnpoint without losing any items

If you don't want to cheat, just dig straight up or build a staircase up, but watch out for sand/gravel/water

/home /spawn /hub

You're in a mineshaft, I believe, with the rails. Just go into creative, get a map out, and fly home.