class_docstr: PositionWeightedProcessor represents a processor to apply position weight to a KeyedJaggedTensor.
  
  It can handle both unsharded and sharded input and output corresponding output
  
  Args:
      max_feature_lengths (Dict[str, int]): Dict of feature_lengths, the key is the feature_name and value is length.
      device (Optional[torch.device]): default compute device.
  
  Example::
  
      keys=["Feature0", "Feature1", "Feature2"]
      values=torch.tensor([0, 1, 2, 3, 4, 5, 6, 7, 3, 4, 5, 6, 7])
      lengths=torch.tensor([2, 0, 1, 1, 1, 3, 2, 3, 0])
      features = KeyedJaggedTensor.from_lengths_sync(keys=keys, values=values, lengths=lengths)
      pw = FeatureProcessorCollection(
          feature_processor_modules={key: PositionWeightedFeatureProcessor(max_feature_length=100) for key in keys}
      )
      result = pw(features)
      # result is
      # KeyedJaggedTensor({
      #     "Feature0": {
      #         "values": [[0, 1], [], [2]],
      #         "weights": [[1.0, 1.0], [], [1.0]]
      #     },
      #     "Feature1": {
      #         "values": [[3], [4], [5, 6, 7]],
      #         "weights": [[1.0], [1.0], [1.0, 1.0, 1.0]]
      #     },
      #     "Feature2": {
      #         "values": [[3, 4], [5, 6, 7], []],
      #         "weights": [[1.0, 1.0], [1.0, 1.0, 1.0], []]
      #     }
      # })
code: def state_dict(
      self,
      destination: Optional[Dict[str, Any]] = None,
      prefix: str = "",
      keep_vars: bool = False,
  ) -> Dict[str, Any]:
      if destination is None:
          destination = OrderedDict()
          # pyre-ignore [16]
          destination._metadata = OrderedDict()
      for name, param in self.position_weights.items():
          destination[prefix + f"position_weights.{name}"] = (
              param if keep_vars else param.detach()
          )
      return destination
  
imports: import abc
  from collections import OrderedDict
  from typing import Any, Dict, Iterator, List, Optional, Tuple
  import torch
  import torch.nn
  from torchrec.fx.tracer import is_fx_tracing
  from torchrec.sparse.jagged_tensor import JaggedTensor, KeyedJaggedTensor
label_desc: Use image node_id 4 for calling the PositionWeightedProcessor obj's underlying member method code with example usage: obj.state_dict(destination, prefix, keep_vars) and returns: destination