class_docstr: Implements the multi-layer perceptron architecture of the Neural Radiance Field.
  
  As such, `MLPWithInputSkips` is a multi layer perceptron consisting
  of a sequence of linear layers with ReLU activations.
  
  Additionally, for a set of predefined layers `input_skips`, the forward pass
  appends a skip tensor `z` to the output of the preceding layer.
  
  Note that this follows the architecture described in the Supplementary
  Material (Fig. 7) of [1].
  
  References:
      [1] Ben Mildenhall and Pratul P. Srinivasan and Matthew Tancik
          and Jonathan T. Barron and Ravi Ramamoorthi and Ren Ng:
          NeRF: Representing Scenes as Neural Radiance Fields for View
          Synthesis, ECCV2020
class_docstr_tok: ["Implements","the","multi-layer","perceptron","architecture","of","the","Neural","Radiance","Field",".","As","such",",","`","MLPWithInputSkips","`","is","a","multi","layer","perceptron","consisting","of","a","sequence","of","linear","layers","with","ReLU","activations",".","Additionally",",","for","a","set","of","predefined","layers","`","input_skips","`",",","the","forward","pass","appends","a","skip","tensor","`","z","`","to","the","output","of","the","preceding","layer",".","Note","that","this","follows","the","architecture","described","in","the","Supplementary","Material","(","Fig",".","7",")","of","[","1","]",".","References",":","[","1","]","Ben","Mildenhall","and","Pratul","P.","Srinivasan","and","Matthew","Tancik","and","Jonathan","T.","Barron","and","Ravi","Ramamoorthi","and","Ren","Ng",":","NeRF",":","Representing","Scenes","as","Neural","Radiance","Fields","for","View","Synthesis",",","ECCV2020"]
docstr: Args:
      n_layers: The number of linear layers of the MLP.
      input_dim: The number of channels of the input tensor.
      output_dim: The number of channels of the output.
      skip_dim: The number of channels of the tensor `z` appended when
          evaluating the skip layers.
      hidden_dim: The number of hidden units of the MLP.
      input_skips: The list of layer indices at which we append the skip
          tensor `z`.
docstr_tok: ["Args",":","n_layers",":","The","number","of","linear","layers","of","the","MLP",".","input_dim",":","The","number","of","channels","of","the","input","tensor",".","output_dim",":","The","number","of","channels","of","the","output",".","skip_dim",":","The","number","of","channels","of","the","tensor","`","z","`","appended","when","evaluating","the","skip","layers",".","hidden_dim",":","The","number","of","hidden","units","of","the","MLP",".","input_skips",":","The","list","of","layer","indices","at","which","we","append","the","skip","tensor","`","z","`","."]
code: def __init__(
      self,
      n_layers: int,
      input_dim: int,
      output_dim: int,
      skip_dim: int,
      hidden_dim: int,
      input_skips: Tuple[int, ...] = (),
  ):
      """
      Args:
          n_layers: The number of linear layers of the MLP.
          input_dim: The number of channels of the input tensor.
          output_dim: The number of channels of the output.
          skip_dim: The number of channels of the tensor `z` appended when
              evaluating the skip layers.
          hidden_dim: The number of hidden units of the MLP.
          input_skips: The list of layer indices at which we append the skip
              tensor `z`.
      """
      super().__init__()
      layers = []
      for layeri in range(n_layers):
          if layeri == 0:
              dimin = input_dim
              dimout = hidden_dim
          elif layeri in input_skips:
              dimin = hidden_dim + skip_dim
              dimout = hidden_dim
          else:
              dimin = hidden_dim
              dimout = hidden_dim
          linear = torch.nn.Linear(dimin, dimout)
          _xavier_init(linear)
          layers.append(
              torch.nn.Sequential(linear, torch.nn.ReLU(True))
          )
      self.mlp = torch.nn.ModuleList(layers)
      self._input_skips = set(input_skips)
  
file_path: pytorch3d/projects/nerf/nerf/implicit_function.py
imports: from typing import Tuple
  import torch
  from pytorch3d.common.linear_with_repeat import LinearWithRepeat
  from pytorch3d.renderer import HarmonicEmbedding, ray_bundle_to_ray_points, RayBundle
label_desc: Use image node_id 1 to create a new MLPWithInputSkips object from inherited base classes: torch.nn with example: obj = MLPWithInputSkips(n_layers, input_dim, output_dim, skip_dim, hidden_dim, input_skips)