class_docstr: Renders the Z distances using an aggregate of the distances of each face
  based off of the point distance.  If no face is found it returns the zfar
  value of the camera.
  
  Output from this shader is [N, H, W, 1] since it's only depth.
  
  To use the default values, simply initialize the shader with the desired
  device e.g.
  
  .. code-block::
  
      shader = SoftDepthShader(device=torch.device("cuda:0"))
class_docstr_tok: ["Renders","the","Z","distances","using","an","aggregate","of","the","distances","of","each","face","based","off","of","the","point","distance",".","If","no","face","is","found","it","returns","the","zfar","value","of","the","camera",".","Output","from","this","shader","is","[","N",",","H",",","W",",","1","]","since","it","'s","only","depth",".","To","use","the","default","values",",","simply","initialize","the","shader","with","the","desired","device","e.g",".","..","code-block",":",":","shader","=","SoftDepthShader","(","device=torch.device","(","``","cuda:0","''",")",")"]
code: def forward(
      self, fragments: Fragments, meshes: Meshes, **kwargs
  ) -> torch.Tensor:
      if fragments.dists is None:
          raise ValueError(
              "SoftDepthShader requires Fragments.dists to be present."
          )
  
      cameras = super()._get_cameras(**kwargs)
  
      N, H, W, K = fragments.pix_to_face.shape
      device = fragments.zbuf.device
      mask = fragments.pix_to_face >= 0
  
      zfar = kwargs.get("zfar", getattr(cameras, "zfar", 100.0))
  
      # Sigmoid probability map based on the distance of the pixel to the face.
      prob_map = (
          torch.sigmoid(-fragments.dists / self.blend_params.sigma)
          * mask
      )
  
      # append extra face for zfar
      dists = torch.cat(
          (
              fragments.zbuf,
              torch.ones((N, H, W, 1), device=device) * zfar,
          ),
          dim=3,
      )
      probs = torch.cat(
          (prob_map, torch.ones((N, H, W, 1), device=device)), dim=3
      )
  
      # compute weighting based off of probabilities using cumsum
      probs = probs.cumsum(dim=3)
      probs = probs.clamp(max=1)
      probs = probs.diff(
          dim=3, prepend=torch.zeros((N, H, W, 1), device=device)
      )
  
      return (probs * dists).sum(dim=3).unsqueeze(3)
  
imports: import warnings
  from typing import Optional
  import torch
  import torch.nn
  from ...common.datatypes import Device
  from ...structures.meshes import Meshes
  from ..blending import BlendParams, hard_rgb_blend, sigmoid_alpha_blend, softmax_rgb_blend
  from ..lighting import PointLights
  from ..materials import Materials
  from ..splatter_blend import SplatterBlender
  from ..utils import TensorProperties
  from .rasterizer import Fragments
  from .shading import _phong_shading_with_pixels, flat_shading, gouraud_shading, phong_shading
label_desc: Use image node_id 1 for calling the SoftDepthShader obj's underlying member method code with example usage: obj.forward(fragments, meshes) and returns: unknown