docstr: labels (`torch.LongTensor` of shape `(batch_size, height, width)`, *optional*):
      Ground truth semantic segmentation maps for computing the loss. Indices should be in `[0, ...,
      config.num_labels - 1]`. If `config.num_labels > 1`, a classification loss is computed (Cross-Entropy).
  
  Returns:
  
  Examples:
  
  ```python
  >>> from transformers import AutoImageProcessor, MobileNetV2ForSemanticSegmentation
  >>> from PIL import Image
  >>> import requests
  
  >>> url = "http://images.cocodataset.org/val2017/000000039769.jpg"
  >>> image = Image.open(requests.get(url, stream=True).raw)
  
  >>> image_processor = AutoImageProcessor.from_pretrained("google/deeplabv3_mobilenet_v2_1.0_513")
  >>> model = MobileNetV2ForSemanticSegmentation.from_pretrained("google/deeplabv3_mobilenet_v2_1.0_513")
  
  >>> inputs = image_processor(images=image, return_tensors="pt")
  
  >>> with torch.no_grad():
  ...     outputs = model(**inputs)
  
  >>> # logits are of shape (batch_size, num_labels, height, width)
  >>> logits = outputs.logits
  ```
docstr_tok: ["labels","(","`","torch.LongTensor","`","of","shape","`","(","batch_size",",","height",",","width",")","`",",","*","optional","*",")",":","Ground","truth","semantic","segmentation","maps","for","computing","the","loss",".","Indices","should","be","in","`","[","0",",","...",",","config.num_labels","-","1","]","`",".","If","`","config.num_labels",">","1","`",",","a","classification","loss","is","computed","(","Cross-Entropy",")",".","Returns",":","Examples",":","``","`","python",">",">",">","from","transformers","import","AutoImageProcessor",",","MobileNetV2ForSemanticSegmentation",">",">",">","from","PIL","import","Image",">",">",">","import","requests",">",">",">","url","=","``","http",":","\/\/images.cocodataset.org\/val2017\/000000039769.jpg","''",">",">",">","image","=","Image.open","(","requests.get","(","url",",","stream=True",")",".raw",")",">",">",">","image_processor","=","AutoImageProcessor.from_pretrained","(","``","google\/deeplabv3_mobilenet_v2_1.0_513","''",")",">",">",">","model","=","MobileNetV2ForSemanticSegmentation.from_pretrained","(","``","google\/deeplabv3_mobilenet_v2_1.0_513","''",")",">",">",">","inputs","=","image_processor","(","images=image",",","return_tensors=","''","pt","''",")",">",">",">","with","torch.no_grad","(",")",":","...","outputs","=","model","(","*","*","inputs",")",">",">",">","#","logits","are","of","shape","(","batch_size",",","num_labels",",","height",",","width",")",">",">",">","logits","=","outputs.logits","``","`"]
code: def forward(
      self,
      pixel_values: Optional[torch.Tensor] = None,
      labels: Optional[torch.Tensor] = None,
      output_hidden_states: Optional[bool] = None,
      return_dict: Optional[bool] = None,
  ) -> Union[tuple, SemanticSegmenterOutput]:
      r"""
      labels (`torch.LongTensor` of shape `(batch_size, height, width)`, *optional*):
          Ground truth semantic segmentation maps for computing the loss. Indices should be in `[0, ...,
          config.num_labels - 1]`. If `config.num_labels > 1`, a classification loss is computed (Cross-Entropy).
  
      Returns:
  
      Examples:
  
      ```python
      >>> from transformers import AutoImageProcessor, MobileNetV2ForSemanticSegmentation
      >>> from PIL import Image
      >>> import requests
  
      >>> url = "http://images.cocodataset.org/val2017/000000039769.jpg"
      >>> image = Image.open(requests.get(url, stream=True).raw)
  
      >>> image_processor = AutoImageProcessor.from_pretrained("google/deeplabv3_mobilenet_v2_1.0_513")
      >>> model = MobileNetV2ForSemanticSegmentation.from_pretrained("google/deeplabv3_mobilenet_v2_1.0_513")
  
      >>> inputs = image_processor(images=image, return_tensors="pt")
  
      >>> with torch.no_grad():
      ...     outputs = model(**inputs)
  
      >>> # logits are of shape (batch_size, num_labels, height, width)
      >>> logits = outputs.logits
      ```"""
      output_hidden_states = (
          output_hidden_states
          if output_hidden_states is not None
          else self.config.output_hidden_states
      )
      return_dict = (
          return_dict
          if return_dict is not None
          else self.config.use_return_dict
      )
  
      outputs = self.mobilenet_v2(
          pixel_values,
          output_hidden_states=True,  # we need the intermediate hidden states
          return_dict=return_dict,
      )
  
      encoder_hidden_states = (
          outputs.hidden_states if return_dict else outputs[1]
      )
  
      logits = self.segmentation_head(encoder_hidden_states[-1])
  
      loss = None
      if labels is not None:
          if self.config.num_labels == 1:
              raise ValueError(
                  "The number of labels should be greater than one"
              )
          else:
              # upsample logits to the images' original size
              upsampled_logits = nn.functional.interpolate(
                  logits,
                  size=labels.shape[-2:],
                  mode="bilinear",
                  align_corners=False,
              )
              loss_fct = CrossEntropyLoss(
                  ignore_index=self.config.semantic_loss_ignore_index
              )
              loss = loss_fct(upsampled_logits, labels)
  
      if not return_dict:
          if output_hidden_states:
              output = (logits,) + outputs[1:]
          else:
              output = (logits,) + outputs[2:]
          return ((loss,) + output) if loss is not None else output
  
      return SemanticSegmenterOutput(
          loss=loss,
          logits=logits,
          hidden_states=outputs.hidden_states
          if output_hidden_states
          else None,
          attentions=None,
      )
  
imports: from typing import Optional, Union
  import torch
  from torch import nn
  from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss
  from ...activations import ACT2FN
  from ...modeling_outputs import BaseModelOutputWithPoolingAndNoAttention, ImageClassifierOutputWithNoAttention, SemanticSegmenterOutput
  from ...modeling_utils import PreTrainedModel
  from ...utils import add_code_sample_docstrings, add_start_docstrings, add_start_docstrings_to_model_forward, logging, replace_return_docstrings
  from .configuration_mobilenet_v2 import MobileNetV2Config
label_desc: Use image node_id 2 for calling the MobileNetV2ForSemanticSegmentation obj's underlying member method code with example usage: obj.forward(pixel_values, labels, output_hidden_states, return_dict) and returns: SemanticSegmenterOutput, unknown