hi, sorry for late reply . i have created a dataset class and i used .repeat function in that class to convert every image into RGB.
class MyDataset(Dataset):

    def __init__(self, data, targets, transform=None):

        self.data = data

        self.targets = torch.LongTensor(targets)

        self.transform = transform

    def __getitem__(self, index):

        x = self.data[index]

        x = torch.from_numpy(x)

        y = self.targets[index]

        if self.transform:

            x=x.repeat(3,1,1)

            x = self.transform(x)

        return x, y

    def __len__(self):

        return len(self.data)