code: def create_embeddings_for_implicit_function(
      xyz_world: torch.Tensor,
      xyz_in_camera_coords: bool,
      global_code: Optional[torch.Tensor],
      camera: Optional[CamerasBase],
      fun_viewpool: Optional[Callable],
      xyz_embedding_function: Optional[Callable],
      diag_cov: Optional[torch.Tensor] = None,
  ) -> torch.Tensor:
      bs, *spatial_size, pts_per_ray, _ = xyz_world.shape
  
      if xyz_in_camera_coords:
          if camera is None:
              raise ValueError(
                  "Camera must be given if xyz_in_camera_coords"
              )
  
          ray_points_for_embed = (
              camera.get_world_to_view_transform()
              .transform_points(xyz_world.view(bs, -1, 3))
              .view(xyz_world.shape)
          )
      else:
          ray_points_for_embed = xyz_world
  
      if xyz_embedding_function is None:
          embeds = torch.empty(
              bs,
              1,
              prod(spatial_size),
              pts_per_ray,
              0,
          )
      else:
          embeds = xyz_embedding_function(
              ray_points_for_embed, diag_cov=diag_cov
          )
          embeds = embeds.reshape(
              bs,
              1,
              prod(spatial_size),
              pts_per_ray,
              -1,
          )  # flatten spatial, add n_src dim
  
      if fun_viewpool is not None:
          # viewpooling
          embeds_viewpooled = fun_viewpool(xyz_world.reshape(bs, -1, 3))
          embed_shape = (
              bs,
              embeds_viewpooled.shape[1],
              prod(spatial_size),
              pts_per_ray,
              -1,
          )
          embeds_viewpooled = embeds_viewpooled.reshape(*embed_shape)
          if embeds is not None:
              embeds = torch.cat(
                  [embeds.expand(*embed_shape), embeds_viewpooled],
                  dim=-1,
              )
          else:
              embeds = embeds_viewpooled
  
      if global_code is not None:
          # append the broadcasted global code to embeds
          embeds = broadcast_global_code(embeds, global_code)
  
      return embeds
  
file_path: pytorch3d/pytorch3d/implicitron/models/implicit_function/utils.py
imports: from typing import Callable, Optional
  import torch
  import torch.nn.functional
  from pytorch3d.common.compat import prod
  from pytorch3d.implicitron.models.renderer.base import ImplicitronRayBundle
  from pytorch3d.renderer import ray_bundle_to_ray_points
  from pytorch3d.renderer.cameras import CamerasBase
label_desc: Use image node_id 2 for calling a global function with example usage: create_embeddings_for_implicit_function(xyz_world, xyz_in_camera_coords, global_code, camera, fun_viewpool, xyz_embedding_function, diag_cov) and returns: embeds