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,

Section "OutputClass"
    Identifier "nvidia"
    MatchDriver "nvidia-drm"
    Driver "nvidia"
    Option "AllowEmptyInitialConfiguration"
    Option "RegistryDwords" "EnableBrightnessControl=1"
    ModulePath "/usr/lib/x86_64-linux-gnu/nvidia/xorg"
    ModulePath "/usr/lib/nvidia/xorg"
    ModulePath "/usr/lib/xorg/modules"    
EndSection


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

nvidia
nvidia-drm
nvidia-modeset


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,

GRUB_DEFAULT=0
GRUB_TIMEOUT_STYLE=hidden
GRUB_TIMEOUT=0
GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash video.use_native_backlight=1"
GRUB_CMDLINE_LINUX=""

Finally, update the grub the changes are will be reflected using the command below, and reboot your system.

sudo update-grub

reboot