code: def forward(self, batch, tokenizer, compute_loss: bool = False):
      encoder_output = self.encoder.encode(
          input_ids=batch.input_ids,
          segment_ids=batch.segment_ids,
          input_mask=batch.input_mask,
      )
  
      # A tuple of layers of hidden states
      hidden_states = take_one(encoder_output.other)
      layer_hidden_states = hidden_states[self.layer]
  
      if isinstance(self.head, heads.MeanPoolerHead):
          logits = self.head(
              unpooled=layer_hidden_states, input_mask=batch.input_mask
          )
      elif isinstance(self.head, heads.FirstPoolerHead):
          logits = self.head(layer_hidden_states)
      else:
          raise TypeError(type(self.head))
  
      # TODO: Abuse of notation - these aren't really logits  (issue #1187)
      if compute_loss:
          # TODO: make this optional?   (issue #1187)
          return LogitsAndLossOutput(
              logits=logits,
              loss=torch.tensor([0.0]),  # This is a horrible hack
              other=encoder_output.other,
          )
      else:
          return LogitsOutput(logits=logits, other=encoder_output.other)
  
imports: import abc
  import torch
  import torch.nn
  from typing import Callable
  import jiant.proj.main.modeling.heads
  from jiant.proj.main.components.outputs import LogitsAndLossOutput
  from jiant.proj.main.components.outputs import LogitsOutput
  from jiant.utils.python.datastructures import take_one
  from jiant.tasks.core import TaskTypes
label_desc: Use image node_id 2 for calling the EmbeddingModel obj's underlying member method code with example usage: obj.forward(batch, tokenizer, compute_loss) and returns: LogitsAndLossOutput, LogitsOutput