Good morning,
I’ve implemented the majority of your suggested changes, and the code now runs BUT only when I pass in a desired set of mean and scale values to the StandardScaler() class e.g., StandardScaler(0, 1).
In other words, my custom StandardScaler() class doesn’t seem to be properly calculating the mean and standard deviation for each feature or target variable.
I suspect this has to do with how you mentioned I need to properly call the fit function.
You had suggested:
        # call fit on training data.
        self.transform(self.train_X)
        self.train = train

But I felt I was doing so (or similar) in the getitem function definition:
def __getitem__(self, index):
        if self.train is True:
            X_data = self.train_X[index]
            Y_data = self.train_Y[index]
            if self.transform is not None:
                X_data = self.transform(X_data)
                Y_data = self.transform(Y_data)
            return X_data, Y_data

        else:
            X_data = self.test_X[index]
            if self.transform is not None:
                X_data = self.transform(X_data)
            return X_data

Here is the entire code as it currently stands:
class CSVDataset(Dataset):
    # Load the dataset.
    def __init__(self, file_path, train, transform=None):
        # Read the data into a dataframe.
        df = pd.read_csv(file_path)
        # Store the input & output variables.
        self.train_X = df.iloc[:, 1:-1].values.astype('float32')
        self.train_Y = df.iloc[:, -1].values.astype('float32')
        self.test_X = df.iloc[:, 1:-1].values.astype('float32')
        self.test_Y = np.empty(len(self.test_X))
        self.transform = transform

        
        self.train = train

    def __getitem__(self, index):
        if self.train is True:
            X_data = self.train_X[index]
            Y_data = self.train_Y[index]
            if self.transform is not None:
                X_data = self.transform(X_data)
                Y_data = self.transform(Y_data)
            return X_data, Y_data

        else:
            X_data = self.test_X[index]
            if self.transform is not None:
                X_data = self.transform(X_data)
            return X_data

    def __len__(self):
        if self.train is True:
            return len(self.train_Y)
        else:
            return len(self.test_Y)

def train_val_dataset(dataset, val_split=0.2):
    train_idx, val_idx = train_test_split(list(range(len(dataset))), \
        test_size=val_split, shuffle=False, random_state=42)
    train_val_splits = {}
    train_val_splits['train'] = Subset(dataset, train_idx)
    train_val_splits['val'] = Subset(dataset, val_idx)
    return train_val_splits

def test_dataset(dataset):
    test_idx = list(range(len(dataset)))
    test_split = {}
    test_split['test'] = Subset(dataset, test_idx)
    return test_split


################################################################################################
class StandardScaler():
    """Standardize data by removing the mean and scaling to unit variance.
       This object can be used as a transform in PyTorch data loaders.

    Args:
        mean (FloatTensor): The mean value for each feature in the data.
        scale (FloatTensor): Per-feature relative scaling.
    """

    def __init__(self, mean=None, scale=None):
        if mean is not None:
            #mean = torch.FloatTensor(mean)
            mean = mean
        if scale is not None:
            scale = scale
            #scale = torch.FloatTensor(scale)
        self.mean_ = mean
        self.scale_ = scale

    def fit(self, sample):
        """Set the mean and scale values based on the sample data.
        """
        self.mean_ = sample.mean(axis=0, keepdims=True)
        self.scale_ = sample.std(axis=0, ddof=1, keepdims=True)
        return self

    def __call__(self, sample):
        return (sample - self.mean_)/self.scale_

    def inverse_transform(self, sample):
        """Scale the data back to the original sample space.
        """
        return sample * self.scale_ + self.mean_
################################################################################################

# Create transform function to pass into CSVDataset class.
transform = StandardScaler()

# Test CSVDataset class definition & print train/test dataset sizes.
dataset = CSVDataset(file_path, train=True, transform=transform)
print(dataset.train_X)
print()

print(dataset.train_Y)
print()

print(dataset.test_X)
print()

# Print the length of the entire passed dataset.
print("Dataset Length:", len(dataset))
print()

# Split into train/validation sets & print respective lengths.
train_val_splits = train_val_dataset(dataset)
print("Train Set Length:", len(train_val_splits['train']))
print("Val Set Length:", len(train_val_splits['val']))
print()

# Pass train/validation splits into PyTorch DataLoader functions.
def cycle(iterable):
    while True:
        for x in iterable:
            yield x

train_loader = DataLoader(train_val_splits['train'], batch_size=8, shuffle=False, num_workers=0, pin_memory=True)
train_iter = iter(cycle(train_loader))

val_loader = DataLoader(train_val_splits['val'], batch_size=8, shuffle=False, num_workers=0, pin_memory=True)
val_iter = iter(cycle(val_loader))

# Acquire & print test batch of training/validation data.
dataiter = iter(train_loader)
train_batch = dataiter.next()
print(train_batch)
print()

dataiter2 = iter(val_loader)
val_batch = dataiter2.next()
print(val_batch)
print()

And the error I’m getting is as follows:
Traceback (most recent call last):
  File "filepath", line 172, in <module>       
    train_batch = dataiter.next()
  File "C:\Users\rwils\Anaconda3\lib\site-packages\torch\utils\data\dataloader.py", line 435, in __next__
    data = self._next_data()
  File "C:\Users\rwils\Anaconda3\lib\site-packages\torch\utils\data\dataloader.py", line 475, in _next_data
    data = self._dataset_fetcher.fetch(index)  # may raise StopIteration
  File "C:\Users\rwils\Anaconda3\lib\site-packages\torch\utils\data\_utils\fetch.py", line 44, in fetch
    data = [self.dataset[idx] for idx in possibly_batched_index]
  File "C:\Users\rwils\Anaconda3\lib\site-packages\torch\utils\data\_utils\fetch.py", line 44, in <listcomp>
    data = [self.dataset[idx] for idx in possibly_batched_index]
  File "C:\Users\rwils\Anaconda3\lib\site-packages\torch\utils\data\dataset.py", line 272, in __getitem__
    return self.dataset[self.indices[idx]]
  File "filepath", line 67, in __getitem__     
    X_data = self.transform(X_data)
  File "filepath", line 126, in __call__       
    return (sample - self.mean_)/self.scale_
TypeError: unsupported operand type(s) for -: 'float' and 'NoneType'

When I insert specified mean and standard deviation values to StandardScaler(), I get tensor outputs that correspond correctly to the selected batch sizes in the dataloaders, but this is not what I really need because the mean and std dev need to come from the population sample for each feature/target (i.e., column-wise).
Any more insights???
Thanks again!
Cheers