class_docstr: Subclass of TorchAgent that allows for encoding image features.
  
  Provides flags and utility methods.
class_docstr_tok: ["Subclass","of","TorchAgent","that","allows","for","encoding","image","features",".","Provides","flags","and","utility","methods","."]
docstr: Format shape and type of input image-feature tensor.
docstr_tok: ["Format","shape","and","type","of","input","image-feature","tensor","."]
code: def _process_image_features(
      self, features: torch.Tensor
  ) -> torch.Tensor:
      """
      Format shape and type of input image-feature tensor.
      """
      if features.dim() == 4:
          features = features[0, :, 0, 0]
      assert features.size() == (self.image_features_dim,)
      if self.use_cuda:
          features = features.cuda()
      else:
          features = features.cpu()
      if self.opt.get("fp16"):
          features = features.half()
      else:
          features = features.float()
  
      return features
  
file_path: ParlAI/parlai/core/torch_image_agent.py
imports: from typing import Optional
  from parlai.core.params import ParlaiParser
  from parlai.core.opt import Opt
  from abc import abstractmethod
  from typing import List
  import torch
  from parlai.core.message import Message
  from parlai.core.torch_agent import Batch, TorchAgent
label_desc: Use image node_id 5 for calling the TorchImageAgent obj's underlying member method code with example usage: obj._process_image_features(features) and returns: features