Blueprint functions require a Cached Anim State Data input to access a specific state, how do we create that?

Turns out you can set the default values of a CachedAnimStateData struct (State Name and State Machine Name) when you have a CachedAnimStateData variable. The values are blueprint read-only after that.
If you want to set the values at runtime, you have to do it with C++. Here’s a blueprint function that works. (To get it into your project, create a BlueprintFunctionLibrary plugin and paste these into the [plugin name]BPLibrary.h and .cpp files respectively. I called mine RobLibrary)
// RobLibraryBPLibrary.h
// .h = Declaring the functions we will make, and 'decorating' them with Unreal-specific stuff about the blueprint node that will correspond to each function
#pragma once
#include "Animation/CachedAnimData.h"
#include "Kismet/BlueprintFunctionLibrary.h"
#include "RobLibraryBPLibrary.generated.h"
UCLASS()
class URobLibraryBPLibrary : public UBlueprintFunctionLibrary
{
GENERATED_UCLASS_BODY()
// A callable blueprint node (aka. has execution pins because it changes an existing structure)
UFUNCTION(BlueprintCallable, meta = (DisplayName = "Set CachedAnimStateData members"), Category = "RobLibrary")
static FCachedAnimStateData SetCachedAnimStateDataValues(FCachedAnimStateData structure, const FName state_machine_name, const FName state_name);
// A pure blueprint node (aka. has no execution pins because it doesn't bother anything because the structure is new)
UFUNCTION(BlueprintPure, meta = (DisplayName = "Make CachedAnimStateData"), Category = "RobLibrary")
static FCachedAnimStateData MakeCachedAnimStateDataValues(const FName state_machine_name, const FName state_name);
};
// -------------------------------------------------------------
// RobLibraryBPLibrary.cpp
// .cpp = The code that runs inside the functions we created in the .h file
#include "RobLibraryBPLibrary.h"
#include "RobLibrary.h"
URobLibraryBPLibrary::URobLibraryBPLibrary(const FObjectInitializer& ObjectInitializer)
: Super(ObjectInitializer)
{
//empty constructor
}
FCachedAnimStateData URobLibraryBPLibrary::SetCachedAnimStateDataValues(FCachedAnimStateData structure, const FName state_machine_name, const FName state_name)
{
// Simply setting the struct's values to the input pins of our blueprint node
structure.StateMachineName = state_machine_name;
structure.StateName = state_name;
return structure;
}
FCachedAnimStateData URobLibraryBPLibrary::MakeCachedAnimStateDataValues(const FName state_machine_name, const FName state_name)
{
// Calls our other function, passing in a new CachedAnimStateData, which will set its values immediately
return URobLibraryBPLibrary::SetCachedAnimStateDataValues(FCachedAnimStateData(), state_machine_name, state_name);
}