class_docstr: Generates embedding sharding options for given `nn.Module`, considering user provided
  constraints.
  
  Args:
      topology (Topology): device topology.
      batch_size (int): batch size.
      constraints (Optional[Dict[str, ParameterConstraints]]): dict of parameter names
          to provided ParameterConstraints.
class_docstr_tok: ["Generates","embedding","sharding","options","for","given","`","nn.Module","`",",","considering","user","provided","constraints",".","Args",":","topology","(","Topology",")",":","device","topology",".","batch_size","(","int",")",":","batch","size",".","constraints","(","Optional","[","Dict","[","str",",","ParameterConstraints","]","]",")",":","dict","of","parameter","names","to","provided","ParameterConstraints","."]
code: def _filter_sharding_types(
      self, name: str, allowed_sharding_types: List[str]
  ) -> List[str]:
      if not self._constraints or not self._constraints.get(name):
          return allowed_sharding_types
      constraints: ParameterConstraints = self._constraints[name]
      if not constraints.sharding_types:
          return allowed_sharding_types
      constrained_sharding_types: List[str] = constraints.sharding_types
  
      filtered_sharding_types = list(
          set(constrained_sharding_types) & set(allowed_sharding_types)
      )
  
      if not filtered_sharding_types:
          logger.warn(
              "No available sharding types after applying user provided "
              f"constraints for {name}. Constrained sharding types: "
              f"{constrained_sharding_types}, allowed sharding types: "
              f"{allowed_sharding_types}, filtered sharding types: "
              f"{filtered_sharding_types}. Please check if the constrained "
              "sharding types are too restrictive, if the sharder allows the "
              "sharding types, or if non-strings are passed in."
          )
      return filtered_sharding_types
  
imports: import logging
  from typing import Dict, List, Optional, Tuple, Union
  from torch import nn
  from torchrec.distributed.embedding_types import EmbeddingComputeKernel
  from torchrec.distributed.planner.constants import POOLING_FACTOR
  from torchrec.distributed.planner.shard_estimators import EmbeddingPerfEstimator, EmbeddingStorageEstimator
  from torchrec.distributed.planner.types import Enumerator, ParameterConstraints, PartitionByType, Shard, ShardEstimator, ShardingOption, Topology
  from torchrec.distributed.planner.utils import sharder_name
  from torchrec.distributed.sharding_plan import calculate_shard_sizes_and_offsets
  from torchrec.distributed.types import BoundsCheckMode, CacheParams, ModuleSharder, ShardingType
  from torchrec.modules.embedding_tower import EmbeddingTower, EmbeddingTowerCollection
label_desc: Use image node_id 4 for calling the EmbeddingEnumerator obj's underlying member method code with example usage: obj._filter_sharding_types(name, allowed_sharding_types) and returns: filtered_sharding_types, allowed_sharding_types, allowed_sharding_types