A problem in transform compose

I want to add the adjust_brightness function to my transform.Compose,but that function has a integrant parameter img so that i can only apply this to my loop. Is there any methods to make it a compatible part in transform.Compose for other similar datasets? I’m a beginner in pytorch.
Thanks in advance!

import matplotlib.pyplot as plt
import numpy as np
import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
import torchvision
from torchvision import datasets, transforms
transform = transforms.Compose([transforms.ToTensor(),
#Load the training data
trainset = datasets.FashionMNIST(root='./data', train=False,
                                       download=True, transform=transform)
trainloader = torch.utils.data.DataLoader(trainset, batch_size=batchSize,
                                          shuffle=True, num_workers=0)
def imshow(img):
    img = img / 2 + 0.5     # unnormalize back to range [0, 1]
    npimg = img.numpy()
    plt.imshow(np.transpose(npimg, (1, 2, 0))) #rearrange dimensions to numpy format for disply
for images, labels in trainloader:  # only take first element of dataset
    if labels==torch.tensor([9]):
        images = transforms.functional.adjust_brightness(img = images,brightness_factor = 100)

You could use transforms.Lambda and pass the method (via a partial) to it or write a custom transformation class and use it in the transforms.Compose.