parameters: (cls, x: torch.Tensor)
return_statement: return cls(features_th, indices_th, spatial_shape, batch_size)
docstring: create sparse tensor fron channel last dense tensor by to_sparse
          x must be NHWC tensor, channel last
docstring_summary: create sparse tensor fron channel last dense tensor by to_sparse
          x must be NHWC tensor, channel last
docstring_tokens: create sparse tensor fron channel last dense tensor by to_sparse x must be NHWC tensor channel last
function: def from_dense(cls, x: torch.Tensor):
          """create sparse tensor fron channel last dense tensor by to_sparse
          x must be NHWC tensor, channel last
          """
          x_sp = x.to_sparse(x.ndim - 1)
          spatial_shape = list(x_sp.shape[1:-1])
          batch_size = x_sp.shape[0]
          indices_th = x_sp.indices().permute(1, 0).contiguous().int()
          features_th = x_sp.values()
          return cls(features_th, indices_th, spatial_shape, batch_size)
function_tokens: def from_dense ( cls , x : torch . Tensor ) : x_sp = x . to_sparse ( x . ndim - 1 ) spatial_shape = list ( x_sp . shape [ 1 : - 1 ] ) batch_size = x_sp . shape [ 0 ] indices_th = x_sp . indices ( ) . permute ( 1 , 0 ) . contiguous ( ) . int ( ) features_th = x_sp . values ( ) return cls ( features_th , indices_th , spatial_shape , batch_size )