If you are using a Lenovo Legion 5 15IMH05H with NVIDIA GeForce RTX 2060 6GB GDDR6/Intel Corporation UHD Graphics and the brightness is not working and tried to install dependencies packages on the Ubuntu doesn't helps. Finally fixed that issue.
Open a 10-nvidia.conf config file /usr/share/X11/xorg.conf.d/10-nvidia.conf using the text editor,
$ sudo vim /usr/share/X11/xorg.conf.d/10-nvidia.conf
And make sure that the below lines are available on the config file,
Note: ModulePath is added multiple times for checking, you can removed which are not available the location.
next, open the /etc/initramfs-tools/modules file and add the lines below,
$ sudo vim /etc/initramfs-tools/modules
Next, open the grub configuration file, compare and update the changes below if have any miss matching lines,
sudo vim /etc/default/ grub
Before you update take a backup and update very carefully,
Finally, update the grub the changes are will be reflected using the command below, and reboot your system.