class_docstr: Class for KITTI Semantic Segmentation Benchmark dataset.
  
  Dataset link - http://www.cvlibs.net/datasets/kitti/eval_semseg.php?benchmark=semantics2015
  
  There are 34 classes in the given labels. However, not all of them are useful for training
  (like railings on highways, road dividers, etc.).
  So, these useless classes (the pixel values of these classes) are stored in the `void_labels`.
  The useful classes are stored in the `valid_labels`.
  
  The `encode_segmap` function sets all pixels with any of the `void_labels` to `ignore_index`
  (250 by default). It also sets all of the valid pixels to the appropriate value between 0 and
  `len(valid_labels)` (since that is the number of valid classes), so it can be used properly by
  the loss function when comparing with the output.
  
  The `get_filenames` function retrieves the filenames of all images in the given `path` and
  saves the absolute path in a list.
  
  In the `get_item` function, images and masks are resized to the given `img_size`, masks are
  encoded using `encode_segmap`, and given `transform` (if any) are applied to the image only
  (mask does not usually require transforms, but they can be implemented in a similar way).
class_docstr_tok: ["Class","for","KITTI","Semantic","Segmentation","Benchmark","dataset",".","Dataset","link","-","http",":","\/\/www.cvlibs.net\/datasets\/kitti\/eval_semseg.php","?","benchmark=semantics2015","There","are","34","classes","in","the","given","labels",".","However",",","not","all","of","them","are","useful","for","training","(","like","railings","on","highways",",","road","dividers",",","etc.",")",".","So",",","these","useless","classes","(","the","pixel","values","of","these","classes",")","are","stored","in","the","`","void_labels","`",".","The","useful","classes","are","stored","in","the","`","valid_labels","`",".","The","`","encode_segmap","`","function","sets","all","pixels","with","any","of","the","`","void_labels","`","to","`","ignore_index","`","(","250","by","default",")",".","It","also","sets","all","of","the","valid","pixels","to","the","appropriate","value","between","0","and","`","len","(","valid_labels",")","`","(","since","that","is","the","number","of","valid","classes",")",",","so","it","can","be","used","properly","by","the","loss","function","when","comparing","with","the","output",".","The","`","get_filenames","`","function","retrieves","the","filenames","of","all","images","in","the","given","`","path","`","and","saves","the","absolute","path","in","a","list",".","In","the","`","get_item","`","function",",","images","and","masks","are","resized","to","the","given","`","img_size","`",",","masks","are","encoded","using","`","encode_segmap","`",",","and","given","`","transform","`","(","if","any",")","are","applied","to","the","image","only","(","mask","does","not","usually","require","transforms",",","but","they","can","be","implemented","in","a","similar","way",")","."]
docstr: Sets void classes to zero so they won't be considered for training.
docstr_tok: ["Sets","void","classes","to","zero","so","they","wo","n't","be","considered","for","training","."]
code: def encode_segmap(self, mask):
      """Sets void classes to zero so they won't be considered for training."""
      for voidc in self.void_labels:
          mask[mask == voidc] = self.ignore_index
      for validc in self.valid_labels:
          mask[mask == validc] = self.class_map[validc]
      # remove extra idxs from updated dataset
      mask[mask > 18] = self.ignore_index
      return mask
  
imports: import os
  import random
  from argparse import ArgumentParser, Namespace
  import numpy
  import torch
  import torch.nn.functional
  import torchvision.transforms
  from lightning.pytorch import LightningModule, Trainer, cli_lightning_logo
  from PIL import Image
  from torch import nn
  from torch.utils.data import DataLoader, Dataset
label_desc: Use image node_id 4 for calling the KITTI obj's underlying member method code with example usage: obj.encode_segmap(mask) and returns: mask